Class: PinterestSdkClient::KeywordsApi

Inherits:
Object
  • Object
show all
Defined in:
lib/pinterest_sdk/api/keywords_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ KeywordsApi

Returns a new instance of KeywordsApi.



19
20
21
# File 'lib/pinterest_sdk/api/keywords_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/pinterest_sdk/api/keywords_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#country_keywords_metrics_get(ad_account_id, country_code, keywords, opts = {}) ⇒ KeywordsMetricsArrayResponse

Get country’s keyword metrics See keyword metrics for a specified country, aggregated across all of Pinterest. (Definitions are available from the "Get delivery metrics definitions" <a href="/docs/api/v5/#operation/delivery_metrics/get">API endpoint</a>).

Parameters:

  • ad_account_id (String)

    Unique identifier of an ad account.

  • country_code (String)

    Two letter country code (ISO 3166-1 alpha-2)

  • keywords (Array<String>)

    Comma-separated keywords

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

    the optional parameters

Returns:



29
30
31
32
# File 'lib/pinterest_sdk/api/keywords_api.rb', line 29

def country_keywords_metrics_get(, country_code, keywords, opts = {})
  data, _status_code, _headers = country_keywords_metrics_get_with_http_info(, country_code, keywords, opts)
  data
end

#country_keywords_metrics_get_with_http_info(ad_account_id, country_code, keywords, opts = {}) ⇒ Array<(KeywordsMetricsArrayResponse, Integer, Hash)>

Get country&#39;s keyword metrics See keyword metrics for a specified country, aggregated across all of Pinterest. (Definitions are available from the &quot;Get delivery metrics definitions&quot; &lt;a href&#x3D;&quot;/docs/api/v5/#operation/delivery_metrics/get&quot;&gt;API endpoint&lt;/a&gt;).

Parameters:

  • ad_account_id (String)

    Unique identifier of an ad account.

  • country_code (String)

    Two letter country code (ISO 3166-1 alpha-2)

  • keywords (Array<String>)

    Comma-separated keywords

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

    the optional parameters

Returns:



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/pinterest_sdk/api/keywords_api.rb', line 41

def country_keywords_metrics_get_with_http_info(, country_code, keywords, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: KeywordsApi.country_keywords_metrics_get ...'
  end
  # verify the required parameter 'ad_account_id' is set
  if @api_client.config.client_side_validation && .nil?
    fail ArgumentError, "Missing the required parameter 'ad_account_id' when calling KeywordsApi.country_keywords_metrics_get"
  end
  if @api_client.config.client_side_validation && .to_s.length > 18
    fail ArgumentError, 'invalid value for "ad_account_id" when calling KeywordsApi.country_keywords_metrics_get, the character length must be smaller than or equal to 18.'
  end

  pattern = Regexp.new(/^\d+$/)
  if @api_client.config.client_side_validation &&  !~ pattern
    fail ArgumentError, "invalid value for 'ad_account_id' when calling KeywordsApi.country_keywords_metrics_get, must conform to the pattern #{pattern}."
  end

  # verify the required parameter 'country_code' is set
  if @api_client.config.client_side_validation && country_code.nil?
    fail ArgumentError, "Missing the required parameter 'country_code' when calling KeywordsApi.country_keywords_metrics_get"
  end
  # verify the required parameter 'keywords' is set
  if @api_client.config.client_side_validation && keywords.nil?
    fail ArgumentError, "Missing the required parameter 'keywords' when calling KeywordsApi.country_keywords_metrics_get"
  end
  if @api_client.config.client_side_validation && keywords.length > 2000
    fail ArgumentError, 'invalid value for "keywords" when calling KeywordsApi.country_keywords_metrics_get, number of items must be less than or equal to 2000.'
  end

  if @api_client.config.client_side_validation && keywords.length < 1
    fail ArgumentError, 'invalid value for "keywords" when calling KeywordsApi.country_keywords_metrics_get, number of items must be greater than or equal to 1.'
  end

  # resource path
  local_var_path = '/ad_accounts/{ad_account_id}/keywords/metrics'.sub('{' + 'ad_account_id' + '}', CGI.escape(.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'country_code'] = country_code
  query_params[:'keywords'] = @api_client.build_collection_param(keywords, :csv)

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'KeywordsMetricsArrayResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['pinterest_oauth2', 'client_credentials']

  new_options = opts.merge(
    :operation => :"KeywordsApi.country_keywords_metrics_get",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: KeywordsApi#country_keywords_metrics_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#keywords_create(ad_account_id, keywords_request, opts = {}) ⇒ KeywordsResponse

Create keywords <p>Create keywords for following entity types(advertiser, campaign, ad group or ad).</p> <p>For more information, see <a target="_blank" href="help.pinterest.com/en/business/article/keyword-targeting">Keyword targeting</a>.</p> <p>Notes:</p> <ul style="list-style-type: square;"> <li>Advertisers and campaigns can only be assigned keywords with excluding (‘_NEGATIVE’).</li> <li>All keyword match types are available for ad groups.</li> </ul> <p>For more information on match types, see <a target="_blank" href="/docs/api-features/targeting-overview/">match type enums</a>.</p> <p>Returns:</p> <ul style="list-style-type: square;"> <li><p>A successful call returns an object containing an array of new keyword objects and an empty &quot;errors&quot; object array.</p></li> <li><p>An unsuccessful call returns an empty keywords array, and, instead, inserts the entire object with nulled/negated properties into the &quot;errors&quot; object array:</p> <pre class="last literal-block"> { "keywords": [], "errors": [ { "data": { "archived": null, "match_type": "EXACT", "parent_type": null, "value": "foobar", "parent_id": null, "type": "keyword", "id": null }, "error_messages": [ "Advertisers and Campaigns only accept excluded targeting attributes." ] } } </pre></li> </ul> <p>Rate limit: <a href="/docs/reference/rate-limits/">WRITE</a>.</p>

Parameters:

  • ad_account_id (String)

    Unique identifier of an ad account.

  • keywords_request (KeywordsRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



122
123
124
125
# File 'lib/pinterest_sdk/api/keywords_api.rb', line 122

def keywords_create(, keywords_request, opts = {})
  data, _status_code, _headers = keywords_create_with_http_info(, keywords_request, opts)
  data
end

#keywords_create_with_http_info(ad_account_id, keywords_request, opts = {}) ⇒ Array<(KeywordsResponse, Integer, Hash)>

Create keywords &lt;p&gt;Create keywords for following entity types(advertiser, campaign, ad group or ad).&lt;/p&gt; &lt;p&gt;For more information, see &lt;a target&#x3D;&quot;_blank&quot; href&#x3D;&quot;help.pinterest.com/en/business/article/keyword-targeting&quot;&gt;Keyword targeting&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;&lt;b&gt;Notes:&lt;/b&gt;&lt;/p&gt; &lt;ul style&#x3D;&quot;list-style-type: square;&quot;&gt; &lt;li&gt;Advertisers and campaigns can only be assigned keywords with excluding (&#39;_NEGATIVE&#39;).&lt;/li&gt; &lt;li&gt;All keyword match types are available for ad groups.&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;For more information on match types, see &lt;a target&#x3D;&quot;_blank&quot; href&#x3D;&quot;/docs/api-features/targeting-overview/&quot;&gt;match type enums&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;&lt;b&gt;Returns:&lt;/b&gt;&lt;/p&gt; &lt;ul style&#x3D;&quot;list-style-type: square;&quot;&gt; &lt;li&gt;&lt;p&gt;A successful call returns an object containing an array of new keyword objects and an empty &amp;quot;errors&amp;quot; object array.&lt;/p&gt;&lt;/li&gt; &lt;li&gt;&lt;p&gt;An unsuccessful call returns an empty keywords array, and, instead, inserts the entire object with nulled/negated properties into the &amp;quot;errors&amp;quot; object array:&lt;/p&gt; &lt;pre class&#x3D;&quot;last literal-block&quot;&gt; { &quot;keywords&quot;: [], &quot;errors&quot;: [ { &quot;data&quot;: { &quot;archived&quot;: null, &quot;match_type&quot;: &quot;EXACT&quot;, &quot;parent_type&quot;: null, &quot;value&quot;: &quot;foobar&quot;, &quot;parent_id&quot;: null, &quot;type&quot;: &quot;keyword&quot;, &quot;id&quot;: null }, &quot;error_messages&quot;: [ &quot;Advertisers and Campaigns only accept excluded targeting attributes.&quot; ] } } &lt;/pre&gt;&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;&lt;b&gt;Rate limit&lt;/b&gt;: &lt;a href&#x3D;&quot;/docs/reference/rate-limits/&quot;&gt;WRITE&lt;/a&gt;.&lt;/p&gt;

Parameters:

  • ad_account_id (String)

    Unique identifier of an ad account.

  • keywords_request (KeywordsRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(KeywordsResponse, Integer, Hash)>)

    KeywordsResponse data, response status code and response headers



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
# File 'lib/pinterest_sdk/api/keywords_api.rb', line 133

def keywords_create_with_http_info(, keywords_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: KeywordsApi.keywords_create ...'
  end
  # verify the required parameter 'ad_account_id' is set
  if @api_client.config.client_side_validation && .nil?
    fail ArgumentError, "Missing the required parameter 'ad_account_id' when calling KeywordsApi.keywords_create"
  end
  if @api_client.config.client_side_validation && .to_s.length > 18
    fail ArgumentError, 'invalid value for "ad_account_id" when calling KeywordsApi.keywords_create, the character length must be smaller than or equal to 18.'
  end

  pattern = Regexp.new(/^\d+$/)
  if @api_client.config.client_side_validation &&  !~ pattern
    fail ArgumentError, "invalid value for 'ad_account_id' when calling KeywordsApi.keywords_create, must conform to the pattern #{pattern}."
  end

  # verify the required parameter 'keywords_request' is set
  if @api_client.config.client_side_validation && keywords_request.nil?
    fail ArgumentError, "Missing the required parameter 'keywords_request' when calling KeywordsApi.keywords_create"
  end
  # resource path
  local_var_path = '/ad_accounts/{ad_account_id}/keywords'.sub('{' + 'ad_account_id' + '}', CGI.escape(.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(keywords_request)

  # return_type
  return_type = opts[:debug_return_type] || 'KeywordsResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['pinterest_oauth2']

  new_options = opts.merge(
    :operation => :"KeywordsApi.keywords_create",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: KeywordsApi#keywords_create\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#keywords_get(ad_account_id, opts = {}) ⇒ KeywordsGet200Response

Get keywords <p>Get a list of keywords based on the filters provided. If no filter is provided, it will default to the ad_account_id filter, which means it will only return keywords that specifically have parent_id set to the ad_account_id. Note: Keywords can have ad_account_ids, campaign_ids, and ad_group_ids set as their parent_ids. Keywords created through Ads Manager will have their parent_id set to an ad_group_id, not ad_account_id.</p> <p>For more information, see <a target="_blank" href="help.pinterest.com/en/business/article/keyword-targeting">Keyword targeting</a>.</p> <p>Notes:</p> <ul style="list-style-type: square;"> <li>Advertisers and campaigns can only be assigned keywords with excluding (‘_NEGATIVE’).</li> <li>All keyword match types are available for ad groups.</li> </ul> <p>For more information on match types, see <a target="_blank" href="/docs/api-features/targeting-overview/">match type enums</a>.</p> <p>Returns:</p> <ul style="list-style-type: square;"> <li><p>A successful call returns an object containing an array of new keyword objects and an empty &quot;errors&quot; object array.</p></li> <li><p>An unsuccessful call returns an empty keywords array, and, instead, inserts the entire object with nulled/negated properties into the &quot;errors&quot; object array:</p> <pre class="last literal-block"> { "keywords": [], "errors": [ { "data": { "archived": null, "match_type": "EXACT", "parent_type": null, "value": "foobar", "parent_id": null, "type": "keyword", "id": null }, "error_messages": [ "Advertisers and Campaigns only accept excluded targeting attributes." ] } } </pre></li> </ul>

Parameters:

  • ad_account_id (String)

    Unique identifier of an ad account.

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

    the optional parameters

Options Hash (opts):

  • :campaign_id (String)

    Campaign Id to use to filter the results.

  • :ad_group_id (String)

    Ad group Id.

  • :ad_group_ids (Array<String>)

    List of Ad group Ids to retrieve keywords from. This feature is currently in BETA and is not available to all users.

  • :match_types (Array<MatchType>)

    Keyword &lt;a target&#x3D;&quot;_blank&quot; href&#x3D;&quot;/docs/api-features/targeting-overview/&quot;&gt;match type&lt;/a&gt;

  • :page_size (Integer)

    Maximum number of items to include in a single page of the response. Default maximum of 250. See documentation on &lt;a href&#x3D;&#39;/docs/reference/pagination/&#39;&gt;Pagination&lt;/a&gt; for more information. (default to 25)

  • :bookmark (String)

    Cursor used to fetch the next page of items

Returns:



210
211
212
213
# File 'lib/pinterest_sdk/api/keywords_api.rb', line 210

def keywords_get(, opts = {})
  data, _status_code, _headers = keywords_get_with_http_info(, opts)
  data
end

#keywords_get_with_http_info(ad_account_id, opts = {}) ⇒ Array<(KeywordsGet200Response, Integer, Hash)>

Get keywords &lt;p&gt;Get a list of keywords based on the filters provided. If no filter is provided, it will default to the ad_account_id filter, which means it will only return keywords that specifically have parent_id set to the ad_account_id. Note: Keywords can have ad_account_ids, campaign_ids, and ad_group_ids set as their parent_ids. Keywords created through Ads Manager will have their parent_id set to an ad_group_id, not ad_account_id.&lt;/p&gt; &lt;p&gt;For more information, see &lt;a target&#x3D;&quot;_blank&quot; href&#x3D;&quot;help.pinterest.com/en/business/article/keyword-targeting&quot;&gt;Keyword targeting&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;&lt;b&gt;Notes:&lt;/b&gt;&lt;/p&gt; &lt;ul style&#x3D;&quot;list-style-type: square;&quot;&gt; &lt;li&gt;Advertisers and campaigns can only be assigned keywords with excluding (&#39;_NEGATIVE&#39;).&lt;/li&gt; &lt;li&gt;All keyword match types are available for ad groups.&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;For more information on match types, see &lt;a target&#x3D;&quot;_blank&quot; href&#x3D;&quot;/docs/api-features/targeting-overview/&quot;&gt;match type enums&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;&lt;b&gt;Returns:&lt;/b&gt;&lt;/p&gt; &lt;ul style&#x3D;&quot;list-style-type: square;&quot;&gt; &lt;li&gt;&lt;p&gt;A successful call returns an object containing an array of new keyword objects and an empty &amp;quot;errors&amp;quot; object array.&lt;/p&gt;&lt;/li&gt; &lt;li&gt;&lt;p&gt;An unsuccessful call returns an empty keywords array, and, instead, inserts the entire object with nulled/negated properties into the &amp;quot;errors&amp;quot; object array:&lt;/p&gt; &lt;pre class&#x3D;&quot;last literal-block&quot;&gt; { &quot;keywords&quot;: [], &quot;errors&quot;: [ { &quot;data&quot;: { &quot;archived&quot;: null, &quot;match_type&quot;: &quot;EXACT&quot;, &quot;parent_type&quot;: null, &quot;value&quot;: &quot;foobar&quot;, &quot;parent_id&quot;: null, &quot;type&quot;: &quot;keyword&quot;, &quot;id&quot;: null }, &quot;error_messages&quot;: [ &quot;Advertisers and Campaigns only accept excluded targeting attributes.&quot; ] } } &lt;/pre&gt;&lt;/li&gt; &lt;/ul&gt;

Parameters:

  • ad_account_id (String)

    Unique identifier of an ad account.

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

    the optional parameters

Options Hash (opts):

  • :campaign_id (String)

    Campaign Id to use to filter the results.

  • :ad_group_id (String)

    Ad group Id.

  • :ad_group_ids (Array<String>)

    List of Ad group Ids to retrieve keywords from. This feature is currently in BETA and is not available to all users.

  • :match_types (Array<MatchType>)

    Keyword &lt;a target&#x3D;&quot;_blank&quot; href&#x3D;&quot;/docs/api-features/targeting-overview/&quot;&gt;match type&lt;/a&gt;

  • :page_size (Integer)

    Maximum number of items to include in a single page of the response. Default maximum of 250. See documentation on &lt;a href&#x3D;&#39;/docs/reference/pagination/&#39;&gt;Pagination&lt;/a&gt; for more information. (default to 25)

  • :bookmark (String)

    Cursor used to fetch the next page of items

Returns:

  • (Array<(KeywordsGet200Response, Integer, Hash)>)

    KeywordsGet200Response data, response status code and response headers



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
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
320
321
322
323
324
325
# File 'lib/pinterest_sdk/api/keywords_api.rb', line 226

def keywords_get_with_http_info(, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: KeywordsApi.keywords_get ...'
  end
  # verify the required parameter 'ad_account_id' is set
  if @api_client.config.client_side_validation && .nil?
    fail ArgumentError, "Missing the required parameter 'ad_account_id' when calling KeywordsApi.keywords_get"
  end
  if @api_client.config.client_side_validation && .to_s.length > 18
    fail ArgumentError, 'invalid value for "ad_account_id" when calling KeywordsApi.keywords_get, the character length must be smaller than or equal to 18.'
  end

  pattern = Regexp.new(/^\d+$/)
  if @api_client.config.client_side_validation &&  !~ pattern
    fail ArgumentError, "invalid value for 'ad_account_id' when calling KeywordsApi.keywords_get, must conform to the pattern #{pattern}."
  end

  if @api_client.config.client_side_validation && !opts[:'campaign_id'].nil? && opts[:'campaign_id'].to_s.length > 18
    fail ArgumentError, 'invalid value for "opts[:"campaign_id"]" when calling KeywordsApi.keywords_get, the character length must be smaller than or equal to 18.'
  end

  pattern = Regexp.new(/^\d+$/)
  if @api_client.config.client_side_validation && !opts[:'campaign_id'].nil? && opts[:'campaign_id'] !~ pattern
    fail ArgumentError, "invalid value for 'opts[:\"campaign_id\"]' when calling KeywordsApi.keywords_get, must conform to the pattern #{pattern}."
  end

  if @api_client.config.client_side_validation && !opts[:'ad_group_id'].nil? && opts[:'ad_group_id'].to_s.length > 18
    fail ArgumentError, 'invalid value for "opts[:"ad_group_id"]" when calling KeywordsApi.keywords_get, the character length must be smaller than or equal to 18.'
  end

  pattern = Regexp.new(/^\d+$/)
  if @api_client.config.client_side_validation && !opts[:'ad_group_id'].nil? && opts[:'ad_group_id'] !~ pattern
    fail ArgumentError, "invalid value for 'opts[:\"ad_group_id\"]' when calling KeywordsApi.keywords_get, must conform to the pattern #{pattern}."
  end

  if @api_client.config.client_side_validation && !opts[:'ad_group_ids'].nil? && opts[:'ad_group_ids'].length > 250
    fail ArgumentError, 'invalid value for "opts[:"ad_group_ids"]" when calling KeywordsApi.keywords_get, number of items must be less than or equal to 250.'
  end

  if @api_client.config.client_side_validation && !opts[:'ad_group_ids'].nil? && opts[:'ad_group_ids'].length < 1
    fail ArgumentError, 'invalid value for "opts[:"ad_group_ids"]" when calling KeywordsApi.keywords_get, number of items must be greater than or equal to 1.'
  end

  if @api_client.config.client_side_validation && !opts[:'match_types'].nil? && opts[:'match_types'].length > 5
    fail ArgumentError, 'invalid value for "opts[:"match_types"]" when calling KeywordsApi.keywords_get, number of items must be less than or equal to 5.'
  end

  if @api_client.config.client_side_validation && !opts[:'match_types'].nil? && opts[:'match_types'].length < 1
    fail ArgumentError, 'invalid value for "opts[:"match_types"]" when calling KeywordsApi.keywords_get, number of items must be greater than or equal to 1.'
  end

  if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] < 1
    fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling KeywordsApi.keywords_get, must be greater than or equal to 1.'
  end

  # resource path
  local_var_path = '/ad_accounts/{ad_account_id}/keywords'.sub('{' + 'ad_account_id' + '}', CGI.escape(.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'campaign_id'] = opts[:'campaign_id'] if !opts[:'campaign_id'].nil?
  query_params[:'ad_group_id'] = opts[:'ad_group_id'] if !opts[:'ad_group_id'].nil?
  query_params[:'ad_group_ids'] = @api_client.build_collection_param(opts[:'ad_group_ids'], :multi) if !opts[:'ad_group_ids'].nil?
  query_params[:'match_types'] = @api_client.build_collection_param(opts[:'match_types'], :multi) if !opts[:'match_types'].nil?
  query_params[:'page_size'] = opts[:'page_size'] if !opts[:'page_size'].nil?
  query_params[:'bookmark'] = opts[:'bookmark'] if !opts[:'bookmark'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'KeywordsGet200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['pinterest_oauth2', 'client_credentials']

  new_options = opts.merge(
    :operation => :"KeywordsApi.keywords_get",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: KeywordsApi#keywords_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#keywords_update(ad_account_id, keyword_update_body, opts = {}) ⇒ KeywordsResponse

Update keywords <p>Update one or more keywords’ bid and archived fields.</p> <p>Archiving a keyword effectively deletes it - keywords no longer receive metrics and no longer visible within the parent entity’s keywords list.</p>

Parameters:

  • ad_account_id (String)

    Unique identifier of an ad account.

  • keyword_update_body (KeywordUpdateBody)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



333
334
335
336
# File 'lib/pinterest_sdk/api/keywords_api.rb', line 333

def keywords_update(, keyword_update_body, opts = {})
  data, _status_code, _headers = keywords_update_with_http_info(, keyword_update_body, opts)
  data
end

#keywords_update_with_http_info(ad_account_id, keyword_update_body, opts = {}) ⇒ Array<(KeywordsResponse, Integer, Hash)>

Update keywords &lt;p&gt;Update one or more keywords&#39; bid and archived fields.&lt;/p&gt; &lt;p&gt;Archiving a keyword effectively deletes it - keywords no longer receive metrics and no longer visible within the parent entity&#39;s keywords list.&lt;/p&gt;

Parameters:

  • ad_account_id (String)

    Unique identifier of an ad account.

  • keyword_update_body (KeywordUpdateBody)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(KeywordsResponse, Integer, Hash)>)

    KeywordsResponse data, response status code and response headers



344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
# File 'lib/pinterest_sdk/api/keywords_api.rb', line 344

def keywords_update_with_http_info(, keyword_update_body, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: KeywordsApi.keywords_update ...'
  end
  # verify the required parameter 'ad_account_id' is set
  if @api_client.config.client_side_validation && .nil?
    fail ArgumentError, "Missing the required parameter 'ad_account_id' when calling KeywordsApi.keywords_update"
  end
  if @api_client.config.client_side_validation && .to_s.length > 18
    fail ArgumentError, 'invalid value for "ad_account_id" when calling KeywordsApi.keywords_update, the character length must be smaller than or equal to 18.'
  end

  pattern = Regexp.new(/^\d+$/)
  if @api_client.config.client_side_validation &&  !~ pattern
    fail ArgumentError, "invalid value for 'ad_account_id' when calling KeywordsApi.keywords_update, must conform to the pattern #{pattern}."
  end

  # verify the required parameter 'keyword_update_body' is set
  if @api_client.config.client_side_validation && keyword_update_body.nil?
    fail ArgumentError, "Missing the required parameter 'keyword_update_body' when calling KeywordsApi.keywords_update"
  end
  # resource path
  local_var_path = '/ad_accounts/{ad_account_id}/keywords'.sub('{' + 'ad_account_id' + '}', CGI.escape(.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(keyword_update_body)

  # return_type
  return_type = opts[:debug_return_type] || 'KeywordsResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['pinterest_oauth2']

  new_options = opts.merge(
    :operation => :"KeywordsApi.keywords_update",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: KeywordsApi#keywords_update\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

List trending keywords <p>Get the top trending search keywords among the Pinterest user audience.</p> <p>Trending keywords can be used to inform ad targeting, budget strategy, and creative decisions about which products and Pins will resonate with your audience.</p> <p>Geographic, demographic and interest-based filters are available to narrow down to the top trends among a specific audience. Multiple trend types are supported that can be used to identify newly-popular, evergreen or seasonal keywords.</p> <p>For an interactive way to explore this data, please visit <a href="trends.pinterest.com">trends.pinterest.com</a>.

Parameters:

  • region (TrendsSupportedRegion)

    The geographic region of interest. Only top trends within the specified region will be returned.&lt;br /&gt; The &#x60;region&#x60; parameter is formatted as ISO 3166-2 country codes delimited by &#x60;+&#x60;, corresponding to the following geographic areas: - &#x60;US&#x60; - United States - &#x60;CA&#x60; - Canada - &#x60;DE&#x60; - Germany - &#x60;FR&#x60; - France - &#x60;ES&#x60; - Spain - &#x60;IT&#x60; - Italy - &#x60;DE+AT+CH&#x60; - Germanic countries - &#x60;GB+IE&#x60; - Great Britain &amp; Ireland - &#x60;IT+ES+PT+GR+MT&#x60; - Southern Europe - &#x60;PL+RO+HU+SK+CZ&#x60; - Eastern Europe - &#x60;SE+DK+FI+NO&#x60; - Nordic countries - &#x60;NL+BE+LU&#x60; - Benelux - &#x60;AR&#x60; - Argentina - &#x60;BR&#x60; - Brazil - &#x60;CO&#x60; - Colombia - &#x60;MX&#x60; - Mexico - &#x60;MX+AR+CO+CL&#x60; - Hispanic LatAm - &#x60;AU+NZ&#x60; - Australasia

  • trend_type (TrendType)

    The methodology used to rank how trendy a keyword is. - &#x60;growing&#x60; trends have high upward growth in search volume over the last quarter - &#x60;monthly&#x60; trends have high search volume in the last month - &#x60;yearly&#x60; trends have high search volume in the last year - &#x60;seasonal&#x60; trends have high upward growth in search volume over the last month and exhibit a seasonal recurring pattern (typically annual)

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

    the optional parameters

Options Hash (opts):

  • :interests (Array<String>)

    If set, filters the results to trends associated with the specified interests.&lt;br /&gt; If unset, trends for all interests will be returned.&lt;br /&gt; The list of supported interests is: - &#x60;animals&#x60; - Animals - &#x60;architecture&#x60; - Architecture - &#x60;art&#x60; - Art - &#x60;beauty&#x60; - Beauty - &#x60;childrens_fashion&#x60; - Children&#39;s Fashion - &#x60;design&#x60; - Design - &#x60;diy_and_crafts&#x60; - DIY &amp; Crafts - &#x60;education&#x60; - Education - &#x60;electronics&#x60; - Electronics - &#x60;entertainment&#x60; - Entertainment - &#x60;event_planning&#x60; - Event Planning - &#x60;finance&#x60; - Finance - &#x60;food_and_drinks&#x60; - Food &amp; Drink - &#x60;gardening&#x60; - Gardening - &#x60;health&#x60; - Health - &#x60;home_decor&#x60; - Home Decor - &#x60;mens_fashion&#x60; - Men&#39;s Fashion - &#x60;parenting&#x60; - Parenting - &#x60;quotes&#x60; - Quotes - &#x60;sport&#x60; - Sports - &#x60;travel&#x60; - Travel - &#x60;vehicles&#x60; - Vehicles - &#x60;wedding&#x60; - Wedding - &#x60;womens_fashion&#x60; - Women&#39;s Fashion

  • :genders (Array<String>)

    If set, filters the results to trends among users who identify with the specified gender(s).&lt;br /&gt; If unset, trends among all genders will be returned.&lt;br /&gt; The &#x60;unknown&#x60; group includes users with unspecified or customized gender profile settings.

  • :ages (Array<String>)

    If set, filters the results to trends among users in the specified age range(s).&lt;br /&gt; If unset, trends among all age groups will be returned.

  • :include_keywords (Array<String>)

    If set, filters the results to top trends which include at least one of the specified keywords.&lt;br /&gt; If unset, no keyword filtering logic is applied.

  • :normalize_against_group (Boolean)

    Governs how the resulting time series data will be normalized to a [0-100] scale.&lt;br /&gt; By default (&#x60;false&#x60;), the data will be normalized independently for each keyword. The peak search volume observation in each keyword&#39;s time series will be represented by the value 100. This is ideal for analyzing when an individual keyword is expected to peak in interest.&lt;br /&gt; If set to &#x60;true&#x60;, the data will be normalized as a group. The peak search volume observation across all keywords in the response will be represented by the value 100, and all other values scaled accordingly. Use this option when you wish to compare relative search volume between multiple keywords. (default to false)

  • :limit (Integer)

    The maximum number of trending keywords that will be returned. Keywords are returned in trend-ranked order, so a &#x60;limit&#x60; of 50 will return the top 50 trends. (default to 50)

  • :include_prediction (Boolean)

    &lt;a href&#x3D;&quot;/docs/getting-started/using-beta-and-restricted-features/&quot; target&#x3D;&quot;blank&quot; target&#x3D;&quot;blank&quot;&gt;Closed beta&lt;/a&gt; Including predicted weekly search volume data for the next 90 days. By default (&#x60;false&#x60;), the response will not include predicted data. (default to false)

  • :include_demographics (Boolean)

    &lt;a href&#x3D;&quot;/docs/getting-started/using-beta-and-restricted-features/&quot; target&#x3D;&quot;blank&quot; target&#x3D;&quot;blank&quot;&gt;Closed beta&lt;/a&gt; Including the age and gender distribution for each keyword. By default (&#x60;false&#x60;), the response will not include demographics data. (default to false)

Returns:



424
425
426
427
# File 'lib/pinterest_sdk/api/keywords_api.rb', line 424

def trending_keywords_list(region, trend_type, opts = {})
  data, _status_code, _headers = trending_keywords_list_with_http_info(region, trend_type, opts)
  data
end

List trending keywords &lt;p&gt;Get the top trending search keywords among the Pinterest user audience.&lt;/p&gt; &lt;p&gt;Trending keywords can be used to inform ad targeting, budget strategy, and creative decisions about which products and Pins will resonate with your audience.&lt;/p&gt; &lt;p&gt;Geographic, demographic and interest-based filters are available to narrow down to the top trends among a specific audience. Multiple trend types are supported that can be used to identify newly-popular, evergreen or seasonal keywords.&lt;/p&gt; &lt;p&gt;For an interactive way to explore this data, please visit &lt;a href&#x3D;&quot;trends.pinterest.com&quot;&gt;trends.pinterest.com&lt;/a&gt;.

Parameters:

  • region (TrendsSupportedRegion)

    The geographic region of interest. Only top trends within the specified region will be returned.&lt;br /&gt; The &#x60;region&#x60; parameter is formatted as ISO 3166-2 country codes delimited by &#x60;+&#x60;, corresponding to the following geographic areas: - &#x60;US&#x60; - United States - &#x60;CA&#x60; - Canada - &#x60;DE&#x60; - Germany - &#x60;FR&#x60; - France - &#x60;ES&#x60; - Spain - &#x60;IT&#x60; - Italy - &#x60;DE+AT+CH&#x60; - Germanic countries - &#x60;GB+IE&#x60; - Great Britain &amp; Ireland - &#x60;IT+ES+PT+GR+MT&#x60; - Southern Europe - &#x60;PL+RO+HU+SK+CZ&#x60; - Eastern Europe - &#x60;SE+DK+FI+NO&#x60; - Nordic countries - &#x60;NL+BE+LU&#x60; - Benelux - &#x60;AR&#x60; - Argentina - &#x60;BR&#x60; - Brazil - &#x60;CO&#x60; - Colombia - &#x60;MX&#x60; - Mexico - &#x60;MX+AR+CO+CL&#x60; - Hispanic LatAm - &#x60;AU+NZ&#x60; - Australasia

  • trend_type (TrendType)

    The methodology used to rank how trendy a keyword is. - &#x60;growing&#x60; trends have high upward growth in search volume over the last quarter - &#x60;monthly&#x60; trends have high search volume in the last month - &#x60;yearly&#x60; trends have high search volume in the last year - &#x60;seasonal&#x60; trends have high upward growth in search volume over the last month and exhibit a seasonal recurring pattern (typically annual)

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

    the optional parameters

Options Hash (opts):

  • :interests (Array<String>)

    If set, filters the results to trends associated with the specified interests.&lt;br /&gt; If unset, trends for all interests will be returned.&lt;br /&gt; The list of supported interests is: - &#x60;animals&#x60; - Animals - &#x60;architecture&#x60; - Architecture - &#x60;art&#x60; - Art - &#x60;beauty&#x60; - Beauty - &#x60;childrens_fashion&#x60; - Children&#39;s Fashion - &#x60;design&#x60; - Design - &#x60;diy_and_crafts&#x60; - DIY &amp; Crafts - &#x60;education&#x60; - Education - &#x60;electronics&#x60; - Electronics - &#x60;entertainment&#x60; - Entertainment - &#x60;event_planning&#x60; - Event Planning - &#x60;finance&#x60; - Finance - &#x60;food_and_drinks&#x60; - Food &amp; Drink - &#x60;gardening&#x60; - Gardening - &#x60;health&#x60; - Health - &#x60;home_decor&#x60; - Home Decor - &#x60;mens_fashion&#x60; - Men&#39;s Fashion - &#x60;parenting&#x60; - Parenting - &#x60;quotes&#x60; - Quotes - &#x60;sport&#x60; - Sports - &#x60;travel&#x60; - Travel - &#x60;vehicles&#x60; - Vehicles - &#x60;wedding&#x60; - Wedding - &#x60;womens_fashion&#x60; - Women&#39;s Fashion

  • :genders (Array<String>)

    If set, filters the results to trends among users who identify with the specified gender(s).&lt;br /&gt; If unset, trends among all genders will be returned.&lt;br /&gt; The &#x60;unknown&#x60; group includes users with unspecified or customized gender profile settings.

  • :ages (Array<String>)

    If set, filters the results to trends among users in the specified age range(s).&lt;br /&gt; If unset, trends among all age groups will be returned.

  • :include_keywords (Array<String>)

    If set, filters the results to top trends which include at least one of the specified keywords.&lt;br /&gt; If unset, no keyword filtering logic is applied.

  • :normalize_against_group (Boolean)

    Governs how the resulting time series data will be normalized to a [0-100] scale.&lt;br /&gt; By default (&#x60;false&#x60;), the data will be normalized independently for each keyword. The peak search volume observation in each keyword&#39;s time series will be represented by the value 100. This is ideal for analyzing when an individual keyword is expected to peak in interest.&lt;br /&gt; If set to &#x60;true&#x60;, the data will be normalized as a group. The peak search volume observation across all keywords in the response will be represented by the value 100, and all other values scaled accordingly. Use this option when you wish to compare relative search volume between multiple keywords. (default to false)

  • :limit (Integer)

    The maximum number of trending keywords that will be returned. Keywords are returned in trend-ranked order, so a &#x60;limit&#x60; of 50 will return the top 50 trends. (default to 50)

  • :include_prediction (Boolean)

    &lt;a href&#x3D;&quot;/docs/getting-started/using-beta-and-restricted-features/&quot; target&#x3D;&quot;blank&quot; target&#x3D;&quot;blank&quot;&gt;Closed beta&lt;/a&gt; Including predicted weekly search volume data for the next 90 days. By default (&#x60;false&#x60;), the response will not include predicted data. (default to false)

  • :include_demographics (Boolean)

    &lt;a href&#x3D;&quot;/docs/getting-started/using-beta-and-restricted-features/&quot; target&#x3D;&quot;blank&quot; target&#x3D;&quot;blank&quot;&gt;Closed beta&lt;/a&gt; Including the age and gender distribution for each keyword. By default (&#x60;false&#x60;), the response will not include demographics data. (default to false)

Returns:

  • (Array<(TrendingKeywordsResponse, Integer, Hash)>)

    TrendingKeywordsResponse data, response status code and response headers



443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
# File 'lib/pinterest_sdk/api/keywords_api.rb', line 443

def trending_keywords_list_with_http_info(region, trend_type, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: KeywordsApi.trending_keywords_list ...'
  end
  # verify the required parameter 'region' is set
  if @api_client.config.client_side_validation && region.nil?
    fail ArgumentError, "Missing the required parameter 'region' when calling KeywordsApi.trending_keywords_list"
  end
  # verify the required parameter 'trend_type' is set
  if @api_client.config.client_side_validation && trend_type.nil?
    fail ArgumentError, "Missing the required parameter 'trend_type' when calling KeywordsApi.trending_keywords_list"
  end
  allowable_values = ["animals", "architecture", "art", "beauty", "childrens_fashion", "design", "diy_and_crafts", "education", "electronics", "entertainment", "event_planning", "finance", "food_and_drinks", "gardening", "health", "home_decor", "mens_fashion", "parenting", "quotes", "sport", "travel", "vehicles", "wedding", "womens_fashion"]
  if @api_client.config.client_side_validation && opts[:'interests'] && !opts[:'interests'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"interests\", must include one of #{allowable_values}"
  end
  allowable_values = ["female", "male", "unknown"]
  if @api_client.config.client_side_validation && opts[:'genders'] && !opts[:'genders'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"genders\", must include one of #{allowable_values}"
  end
  allowable_values = ["18-24", "25-34", "35-44", "45-49", "50-54", "55-64", "65+"]
  if @api_client.config.client_side_validation && opts[:'ages'] && !opts[:'ages'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"ages\", must include one of #{allowable_values}"
  end
  if @api_client.config.client_side_validation && !opts[:'include_keywords'].nil? && opts[:'include_keywords'].length > 50
    fail ArgumentError, 'invalid value for "opts[:"include_keywords"]" when calling KeywordsApi.trending_keywords_list, number of items must be less than or equal to 50.'
  end

  if @api_client.config.client_side_validation && !opts[:'include_keywords'].nil? && opts[:'include_keywords'].length < 1
    fail ArgumentError, 'invalid value for "opts[:"include_keywords"]" when calling KeywordsApi.trending_keywords_list, number of items must be greater than or equal to 1.'
  end

  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 50
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling KeywordsApi.trending_keywords_list, must be smaller than or equal to 50.'
  end

  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling KeywordsApi.trending_keywords_list, must be greater than or equal to 1.'
  end

  # resource path
  local_var_path = '/trends/keywords/{region}/top/{trend_type}'.sub('{' + 'region' + '}', CGI.escape(region.to_s)).sub('{' + 'trend_type' + '}', CGI.escape(trend_type.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'interests'] = @api_client.build_collection_param(opts[:'interests'], :multi) if !opts[:'interests'].nil?
  query_params[:'genders'] = @api_client.build_collection_param(opts[:'genders'], :multi) if !opts[:'genders'].nil?
  query_params[:'ages'] = @api_client.build_collection_param(opts[:'ages'], :multi) if !opts[:'ages'].nil?
  query_params[:'include_keywords'] = @api_client.build_collection_param(opts[:'include_keywords'], :multi) if !opts[:'include_keywords'].nil?
  query_params[:'normalize_against_group'] = opts[:'normalize_against_group'] if !opts[:'normalize_against_group'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'include_prediction'] = opts[:'include_prediction'] if !opts[:'include_prediction'].nil?
  query_params[:'include_demographics'] = opts[:'include_demographics'] if !opts[:'include_demographics'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'TrendingKeywordsResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['pinterest_oauth2']

  new_options = opts.merge(
    :operation => :"KeywordsApi.trending_keywords_list",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: KeywordsApi#trending_keywords_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end