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

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

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 <a href="developers.pinterest.com/docs/api/v5/#operation/ad_accounts/list">List ad accounts</a>) 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 <a href="help.pinterest.com/en/business/article/share-and-manage-access-to-your-ad-accounts">Business Access</a> roles on the ad_account: - For Pins on public or protected boards: Admin, Analyst. - For Pins on secret boards: Admin.

Parameters:

  • pin_id (String)

    Unique identifier of a Pin.

  • start_date (Date)

    Metric report start date (UTC). Format: YYYY-MM-DD

  • end_date (Date)

    Metric report end date (UTC). Format: YYYY-MM-DD

  • metric_types (Array<String>)

    Pin metric types to get data for, default is all.

  • 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&#39;t be split. (default to ‘NO_SPLIT’)

  • :ad_account_id (String)

    Unique identifier of an ad account.

Returns:



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

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, AnalyticsMetricsResponse>, 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 &lt;code&gt;ad_account_id&lt;/code&gt; (obtained via &lt;a href&#x3D;&quot;developers.pinterest.com/docs/api/v5/#operation/ad_accounts/list&quot;&gt;List ad accounts&lt;/a&gt;) 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 &lt;a href&#x3D;&quot;help.pinterest.com/en/business/article/share-and-manage-access-to-your-ad-accounts&quot;&gt;Business Access&lt;/a&gt; roles on the ad_account: - For Pins on public or protected boards: Admin, Analyst. - For Pins on secret boards: Admin.

Parameters:

  • pin_id (String)

    Unique identifier of a Pin.

  • start_date (Date)

    Metric report start date (UTC). Format: YYYY-MM-DD

  • end_date (Date)

    Metric report end date (UTC). Format: YYYY-MM-DD

  • metric_types (Array<String>)

    Pin metric types to get data for, default is all.

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

    the optional parameters

Options Hash (opts):

  • :app_types (String)

    Apps or devices to get data for, default is all.

  • :split_field (String)

    How to split the data into groups. Not including this param means data won&#39;t be split.

  • :ad_account_id (String)

    Unique identifier of an ad account.

Returns:

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

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



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

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

  # 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, AnalyticsMetricsResponse>'

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

  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, 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 <a href=‘/docs/add-ons/save-button’>Save button</a> instead. For more tips on creating fresh content for Pinterest, review our <a href=‘/docs/solutions/content-apps’>Content App Solutions Guide</a>. <strong><a href=‘/docs/solutions/content-apps/#creatingvideopins’>Learn more</a></strong> about video Pin creation.

Parameters:

  • pin (Pin)

    Create a new Pin.

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

    the optional parameters

Returns:



133
134
135
136
# File 'lib/pinterest_sdk/api/pins_api.rb', line 133

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

#pins_create_with_http_info(pin, 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&#39;s Ad Accounts via Pinterest Business Access, you can modify your request to make use of the current operation_user_account&#39;s permissions to those Ad Accounts by including the ad_account_id in the path parameters for the request (e.g. …/?ad_account_id&#x3D;12345&amp;…). - 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 &#39;curated content&#39;, please use our &lt;a href&#x3D;&#39;/docs/add-ons/save-button&#39;&gt;Save button&lt;/a&gt; instead. For more tips on creating fresh content for Pinterest, review our &lt;a href&#x3D;&#39;/docs/solutions/content-apps&#39;&gt;Content App Solutions Guide&lt;/a&gt;. &lt;strong&gt;&lt;a href&#x3D;&#39;/docs/solutions/content-apps/#creatingvideopins&#39;&gt;Learn more&lt;/a&gt;&lt;/strong&gt; about video Pin creation.

Parameters:

  • pin (Pin)

    Create a new Pin.

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

    the optional parameters

Returns:

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

    Pin data, response status code and response headers



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

def pins_create_with_http_info(pin, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: PinsApi.pins_create ...'
  end
  # verify the required parameter 'pin' is set
  if @api_client.config.client_side_validation && pin.nil?
    fail ArgumentError, "Missing the required parameter 'pin' when calling PinsApi.pins_create"
  end
  # resource path
  local_var_path = '/pins'

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

  # 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_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 = {}) ⇒ nil

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.

Parameters:

  • pin_id (String)

    Unique identifier of a Pin.

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

    the optional parameters

Returns:

  • (nil)


201
202
203
204
# File 'lib/pinterest_sdk/api/pins_api.rb', line 201

def pins_delete(pin_id, opts = {})
  pins_delete_with_http_info(pin_id, opts)
  nil
end

#pins_delete_with_http_info(pin_id, opts = {}) ⇒ Array<(nil, 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.

Parameters:

  • pin_id (String)

    Unique identifier of a Pin.

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

    the optional parameters

Returns:

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

    nil, response status code and response headers



211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
# File 'lib/pinterest_sdk/api/pins_api.rb', line 211

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
  # resource path
  local_var_path = '/pins/{pin_id}'.sub('{' + 'pin_id' + '}', CGI.escape(pin_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'])

  # 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 => :"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 <a href=‘/docs/api/v5/#operation/ad_accounts/list’>List ad accounts</a>) 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 <a href="help.pinterest.com/en/business/article/share-and-manage-access-to-your-ad-accounts">Business Access</a> 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)

    Unique identifier of a Pin.

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

    the optional parameters

Options Hash (opts):

  • :ad_account_id (String)

    Unique identifier of an ad account.

Returns:



265
266
267
268
# File 'lib/pinterest_sdk/api/pins_api.rb', line 265

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 &lt;code&gt;ad_account_id&lt;/code&gt; (obtained via &lt;a href&#x3D;&#39;/docs/api/v5/#operation/ad_accounts/list&#39;&gt;List ad accounts&lt;/a&gt;) 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 &lt;a href&#x3D;&quot;help.pinterest.com/en/business/article/share-and-manage-access-to-your-ad-accounts&quot;&gt;Business Access&lt;/a&gt; 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)

    Unique identifier of a Pin.

  • 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



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

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 && !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?

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

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

  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