Class: PinterestSdkClient::TargetingSpecOptimal

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

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

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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
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
# File 'lib/pinterest_sdk/models/targeting_spec_optimal.rb', line 132

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Instance Attribute Details

#age_bucketObject

Legacy field. Predefined age ranges. We recommend using MINIMUM_AGE and MAXIMUM_AGE instead for more flexible targeting. Cannot be combined with MINIMUM_AGE/MAXIMUM_AGE. If neither AGE_BUCKET nor MINIMUM_AGE/MAXIMUM_AGE are specified, all ages will be targeted.



19
20
21
# File 'lib/pinterest_sdk/models/targeting_spec_optimal.rb', line 19

def age_bucket
  @age_bucket
end

#apptypeObject

Allowed devices. If the APPTYPE field is missing, the default behavior in terms of ad delivery is that All devices/apptypes will be targeted.



22
23
24
# File 'lib/pinterest_sdk/models/targeting_spec_optimal.rb', line 22

def apptype
  @apptype
end

#audience_excludeObject

Excluded customer list IDs. Used to drive new customer acquisition goals. For example: ["2542620905475"]. Audience lists need to have at least 100 people with Pinterest accounts in them. If the AUDIENCE_EXCLUDE field is missing, the default behavior in terms of ad delivery is that No users will be excluded.



25
26
27
# File 'lib/pinterest_sdk/models/targeting_spec_optimal.rb', line 25

def audience_exclude
  @audience_exclude
end

#audience_includeObject

Targeted customer list IDs. For example: ["2542620905473"]. Audience lists need to have at least 100 people with Pinterest accounts in them Audience lists need to have at least 100 people with Pinterest accounts in them. If the AUDIENCE_INCLUDE field is missing, the default behavior in terms of ad delivery is that All users will be included.



28
29
30
# File 'lib/pinterest_sdk/models/targeting_spec_optimal.rb', line 28

def audience_include
  @audience_include
end

#genderObject

Targeted genders. Values: ["unknown","male","female"]. If the GENDER field is missing, the default behavior in terms of ad delivery is that All genders will be targeted.



31
32
33
# File 'lib/pinterest_sdk/models/targeting_spec_optimal.rb', line 31

def gender
  @gender
end

#geoObject

Region codes or postal codes to include for targeting. Region codes represent broader geographical areas. Example: US-CA is the region code for California in the United States. Postal codes represent more granular, specific areas. Example: 94103 is a postal code for a specifc area in San Francisco, California, U.S.A. For each ad group, use only one of these methods, depending on which fits your targeting needs. Do not use both. For example, either specify a broader region code like US-CA or a more granular postal code within that regon, such as 94103. You can specify multiple region codes or postal codes in an array, depending on which method you choose. Precede a region code array with the region_codes key and a postal code value with the postal_codes key. Examples: \"geo\": { \"region_codes\": [\"US-CA\"] } \"geo\": { \"postal_codes\": [\"94103\"] } For each ad group, specify at least one GEO or LOCATION. If you do not specifiy a GEO code, only LOCATION values will be targeted (See LOCATION parameter in this targeting spec.). Learn how to get a current, complete list of codes.



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

def geo
  @geo
end

#geo_excludeObject

Closed beta Region codes or postal codes to exclude from the targeting inclusion area. See GEO parameter in this targeting spec for rules, syntax, and other information.



37
38
39
# File 'lib/pinterest_sdk/models/targeting_spec_optimal.rb', line 37

def geo_exclude
  @geo_exclude
end

#interestObject

Array of interest object IDs. If the INTEREST field is missing, the default behavior in terms of ad delivery is that All interests will be targeted.



40
41
42
# File 'lib/pinterest_sdk/models/targeting_spec_optimal.rb', line 40

def interest
  @interest
end

#localeObject

24 ISO 639-1 two-letter language codes. If the LOCALE field is not included in the request, all languages are targeted.



43
44
45
# File 'lib/pinterest_sdk/models/targeting_spec_optimal.rb', line 43

def locale
  @locale
end

#locationObject

Metropolitan codes and/or ISO-Alpha-2, two-letter country codes to include for targeting. Precede country code values with the country_codes key and metro code values with metro_codes key. Example: \"location\": { \"country_codes\": [\"US\", \"CA\"], \"metro_codes\": [\"501\", \"602\"] } For each ad group, specify at least one GEO or LOCATION code. If you do not specify a LOCATION code, only GEO values will be targeted (See GEO parameter in this targeting spec.). Learn how to get a current, complete list of codes.



46
47
48
# File 'lib/pinterest_sdk/models/targeting_spec_optimal.rb', line 46

def location
  @location
end

#location_excludeObject

Closed beta Metropolitan codes and/or ISO-Alpha-2, two-letter country codes to exclude from targeting. See LOCATION parameter in this targeting spec for rules, syntax, and other information.



49
50
51
# File 'lib/pinterest_sdk/models/targeting_spec_optimal.rb', line 49

def location_exclude
  @location_exclude
end

#maximum_ageObject

Maximum age to target (inclusive). Values: "18", "19", ..., "65", "65+". Must be used together with MINIMUM_AGE. Cannot be combined with AGE_BUCKET. If neither MINIMUM_AGE/MAXIMUM_AGE nor AGE_BUCKET are specified, all ages will be targeted.



52
53
54
# File 'lib/pinterest_sdk/models/targeting_spec_optimal.rb', line 52

def maximum_age
  @maximum_age
end

#minimum_ageObject

Minimum age to target (inclusive). Values: "18", "19", ..., "65". Note: 65+ is not allowed for minimum age. Must be used together with MAXIMUM_AGE. Cannot be combined with AGE_BUCKET. If neither MINIMUM_AGE/MAXIMUM_AGE nor AGE_BUCKET are specified, all ages will be targeted.



55
56
57
# File 'lib/pinterest_sdk/models/targeting_spec_optimal.rb', line 55

def minimum_age
  @minimum_age
end

#shopping_retargetingObject

Array of object: lookback_window [Integer]: Number of days ago to start lookback timeframe for dynamic retargeting tag_types [Array of integer]: Event types to target for dynamic retargeting exclusion_window [Integer]: Number of days ago to stop lookback timeframe for dynamic retargeting



58
59
60
# File 'lib/pinterest_sdk/models/targeting_spec_optimal.rb', line 58

def shopping_retargeting
  @shopping_retargeting
end

#targeting_strategyObject

Returns the value of attribute targeting_strategy.



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

def targeting_strategy
  @targeting_strategy
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



84
85
86
# File 'lib/pinterest_sdk/models/targeting_spec_optimal.rb', line 84

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



89
90
91
# File 'lib/pinterest_sdk/models/targeting_spec_optimal.rb', line 89

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

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



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/pinterest_sdk/models/targeting_spec_optimal.rb', line 63

def self.attribute_map
  {
    :'age_bucket' => :'AGE_BUCKET',
    :'apptype' => :'APPTYPE',
    :'audience_exclude' => :'AUDIENCE_EXCLUDE',
    :'audience_include' => :'AUDIENCE_INCLUDE',
    :'gender' => :'GENDER',
    :'geo' => :'GEO',
    :'geo_exclude' => :'GEO_EXCLUDE',
    :'interest' => :'INTEREST',
    :'locale' => :'LOCALE',
    :'location' => :'LOCATION',
    :'location_exclude' => :'LOCATION_EXCLUDE',
    :'maximum_age' => :'MAXIMUM_AGE',
    :'minimum_age' => :'MINIMUM_AGE',
    :'shopping_retargeting' => :'SHOPPING_RETARGETING',
    :'targeting_strategy' => :'TARGETING_STRATEGY'
  }
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



327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
# File 'lib/pinterest_sdk/models/targeting_spec_optimal.rb', line 327

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



115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/pinterest_sdk/models/targeting_spec_optimal.rb', line 115

def self.openapi_nullable
  Set.new([
    :'age_bucket',
    :'apptype',
    :'audience_exclude',
    :'audience_include',
    :'gender',
    :'geo',
    :'locale',
    :'location',
    :'shopping_retargeting',
    :'targeting_strategy'
  ])
end

.openapi_typesObject

Attribute type mapping.



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/pinterest_sdk/models/targeting_spec_optimal.rb', line 94

def self.openapi_types
  {
    :'age_bucket' => :'Array<TargetingSpecAgeBucket>',
    :'apptype' => :'Array<TargetingSpecAppType>',
    :'audience_exclude' => :'Array<String>',
    :'audience_include' => :'Array<String>',
    :'gender' => :'Array<TargetingSpecGender>',
    :'geo' => :'Array<String>',
    :'geo_exclude' => :'Array<String>',
    :'interest' => :'Array<String>',
    :'locale' => :'Array<String>',
    :'location' => :'Array<String>',
    :'location_exclude' => :'Array<String>',
    :'maximum_age' => :'String',
    :'minimum_age' => :'String',
    :'shopping_retargeting' => :'Array<TargetingSpecShoppingRetargeting>',
    :'targeting_strategy' => :'Array<TargetingStrategy>'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
# File 'lib/pinterest_sdk/models/targeting_spec_optimal.rb', line 292

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      age_bucket == o.age_bucket &&
      apptype == o.apptype &&
      audience_exclude == o.audience_exclude &&
      audience_include == o.audience_include &&
      gender == o.gender &&
      geo == o.geo &&
      geo_exclude == o.geo_exclude &&
      interest == o.interest &&
      locale == o.locale &&
      location == o.location &&
      location_exclude == o.location_exclude &&
      maximum_age == o.maximum_age &&
      minimum_age == o.minimum_age &&
      shopping_retargeting == o.shopping_retargeting &&
      targeting_strategy == o.targeting_strategy
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


314
315
316
# File 'lib/pinterest_sdk/models/targeting_spec_optimal.rb', line 314

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



320
321
322
# File 'lib/pinterest_sdk/models/targeting_spec_optimal.rb', line 320

def hash
  [age_bucket, apptype, audience_exclude, audience_include, gender, geo, geo_exclude, interest, locale, location, location_exclude, maximum_age, minimum_age, shopping_retargeting, targeting_strategy].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# File 'lib/pinterest_sdk/models/targeting_spec_optimal.rb', line 235

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  pattern = Regexp.new(/^\d+\+?$/)
  if !@maximum_age.nil? && @maximum_age !~ pattern
    invalid_properties.push("invalid value for \"maximum_age\", must conform to the pattern #{pattern}.")
  end

  pattern = Regexp.new(/^\d+$/)
  if !@minimum_age.nil? && @minimum_age !~ pattern
    invalid_properties.push("invalid value for \"minimum_age\", 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



349
350
351
352
353
354
355
356
357
358
359
360
361
# File 'lib/pinterest_sdk/models/targeting_spec_optimal.rb', line 349

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



253
254
255
256
257
258
# File 'lib/pinterest_sdk/models/targeting_spec_optimal.rb', line 253

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if !@maximum_age.nil? && @maximum_age !~ Regexp.new(/^\d+\+?$/)
  return false if !@minimum_age.nil? && @minimum_age !~ Regexp.new(/^\d+$/)
  true
end