Class: Urbanairship::AbTests::Variant

Inherits:
Object
  • Object
show all
Includes:
Common, Loggable
Defined in:
lib/urbanairship/ab_tests/variant.rb

Constant Summary

Constants included from Common

Common::CONTENT_TYPE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Loggable

create_logger, logger, #logger

Methods included from Common

#apid_path, #channel_path, #compact_helper, #create_and_send_path, #custom_events_path, #device_token_path, #experiments_path, #lists_path, #named_users_path, #open_channel_path, #pipelines_path, #push_path, #reports_path, #required, #schedules_path, #segments_path, #tag_lists_path, #try_helper

Constructor Details

#initialize(client: required('client')) ⇒ Variant

Returns a new instance of Variant.



15
16
17
# File 'lib/urbanairship/ab_tests/variant.rb', line 15

def initialize(client: required('client'))
    @client = client
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



8
9
10
# File 'lib/urbanairship/ab_tests/variant.rb', line 8

def description
  @description
end

#idObject

Returns the value of attribute id.



8
9
10
# File 'lib/urbanairship/ab_tests/variant.rb', line 8

def id
  @id
end

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/urbanairship/ab_tests/variant.rb', line 8

def name
  @name
end

#pushObject

Returns the value of attribute push.



8
9
10
# File 'lib/urbanairship/ab_tests/variant.rb', line 8

def push
  @push
end

#scheduleObject

Returns the value of attribute schedule.



8
9
10
# File 'lib/urbanairship/ab_tests/variant.rb', line 8

def schedule
  @schedule
end

#weightObject

Returns the value of attribute weight.



8
9
10
# File 'lib/urbanairship/ab_tests/variant.rb', line 8

def weight
  @weight
end

Instance Method Details

#payloadObject



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/urbanairship/ab_tests/variant.rb', line 19

def payload
    fail ArgumentError, 'a push must be added to create a variant' if @push.nil?

    {
     'description': description,
     'id': id,
     'name': name,
     'push': push,
     'schedule': schedule,
     'weight': weight   
    }.delete_if {|key, value| value.nil?} #this removes the nil key value pairs
end