Class: PinterestSdkClient::ConversionProductReportRequest

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

Overview

Request for a brand, category, SKU report

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

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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
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
239
240
241
242
243
244
245
# File 'lib/pinterest_sdk/models/conversion_product_report_request.rb', line 144

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

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

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

  if attributes.key?(:'click_window_days')
    self.click_window_days = attributes[:'click_window_days']
  else
    self.click_window_days = ConversionAttributionWindowDays::N30
  end

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

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

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

  if attributes.key?(:'conversion_report_time')
    self.conversion_report_time = attributes[:'conversion_report_time']
  else
    self.conversion_report_time = 'TIME_OF_AD_ACTION'
  end

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

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

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

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

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

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

  if attributes.key?(:'view_window_days')
    self.view_window_days = attributes[:'view_window_days']
  else
    self.view_window_days = ConversionAttributionWindowDays::N30
  end
end

Instance Attribute Details

#ad_group_idsObject

List of ad group ids.
Only support ad_group_ids field when level of the report is AD_GROUP.



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

def ad_group_ids
  @ad_group_ids
end

#campaign_idsObject

List of campaign ids.
Only support campaign_ids field when level of the report is CAMPAIGN.



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

def campaign_ids
  @campaign_ids
end

#campaign_objective_typesObject

List of values for filtering. Default is [‘CONSIDERATION’,‘AWARENESS’,‘WEB_CONVERSION’,‘VIDEO_COMPLETION’].



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

def campaign_objective_types
  @campaign_objective_types
end

#click_window_daysObject

Number of days to use as the conversion attribution window for a pin click action. Applies to Pinterest Tag conversion metrics. Prior conversion tags use their defined attribution windows. If not specified, defaults to 30 days.



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

def click_window_days
  @click_window_days
end

#columnsObject

Metric and entity columns



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

def columns
  @columns
end

#conversion_product_attribution_typeObject

Returns the value of attribute conversion_product_attribution_type.



34
35
36
# File 'lib/pinterest_sdk/models/conversion_product_report_request.rb', line 34

def conversion_product_attribution_type
  @conversion_product_attribution_type
end

#conversion_product_breakdownObject

Returns the value of attribute conversion_product_breakdown.



36
37
38
# File 'lib/pinterest_sdk/models/conversion_product_report_request.rb', line 36

def conversion_product_breakdown
  @conversion_product_breakdown
end

#conversion_report_timeObject

The date by which the conversion metrics returned from this endpoint will be reported. There are two dates associated with a conversion event: the date that the user interacted with the ad, and the date that the user completed a conversion event.



39
40
41
# File 'lib/pinterest_sdk/models/conversion_product_report_request.rb', line 39

def conversion_report_time
  @conversion_report_time
end

#end_dateObject

Metric report end date (UTC). Format: YYYY-MM-DD.
A max of 1 year is allowed between the start and end date for reports.



42
43
44
# File 'lib/pinterest_sdk/models/conversion_product_report_request.rb', line 42

def end_date
  @end_date
end

#granularityObject

TOTAL - metrics are aggregated over the specified date range.
WEEK - metrics are broken down weekly.
MONTH - metrics are broken down monthly.



45
46
47
# File 'lib/pinterest_sdk/models/conversion_product_report_request.rb', line 45

def granularity
  @granularity
end

#levelObject

Level of the report



48
49
50
# File 'lib/pinterest_sdk/models/conversion_product_report_request.rb', line 48

def level
  @level
end

#product_sku_idsObject

List of SKU ids.
Only support product_sku_ids field when report breakdown type is PRODUCT_SKU_GROUP.



51
52
53
# File 'lib/pinterest_sdk/models/conversion_product_report_request.rb', line 51

def product_sku_ids
  @product_sku_ids
end

#report_nameObject

Name of the conversion product report.



54
55
56
# File 'lib/pinterest_sdk/models/conversion_product_report_request.rb', line 54

def report_name
  @report_name
end

#start_dateObject

Metric report start date (UTC). Format: YYYY-MM-DD.
Start date must be after 2024-03-16. 7 day minimum time window for report is required.



57
58
59
# File 'lib/pinterest_sdk/models/conversion_product_report_request.rb', line 57

def start_date
  @start_date
end

#view_window_daysObject

Number of days to use as the conversion attribution window for a view action. Applies to Pinterest Tag conversion metrics. Prior conversion tags use their defined attribution windows. If not specified, defaults to 30 day.



60
61
62
# File 'lib/pinterest_sdk/models/conversion_product_report_request.rb', line 60

def view_window_days
  @view_window_days
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



106
107
108
# File 'lib/pinterest_sdk/models/conversion_product_report_request.rb', line 106

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



111
112
113
# File 'lib/pinterest_sdk/models/conversion_product_report_request.rb', line 111

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

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



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/pinterest_sdk/models/conversion_product_report_request.rb', line 85

def self.attribute_map
  {
    :'ad_group_ids' => :'ad_group_ids',
    :'campaign_ids' => :'campaign_ids',
    :'campaign_objective_types' => :'campaign_objective_types',
    :'click_window_days' => :'click_window_days',
    :'columns' => :'columns',
    :'conversion_product_attribution_type' => :'conversion_product_attribution_type',
    :'conversion_product_breakdown' => :'conversion_product_breakdown',
    :'conversion_report_time' => :'conversion_report_time',
    :'end_date' => :'end_date',
    :'granularity' => :'granularity',
    :'level' => :'level',
    :'product_sku_ids' => :'product_sku_ids',
    :'report_name' => :'report_name',
    :'start_date' => :'start_date',
    :'view_window_days' => :'view_window_days'
  }
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



551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
# File 'lib/pinterest_sdk/models/conversion_product_report_request.rb', line 551

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



137
138
139
140
# File 'lib/pinterest_sdk/models/conversion_product_report_request.rb', line 137

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

.openapi_typesObject

Attribute type mapping.



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/pinterest_sdk/models/conversion_product_report_request.rb', line 116

def self.openapi_types
  {
    :'ad_group_ids' => :'Array<String>',
    :'campaign_ids' => :'Array<String>',
    :'campaign_objective_types' => :'Array<ObjectiveType>',
    :'click_window_days' => :'ConversionAttributionWindowDays',
    :'columns' => :'Array<ConversionProductReportingColumn>',
    :'conversion_product_attribution_type' => :'String',
    :'conversion_product_breakdown' => :'String',
    :'conversion_report_time' => :'ConversionReportTimeType',
    :'end_date' => :'String',
    :'granularity' => :'String',
    :'level' => :'String',
    :'product_sku_ids' => :'Array<String>',
    :'report_name' => :'String',
    :'start_date' => :'String',
    :'view_window_days' => :'ConversionAttributionWindowDays'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
# File 'lib/pinterest_sdk/models/conversion_product_report_request.rb', line 516

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      ad_group_ids == o.ad_group_ids &&
      campaign_ids == o.campaign_ids &&
      campaign_objective_types == o.campaign_objective_types &&
      click_window_days == o.click_window_days &&
      columns == o.columns &&
      conversion_product_attribution_type == o.conversion_product_attribution_type &&
      conversion_product_breakdown == o.conversion_product_breakdown &&
      conversion_report_time == o.conversion_report_time &&
      end_date == o.end_date &&
      granularity == o.granularity &&
      level == o.level &&
      product_sku_ids == o.product_sku_ids &&
      report_name == o.report_name &&
      start_date == o.start_date &&
      view_window_days == o.view_window_days
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


538
539
540
# File 'lib/pinterest_sdk/models/conversion_product_report_request.rb', line 538

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



544
545
546
# File 'lib/pinterest_sdk/models/conversion_product_report_request.rb', line 544

def hash
  [ad_group_ids, campaign_ids, campaign_objective_types, click_window_days, columns, conversion_product_attribution_type, conversion_product_breakdown, conversion_report_time, end_date, granularity, level, product_sku_ids, report_name, start_date, view_window_days].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
# File 'lib/pinterest_sdk/models/conversion_product_report_request.rb', line 249

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if !@ad_group_ids.nil? && @ad_group_ids.length > 500
    invalid_properties.push('invalid value for "ad_group_ids", number of items must be less than or equal to 500.')
  end

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

  if !@campaign_ids.nil? && @campaign_ids.length > 500
    invalid_properties.push('invalid value for "campaign_ids", number of items must be less than or equal to 500.')
  end

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

  if !@campaign_objective_types.nil? && @campaign_objective_types.length > 7
    invalid_properties.push('invalid value for "campaign_objective_types", number of items must be less than or equal to 7.')
  end

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

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

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

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

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

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

  if !@product_sku_ids.nil? && @product_sku_ids.length > 500
    invalid_properties.push('invalid value for "product_sku_ids", number of items must be less than or equal to 500.')
  end

  if !@product_sku_ids.nil? && @product_sku_ids.length < 2
    invalid_properties.push('invalid value for "product_sku_ids", number of items must be greater than or equal to 2.')
  end

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

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

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

  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



573
574
575
576
577
578
579
580
581
582
583
584
585
# File 'lib/pinterest_sdk/models/conversion_product_report_request.rb', line 573

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



323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
# File 'lib/pinterest_sdk/models/conversion_product_report_request.rb', line 323

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if !@ad_group_ids.nil? && @ad_group_ids.length > 500
  return false if !@ad_group_ids.nil? && @ad_group_ids.length < 1
  return false if !@campaign_ids.nil? && @campaign_ids.length > 500
  return false if !@campaign_ids.nil? && @campaign_ids.length < 1
  return false if !@campaign_objective_types.nil? && @campaign_objective_types.length > 7
  return false if !@campaign_objective_types.nil? && @campaign_objective_types.length < 1
  return false if @columns.nil?
  conversion_product_attribution_type_validator = EnumAttributeValidator.new('String', ["DEFAULT", "BRAND_ATTRIBUTION"])
  return false unless conversion_product_attribution_type_validator.valid?(@conversion_product_attribution_type)
  conversion_product_breakdown_validator = EnumAttributeValidator.new('String', ["PRODUCT_BRAND", "PRODUCT_CATEGORY", "PRODUCT_BRAND_AND_CATEGORY", "PRODUCT_SKU", "PRODUCT_SKU_GROUP"])
  return false unless conversion_product_breakdown_validator.valid?(@conversion_product_breakdown)
  return false if @end_date.nil?
  return false if @end_date !~ Regexp.new(/^(\d{4})-(\d{2})-(\d{2})$/)
  return false if @granularity.nil?
  granularity_validator = EnumAttributeValidator.new('String', ["WEEK", "MONTH", "TOTAL"])
  return false unless granularity_validator.valid?(@granularity)
  return false if @level.nil?
  level_validator = EnumAttributeValidator.new('String', ["ADVERTISER", "CAMPAIGN", "AD_GROUP"])
  return false unless level_validator.valid?(@level)
  return false if !@product_sku_ids.nil? && @product_sku_ids.length > 500
  return false if !@product_sku_ids.nil? && @product_sku_ids.length < 2
  return false if @report_name.nil?
  return false if @start_date.nil?
  return false if @start_date !~ Regexp.new(/^(\d{4})-(\d{2})-(\d{2})$/)
  true
end