Class: Zernio::BoostPostRequestTargeting

Inherits:
ApiModelBase show all
Defined in:
lib/zernio-sdk/models/boost_post_request_targeting.rb

Overview

Same geo/demographic fields as the TargetingSpec used by /v1/ads/create. Geo keys (regions/cities/zips/metros) resolve via GET /v1/ads/targeting/search?dimension=geo. City radius and lat/lng customLocations are Meta-only and preserve the boosted post's social proof (the ad references the existing post).

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

Initializes the object

Parameters:

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

    Model attributes in the form of hash



129
130
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
201
202
203
204
205
206
# File 'lib/zernio-sdk/models/boost_post_request_targeting.rb', line 129

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

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

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

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

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

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

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

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

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

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

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

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

Instance Attribute Details

#advantage_audienceObject

Meta only. 0 = disabled (default), 1 = enabled.



51
52
53
# File 'lib/zernio-sdk/models/boost_post_request_targeting.rb', line 51

def advantage_audience
  @advantage_audience
end

#age_maxObject

Returns the value of attribute age_max.



21
22
23
# File 'lib/zernio-sdk/models/boost_post_request_targeting.rb', line 21

def age_max
  @age_max
end

#age_minObject

Returns the value of attribute age_min.



19
20
21
# File 'lib/zernio-sdk/models/boost_post_request_targeting.rb', line 19

def age_min
  @age_min
end

#citiesObject

City targeting. Optional radius + distanceUnit extend beyond the city limits (both set together, Meta only).



36
37
38
# File 'lib/zernio-sdk/models/boost_post_request_targeting.rb', line 36

def cities
  @cities
end

#countriesObject

ISO country codes. Required for TikTok boosts (TikTok's ad group requires location_ids); optional on other platforms.



30
31
32
# File 'lib/zernio-sdk/models/boost_post_request_targeting.rb', line 30

def countries
  @countries
end

#custom_locationsObject

Point-radius (lat/lng) targeting (Meta custom_locations). No geo key lookup needed.



45
46
47
# File 'lib/zernio-sdk/models/boost_post_request_targeting.rb', line 45

def custom_locations
  @custom_locations
end

#genderObject

Meta only.



24
25
26
# File 'lib/zernio-sdk/models/boost_post_request_targeting.rb', line 24

def gender
  @gender
end

#interestsObject

Interest objects from /v1/ads/interests. Each must include id and name.



48
49
50
# File 'lib/zernio-sdk/models/boost_post_request_targeting.rb', line 48

def interests
  @interests
end

#languagesObject

Meta locale ids (numeric), passed through as given.



27
28
29
# File 'lib/zernio-sdk/models/boost_post_request_targeting.rb', line 27

def languages
  @languages
end

#metrosObject

DMA / metro-area targeting. key is the platform's metro ID (e.g. Meta DMA:807).



42
43
44
# File 'lib/zernio-sdk/models/boost_post_request_targeting.rb', line 42

def metros
  @metros
end

#regionsObject

Region/state targeting. key from /v1/ads/targeting/search?dimension=geo&geoType=region.



33
34
35
# File 'lib/zernio-sdk/models/boost_post_request_targeting.rb', line 33

def regions
  @regions
end

#zipsObject

Postal/ZIP targeting. key is the platform's postal location ID (e.g. Meta US:94304).



39
40
41
# File 'lib/zernio-sdk/models/boost_post_request_targeting.rb', line 39

def zips
  @zips
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



94
95
96
# File 'lib/zernio-sdk/models/boost_post_request_targeting.rb', line 94

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



99
100
101
# File 'lib/zernio-sdk/models/boost_post_request_targeting.rb', line 99

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

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



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/zernio-sdk/models/boost_post_request_targeting.rb', line 76

def self.attribute_map
  {
    :'age_min' => :'ageMin',
    :'age_max' => :'ageMax',
    :'gender' => :'gender',
    :'languages' => :'languages',
    :'countries' => :'countries',
    :'regions' => :'regions',
    :'cities' => :'cities',
    :'zips' => :'zips',
    :'metros' => :'metros',
    :'custom_locations' => :'customLocations',
    :'interests' => :'interests',
    :'advantage_audience' => :'advantage_audience'
  }
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



337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
# File 'lib/zernio-sdk/models/boost_post_request_targeting.rb', line 337

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



122
123
124
125
# File 'lib/zernio-sdk/models/boost_post_request_targeting.rb', line 122

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

.openapi_typesObject

Attribute type mapping.



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/zernio-sdk/models/boost_post_request_targeting.rb', line 104

def self.openapi_types
  {
    :'age_min' => :'Integer',
    :'age_max' => :'Integer',
    :'gender' => :'String',
    :'languages' => :'Array<String>',
    :'countries' => :'Array<String>',
    :'regions' => :'Array<BoostPostRequestTargetingRegionsInner>',
    :'cities' => :'Array<BoostPostRequestTargetingCitiesInner>',
    :'zips' => :'Array<BoostPostRequestTargetingRegionsInner>',
    :'metros' => :'Array<BoostPostRequestTargetingRegionsInner>',
    :'custom_locations' => :'Array<BoostPostRequestTargetingCustomLocationsInner>',
    :'interests' => :'Array<UpdateAdRequestTargetingInterestsInner>',
    :'advantage_audience' => :'Integer'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
# File 'lib/zernio-sdk/models/boost_post_request_targeting.rb', line 305

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      age_min == o.age_min &&
      age_max == o.age_max &&
      gender == o.gender &&
      languages == o.languages &&
      countries == o.countries &&
      regions == o.regions &&
      cities == o.cities &&
      zips == o.zips &&
      metros == o.metros &&
      custom_locations == o.custom_locations &&
      interests == o.interests &&
      advantage_audience == o.advantage_audience
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


324
325
326
# File 'lib/zernio-sdk/models/boost_post_request_targeting.rb', line 324

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



330
331
332
# File 'lib/zernio-sdk/models/boost_post_request_targeting.rb', line 330

def hash
  [age_min, age_max, gender, languages, countries, regions, cities, zips, metros, custom_locations, interests, advantage_audience].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# File 'lib/zernio-sdk/models/boost_post_request_targeting.rb', line 210

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if !@age_min.nil? && @age_min > 65
    invalid_properties.push('invalid value for "age_min", must be smaller than or equal to 65.')
  end

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

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

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

  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



359
360
361
362
363
364
365
366
367
368
369
370
371
# File 'lib/zernio-sdk/models/boost_post_request_targeting.rb', line 359

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



234
235
236
237
238
239
240
241
242
243
244
245
# File 'lib/zernio-sdk/models/boost_post_request_targeting.rb', line 234

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if !@age_min.nil? && @age_min > 65
  return false if !@age_min.nil? && @age_min < 13
  return false if !@age_max.nil? && @age_max > 65
  return false if !@age_max.nil? && @age_max < 13
  gender_validator = EnumAttributeValidator.new('String', ["all", "male", "female"])
  return false unless gender_validator.valid?(@gender)
  advantage_audience_validator = EnumAttributeValidator.new('Integer', [0, 1])
  return false unless advantage_audience_validator.valid?(@advantage_audience)
  true
end