Class: PinterestSdkClient::PinsApi

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ PinsApi

Returns a new instance of PinsApi.



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

def api_client
  @api_client
end

Instance Method Details

#multi_pins_analytics(pin_ids, start_date, end_date, metric_types, opts = {}) ⇒ Hash<String, Hash>

Get multiple Pin analytics This endpoint is currently in beta and not available to all apps. Learn more. Get analytics for multiple pins owned by the "operation user_account" - or on a group board that has been shared with this account. - The maximum number of pins supported in a single request is 100. - By default, the "operation user_account" is the token user_account. Optional: Business Access: Specify an ad_account_id (obtained via List ad accounts) to use the owner of that ad_account as the "operation user_account". In order to do this, the token user_account must have one of the following Business Access roles on the ad_account: - For Pins on public or protected boards: Admin, Analyst. - For Pins on secret boards: Admin. If Pin was created before 2023-03-20 lifetime metrics will only be available for Video and Idea Pin formats. Lifetime metrics are available for all Pin formats since then.

Parameters:

  • pin_ids (Array<String>)

    List of Pin IDs.

  • start_date (Date)

    Metric report start date (UTC). Format: YYYY-MM-DD. Cannot be more than 90 days back from today.

  • end_date (Date)

    Metric report end date (UTC). Format: YYYY-MM-DD. Cannot be more than 90 days past start_date.

  • metric_types (Array<MultiPinsAnalyticsMetricTypesItem>)

    Pin metric types to get data for.

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

    the optional parameters

Options Hash (opts):

  • :app_types (String)

    Apps or devices to get data for, default is all. (default to 'ALL')

  • :ad_account_id (String)

    Unique identifier of an ad account.

Returns:

  • (Hash<String, Hash>)


32
33
34
35
# File 'lib/pinterest_sdk/api/pins_api.rb', line 32

def multi_pins_analytics(pin_ids, start_date, end_date, metric_types, opts = {})
  data, _status_code, _headers = multi_pins_analytics_with_http_info(pin_ids, start_date, end_date, metric_types, opts)
  data
end

#multi_pins_analytics_with_http_info(pin_ids, start_date, end_date, metric_types, opts = {}) ⇒ Array<(Hash<String, Hash>, Integer, Hash)>

Get multiple Pin analytics This endpoint is currently in beta and not available to all apps. Learn more. Get analytics for multiple pins owned by the &quot;operation user_account&quot; - or on a group board that has been shared with this account. - The maximum number of pins supported in a single request is 100. - By default, the &quot;operation user_account&quot; is the token user_account. Optional: Business Access: Specify an `ad_account_id` (obtained via List ad accounts) to use the owner of that ad_account as the &quot;operation user_account&quot;. In order to do this, the token user_account must have one of the following Business Access roles on the ad_account: - For Pins on public or protected boards: Admin, Analyst. - For Pins on secret boards: Admin. If Pin was created before `2023-03-20` lifetime metrics will only be available for Video and Idea Pin formats. Lifetime metrics are available for all Pin formats since then.

Parameters:

  • pin_ids (Array<String>)

    List of Pin IDs.

  • start_date (Date)

    Metric report start date (UTC). Format: YYYY-MM-DD. Cannot be more than 90 days back from today.

  • end_date (Date)

    Metric report end date (UTC). Format: YYYY-MM-DD. Cannot be more than 90 days past start_date.

  • metric_types (Array<MultiPinsAnalyticsMetricTypesItem>)

    Pin metric types to get data for.

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

    the optional parameters

Options Hash (opts):

  • :app_types (String)

    Apps or devices to get data for, default is all. (default to 'ALL')

  • :ad_account_id (String)

    Unique identifier of an ad account.

Returns:

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

    Hash<String, Hash> data, response status code and response headers



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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/pinterest_sdk/api/pins_api.rb', line 47

def multi_pins_analytics_with_http_info(pin_ids, start_date, end_date, metric_types, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: PinsApi.multi_pins_analytics ...'
  end
  # verify the required parameter 'pin_ids' is set
  if @api_client.config.client_side_validation && pin_ids.nil?
    fail ArgumentError, "Missing the required parameter 'pin_ids' when calling PinsApi.multi_pins_analytics"
  end
  if @api_client.config.client_side_validation && pin_ids.length > 100
    fail ArgumentError, 'invalid value for "pin_ids" when calling PinsApi.multi_pins_analytics, number of items must be less than or equal to 100.'
  end

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

  # verify the required parameter 'start_date' is set
  if @api_client.config.client_side_validation && start_date.nil?
    fail ArgumentError, "Missing the required parameter 'start_date' when calling PinsApi.multi_pins_analytics"
  end
  # verify the required parameter 'end_date' is set
  if @api_client.config.client_side_validation && end_date.nil?
    fail ArgumentError, "Missing the required parameter 'end_date' when calling PinsApi.multi_pins_analytics"
  end
  # verify the required parameter 'metric_types' is set
  if @api_client.config.client_side_validation && metric_types.nil?
    fail ArgumentError, "Missing the required parameter 'metric_types' when calling PinsApi.multi_pins_analytics"
  end
  allowable_values = ["ALL", "MOBILE", "TABLET", "WEB"]
  if @api_client.config.client_side_validation && opts[:'app_types'] && !allowable_values.include?(opts[:'app_types'])
    fail ArgumentError, "invalid value for \"app_types\", must be one of #{allowable_values}"
  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 PinsApi.multi_pins_analytics, 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 PinsApi.multi_pins_analytics, must conform to the pattern #{pattern}."
  end

  # resource path
  local_var_path = '/pins/analytics'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'pin_ids'] = @api_client.build_collection_param(pin_ids, :multi)
  query_params[:'start_date'] = start_date
  query_params[:'end_date'] = end_date
  query_params[:'metric_types'] = @api_client.build_collection_param(metric_types, :csv)
  query_params[:'app_types'] = opts[:'app_types'] if !opts[:'app_types'].nil?
  query_params[:'ad_account_id'] = opts[:'ad_account_id'] if !opts[:'ad_account_id'].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] || 'Hash<String, Hash>'

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

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

#pins_analytics(pin_id, start_date, end_date, metric_types, opts = {}) ⇒ Hash<String, PinAnalyticsMetricsResponse>

Get Pin analytics Get analytics for a Pin owned by the "operation user_account" - or on a group board that has been shared with this account. - By default, the "operation user_account" is the token user_account. Optional: Business Access: Specify an ad_account_id (obtained via List ad accounts) to use the owner of that ad_account as the "operation user_account". In order to do this, the token user_account must have one of the following Business Access roles on the ad_account: - For Pins on public or protected boards: Admin, Analyst. - For Pins on secret boards: Admin. If Pin was created before 2023-03-20 lifetime metrics will only be available for Video and Idea Pin formats. Lifetime metrics are available for all Pin formats since then.

Parameters:

  • pin_id (String)

    Unique identifier of a Pin.

  • start_date (Date)

    Metric report start date (UTC). Format: YYYY-MM-DD. Cannot be more than 90 days back from today.

  • end_date (Date)

    Metric report end date (UTC). Format: YYYY-MM-DD. Cannot be more than 90 days past start_date.

  • metric_types (Array<QuerypinanalyticsmetrictypesItems>)

    Pin metric types to get data for. VIDEO_MRC_VIEW are Video views, VIDEO_V50_WATCH_TIME is Total play time. If Pin was created before `2023-03-20`, Profile visits and Follows will only be available for Idea Pins. These metrics are available for all Pin formats since then. Keep in mind this cannot have ALL if split_field is set to any value other than `NO_SPLIT`.

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

    the optional parameters

Options Hash (opts):

  • :app_types (String)

    Apps or devices to get data for, default is all. (default to 'ALL')

  • :split_field (String)

    How to split the data into groups. Not including this param means data won't be split. (default to 'NO_SPLIT')

  • :ad_account_id (String)

    Unique identifier of an ad account.

Returns:



145
146
147
148
# File 'lib/pinterest_sdk/api/pins_api.rb', line 145

def pins_analytics(pin_id, start_date, end_date, metric_types, opts = {})
  data, _status_code, _headers = pins_analytics_with_http_info(pin_id, start_date, end_date, metric_types, opts)
  data
end

#pins_analytics_with_http_info(pin_id, start_date, end_date, metric_types, opts = {}) ⇒ Array<(Hash<String, PinAnalyticsMetricsResponse>, Integer, Hash)>

Get Pin analytics Get analytics for a Pin owned by the &quot;operation user_account&quot; - or on a group board that has been shared with this account. - By default, the &quot;operation user_account&quot; is the token user_account. Optional: Business Access: Specify an `ad_account_id` (obtained via List ad accounts) to use the owner of that ad_account as the &quot;operation user_account&quot;. In order to do this, the token user_account must have one of the following Business Access roles on the ad_account: - For Pins on public or protected boards: Admin, Analyst. - For Pins on secret boards: Admin. If Pin was created before `2023-03-20` lifetime metrics will only be available for Video and Idea Pin formats. Lifetime metrics are available for all Pin formats since then.

Parameters:

  • pin_id (String)

    Unique identifier of a Pin.

  • start_date (Date)

    Metric report start date (UTC). Format: YYYY-MM-DD. Cannot be more than 90 days back from today.

  • end_date (Date)

    Metric report end date (UTC). Format: YYYY-MM-DD. Cannot be more than 90 days past start_date.

  • metric_types (Array<QuerypinanalyticsmetrictypesItems>)

    Pin metric types to get data for. VIDEO_MRC_VIEW are Video views, VIDEO_V50_WATCH_TIME is Total play time. If Pin was created before `2023-03-20`, Profile visits and Follows will only be available for Idea Pins. These metrics are available for all Pin formats since then. Keep in mind this cannot have ALL if split_field is set to any value other than `NO_SPLIT`.

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

    the optional parameters

Options Hash (opts):

  • :app_types (String)

    Apps or devices to get data for, default is all. (default to 'ALL')

  • :split_field (String)

    How to split the data into groups. Not including this param means data won't be split. (default to 'NO_SPLIT')

  • :ad_account_id (String)

    Unique identifier of an ad account.

Returns:

  • (Array<(Hash<String, PinAnalyticsMetricsResponse>, Integer, Hash)>)

    Hash<String, PinAnalyticsMetricsResponse> data, response status code and response headers



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

def pins_analytics_with_http_info(pin_id, start_date, end_date, metric_types, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: PinsApi.pins_analytics ...'
  end
  # verify the required parameter 'pin_id' is set
  if @api_client.config.client_side_validation && pin_id.nil?
    fail ArgumentError, "Missing the required parameter 'pin_id' when calling PinsApi.pins_analytics"
  end
  # verify the required parameter 'start_date' is set
  if @api_client.config.client_side_validation && start_date.nil?
    fail ArgumentError, "Missing the required parameter 'start_date' when calling PinsApi.pins_analytics"
  end
  # verify the required parameter 'end_date' is set
  if @api_client.config.client_side_validation && end_date.nil?
    fail ArgumentError, "Missing the required parameter 'end_date' when calling PinsApi.pins_analytics"
  end
  # verify the required parameter 'metric_types' is set
  if @api_client.config.client_side_validation && metric_types.nil?
    fail ArgumentError, "Missing the required parameter 'metric_types' when calling PinsApi.pins_analytics"
  end
  allowable_values = ["ALL", "MOBILE", "TABLET", "WEB"]
  if @api_client.config.client_side_validation && opts[:'app_types'] && !allowable_values.include?(opts[:'app_types'])
    fail ArgumentError, "invalid value for \"app_types\", must be one of #{allowable_values}"
  end
  allowable_values = ["NO_SPLIT", "APP_TYPE"]
  if @api_client.config.client_side_validation && opts[:'split_field'] && !allowable_values.include?(opts[:'split_field'])
    fail ArgumentError, "invalid value for \"split_field\", must be one of #{allowable_values}"
  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 PinsApi.pins_analytics, 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 PinsApi.pins_analytics, must conform to the pattern #{pattern}."
  end

  # resource path
  local_var_path = '/pins/{pin_id}/analytics'.sub('{pin_id}', CGI.escape(pin_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'start_date'] = start_date
  query_params[:'end_date'] = end_date
  query_params[:'metric_types'] = @api_client.build_collection_param(metric_types, :csv)
  query_params[:'app_types'] = opts[:'app_types'] if !opts[:'app_types'].nil?
  query_params[:'split_field'] = opts[:'split_field'] if !opts[:'split_field'].nil?
  query_params[:'ad_account_id'] = opts[:'ad_account_id'] if !opts[:'ad_account_id'].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] || 'Hash<String, PinAnalyticsMetricsResponse>'

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

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

#pins_create(pin_create, opts = {}) ⇒ Pin

Create Pin Create a Pin on a board or board section owned by the "operation user_account". Note: If the current "operation user_account" (defined by the access token) has access to another user's Ad Accounts via Pinterest Business Access, you can modify your request to make use of the current operation_user_account's permissions to those Ad Accounts by including the ad_account_id in the path parameters for the request (e.g. .../?ad_account_id=12345&...). - This function is intended solely for publishing new content created by the user. If you are interested in saving content created by others to your Pinterest boards, sometimes called 'curated content', please use our Save button instead. For more tips on creating fresh content for Pinterest, review our Content App Solutions Guide. Learn more about video Pin creation. Learn more about image Pin creation.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :ad_account_id (String)

    Unique identifier of an ad account.

Returns:



250
251
252
253
# File 'lib/pinterest_sdk/api/pins_api.rb', line 250

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

#pins_create_with_http_info(pin_create, opts = {}) ⇒ Array<(Pin, Integer, Hash)>

Create Pin Create a Pin on a board or board section owned by the &quot;operation user_account&quot;. Note: If the current &quot;operation user_account&quot; (defined by the access token) has access to another user's Ad Accounts via Pinterest Business Access, you can modify your request to make use of the current operation_user_account's permissions to those Ad Accounts by including the ad_account_id in the path parameters for the request (e.g. .../?ad_account_id=12345&...). - This function is intended solely for publishing new content created by the user. If you are interested in saving content created by others to your Pinterest boards, sometimes called 'curated content', please use our Save button instead. For more tips on creating fresh content for Pinterest, review our Content App Solutions Guide. Learn more about video Pin creation. Learn more about image Pin creation.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :ad_account_id (String)

    Unique identifier of an ad account.

Returns:

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

    Pin data, response status code and response headers



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

def pins_create_with_http_info(pin_create, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: PinsApi.pins_create ...'
  end
  # verify the required parameter 'pin_create' is set
  if @api_client.config.client_side_validation && pin_create.nil?
    fail ArgumentError, "Missing the required parameter 'pin_create' when calling PinsApi.pins_create"
  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 PinsApi.pins_create, 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 PinsApi.pins_create, must conform to the pattern #{pattern}."
  end

  # resource path
  local_var_path = '/pins'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'ad_account_id'] = opts[:'ad_account_id'] if !opts[:'ad_account_id'].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']
  # 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(pin_create)

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

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

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

#pins_delete(pin_id, opts = {}) ⇒ Pin

Delete Pin Delete a Pins owned by the "operation user_account" - or on a group board that has been shared with this account. - By default, the "operation user_account" is the token user_account. Optional: Business Access: Specify an ad_account_id (obtained via List ad accounts) to use the owner of that ad_account as the "operation user_account". In order to do this, the token user_account must have one of the following Business Access roles on the ad_account: - For Pins on public or protected boards: Owner, Admin, Analyst, Campaign Manager. - For Pins on secret boards: Owner, Admin.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :ad_account_id (String)

    Unique identifier of an ad account.

Returns:



330
331
332
333
# File 'lib/pinterest_sdk/api/pins_api.rb', line 330

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

#pins_delete_with_http_info(pin_id, opts = {}) ⇒ Array<(Pin, Integer, Hash)>

Delete Pin Delete a Pins owned by the &quot;operation user_account&quot; - or on a group board that has been shared with this account. - By default, the &quot;operation user_account&quot; is the token user_account. Optional: Business Access: Specify an `ad_account_id` (obtained via List ad accounts) to use the owner of that ad_account as the &quot;operation user_account&quot;. In order to do this, the token user_account must have one of the following Business Access roles on the ad_account: - For Pins on public or protected boards: Owner, Admin, Analyst, Campaign Manager. - For Pins on secret boards: Owner, Admin.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :ad_account_id (String)

    Unique identifier of an ad account.

Returns:

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

    Pin data, response status code and response headers



341
342
343
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
# File 'lib/pinterest_sdk/api/pins_api.rb', line 341

def pins_delete_with_http_info(pin_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: PinsApi.pins_delete ...'
  end
  # verify the required parameter 'pin_id' is set
  if @api_client.config.client_side_validation && pin_id.nil?
    fail ArgumentError, "Missing the required parameter 'pin_id' when calling PinsApi.pins_delete"
  end
  pattern = Regexp.new(/^\d+$/)
  if @api_client.config.client_side_validation && pin_id !~ pattern
    fail ArgumentError, "invalid value for 'pin_id' when calling PinsApi.pins_delete, must conform to the pattern #{pattern}."
  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 PinsApi.pins_delete, 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 PinsApi.pins_delete, must conform to the pattern #{pattern}."
  end

  # resource path
  local_var_path = '/pins/{pin_id}'.sub('{pin_id}', CGI.escape(pin_id.to_s))

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

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

  new_options = opts.merge(
    :operation => :"PinsApi.pins_delete",
    :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(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: PinsApi#pins_delete\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#pins_get(pin_id, opts = {}) ⇒ Pin

Get Pin Get a Pin owned by the "operation user_account" - or on a group board that has been shared with this account. - By default, the "operation user_account" is the token user_account. Optional: Business Access: Specify an ad_account_id (obtained via List ad accounts) to use the owner of that ad_account as the "operation user_account". In order to do this, the token user_account must have one of the following Business Access roles on the ad_account: - For Pins on public or protected boards: Owner, Admin, Analyst, Campaign Manager. - For Pins on secret boards: Owner, Admin.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :ad_account_id (String)

    Unique identifier of an ad account.

  • :pin_metrics (Boolean)

    Specify whether to return 90d and lifetime Pin metrics. Total comments and total reactions are only available with lifetime Pin metrics. If Pin was created before `2023-03-20` lifetime metrics will only be available for Video and Idea Pin formats. Lifetime metrics are available for all Pin formats since then. (default to false)

Returns:



411
412
413
414
# File 'lib/pinterest_sdk/api/pins_api.rb', line 411

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

#pins_get_with_http_info(pin_id, opts = {}) ⇒ Array<(Pin, Integer, Hash)>

Get Pin Get a Pin owned by the &quot;operation user_account&quot; - or on a group board that has been shared with this account. - By default, the &quot;operation user_account&quot; is the token user_account. Optional: Business Access: Specify an `ad_account_id` (obtained via List ad accounts) to use the owner of that ad_account as the &quot;operation user_account&quot;. In order to do this, the token user_account must have one of the following Business Access roles on the ad_account: - For Pins on public or protected boards: Owner, Admin, Analyst, Campaign Manager. - For Pins on secret boards: Owner, Admin.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :ad_account_id (String)

    Unique identifier of an ad account.

  • :pin_metrics (Boolean)

    Specify whether to return 90d and lifetime Pin metrics. Total comments and total reactions are only available with lifetime Pin metrics. If Pin was created before `2023-03-20` lifetime metrics will only be available for Video and Idea Pin formats. Lifetime metrics are available for all Pin formats since then. (default to false)

Returns:

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

    Pin data, response status code and response headers



423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
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
# File 'lib/pinterest_sdk/api/pins_api.rb', line 423

def pins_get_with_http_info(pin_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: PinsApi.pins_get ...'
  end
  # verify the required parameter 'pin_id' is set
  if @api_client.config.client_side_validation && pin_id.nil?
    fail ArgumentError, "Missing the required parameter 'pin_id' when calling PinsApi.pins_get"
  end
  pattern = Regexp.new(/^\d+$/)
  if @api_client.config.client_side_validation && pin_id !~ pattern
    fail ArgumentError, "invalid value for 'pin_id' when calling PinsApi.pins_get, must conform to the pattern #{pattern}."
  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 PinsApi.pins_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 PinsApi.pins_get, must conform to the pattern #{pattern}."
  end

  # resource path
  local_var_path = '/pins/{pin_id}'.sub('{pin_id}', CGI.escape(pin_id.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[:'pin_metrics'] = opts[:'pin_metrics'] if !opts[:'pin_metrics'].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] || 'Pin'

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

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

#pins_list(opts = {}) ⇒ PinsList200Response

List Pins Get a list of the Pins owned by the "operation user_account". - By default, the "operation user_account" is the token user_account. - All Pins owned by the "operation user_account" are included, regardless of who owns the board they are on. Optional: Business Access: Specify an ad_account_id to use the owner of that ad_account as the "operation user_account". Disclaimer: There are known performance issues when filtering by field creative_type and including protected pins. If your request is timing out in this scenario, we encourage you to use GET List Pins on Board.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :pin_filter (PinFilter)

    The filter to apply to the pins

  • :pin_metrics (Boolean)

    Specify whether to return 90d and lifetime Pin metrics. Total comments and total reactions are only available with lifetime Pin metrics. If Pin was created before `2023-03-20` lifetime metrics will only be available for Video and Idea Pin formats. Lifetime metrics are available for all Pin formats since then. (default to false)

  • :include_protected_pins (Boolean)

    Whether to include protected pins in the results (default to false)

  • :pin_type (PinType)

    The type of pins to return, currently only enabled for private pins

  • :creative_types (Array<CreativeType>)

    Pin creative types filter. Note: SHOP_THE_PIN has been deprecated. Please use COLLECTION instead.

  • :ad_account_id (String)

    Unique identifier of an ad account.

  • :domain (String)

    Only return pins with links that match the exact domain. Domain should not include 'www.' prefix. For example, 'pinterest.com' is a valid domain, but 'www.pinterest.com' is not (will not match any pins).

  • :domains (Array<String>)

    Only return pins with links whose domain matches any value in the list. Values are joined comma-separated on the wire (e.g. `?domains=instagram.com,jcpenney.com`).

  • :include_product_tag_obj (Boolean)

    Include product tag objects in the response with their associated links.

  • :bookmark (String)

    Cursor used to fetch the next page of items

  • :page_size (Integer)

    Maximum number of items to include in a single page. See documentation on Pagination for more information. (default to 25)

Returns:



502
503
504
505
# File 'lib/pinterest_sdk/api/pins_api.rb', line 502

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

#pins_list_with_http_info(opts = {}) ⇒ Array<(PinsList200Response, Integer, Hash)>

List Pins Get a list of the Pins owned by the &quot;operation user_account&quot;. - By default, the &quot;operation user_account&quot; is the token user_account. - All Pins owned by the &quot;operation user_account&quot; are included, regardless of who owns the board they are on. Optional: Business Access: Specify an `ad_account_id` to use the owner of that ad_account as the &quot;operation user_account&quot;. Disclaimer: There are known performance issues when filtering by field `creative_type` and including protected pins. If your request is timing out in this scenario, we encourage you to use GET List Pins on Board.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :pin_filter (PinFilter)

    The filter to apply to the pins

  • :pin_metrics (Boolean)

    Specify whether to return 90d and lifetime Pin metrics. Total comments and total reactions are only available with lifetime Pin metrics. If Pin was created before `2023-03-20` lifetime metrics will only be available for Video and Idea Pin formats. Lifetime metrics are available for all Pin formats since then. (default to false)

  • :include_protected_pins (Boolean)

    Whether to include protected pins in the results (default to false)

  • :pin_type (PinType)

    The type of pins to return, currently only enabled for private pins

  • :creative_types (Array<CreativeType>)

    Pin creative types filter. Note: SHOP_THE_PIN has been deprecated. Please use COLLECTION instead.

  • :ad_account_id (String)

    Unique identifier of an ad account.

  • :domain (String)

    Only return pins with links that match the exact domain. Domain should not include 'www.' prefix. For example, 'pinterest.com' is a valid domain, but 'www.pinterest.com' is not (will not match any pins).

  • :domains (Array<String>)

    Only return pins with links whose domain matches any value in the list. Values are joined comma-separated on the wire (e.g. `?domains=instagram.com,jcpenney.com`).

  • :include_product_tag_obj (Boolean)

    Include product tag objects in the response with their associated links.

  • :bookmark (String)

    Cursor used to fetch the next page of items

  • :page_size (Integer)

    Maximum number of items to include in a single page. See documentation on Pagination for more information. (default to 25)

Returns:

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

    PinsList200Response data, response status code and response headers



522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
# File 'lib/pinterest_sdk/api/pins_api.rb', line 522

def pins_list_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: PinsApi.pins_list ...'
  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 PinsApi.pins_list, 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 PinsApi.pins_list, must conform to the pattern #{pattern}."
  end

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

  if @api_client.config.client_side_validation && !opts[:'domains'].nil? && opts[:'domains'].length < 1
    fail ArgumentError, 'invalid value for "opts[:"domains"]" when calling PinsApi.pins_list, 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'] > 250
    fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling PinsApi.pins_list, must be smaller than or equal to 250.'
  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 PinsApi.pins_list, must be greater than or equal to 1.'
  end

  # resource path
  local_var_path = '/pins'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'pin_filter'] = opts[:'pin_filter'] if !opts[:'pin_filter'].nil?
  query_params[:'pin_metrics'] = opts[:'pin_metrics'] if !opts[:'pin_metrics'].nil?
  query_params[:'include_protected_pins'] = opts[:'include_protected_pins'] if !opts[:'include_protected_pins'].nil?
  query_params[:'pin_type'] = opts[:'pin_type'] if !opts[:'pin_type'].nil?
  query_params[:'creative_types'] = @api_client.build_collection_param(opts[:'creative_types'], :multi) if !opts[:'creative_types'].nil?
  query_params[:'ad_account_id'] = opts[:'ad_account_id'] if !opts[:'ad_account_id'].nil?
  query_params[:'domain'] = opts[:'domain'] if !opts[:'domain'].nil?
  query_params[:'domains'] = @api_client.build_collection_param(opts[:'domains'], :multi) if !opts[:'domains'].nil?
  query_params[:'include_product_tag_obj'] = opts[:'include_product_tag_obj'] if !opts[:'include_product_tag_obj'].nil?
  query_params[:'bookmark'] = opts[:'bookmark'] if !opts[:'bookmark'].nil?
  query_params[:'page_size'] = opts[:'page_size'] if !opts[:'page_size'].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] || 'PinsList200Response'

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

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

#pins_save(pin_id, pins_save_request_create, opts = {}) ⇒ Pin

Save Pin Save a Pin on a board or board section owned by the "operation user_account". - By default, the "operation user_account" is the token user_account. Optional: Business Access: Specify an ad_account_id (obtained via List ad accounts) to use the owner of that ad_account as the "operation user_account". In order to do this, the token user_account must have one of the following Business Access roles on the ad_account: - For Pins on public or protected boards: Owner, Admin, Analyst, Campaign Manager. - For Pins on secret boards: Owner, Admin. - Any Pin type can be saved: image Pin, video Pin, Idea Pin, product Pin, etc. - Any public Pin can be saved given a pin ID.

Parameters:

  • pin_id (String)

    Unique identifier of a Pin.

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

    the optional parameters

Options Hash (opts):

  • :ad_account_id (String)

    Unique identifier of an ad account.

Returns:



609
610
611
612
# File 'lib/pinterest_sdk/api/pins_api.rb', line 609

def pins_save(pin_id, pins_save_request_create, opts = {})
  data, _status_code, _headers = pins_save_with_http_info(pin_id, pins_save_request_create, opts)
  data
end

#pins_save_with_http_info(pin_id, pins_save_request_create, opts = {}) ⇒ Array<(Pin, Integer, Hash)>

Save Pin Save a Pin on a board or board section owned by the &quot;operation user_account&quot;. - By default, the &quot;operation user_account&quot; is the token user_account. Optional: Business Access: Specify an `ad_account_id` (obtained via List ad accounts) to use the owner of that ad_account as the &quot;operation user_account&quot;. In order to do this, the token user_account must have one of the following Business Access roles on the ad_account: - For Pins on public or protected boards: Owner, Admin, Analyst, Campaign Manager. - For Pins on secret boards: Owner, Admin. - Any Pin type can be saved: image Pin, video Pin, Idea Pin, product Pin, etc. - Any public Pin can be saved given a pin ID.

Parameters:

  • pin_id (String)

    Unique identifier of a Pin.

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

    the optional parameters

Options Hash (opts):

  • :ad_account_id (String)

    Unique identifier of an ad account.

Returns:

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

    Pin data, response status code and response headers



621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
# File 'lib/pinterest_sdk/api/pins_api.rb', line 621

def pins_save_with_http_info(pin_id, pins_save_request_create, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: PinsApi.pins_save ...'
  end
  # verify the required parameter 'pin_id' is set
  if @api_client.config.client_side_validation && pin_id.nil?
    fail ArgumentError, "Missing the required parameter 'pin_id' when calling PinsApi.pins_save"
  end
  # verify the required parameter 'pins_save_request_create' is set
  if @api_client.config.client_side_validation && pins_save_request_create.nil?
    fail ArgumentError, "Missing the required parameter 'pins_save_request_create' when calling PinsApi.pins_save"
  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 PinsApi.pins_save, 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 PinsApi.pins_save, must conform to the pattern #{pattern}."
  end

  # resource path
  local_var_path = '/pins/{pin_id}/save'.sub('{pin_id}', CGI.escape(pin_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'ad_account_id'] = opts[:'ad_account_id'] if !opts[:'ad_account_id'].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']
  # 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(pins_save_request_create)

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

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

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

#pins_update(pin_id, pin_update, opts = {}) ⇒ Pin

Update Pin Update a pin owned by the "operating user_account". - By default, the "operation user_account" is the token user_account. Optional: Business Access: Specify an ad_account_id (obtained via List ad accounts) to use the owner of that ad_account as the "operation user_account". In order to do this, the token user_account must have one of the following Business Access roles on the ad_account: - For Pins on public or protected boards: Owner, Admin, Analyst, Campaign Manager. - For Pins on secret boards: Owner, Admin. This endpoint is currently in beta and not available to all apps. Learn more.

Parameters:

  • pin_id (String)
  • pin_update (PinUpdate)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :ad_account_id (String)

    Unique identifier of an ad account.

Returns:



695
696
697
698
# File 'lib/pinterest_sdk/api/pins_api.rb', line 695

def pins_update(pin_id, pin_update, opts = {})
  data, _status_code, _headers = pins_update_with_http_info(pin_id, pin_update, opts)
  data
end

#pins_update_with_http_info(pin_id, pin_update, opts = {}) ⇒ Array<(Pin, Integer, Hash)>

Update Pin Update a pin owned by the &quot;operating user_account&quot;. - By default, the &quot;operation user_account&quot; is the token user_account. Optional: Business Access: Specify an `ad_account_id` (obtained via List ad accounts) to use the owner of that ad_account as the &quot;operation user_account&quot;. In order to do this, the token user_account must have one of the following Business Access roles on the ad_account: - For Pins on public or protected boards: Owner, Admin, Analyst, Campaign Manager. - For Pins on secret boards: Owner, Admin. This endpoint is currently in beta and not available to all apps. Learn more.

Parameters:

  • pin_id (String)
  • pin_update (PinUpdate)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :ad_account_id (String)

    Unique identifier of an ad account.

Returns:

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

    Pin data, response status code and response headers



707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
# File 'lib/pinterest_sdk/api/pins_api.rb', line 707

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

  # verify the required parameter 'pin_update' is set
  if @api_client.config.client_side_validation && pin_update.nil?
    fail ArgumentError, "Missing the required parameter 'pin_update' when calling PinsApi.pins_update"
  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 PinsApi.pins_update, 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 PinsApi.pins_update, must conform to the pattern #{pattern}."
  end

  # resource path
  local_var_path = '/pins/{pin_id}'.sub('{pin_id}', CGI.escape(pin_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'ad_account_id'] = opts[:'ad_account_id'] if !opts[:'ad_account_id'].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']
  # 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(pin_update)

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

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

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