Class: PinterestSdkClient::ConversionMSOTEventsCreate

Inherits:
ApiModelBase
  • Object
show all
Defined in:
lib/pinterest_sdk/models/conversion_msot_events_create.rb

Overview

Resource create operation model.

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 = {}) ⇒ ConversionMSOTEventsCreate

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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
201
202
203
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
229
230
231
232
233
234
235
236
237
238
# File 'lib/pinterest_sdk/models/conversion_msot_events_create.rb', line 151

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `PinterestSdkClient::ConversionMSOTEventsCreate` 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 `PinterestSdkClient::ConversionMSOTEventsCreate`. 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?(:'action_timestamps')
    if (value = attributes[:'action_timestamps']).is_a?(Array)
      self.action_timestamps = value
    end
  end

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Instance Attribute Details

#action_timestampsObject

Timestamp(s) when the ad action(s) happened. Unix timestamp in seconds.



20
21
22
# File 'lib/pinterest_sdk/models/conversion_msot_events_create.rb', line 20

def action_timestamps
  @action_timestamps
end

#ad_group_idObject

The ID of the ad group that was attributed to the conversion event.



23
24
25
# File 'lib/pinterest_sdk/models/conversion_msot_events_create.rb', line 23

def ad_group_id
  @ad_group_id
end

#attribution_modelObject

The attribution model used to attribute the conversion event.



26
27
28
# File 'lib/pinterest_sdk/models/conversion_msot_events_create.rb', line 26

def attribution_model
  @attribution_model
end

#attribution_scopeObject

Ad event type.



29
30
31
# File 'lib/pinterest_sdk/models/conversion_msot_events_create.rb', line 29

def attribution_scope
  @attribution_scope
end

#attribution_scoreObject

Credit given to the attributed ad actions. Allowed values are > 0 and <= 1.



32
33
34
# File 'lib/pinterest_sdk/models/conversion_msot_events_create.rb', line 32

def attribution_score
  @attribution_score
end

#campaign_idObject

The ID of the campaign that was attributed to the conversion event.



35
36
37
# File 'lib/pinterest_sdk/models/conversion_msot_events_create.rb', line 35

def campaign_id
  @campaign_id
end

#click_windowObject

Click window used for attribution (for example, 1d, 7d, 30d, lifetime).



38
39
40
# File 'lib/pinterest_sdk/models/conversion_msot_events_create.rb', line 38

def click_window
  @click_window
end

#currencyObject

Currency code for the value field, required if value is present. Currency Codes should be in ISO 4217 standard.



41
42
43
# File 'lib/pinterest_sdk/models/conversion_msot_events_create.rb', line 41

def currency
  @currency
end

#event_idObject

A unique id string that identifies this event. If you are already sending us events through Conversions API, then this id should match the event_id sent through Conversions API.



44
45
46
# File 'lib/pinterest_sdk/models/conversion_msot_events_create.rb', line 44

def event_id
  @event_id
end

#event_nameObject

Type of user event.



47
48
49
# File 'lib/pinterest_sdk/models/conversion_msot_events_create.rb', line 47

def event_name
  @event_name
end

#event_timestampObject

The time when the event occurred. Unix timestamp in seconds.



50
51
52
# File 'lib/pinterest_sdk/models/conversion_msot_events_create.rb', line 50

def event_timestamp
  @event_timestamp
end

#total_event_touchpointsObject

Total number of ad events including other non-Pinterest ad platforms.



53
54
55
# File 'lib/pinterest_sdk/models/conversion_msot_events_create.rb', line 53

def total_event_touchpoints
  @total_event_touchpoints
end

#total_eventsObject

Deprecated: use total_events_fractional instead to avoid rounding errors. Total number of conversion events that are reported in one API call. If you are sending one API request for one attributed conversion event then this value should be 1. If you are sending multiple attributed conversion events in one API request then this value should be the total number of attributed conversion events in the request.



56
57
58
# File 'lib/pinterest_sdk/models/conversion_msot_events_create.rb', line 56

def total_events
  @total_events
end

#total_events_fractionalObject

Total number of conversion events that are reported in one API call. Use this field instead of total_events to send precise fractional values. If you are sending one API request for one attributed conversion event with full credit, this value should be 1.0. For partial attribution, send the exact fractional value (e.g., 0.5 for half credit).



59
60
61
# File 'lib/pinterest_sdk/models/conversion_msot_events_create.rb', line 59

def total_events_fractional
  @total_events_fractional
end

#valueObject

Order value of the conversion event. Required if event_name is add_to_cart or checkout.



62
63
64
# File 'lib/pinterest_sdk/models/conversion_msot_events_create.rb', line 62

def value
  @value
end

#view_windowObject

View window used for attribution (for example, 1d, 7d, 30d).



65
66
67
# File 'lib/pinterest_sdk/models/conversion_msot_events_create.rb', line 65

def view_window
  @view_window
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



112
113
114
# File 'lib/pinterest_sdk/models/conversion_msot_events_create.rb', line 112

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



117
118
119
# File 'lib/pinterest_sdk/models/conversion_msot_events_create.rb', line 117

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

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



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/pinterest_sdk/models/conversion_msot_events_create.rb', line 90

def self.attribute_map
  {
    :'action_timestamps' => :'action_timestamps',
    :'ad_group_id' => :'ad_group_id',
    :'attribution_model' => :'attribution_model',
    :'attribution_scope' => :'attribution_scope',
    :'attribution_score' => :'attribution_score',
    :'campaign_id' => :'campaign_id',
    :'click_window' => :'click_window',
    :'currency' => :'currency',
    :'event_id' => :'event_id',
    :'event_name' => :'event_name',
    :'event_timestamp' => :'event_timestamp',
    :'total_event_touchpoints' => :'total_event_touchpoints',
    :'total_events' => :'total_events',
    :'total_events_fractional' => :'total_events_fractional',
    :'value' => :'value',
    :'view_window' => :'view_window'
  }
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



479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
# File 'lib/pinterest_sdk/models/conversion_msot_events_create.rb', line 479

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_nullableObject

List of attributes with nullable: true



144
145
146
147
# File 'lib/pinterest_sdk/models/conversion_msot_events_create.rb', line 144

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

.openapi_typesObject

Attribute type mapping.



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/pinterest_sdk/models/conversion_msot_events_create.rb', line 122

def self.openapi_types
  {
    :'action_timestamps' => :'Array<Integer>',
    :'ad_group_id' => :'String',
    :'attribution_model' => :'AttributionModel',
    :'attribution_scope' => :'AttributionScope',
    :'attribution_score' => :'Float',
    :'campaign_id' => :'String',
    :'click_window' => :'String',
    :'currency' => :'Currency',
    :'event_id' => :'String',
    :'event_name' => :'MsotEventName',
    :'event_timestamp' => :'Integer',
    :'total_event_touchpoints' => :'Integer',
    :'total_events' => :'Integer',
    :'total_events_fractional' => :'Float',
    :'value' => :'Float',
    :'view_window' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
# File 'lib/pinterest_sdk/models/conversion_msot_events_create.rb', line 443

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      action_timestamps == o.action_timestamps &&
      ad_group_id == o.ad_group_id &&
      attribution_model == o.attribution_model &&
      attribution_scope == o.attribution_scope &&
      attribution_score == o.attribution_score &&
      campaign_id == o.campaign_id &&
      click_window == o.click_window &&
      currency == o.currency &&
      event_id == o.event_id &&
      event_name == o.event_name &&
      event_timestamp == o.event_timestamp &&
      total_event_touchpoints == o.total_event_touchpoints &&
      total_events == o.total_events &&
      total_events_fractional == o.total_events_fractional &&
      value == o.value &&
      view_window == o.view_window
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


466
467
468
# File 'lib/pinterest_sdk/models/conversion_msot_events_create.rb', line 466

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



472
473
474
# File 'lib/pinterest_sdk/models/conversion_msot_events_create.rb', line 472

def hash
  [action_timestamps, ad_group_id, attribution_model, attribution_scope, attribution_score, campaign_id, click_window, currency, event_id, event_name, event_timestamp, total_event_touchpoints, total_events, total_events_fractional, value, view_window].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
# File 'lib/pinterest_sdk/models/conversion_msot_events_create.rb', line 242

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

  pattern = Regexp.new(/^\d+$/)
  if @ad_group_id !~ pattern
    invalid_properties.push("invalid value for \"ad_group_id\", must conform to the pattern #{pattern}.")
  end

  if !@attribution_score.nil? && @attribution_score > 1
    invalid_properties.push('invalid value for "attribution_score", must be smaller than or equal to 1.')
  end

  if !@attribution_score.nil? && @attribution_score <= 0
    invalid_properties.push('invalid value for "attribution_score", must be greater than 0.')
  end

  pattern = Regexp.new(/^\d+$/)
  if !@campaign_id.nil? && @campaign_id !~ pattern
    invalid_properties.push("invalid value for \"campaign_id\", must conform to the pattern #{pattern}.")
  end

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

  if @event_id.to_s.length > 256
    invalid_properties.push('invalid value for "event_id", the character length must be smaller than or equal to 256.')
  end

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

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

  if !@total_event_touchpoints.nil? && @total_event_touchpoints < 1
    invalid_properties.push('invalid value for "total_event_touchpoints", must be greater than or equal to 1.')
  end

  if !@total_events.nil? && @total_events < 1
    invalid_properties.push('invalid value for "total_events", must be greater than or equal to 1.')
  end

  if !@total_events_fractional.nil? && @total_events_fractional <= 0
    invalid_properties.push('invalid value for "total_events_fractional", must be greater than 0.')
  end

  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



501
502
503
504
505
506
507
508
509
510
511
512
513
# File 'lib/pinterest_sdk/models/conversion_msot_events_create.rb', line 501

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



300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
# File 'lib/pinterest_sdk/models/conversion_msot_events_create.rb', line 300

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @ad_group_id.nil?
  return false if @ad_group_id !~ Regexp.new(/^\d+$/)
  return false if !@attribution_score.nil? && @attribution_score > 1
  return false if !@attribution_score.nil? && @attribution_score <= 0
  return false if !@campaign_id.nil? && @campaign_id !~ Regexp.new(/^\d+$/)
  return false if @event_id.nil?
  return false if @event_id.to_s.length > 256
  return false if @event_name.nil?
  return false if @event_timestamp.nil?
  return false if !@total_event_touchpoints.nil? && @total_event_touchpoints < 1
  return false if !@total_events.nil? && @total_events < 1
  return false if !@total_events_fractional.nil? && @total_events_fractional <= 0
  true
end