Class: PinterestSdkClient::TargetingSpec

Inherits:
ApiModelBase show all
Defined in:
lib/pinterest_sdk/models/targeting_spec.rb

Overview

Ad group targeting specification defining the ad group target audience. For example, {\"APPTYPE\":[\"iphone\"], \"GENDER\":[\"male\"], \"LOCALE\":[\"en-US\"], \"LOCATION\":[\"501\"], \"MINIMUM_AGE\":\"18\", \"MAXIMUM_AGE\":\"65+\"}

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

Initializes the object

Parameters:

  • (defaults to: {})

    Model attributes in the form of hash



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
246
247
248
249
250
251
252
253
254
# File 'lib/pinterest_sdk/models/targeting_spec.rb', line 155

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `PinterestSdkClient::TargetingSpec` 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::TargetingSpec`. 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.



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

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.



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

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.



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

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.



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

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.



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

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 <a href="/docs/analytics-and-reports/ads-reporting/#get-all-available-codes-and-zones" target="_blank">get a current, complete list of codes.



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

def geo
  @geo
end

#geo_excludeObject

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.



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

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.



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

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.



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

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 <a href="/docs/analytics-and-reports/ads-reporting/#get-all-available-codes-and-zones" target="_blank">get a current, complete list of codes.



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

def location
  @location
end

#location_excludeObject

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.



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

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.



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

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.



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

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



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

def shopping_retargeting
  @shopping_retargeting
end

#targeting_strategyObject

Returns the value of attribute targeting_strategy.



61
62
63
# File 'lib/pinterest_sdk/models/targeting_spec.rb', line 61

def targeting_strategy
  @targeting_strategy
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



107
108
109
# File 'lib/pinterest_sdk/models/targeting_spec.rb', line 107

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



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

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

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



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

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:

  • Model attributes in the form of hash

Returns:

  • Returns the model itself



350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
# File 'lib/pinterest_sdk/models/targeting_spec.rb', line 350

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



138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/pinterest_sdk/models/targeting_spec.rb', line 138

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.



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

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<String>'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • to be compared



315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
# File 'lib/pinterest_sdk/models/targeting_spec.rb', line 315

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:

  • to be compared

Returns:

See Also:

  • `==` method


337
338
339
# File 'lib/pinterest_sdk/models/targeting_spec.rb', line 337

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • Hash code



343
344
345
# File 'lib/pinterest_sdk/models/targeting_spec.rb', line 343

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



258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
# File 'lib/pinterest_sdk/models/targeting_spec.rb', line 258

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:

  • Returns the object in the form of hash



372
373
374
375
376
377
378
379
380
381
382
383
384
# File 'lib/pinterest_sdk/models/targeting_spec.rb', line 372

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:

  • true if the model is valid



276
277
278
279
280
281
# File 'lib/pinterest_sdk/models/targeting_spec.rb', line 276

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