Class: TalonOne::Experiment

Inherits:
ApiModelBase show all
Defined in:
lib/talon_one_sdk/models/experiment.rb

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiModelBase

_deserialize, #_to_hash, #to_body, #to_s

Constructor Details

#initialize(attributes = {}) ⇒ Experiment

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/talon_one_sdk/models/experiment.rb', line 131

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `TalonOne::Experiment` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  acceptable_attribute_map = self.class.acceptable_attribute_map
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!acceptable_attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `TalonOne::Experiment`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'id')
    self.id = attributes[:'id']
  else
    self.id = nil
  end

  if attributes.key?(:'created')
    self.created = attributes[:'created']
  else
    self.created = nil
  end

  if attributes.key?(:'application_id')
    self.application_id = attributes[:'application_id']
  else
    self.application_id = nil
  end

  if attributes.key?(:'is_variant_assignment_external')
    self.is_variant_assignment_external = attributes[:'is_variant_assignment_external']
  end

  if attributes.key?(:'campaign')
    self.campaign = attributes[:'campaign']
  end

  if attributes.key?(:'activated')
    self.activated = attributes[:'activated']
  end

  if attributes.key?(:'state')
    self.state = attributes[:'state']
  else
    self.state = 'disabled'
  end

  if attributes.key?(:'variants')
    if (value = attributes[:'variants']).is_a?(Array)
      self.variants = value
    end
  end

  if attributes.key?(:'goal_type')
    self.goal_type = attributes[:'goal_type']
  else
    self.goal_type = nil
  end

  if attributes.key?(:'goal_description')
    self.goal_description = attributes[:'goal_description']
  end

  if attributes.key?(:'deletedat')
    self.deletedat = attributes[:'deletedat']
  end
end

Instance Attribute Details

#activatedObject

The date and time the experiment was activated.



33
34
35
# File 'lib/talon_one_sdk/models/experiment.rb', line 33

def activated
  @activated
end

#application_idObject

The ID of the Application that owns this entity.



25
26
27
# File 'lib/talon_one_sdk/models/experiment.rb', line 25

def application_id
  @application_id
end

#campaignObject

Returns the value of attribute campaign.



30
31
32
# File 'lib/talon_one_sdk/models/experiment.rb', line 30

def campaign
  @campaign
end

#createdObject

The time this entity was created.



22
23
24
# File 'lib/talon_one_sdk/models/experiment.rb', line 22

def created
  @created
end

#deletedatObject

The date and time the experiment was deleted.



47
48
49
# File 'lib/talon_one_sdk/models/experiment.rb', line 47

def deletedat
  @deletedat
end

#goal_descriptionObject

A description of the experiment goal. Provides context for the AI summary and helps it interpret the outcome of the experiment against the stated goal.



44
45
46
# File 'lib/talon_one_sdk/models/experiment.rb', line 44

def goal_description
  @goal_description
end

#goal_typeObject

The goal of the experiment. Determines which single metric is used to decide the winning variant. When set to ‘other`, multiple metrics are used.



41
42
43
# File 'lib/talon_one_sdk/models/experiment.rb', line 41

def goal_type
  @goal_type
end

#idObject

The internal ID of this entity.



19
20
21
# File 'lib/talon_one_sdk/models/experiment.rb', line 19

def id
  @id
end

#is_variant_assignment_externalObject

The source of the assignment. - false - The variant assignment is handled internally by Talon.One. - true - The variant assignment is handled externally.



28
29
30
# File 'lib/talon_one_sdk/models/experiment.rb', line 28

def is_variant_assignment_external
  @is_variant_assignment_external
end

#stateObject

A disabled experiment is not evaluated for rules or coupons.



36
37
38
# File 'lib/talon_one_sdk/models/experiment.rb', line 36

def state
  @state
end

#variantsObject

Returns the value of attribute variants.



38
39
40
# File 'lib/talon_one_sdk/models/experiment.rb', line 38

def variants
  @variants
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



89
90
91
# File 'lib/talon_one_sdk/models/experiment.rb', line 89

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



94
95
96
# File 'lib/talon_one_sdk/models/experiment.rb', line 94

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/talon_one_sdk/models/experiment.rb', line 72

def self.attribute_map
  {
    :'id' => :'id',
    :'created' => :'created',
    :'application_id' => :'applicationId',
    :'is_variant_assignment_external' => :'isVariantAssignmentExternal',
    :'campaign' => :'campaign',
    :'activated' => :'activated',
    :'state' => :'state',
    :'variants' => :'variants',
    :'goal_type' => :'goalType',
    :'goal_description' => :'goalDescription',
    :'deletedat' => :'deletedat'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
# File 'lib/talon_one_sdk/models/experiment.rb', line 329

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  transformed_hash = {}
  openapi_types.each_pair do |key, type|
    if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = nil
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[attribute_map[key]].is_a?(Array)
        transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
      end
    elsif !attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
    end
  end
  new(transformed_hash)
end

.openapi_all_ofObject

List of class defined in allOf (OpenAPI v3)



122
123
124
125
126
127
# File 'lib/talon_one_sdk/models/experiment.rb', line 122

def self.openapi_all_of
  [
  :'ApplicationEntity',
  :'Entity'
  ]
end

.openapi_nullableObject

List of attributes with nullable: true



116
117
118
119
# File 'lib/talon_one_sdk/models/experiment.rb', line 116

def self.openapi_nullable
  Set.new([
  ])
end

.openapi_typesObject

Attribute type mapping.



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/talon_one_sdk/models/experiment.rb', line 99

def self.openapi_types
  {
    :'id' => :'Integer',
    :'created' => :'Time',
    :'application_id' => :'Integer',
    :'is_variant_assignment_external' => :'Boolean',
    :'campaign' => :'Campaign',
    :'activated' => :'Time',
    :'state' => :'String',
    :'variants' => :'Array<ExperimentVariant>',
    :'goal_type' => :'String',
    :'goal_description' => :'String',
    :'deletedat' => :'Time'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
# File 'lib/talon_one_sdk/models/experiment.rb', line 298

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      id == o.id &&
      created == o.created &&
      application_id == o.application_id &&
      is_variant_assignment_external == o.is_variant_assignment_external &&
      campaign == o.campaign &&
      activated == o.activated &&
      state == o.state &&
      variants == o.variants &&
      goal_type == o.goal_type &&
      goal_description == o.goal_description &&
      deletedat == o.deletedat
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


316
317
318
# File 'lib/talon_one_sdk/models/experiment.rb', line 316

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



322
323
324
# File 'lib/talon_one_sdk/models/experiment.rb', line 322

def hash
  [id, created, application_id, is_variant_assignment_external, campaign, activated, state, variants, goal_type, goal_description, deletedat].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
# File 'lib/talon_one_sdk/models/experiment.rb', line 204

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if @id.nil?
    invalid_properties.push('invalid value for "id", id cannot be nil.')
  end

  if @created.nil?
    invalid_properties.push('invalid value for "created", created cannot be nil.')
  end

  if @application_id.nil?
    invalid_properties.push('invalid value for "application_id", application_id cannot be nil.')
  end

  if @state.nil?
    invalid_properties.push('invalid value for "state", state cannot be nil.')
  end

  if @goal_type.nil?
    invalid_properties.push('invalid value for "goal_type", goal_type cannot be nil.')
  end

  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



351
352
353
354
355
356
357
358
359
360
361
362
363
# File 'lib/talon_one_sdk/models/experiment.rb', line 351

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



232
233
234
235
236
237
238
239
240
241
242
243
244
# File 'lib/talon_one_sdk/models/experiment.rb', line 232

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @id.nil?
  return false if @created.nil?
  return false if @application_id.nil?
  return false if @state.nil?
  state_validator = EnumAttributeValidator.new('String', ["enabled", "disabled", "archived"])
  return false unless state_validator.valid?(@state)
  return false if @goal_type.nil?
  goal_type_validator = EnumAttributeValidator.new('String', ["other", "maximize_revenue", "optimize_discount_efficiency", "maximize_items_sold"])
  return false unless goal_type_validator.valid?(@goal_type)
  true
end