Class: PinterestSdkClient::ResourcesApi

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ ResourcesApi

Returns a new instance of ResourcesApi.



19
20
21
# File 'lib/pinterest_sdk/api/resources_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/resources_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#ad_account_countries_get(opts = {}) ⇒ AdAccountCountriesGet200Response

Get ad accounts countries Get Ad Accounts countries

Parameters:

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

    the optional parameters

Returns:



26
27
28
29
# File 'lib/pinterest_sdk/api/resources_api.rb', line 26

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

#ad_account_countries_get_with_http_info(opts = {}) ⇒ Array<(AdAccountCountriesGet200Response, Integer, Hash)>

Get ad accounts countries Get Ad Accounts countries

Parameters:

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

    the optional parameters

Returns:



35
36
37
38
39
40
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
# File 'lib/pinterest_sdk/api/resources_api.rb', line 35

def (opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ResourcesApi.ad_account_countries_get ...'
  end
  # resource path
  local_var_path = '/resources/ad_account_countries'

  # 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']

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

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

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

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

  new_options = opts.merge(
    :operation => :"ResourcesApi.ad_account_countries_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: ResourcesApi#ad_account_countries_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delivery_metrics_get(opts = {}) ⇒ DeliveryMetricsGet200Response

Get available metrics' definitions Get the definitions for ads and organic metrics available across both synchronous and asynchronous report endpoints. The display_name attribute will match how the metric is named in our native tools like Ads Manager. See Organic Analytics and Ads Analytics for more information.

Parameters:

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

    the optional parameters

Options Hash (opts):

Returns:



84
85
86
87
# File 'lib/pinterest_sdk/api/resources_api.rb', line 84

def delivery_metrics_get(opts = {})
  data, _status_code, _headers = delivery_metrics_get_with_http_info(opts)
  data
end

#delivery_metrics_get_with_http_info(opts = {}) ⇒ Array<(DeliveryMetricsGet200Response, Integer, Hash)>

Get available metrics' definitions Get the definitions for ads and organic metrics available across both synchronous and asynchronous report endpoints. The `display_name` attribute will match how the metric is named in our native tools like Ads Manager. See Organic Analytics and Ads Analytics for more information.

Parameters:

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

    the optional parameters

Options Hash (opts):

Returns:



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/pinterest_sdk/api/resources_api.rb', line 94

def delivery_metrics_get_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ResourcesApi.delivery_metrics_get ...'
  end
  # resource path
  local_var_path = '/resources/delivery_metrics'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'report_type'] = opts[:'report_type'] if !opts[:'report_type'].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] || 'DeliveryMetricsGet200Response'

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

  new_options = opts.merge(
    :operation => :"ResourcesApi.delivery_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: ResourcesApi#delivery_metrics_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#interest_targeting_options_get(interest_id, opts = {}) ⇒ SingleInterestTargetingOption

Get interest details Get details of a specific interest given interest ID. Click here for a spreadsheet listing interests and their IDs.

Parameters:

  • interest_id (String)

    Unique identifier of an interest.

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

    the optional parameters

Returns:



144
145
146
147
# File 'lib/pinterest_sdk/api/resources_api.rb', line 144

def interest_targeting_options_get(interest_id, opts = {})
  data, _status_code, _headers = interest_targeting_options_get_with_http_info(interest_id, opts)
  data
end

#interest_targeting_options_get_with_http_info(interest_id, opts = {}) ⇒ Array<(SingleInterestTargetingOption, Integer, Hash)>

Get interest details Get details of a specific interest given interest ID. Click here for a spreadsheet listing interests and their IDs.

Parameters:

  • interest_id (String)

    Unique identifier of an interest.

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

    the optional parameters

Returns:



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

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

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

  # resource path
  local_var_path = '/resources/targeting/interests/{interest_id}'.sub('{interest_id}', CGI.escape(interest_id.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']

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

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

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

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

  new_options = opts.merge(
    :operation => :"ResourcesApi.interest_targeting_options_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: ResourcesApi#interest_targeting_options_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#lead_form_questions_get(opts = {}) ⇒ nil

Get lead form questions Get a list of all lead form question type names. Some questions might not be used. This endpoint is currently in beta and not available to all apps. Learn more.

Parameters:

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

    the optional parameters

Returns:

  • (nil)


215
216
217
218
# File 'lib/pinterest_sdk/api/resources_api.rb', line 215

def lead_form_questions_get(opts = {})
  lead_form_questions_get_with_http_info(opts)
  nil
end

#lead_form_questions_get_with_http_info(opts = {}) ⇒ Array<(nil, Integer, Hash)>

Get lead form questions Get a list of all lead form question type names. Some questions might not be used. This endpoint is currently in beta and not available to all apps. Learn more.

Parameters:

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

    the optional parameters

Returns:

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

    nil, response status code and response headers



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
256
257
258
259
260
261
262
263
264
265
266
# File 'lib/pinterest_sdk/api/resources_api.rb', line 224

def lead_form_questions_get_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ResourcesApi.lead_form_questions_get ...'
  end
  # resource path
  local_var_path = '/resources/lead_form_questions'

  # 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']

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

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

  # return_type
  return_type = opts[:debug_return_type]

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

  new_options = opts.merge(
    :operation => :"ResourcesApi.lead_form_questions_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: ResourcesApi#lead_form_questions_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#metrics_ready_state_get(date, opts = {}) ⇒ BookClosed

Get metrics ready state Learn whether conversion or non-conversion metrics are finalized and ready to query.

Parameters:

  • date (String)

    Analytics reports request date (UTC). Format: YYYY-MM-DD

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

    the optional parameters

Returns:



273
274
275
276
# File 'lib/pinterest_sdk/api/resources_api.rb', line 273

def metrics_ready_state_get(date, opts = {})
  data, _status_code, _headers = metrics_ready_state_get_with_http_info(date, opts)
  data
end

#metrics_ready_state_get_with_http_info(date, opts = {}) ⇒ Array<(BookClosed, Integer, Hash)>

Get metrics ready state Learn whether conversion or non-conversion metrics are finalized and ready to query.

Parameters:

  • date (String)

    Analytics reports request date (UTC). Format: YYYY-MM-DD

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

    the optional parameters

Returns:

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

    BookClosed data, response status code and response headers



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
326
327
328
329
330
331
332
333
334
335
# File 'lib/pinterest_sdk/api/resources_api.rb', line 283

def metrics_ready_state_get_with_http_info(date, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ResourcesApi.metrics_ready_state_get ...'
  end
  # verify the required parameter 'date' is set
  if @api_client.config.client_side_validation && date.nil?
    fail ArgumentError, "Missing the required parameter 'date' when calling ResourcesApi.metrics_ready_state_get"
  end
  pattern = Regexp.new(/^\d{4}-\d{2}-\d{2}$/)
  if @api_client.config.client_side_validation && date !~ pattern
    fail ArgumentError, "invalid value for 'date' when calling ResourcesApi.metrics_ready_state_get, must conform to the pattern #{pattern}."
  end

  # resource path
  local_var_path = '/resources/metrics_ready_state'

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

  # 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] || 'BookClosed'

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

  new_options = opts.merge(
    :operation => :"ResourcesApi.metrics_ready_state_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: ResourcesApi#metrics_ready_state_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#targeting_options_get(targeting_type, opts = {}) ⇒ Array<Object>

Get targeting options You can use targeting values in ads placement to define your intended audience. Targeting metrics are organized around targeting specifications. For more information on ads targeting, see Audience targeting. Sample return: [{\"36313\": \"Australia: Moreton Bay - North\", \"124735\": \"Canada: North Battleford\", \"36109\": \"Australia: Murray\", \"36108\": \"Australia: Mid North Coast\", \"36101\": \"Australia: Capital Region\", \"811\": \"U.S.: Reno\", \"36103\": \"Australia: Central West\", \"36102\": \"Australia: Central Coast\", \"36105\": \"Australia: Far West and Orana\", \"36104\": \"Australia: Coffs Harbour - Grafton\", \"36107\": \"Australia: Illawarra\", \"36106\": \"Australia: Hunter Valley Exc Newcastle\", \"554017\": \"New Zealand: Wanganui\", \"554016\": \"New Zealand: Marlborough\", \"554015\": \"New Zealand: Gisborne\", \"554014\": \"New Zealand: Tararua\", \"554013\": \"New Zealand: Invercargill\", \"GR\": \"Greece\", \"554011\": \"New Zealand: Whangarei\", \"554010\": \"New Zealand: Far North\", \"717\": \"U.S.: Quincy-Hannibal-Keokuk\", \"716\": \"U.S.: Baton Rouge\",...}]

Parameters:

  • targeting_type (PublicTargetingType)

    Public targeting type

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

    the optional parameters

Options Hash (opts):

  • :ad_account_id (String)

    Unique identifier of an ad account.

  • :client_id (String)

    Client ID

  • :oauth_signature (String)

    Oauth signature

  • :timestamp (String)

    Timestamp.

Returns:

  • (Array<Object>)


346
347
348
349
# File 'lib/pinterest_sdk/api/resources_api.rb', line 346

def targeting_options_get(targeting_type, opts = {})
  data, _status_code, _headers = targeting_options_get_with_http_info(targeting_type, opts)
  data
end

#targeting_options_get_with_http_info(targeting_type, opts = {}) ⇒ Array<(Array<Object>, Integer, Hash)>

Get targeting options You can use targeting values in ads placement to define your intended audience. Targeting metrics are organized around targeting specifications. For more information on ads targeting, see Audience targeting. Sample return: ``` [\"Australia: Moreton Bay - North\", \"124735\": \"Canada: North Battleford\", \"36109\": \"Australia: Murray\", \"36108\": \"Australia: Mid North Coast\", \"36101\": \"Australia: Capital Region\", \"811\": \"U.S.: Reno\", \"36103\": \"Australia: Central West\", \"36102\": \"Australia: Central Coast\", \"36105\": \"Australia: Far West and Orana\", \"36104\": \"Australia: Coffs Harbour - Grafton\", \"36107\": \"Australia: Illawarra\", \"36106\": \"Australia: Hunter Valley Exc Newcastle\", \"554017\": \"New Zealand: Wanganui\", \"554016\": \"New Zealand: Marlborough\", \"554015\": \"New Zealand: Gisborne\", \"554014\": \"New Zealand: Tararua\", \"554013\": \"New Zealand: Invercargill\", \"GR\": \"Greece\", \"554011\": \"New Zealand: Whangarei\", \"554010\": \"New Zealand: Far North\", \"717\": \"U.S.: Quincy-Hannibal-Keokuk\", \"716\": \"U.S.: Baton Rouge\",...] ```

Parameters:

  • targeting_type (PublicTargetingType)

    Public targeting type

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

    the optional parameters

Options Hash (opts):

  • :ad_account_id (String)

    Unique identifier of an ad account.

  • :client_id (String)

    Client ID

  • :oauth_signature (String)

    Oauth signature

  • :timestamp (String)

    Timestamp.

Returns:

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

    Array data, response status code and response headers

    
    
    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
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    # File 'lib/pinterest_sdk/api/resources_api.rb', line 360
    
    def targeting_options_get_with_http_info(targeting_type, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: ResourcesApi.targeting_options_get ...'
      end
      # verify the required parameter 'targeting_type' is set
      if @api_client.config.client_side_validation && targeting_type.nil?
        fail ArgumentError, "Missing the required parameter 'targeting_type' when calling ResourcesApi.targeting_options_get"
      end
      if @api_client.config.client_side_validation && !opts[:'ad_account_id'].nil? && opts[:'ad_account_id'].to_s.length > 18
        fail ArgumentError, 'invalid value for "opts[:"ad_account_id"]" when calling ResourcesApi.targeting_options_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_account_id'].nil? && opts[:'ad_account_id'] !~ pattern
        fail ArgumentError, "invalid value for 'opts[:\"ad_account_id\"]' when calling ResourcesApi.targeting_options_get, must conform to the pattern #{pattern}."
      end
    
      if @api_client.config.client_side_validation && !opts[:'client_id'].nil? && opts[:'client_id'].to_s.length > 18
        fail ArgumentError, 'invalid value for "opts[:"client_id"]" when calling ResourcesApi.targeting_options_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[:'client_id'].nil? && opts[:'client_id'] !~ pattern
        fail ArgumentError, "invalid value for 'opts[:\"client_id\"]' when calling ResourcesApi.targeting_options_get, must conform to the pattern #{pattern}."
      end
    
      pattern = Regexp.new(/\d+/)
      if @api_client.config.client_side_validation && !opts[:'timestamp'].nil? && opts[:'timestamp'] !~ pattern
        fail ArgumentError, "invalid value for 'opts[:\"timestamp\"]' when calling ResourcesApi.targeting_options_get, must conform to the pattern #{pattern}."
      end
    
      # resource path
      local_var_path = '/resources/targeting/{targeting_type}'.sub('{targeting_type}', CGI.escape(targeting_type.to_s))
    
      # query parameters
      query_params = opts[:query_params] || {}
      query_params[:'ad_account_id'] = opts[:'ad_account_id'] if !opts[:'ad_account_id'].nil?
      query_params[:'client_id'] = opts[:'client_id'] if !opts[:'client_id'].nil?
      query_params[:'oauth_signature'] = opts[:'oauth_signature'] if !opts[:'oauth_signature'].nil?
      query_params[:'timestamp'] = opts[:'timestamp'] if !opts[:'timestamp'].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] || 'Array<Object>'
    
      # auth_names
      auth_names = opts[:debug_auth_names] || ['pinterest_oauth2', 'client_credentials']
    
      new_options = opts.merge(
        :operation => :"ResourcesApi.targeting_options_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: ResourcesApi#targeting_options_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end