class Urbanairship::AbTests::AbTest

Attributes

experiment_id[RW]
experiment_object[RW]
limit[RW]
offset[RW]

Public Class Methods

new(client: required('client')) click to toggle source
# File lib/urbanairship/ab_tests/ab_test.rb, line 15
def initialize(client: required('client'))
    @client = client
end

Public Instance Methods

create_ab_test() click to toggle source
# File lib/urbanairship/ab_tests/ab_test.rb, line 28
def create_ab_test
    response = @client.send_request(
        method: 'POST',
        body: JSON.dump(experiment_object),
        path: experiments_path,
        content_type: 'application/json'
    )
    logger.info("Created A/B Test")
    response
end
delete_ab_test() click to toggle source
# File lib/urbanairship/ab_tests/ab_test.rb, line 48
def delete_ab_test
    fail ArgumentError, 'experiment_id must be set to delete individual A/B test' if @experiment_id.nil?
    response = @client.send_request(
        method: 'DELETE',
        path: experiments_path('scheduled/' + experiment_id)
    )
    logger.info("Deleting A/B test with ID #{experiment_id}")
    response
end
format_url_with_params() click to toggle source
# File lib/urbanairship/ab_tests/ab_test.rb, line 79
def format_url_with_params
    params = []
    params << ['limit', limit] if limit
    params << ['offset', offset] if offset
    query = URI.encode_www_form(params)
    '?' + query
end
list_ab_test() click to toggle source
# File lib/urbanairship/ab_tests/ab_test.rb, line 19
def list_ab_test
    response = @client.send_request(
        method: 'GET',
        path: experiments_path(format_url_with_params)
    )
    logger.info("Looking up A/B Tests for project")
    response
end
list_scheduled_ab_test() click to toggle source
# File lib/urbanairship/ab_tests/ab_test.rb, line 39
def list_scheduled_ab_test
    response = @client.send_request(
        method: 'GET',
        path: experiments_path('scheduled' + format_url_with_params)
    )
    logger.info("Looking up scheduled A/B Tests for project")
    response
end
lookup_ab_test() click to toggle source
# File lib/urbanairship/ab_tests/ab_test.rb, line 69
def lookup_ab_test
    fail ArgumentError, 'experiment_id must be set to lookup individual A/B Test' if @experiment_id.nil?
    response = @client.send_request(
        method: 'GET',
        path: experiments_path(experiment_id)
    )
    logger.info("Looking up A/B test with ID #{experiment_id}")
    response
end
validate_ab_test() click to toggle source
# File lib/urbanairship/ab_tests/ab_test.rb, line 58
def validate_ab_test
    response = @client.send_request(
        method: 'POST',
        body: JSON.dump(experiment_object),
        path: experiments_path('validate'),
        content_type: 'application/json'
    )
    logger.info("Validating A/B Test")
    response
end