Class: PinterestSdkClient::AudienceRule

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

Overview

JSON object defining targeted audience users. Example rule formats per audience type:
CUSTOMER_LIST: { "customer_list_id": "<customer list ID>"}
ACTALIKE: { "seed_id": ["<audience ID>"], "country": "US", "percentage": "10" }
(Valid countries include: "US", "CA", and "GB". Percentage should be 1-10.
The targeted audience should be this % size across Pinterest.)
VISITOR: { "visitor_source_id": ["<conversion tag ID>"], "retention_days": "180", "event_source": ["web", "mobile"], "ingestion_source": ["tag"]}
(Retention days should be 1-540. Retention applies to specific customers.)
ENGAGEMENT: ["www.example.com"], "engager_type": 1
Learn more about <a href="/docs/work-with-targets-and-audiences/create-audiences/#engagement-audience" target="_blank">engagement audiences</a>.

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

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Instance Attribute Details

#ad_account_idObject

Ad account ID.



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

def 
  
end

#ad_idObject

Ad ID for engagement audience filter.



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

def ad_id
  @ad_id
end

#campaign_idObject

Campaign ID for engagement audience filter.



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

def campaign_id
  @campaign_id
end

#countryObject

Valid countries include: "US", "CA", and "GB".



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

def country
  @country
end

#customer_list_idObject

Customer list ID. For CUSTOMER_LIST audience_type.



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

def customer_list_id
  @customer_list_id
end

#engagement_domainObject

The audience account’s verified domain. Required for ENGAGEMENT audience_type.



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

def engagement_domain
  @engagement_domain
end

#engagement_typeObject

Engagement type enum. Optional for ENGAGEMENT audience_type. Supported values are click, save, closeup, comment and like. All engagements are included if this field is not set.



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

def engagement_type
  @engagement_type
end

#engager_typeObject

Optional for ENGAGEMENT. Engager type value should be 1-2.



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

def engager_type
  @engager_type
end

#eventObject

A Pinterest tag event. Optional for VISITOR audience_type. Possible values are pagevisit, signup, checkout, viewcategory, search, addtocart, watchvideo, lead, and custom. This field also accepts a partner-defined Pinterest tag event.



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

def event
  @event
end

#event_dataObject

Returns the value of attribute event_data.



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

def event_data
  @event_data
end

#event_sourceObject

Optional for VISITOR. You can use it as a [value]. Supported values are: web, mobile, offline



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

def event_source
  @event_source
end

#ingestion_sourceObject

Optional for VISITOR. You can use it as a [value]. Supported values are: tag, mmp, file_upload, conversions_api



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

def ingestion_source
  @ingestion_source
end

#objective_typeObject

Objective for engagement audience filter.



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

def objective_type
  @objective_type
end

#percentageObject

Percentage should be 1-10. The targeted audience should be this % size across Pinterest.



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

def percentage
  @percentage
end

#pin_idObject

IDs of engaged organic pins. Optional for ENGAGEMENT audience_type. For example, "pin_id:": ["34567"]



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

def pin_id
  @pin_id
end

#prefillObject

Optional for VISITOR audience_type. If true, the specified rule on existing engagement data is applied to pre-populate the audience. If false, the audience is empty at creation time. The default is true.



64
65
66
# File 'lib/pinterest_sdk/models/audience_rule.rb', line 64

def prefill
  @prefill
end

#retention_daysObject

Number of days a Pinterest user remains in the audience. Optional for ENGAGEMENT and VISITOR audience_type. Accepted range is 1-540. Defaults to 180 if not specified.



67
68
69
# File 'lib/pinterest_sdk/models/audience_rule.rb', line 67

def retention_days
  @retention_days
end

#seed_idObject

Audience ID(s). For ACTALIKE audience_type.



70
71
72
# File 'lib/pinterest_sdk/models/audience_rule.rb', line 70

def seed_id
  @seed_id
end

#urlObject

Optional for ENGAGEMENT or VISITOR audience_type. For ENGAGEMENT, it is the engaged pin’s URL. For VISITOR, you can use it as a string or a value object for filtering visitors based on conversion tag event URLs. Supported operators are [ =, !=, contains, not_contains].
Example 1: "url": "www.myonlinestore123.com/view_item/shoe"
Example 2: "url": "/view_item/shoe"



73
74
75
# File 'lib/pinterest_sdk/models/audience_rule.rb', line 73

def url
  @url
end

#visitor_source_idObject

The conversion tag ID, or the Pinterest tag ID, that you use on your website. For VISITOR audience_type.



76
77
78
# File 'lib/pinterest_sdk/models/audience_rule.rb', line 76

def visitor_source_id
  @visitor_source_id
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



105
106
107
# File 'lib/pinterest_sdk/models/audience_rule.rb', line 105

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



110
111
112
# File 'lib/pinterest_sdk/models/audience_rule.rb', line 110

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

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



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/pinterest_sdk/models/audience_rule.rb', line 79

def self.attribute_map
  {
    :'ad_account_id' => :'ad_account_id',
    :'ad_id' => :'ad_id',
    :'campaign_id' => :'campaign_id',
    :'country' => :'country',
    :'customer_list_id' => :'customer_list_id',
    :'engagement_domain' => :'engagement_domain',
    :'engagement_type' => :'engagement_type',
    :'engager_type' => :'engager_type',
    :'event' => :'event',
    :'event_data' => :'event_data',
    :'event_source' => :'event_source',
    :'ingestion_source' => :'ingestion_source',
    :'objective_type' => :'objective_type',
    :'percentage' => :'percentage',
    :'pin_id' => :'pin_id',
    :'prefill' => :'prefill',
    :'retention_days' => :'retention_days',
    :'seed_id' => :'seed_id',
    :'url' => :'url',
    :'visitor_source_id' => :'visitor_source_id'
  }
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



377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
# File 'lib/pinterest_sdk/models/audience_rule.rb', line 377

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



141
142
143
144
# File 'lib/pinterest_sdk/models/audience_rule.rb', line 141

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

.openapi_typesObject

Attribute type mapping.



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

def self.openapi_types
  {
    :'ad_account_id' => :'String',
    :'ad_id' => :'Array<String>',
    :'campaign_id' => :'Array<String>',
    :'country' => :'String',
    :'customer_list_id' => :'String',
    :'engagement_domain' => :'Array<String>',
    :'engagement_type' => :'String',
    :'engager_type' => :'Integer',
    :'event' => :'String',
    :'event_data' => :'EventData',
    :'event_source' => :'Object',
    :'ingestion_source' => :'Object',
    :'objective_type' => :'Array<ObjectiveType>',
    :'percentage' => :'Integer',
    :'pin_id' => :'Array<String>',
    :'prefill' => :'Boolean',
    :'retention_days' => :'Integer',
    :'seed_id' => :'Array<String>',
    :'url' => :'Array<String>',
    :'visitor_source_id' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
# File 'lib/pinterest_sdk/models/audience_rule.rb', line 337

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
       == o. &&
      ad_id == o.ad_id &&
      campaign_id == o.campaign_id &&
      country == o.country &&
      customer_list_id == o.customer_list_id &&
      engagement_domain == o.engagement_domain &&
      engagement_type == o.engagement_type &&
      engager_type == o.engager_type &&
      event == o.event &&
      event_data == o.event_data &&
      event_source == o.event_source &&
      ingestion_source == o.ingestion_source &&
      objective_type == o.objective_type &&
      percentage == o.percentage &&
      pin_id == o.pin_id &&
      prefill == o.prefill &&
      retention_days == o.retention_days &&
      seed_id == o.seed_id &&
      url == o.url &&
      visitor_source_id == o.visitor_source_id
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


364
365
366
# File 'lib/pinterest_sdk/models/audience_rule.rb', line 364

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



370
371
372
# File 'lib/pinterest_sdk/models/audience_rule.rb', line 370

def hash
  [, ad_id, campaign_id, country, customer_list_id, engagement_domain, engagement_type, engager_type, event, event_data, event_source, ingestion_source, objective_type, percentage, pin_id, prefill, retention_days, seed_id, url, visitor_source_id].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
# File 'lib/pinterest_sdk/models/audience_rule.rb', line 259

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

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

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



399
400
401
402
403
404
405
406
407
408
409
410
411
# File 'lib/pinterest_sdk/models/audience_rule.rb', line 399

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



282
283
284
285
286
287
288
# File 'lib/pinterest_sdk/models/audience_rule.rb', line 282

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