Class: PinterestSdkClient::UserAccountApi

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ UserAccountApi

Returns a new instance of UserAccountApi.



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

def api_client
  @api_client
end

Instance Method Details

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

Get user account analytics Get analytics for the "operation user_account" - By default, the "operation user_account" is the token user_account. Optional: Business Access: Specify an ad_account_id to use the owner of that ad_account as the "operation user_account".

Parameters:

  • start_date (Date)

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

  • end_date (Date)

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

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

    the optional parameters

Options Hash (opts):

  • :from_claimed_content (String)

    Filter on Pins that match your claimed domain. (default to ‘BOTH’)

  • :pin_format (String)

    Pin formats to get data for, default is all. (default to ‘ALL’)

  • :app_types (String)

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

  • :metric_types (Array<String>)

    Metric types 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. (default to ‘NO_SPLIT’)

  • :ad_account_id (String)

    Unique identifier of an ad account.

Returns:



34
35
36
37
# File 'lib/pinterest_sdk/api/user_account_api.rb', line 34

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

#user_account_analytics_with_http_info(start_date, end_date, opts = {}) ⇒ Array<(Hash<String, AnalyticsMetricsResponse>, Integer, Hash)>

Get user account analytics Get analytics for 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 to use the owner of that ad_account as the &quot;operation user_account&quot;.

Parameters:

  • start_date (Date)

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

  • end_date (Date)

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

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

    the optional parameters

Options Hash (opts):

  • :from_claimed_content (String)

    Filter on Pins that match your claimed domain.

  • :pin_format (String)

    Pin formats to get data for, default is all.

  • :app_types (String)

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

  • :metric_types (Array<String>)

    Metric types 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



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

def (start_date, end_date, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UserAccountApi.user_account_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 UserAccountApi.user_account_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 UserAccountApi.user_account_analytics"
  end
  allowable_values = ["OTHER", "CLAIMED", "BOTH"]
  if @api_client.config.client_side_validation && opts[:'from_claimed_content'] && !allowable_values.include?(opts[:'from_claimed_content'])
    fail ArgumentError, "invalid value for \"from_claimed_content\", must be one of #{allowable_values}"
  end
  allowable_values = ["ALL", "PRODUCT", "REGULAR", "VIDEO"]
  if @api_client.config.client_side_validation && opts[:'pin_format'] && !allowable_values.include?(opts[:'pin_format'])
    fail ArgumentError, "invalid value for \"pin_format\", must be one of #{allowable_values}"
  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 = ["ENGAGEMENT", "ENGAGEMENT_RATE", "IMPRESSION", "OUTBOUND_CLICK", "OUTBOUND_CLICK_RATE", "PIN_CLICK", "PIN_CLICK_RATE", "SAVE", "SAVE_RATE"]
  if @api_client.config.client_side_validation && opts[:'metric_types'] && !opts[:'metric_types'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"metric_types\", must include one of #{allowable_values}"
  end
  allowable_values = ["NO_SPLIT", "APP_TYPE", "OWNED_CONTENT", "PIN_FORMAT"]
  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 UserAccountApi.user_account_analytics, must conform to the pattern #{pattern}."
  end

  # resource path
  local_var_path = '/user_account/analytics'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'start_date'] = start_date
  query_params[:'end_date'] = end_date
  query_params[:'from_claimed_content'] = opts[:'from_claimed_content'] if !opts[:'from_claimed_content'].nil?
  query_params[:'pin_format'] = opts[:'pin_format'] if !opts[:'pin_format'].nil?
  query_params[:'app_types'] = opts[:'app_types'] if !opts[:'app_types'].nil?
  query_params[:'metric_types'] = @api_client.build_collection_param(opts[:'metric_types'], :csv) if !opts[:'metric_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 => :"UserAccountApi.user_account_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: UserAccountApi#user_account_analytics\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#user_account_get(opts = {}) ⇒ Account

Get user account Get account information for the "operation user_account" - By default, the "operation user_account" is the token user_account. If using Business Access: Specify an ad_account_id to use the owner of that ad_account as the "operation user_account". See <a href=‘/docs/api/v5/#tag/Understanding-business-access’>Understanding Business Access</a> for more information.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :ad_account_id (String)

    Unique identifier of an ad account.

Returns:



141
142
143
144
# File 'lib/pinterest_sdk/api/user_account_api.rb', line 141

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

#user_account_get_with_http_info(opts = {}) ⇒ Array<(Account, Integer, Hash)>

Get user account Get account information for the &quot;operation user_account&quot; - By default, the &quot;operation user_account&quot; is the token user_account. If using Business Access: Specify an ad_account_id to use the owner of that ad_account as the &quot;operation user_account&quot;. See &lt;a href&#x3D;&#39;/docs/api/v5/#tag/Understanding-business-access&#39;&gt;Understanding Business Access&lt;/a&gt; for more information.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :ad_account_id (String)

    Unique identifier of an ad account.

Returns:

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

    Account data, response status code and response headers



151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# File 'lib/pinterest_sdk/api/user_account_api.rb', line 151

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

  # resource path
  local_var_path = '/user_account'

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

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

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