Class: PinterestSdkClient::CampaignsApi

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ CampaignsApi

Returns a new instance of CampaignsApi.



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

def api_client
  @api_client
end

Instance Method Details

#ad_pins_analytics(campaign_id, pin_ids, start_date, end_date, columns, granularity, ad_account_id, opts = {}) ⇒ Array<AdPinAnalytics>

Get pins analytics Get analytics for the pins given a campaign and pins in the specified ad_account_id, filtered by the specified options. - The token's user_account must either be the Owner of the specified ad account, or have one of the necessary roles granted to them via Business Access: Admin, Analyst, Campaign Manager. - If granularity is not HOUR, the furthest back you can are allowed to pull data is 90 days before the current date in UTC time and the max time range supported is 90 days. - If granularity is HOUR, the furthest back you can are allowed to pull data is 8 days before the current date in UTC time and the max time range supported is 3 days. Data will not be provided for conversion metrics but will be available for non-conversion metrics.

Parameters:

  • Campaign Id to use to filter the results.

  • List of Pin IDs.

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

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

  • Columns to retrieve, encoded as a comma-separated string. NOTE: Any metrics defined as MICRO_DOLLARS returns a value based on the advertiser profile's currency field. For USD, ($1/1,000,000, or $0.000001 - one one-ten-thousandth of a cent). it's microdollars. Otherwise, it's in microunits of the advertiser's currency. For example, if the advertiser's currency is GBP (British pound sterling), all MICRO_DOLLARS fields will be in GBP microunits (1/1,000,000 British pound). If a column has no value, it may not be returned.

  • TOTAL - metrics are aggregated over the specified date range. DAY - metrics are broken down daily. HOUR - metrics are broken down hourly. WEEK - metrics are broken down weekly. MONTH - metrics are broken down monthly

  • Unique identifier of an ad account.

  • (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :click_window_days (Float)

    Number of days to use as the conversion attribution window for a pin click action. Applies to Pinterest Tag conversion metrics. Prior conversion tags use their defined attribution windows. If not specified, defaults to `30` days. (default to 30)

  • :engagement_window_days (Float)

    Number of days to use as the conversion attribution window for an engagement action. Engagements include saves, closeups, link clicks, and carousel card swipes. Applies to Pinterest Tag conversion metrics. Prior conversion tags use their defined attribution windows. If not specified, defaults to `30` days. Note: This parameter no longer returns new data. However, you can still access historic data through Sept 30, 2027. (default to 30)

  • :view_window_days (Float)

    Number of days to use as the conversion attribution window for a view action. Applies to Pinterest Tag conversion metrics. Prior conversion tags use their defined attribution windows. If not specified, defaults to `1` day. (default to 1)

  • :conversion_report_time (String)

    The date by which the conversion metrics returned from this endpoint will be reported. There are two dates associated with a conversion event: the date that the user interacted with the ad, and the date that the user completed a conversion event. (default to 'TIME_OF_AD_ACTION')

Returns:



37
38
39
40
# File 'lib/pinterest_sdk/api/campaigns_api.rb', line 37

def ad_pins_analytics(campaign_id, pin_ids, start_date, end_date, columns, granularity, , opts = {})
  data, _status_code, _headers = ad_pins_analytics_with_http_info(campaign_id, pin_ids, start_date, end_date, columns, granularity, , opts)
  data
end

#ad_pins_analytics_with_http_info(campaign_id, pin_ids, start_date, end_date, columns, granularity, ad_account_id, opts = {}) ⇒ Array<(Array<AdPinAnalytics>, Integer, Hash)>

Get pins analytics Get analytics for the pins given a campaign and pins in the specified `ad_account_id`, filtered by the specified options. - The token's user_account must either be the Owner of the specified ad account, or have one of the necessary roles granted to them via Business Access: Admin, Analyst, Campaign Manager. - If granularity is not HOUR, the furthest back you can are allowed to pull data is 90 days before the current date in UTC time and the max time range supported is 90 days. - If granularity is HOUR, the furthest back you can are allowed to pull data is 8 days before the current date in UTC time and the max time range supported is 3 days. Data will not be provided for conversion metrics but will be available for non-conversion metrics.

Parameters:

  • Campaign Id to use to filter the results.

  • List of Pin IDs.

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

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

  • Columns to retrieve, encoded as a comma-separated string. NOTE: Any metrics defined as MICRO_DOLLARS returns a value based on the advertiser profile's currency field. For USD, ($1/1,000,000, or $0.000001 - one one-ten-thousandth of a cent). it's microdollars. Otherwise, it's in microunits of the advertiser's currency. For example, if the advertiser's currency is GBP (British pound sterling), all MICRO_DOLLARS fields will be in GBP microunits (1/1,000,000 British pound). If a column has no value, it may not be returned.

  • TOTAL - metrics are aggregated over the specified date range. DAY - metrics are broken down daily. HOUR - metrics are broken down hourly. WEEK - metrics are broken down weekly. MONTH - metrics are broken down monthly

  • Unique identifier of an ad account.

  • (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :click_window_days (Float)

    Number of days to use as the conversion attribution window for a pin click action. Applies to Pinterest Tag conversion metrics. Prior conversion tags use their defined attribution windows. If not specified, defaults to `30` days. (default to 30)

  • :engagement_window_days (Float)

    Number of days to use as the conversion attribution window for an engagement action. Engagements include saves, closeups, link clicks, and carousel card swipes. Applies to Pinterest Tag conversion metrics. Prior conversion tags use their defined attribution windows. If not specified, defaults to `30` days. Note: This parameter no longer returns new data. However, you can still access historic data through Sept 30, 2027. (default to 30)

  • :view_window_days (Float)

    Number of days to use as the conversion attribution window for a view action. Applies to Pinterest Tag conversion metrics. Prior conversion tags use their defined attribution windows. If not specified, defaults to `1` day. (default to 1)

  • :conversion_report_time (String)

    The date by which the conversion metrics returned from this endpoint will be reported. There are two dates associated with a conversion event: the date that the user interacted with the ad, and the date that the user completed a conversion event. (default to 'TIME_OF_AD_ACTION')

Returns:

  • Array data, response status code and response headers



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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/pinterest_sdk/api/campaigns_api.rb', line 57

def ad_pins_analytics_with_http_info(campaign_id, pin_ids, start_date, end_date, columns, granularity, , opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CampaignsApi.ad_pins_analytics ...'
  end
  # verify the required parameter 'campaign_id' is set
  if @api_client.config.client_side_validation && campaign_id.nil?
    fail ArgumentError, "Missing the required parameter 'campaign_id' when calling CampaignsApi.ad_pins_analytics"
  end
  if @api_client.config.client_side_validation && campaign_id.to_s.length > 18
    fail ArgumentError, 'invalid value for "campaign_id" when calling CampaignsApi.ad_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 && campaign_id !~ pattern
    fail ArgumentError, "invalid value for 'campaign_id' when calling CampaignsApi.ad_pins_analytics, must conform to the pattern #{pattern}."
  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 CampaignsApi.ad_pins_analytics"
  end
  if @api_client.config.client_side_validation && pin_ids.length > 100
    fail ArgumentError, 'invalid value for "pin_ids" when calling CampaignsApi.ad_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 CampaignsApi.ad_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 CampaignsApi.ad_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 CampaignsApi.ad_pins_analytics"
  end
  # verify the required parameter 'columns' is set
  if @api_client.config.client_side_validation && columns.nil?
    fail ArgumentError, "Missing the required parameter 'columns' when calling CampaignsApi.ad_pins_analytics"
  end
  # verify the required parameter 'granularity' is set
  if @api_client.config.client_side_validation && granularity.nil?
    fail ArgumentError, "Missing the required parameter 'granularity' when calling CampaignsApi.ad_pins_analytics"
  end
  # verify the required parameter 'ad_account_id' is set
  if @api_client.config.client_side_validation && .nil?
    fail ArgumentError, "Missing the required parameter 'ad_account_id' when calling CampaignsApi.ad_pins_analytics"
  end
  if @api_client.config.client_side_validation && .to_s.length > 18
    fail ArgumentError, 'invalid value for "ad_account_id" when calling CampaignsApi.ad_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 &&  !~ pattern
    fail ArgumentError, "invalid value for 'ad_account_id' when calling CampaignsApi.ad_pins_analytics, must conform to the pattern #{pattern}."
  end

  allowable_values = [0, 1, 7, 14, 30, 60]
  if @api_client.config.client_side_validation && opts[:'click_window_days'] && !allowable_values.include?(opts[:'click_window_days'])
    fail ArgumentError, "invalid value for \"click_window_days\", must be one of #{allowable_values}"
  end
  allowable_values = [0, 1, 7, 14, 30, 60]
  if @api_client.config.client_side_validation && opts[:'engagement_window_days'] && !allowable_values.include?(opts[:'engagement_window_days'])
    fail ArgumentError, "invalid value for \"engagement_window_days\", must be one of #{allowable_values}"
  end
  allowable_values = [0, 1, 7, 14, 30, 60]
  if @api_client.config.client_side_validation && opts[:'view_window_days'] && !allowable_values.include?(opts[:'view_window_days'])
    fail ArgumentError, "invalid value for \"view_window_days\", must be one of #{allowable_values}"
  end
  allowable_values = ["TIME_OF_AD_ACTION", "TIME_OF_CONVERSION"]
  if @api_client.config.client_side_validation && opts[:'conversion_report_time'] && !allowable_values.include?(opts[:'conversion_report_time'])
    fail ArgumentError, "invalid value for \"conversion_report_time\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/ad_accounts/{ad_account_id}/pins/analytics'.sub('{ad_account_id}', CGI.escape(.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'campaign_id'] = campaign_id
  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[:'columns'] = @api_client.build_collection_param(columns, :csv)
  query_params[:'granularity'] = granularity
  query_params[:'click_window_days'] = opts[:'click_window_days'] if !opts[:'click_window_days'].nil?
  query_params[:'engagement_window_days'] = opts[:'engagement_window_days'] if !opts[:'engagement_window_days'].nil?
  query_params[:'view_window_days'] = opts[:'view_window_days'] if !opts[:'view_window_days'].nil?
  query_params[:'conversion_report_time'] = opts[:'conversion_report_time'] if !opts[:'conversion_report_time'].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<AdPinAnalytics>'

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

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

#campaign_targeting_analytics_get(ad_account_id, campaign_ids, start_date, end_date, targeting_types, columns, granularity, opts = {}) ⇒ MetricsResponse

Get targeting analytics for campaigns Get targeting analytics for one or more campaigns. For the requested account and metrics, the response will include the requested metric information (e.g. SPEND_IN_DOLLAR) for the requested target type (e.g. "age_bucket") for applicable values (e.g. "45-49"). * The token's user_account must either be the Owner of the specified ad account, or have one of the necessary roles granted to them via Business Access: Admin, Analyst, Campaign Manager. * If granularity is not HOUR, you can pull data from up to 90 days before the current date in UTC time, with a maximum time range of 90 days. * If granularity is HOUR, you can pull data from up to 8 days before the current date in UTC time, with a maximum time range of 3 days.

Parameters:

  • Unique identifier of an ad account.

  • List of Campaign Ids to use to filter the results.

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

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

  • Targeting type breakdowns for the report. The reporting per targeting type is independent from each other. [&quot;AGE_BUCKET_AND_GENDER&quot;] is in BETA and not yet available to all users.

  • Columns to retrieve, encoded as a comma-separated string. NOTE: Any metrics defined as MICRO_DOLLARS returns a value based on the advertiser profile's currency field. For USD, ($1/1,000,000, or $0.000001 - one one-ten-thousandth of a cent). it's microdollars. Otherwise, it's in microunits of the advertiser's currency. For example, if the advertiser's currency is GBP (British pound sterling), all MICRO_DOLLARS fields will be in GBP microunits (1/1,000,000 British pound). If a column has no value, it may not be returned.

  • TOTAL - metrics are aggregated over the specified date range. DAY - metrics are broken down daily. HOUR - metrics are broken down hourly. WEEK - metrics are broken down weekly. MONTH - metrics are broken down monthly

  • (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :click_window_days (Float)

    Number of days to use as the conversion attribution window for a pin click action. Applies to Pinterest Tag conversion metrics. Prior conversion tags use their defined attribution windows. If not specified, defaults to `30` days. (default to 30)

  • :engagement_window_days (Float)

    Number of days to use as the conversion attribution window for an engagement action. Engagements include saves, closeups, link clicks, and carousel card swipes. Applies to Pinterest Tag conversion metrics. Prior conversion tags use their defined attribution windows. If not specified, defaults to `30` days. Note: This parameter no longer returns new data. However, you can still access historic data through Sept 30, 2027. (default to 30)

  • :view_window_days (Float)

    Number of days to use as the conversion attribution window for a view action. Applies to Pinterest Tag conversion metrics. Prior conversion tags use their defined attribution windows. If not specified, defaults to `1` day. (default to 1)

  • :conversion_report_time (String)

    The date by which the conversion metrics returned from this endpoint will be reported. There are two dates associated with a conversion event: the date that the user interacted with the ad, and the date that the user completed a conversion event. (default to 'TIME_OF_AD_ACTION')

  • :attribution_types (Array<ConversionReportAttributionType>)

    List of types of attribution for the conversion report

  • :reporting_timezone (ReportingTimeZone)

    Specify the timezone to be applied for the reporting. This feature is currently in BETA and is not available to all users.

Returns:



198
199
200
201
# File 'lib/pinterest_sdk/api/campaigns_api.rb', line 198

def campaign_targeting_analytics_get(, campaign_ids, start_date, end_date, targeting_types, columns, granularity, opts = {})
  data, _status_code, _headers = campaign_targeting_analytics_get_with_http_info(, campaign_ids, start_date, end_date, targeting_types, columns, granularity, opts)
  data
end

#campaign_targeting_analytics_get_with_http_info(ad_account_id, campaign_ids, start_date, end_date, targeting_types, columns, granularity, opts = {}) ⇒ Array<(MetricsResponse, Integer, Hash)>

Get targeting analytics for campaigns Get targeting analytics for one or more campaigns. For the requested account and metrics, the response will include the requested metric information (e.g. SPEND_IN_DOLLAR) for the requested target type (e.g. &quot;age_bucket&quot;) for applicable values (e.g. &quot;45-49&quot;). * The token's user_account must either be the Owner of the specified ad account, or have one of the necessary roles granted to them via Business Access: Admin, Analyst, Campaign Manager. * If granularity is not HOUR, you can pull data from up to 90 days before the current date in UTC time, with a maximum time range of 90 days. * If granularity is HOUR, you can pull data from up to 8 days before the current date in UTC time, with a maximum time range of 3 days.

Parameters:

  • Unique identifier of an ad account.

  • List of Campaign Ids to use to filter the results.

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

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

  • Targeting type breakdowns for the report. The reporting per targeting type is independent from each other. [&quot;AGE_BUCKET_AND_GENDER&quot;] is in BETA and not yet available to all users.

  • Columns to retrieve, encoded as a comma-separated string. NOTE: Any metrics defined as MICRO_DOLLARS returns a value based on the advertiser profile's currency field. For USD, ($1/1,000,000, or $0.000001 - one one-ten-thousandth of a cent). it's microdollars. Otherwise, it's in microunits of the advertiser's currency. For example, if the advertiser's currency is GBP (British pound sterling), all MICRO_DOLLARS fields will be in GBP microunits (1/1,000,000 British pound). If a column has no value, it may not be returned.

  • TOTAL - metrics are aggregated over the specified date range. DAY - metrics are broken down daily. HOUR - metrics are broken down hourly. WEEK - metrics are broken down weekly. MONTH - metrics are broken down monthly

  • (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :click_window_days (Float)

    Number of days to use as the conversion attribution window for a pin click action. Applies to Pinterest Tag conversion metrics. Prior conversion tags use their defined attribution windows. If not specified, defaults to `30` days. (default to 30)

  • :engagement_window_days (Float)

    Number of days to use as the conversion attribution window for an engagement action. Engagements include saves, closeups, link clicks, and carousel card swipes. Applies to Pinterest Tag conversion metrics. Prior conversion tags use their defined attribution windows. If not specified, defaults to `30` days. Note: This parameter no longer returns new data. However, you can still access historic data through Sept 30, 2027. (default to 30)

  • :view_window_days (Float)

    Number of days to use as the conversion attribution window for a view action. Applies to Pinterest Tag conversion metrics. Prior conversion tags use their defined attribution windows. If not specified, defaults to `1` day. (default to 1)

  • :conversion_report_time (String)

    The date by which the conversion metrics returned from this endpoint will be reported. There are two dates associated with a conversion event: the date that the user interacted with the ad, and the date that the user completed a conversion event. (default to 'TIME_OF_AD_ACTION')

  • :attribution_types (Array<ConversionReportAttributionType>)

    List of types of attribution for the conversion report

  • :reporting_timezone (ReportingTimeZone)

    Specify the timezone to be applied for the reporting. This feature is currently in BETA and is not available to all users.

Returns:

  • MetricsResponse data, response status code and response headers



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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
# File 'lib/pinterest_sdk/api/campaigns_api.rb', line 220

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

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

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

  if @api_client.config.client_side_validation && campaign_ids.length < 1
    fail ArgumentError, 'invalid value for "campaign_ids" when calling CampaignsApi.campaign_targeting_analytics_get, 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 CampaignsApi.campaign_targeting_analytics_get"
  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 CampaignsApi.campaign_targeting_analytics_get"
  end
  # verify the required parameter 'targeting_types' is set
  if @api_client.config.client_side_validation && targeting_types.nil?
    fail ArgumentError, "Missing the required parameter 'targeting_types' when calling CampaignsApi.campaign_targeting_analytics_get"
  end
  if @api_client.config.client_side_validation && targeting_types.length > 14
    fail ArgumentError, 'invalid value for "targeting_types" when calling CampaignsApi.campaign_targeting_analytics_get, number of items must be less than or equal to 14.'
  end

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

  # verify the required parameter 'columns' is set
  if @api_client.config.client_side_validation && columns.nil?
    fail ArgumentError, "Missing the required parameter 'columns' when calling CampaignsApi.campaign_targeting_analytics_get"
  end
  # verify the required parameter 'granularity' is set
  if @api_client.config.client_side_validation && granularity.nil?
    fail ArgumentError, "Missing the required parameter 'granularity' when calling CampaignsApi.campaign_targeting_analytics_get"
  end
  allowable_values = [0, 1, 7, 14, 30, 60]
  if @api_client.config.client_side_validation && opts[:'click_window_days'] && !allowable_values.include?(opts[:'click_window_days'])
    fail ArgumentError, "invalid value for \"click_window_days\", must be one of #{allowable_values}"
  end
  allowable_values = [0, 1, 7, 14, 30, 60]
  if @api_client.config.client_side_validation && opts[:'engagement_window_days'] && !allowable_values.include?(opts[:'engagement_window_days'])
    fail ArgumentError, "invalid value for \"engagement_window_days\", must be one of #{allowable_values}"
  end
  allowable_values = [0, 1, 7, 14, 30, 60]
  if @api_client.config.client_side_validation && opts[:'view_window_days'] && !allowable_values.include?(opts[:'view_window_days'])
    fail ArgumentError, "invalid value for \"view_window_days\", must be one of #{allowable_values}"
  end
  allowable_values = ["TIME_OF_AD_ACTION", "TIME_OF_CONVERSION"]
  if @api_client.config.client_side_validation && opts[:'conversion_report_time'] && !allowable_values.include?(opts[:'conversion_report_time'])
    fail ArgumentError, "invalid value for \"conversion_report_time\", must be one of #{allowable_values}"
  end
  if @api_client.config.client_side_validation && !opts[:'attribution_types'].nil? && opts[:'attribution_types'].length > 2
    fail ArgumentError, 'invalid value for "opts[:"attribution_types"]" when calling CampaignsApi.campaign_targeting_analytics_get, number of items must be less than or equal to 2.'
  end

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

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'campaign_ids'] = @api_client.build_collection_param(campaign_ids, :multi)
  query_params[:'start_date'] = start_date
  query_params[:'end_date'] = end_date
  query_params[:'targeting_types'] = @api_client.build_collection_param(targeting_types, :csv)
  query_params[:'columns'] = @api_client.build_collection_param(columns, :csv)
  query_params[:'granularity'] = granularity
  query_params[:'click_window_days'] = opts[:'click_window_days'] if !opts[:'click_window_days'].nil?
  query_params[:'engagement_window_days'] = opts[:'engagement_window_days'] if !opts[:'engagement_window_days'].nil?
  query_params[:'view_window_days'] = opts[:'view_window_days'] if !opts[:'view_window_days'].nil?
  query_params[:'conversion_report_time'] = opts[:'conversion_report_time'] if !opts[:'conversion_report_time'].nil?
  query_params[:'attribution_types'] = @api_client.build_collection_param(opts[:'attribution_types'], :csv) if !opts[:'attribution_types'].nil?
  query_params[:'reporting_timezone'] = opts[:'reporting_timezone'] if !opts[:'reporting_timezone'].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] || 'MetricsResponse'

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

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

#campaigns_analytics(start_date, end_date, campaign_ids, columns, granularity, ad_account_id, opts = {}) ⇒ Array<CampaignsAnalyticsMetrics>

Get campaign analytics Get analytics for the specified campaigns in the specified ad_account_id, filtered by the specified options. - The token's user_account must either be the Owner of the specified ad account, or have one of the necessary roles granted to them via Business Access: Admin, Analyst, Campaign Manager. - If granularity is not HOUR, you can pull data from up to 90 days before the current date in UTC time, with a maximum time range of 90 days. - If granularity is HOUR, you can pull data from up to 8 days before the current date in UTC time, with a maximum time range of 3 days.

Parameters:

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

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

  • List of Campaign Ids to use to filter the results.

  • Columns to retrieve, encoded as a comma-separated string. NOTE: Any metrics defined as MICRO_DOLLARS returns a value based on the advertiser profile's currency field. For USD, ($1/1,000,000, or $0.000001 - one one-ten-thousandth of a cent). it's microdollars. Otherwise, it's in microunits of the advertiser's currency. For example, if the advertiser's currency is GBP (British pound sterling), all MICRO_DOLLARS fields will be in GBP microunits (1/1,000,000 British pound). If a column has no value, it may not be returned.

  • TOTAL - metrics are aggregated over the specified date range. DAY - metrics are broken down daily. HOUR - metrics are broken down hourly. WEEK - metrics are broken down weekly. MONTH - metrics are broken down monthly

  • Unique identifier of an ad account.

  • (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :click_window_days (Float)

    Number of days to use as the conversion attribution window for a pin click action. Applies to Pinterest Tag conversion metrics. Prior conversion tags use their defined attribution windows. If not specified, defaults to `30` days. (default to 30)

  • :engagement_window_days (Float)

    Number of days to use as the conversion attribution window for an engagement action. Engagements include saves, closeups, link clicks, and carousel card swipes. Applies to Pinterest Tag conversion metrics. Prior conversion tags use their defined attribution windows. If not specified, defaults to `30` days. Note: This parameter no longer returns new data. However, you can still access historic data through Sept 30, 2027. (default to 30)

  • :view_window_days (Float)

    Number of days to use as the conversion attribution window for a view action. Applies to Pinterest Tag conversion metrics. Prior conversion tags use their defined attribution windows. If not specified, defaults to `1` day. (default to 1)

  • :conversion_report_time (String)

    The date by which the conversion metrics returned from this endpoint will be reported. There are two dates associated with a conversion event: the date that the user interacted with the ad, and the date that the user completed a conversion event. (default to 'TIME_OF_AD_ACTION')

  • :aggregate_report_rows (Boolean)

    Determines if report rows should be aggregated across all requested entities. This feature is currently in BETA and is not available to all users. (default to false)

  • :reporting_timezone (ReportingTimeZone)

    Specify the timezone to be applied for the reporting. This feature is currently in BETA and is not available to all users.

Returns:



365
366
367
368
# File 'lib/pinterest_sdk/api/campaigns_api.rb', line 365

def campaigns_analytics(start_date, end_date, campaign_ids, columns, granularity, , opts = {})
  data, _status_code, _headers = campaigns_analytics_with_http_info(start_date, end_date, campaign_ids, columns, granularity, , opts)
  data
end

#campaigns_analytics_with_http_info(start_date, end_date, campaign_ids, columns, granularity, ad_account_id, opts = {}) ⇒ Array<(Array<CampaignsAnalyticsMetrics>, Integer, Hash)>

Get campaign analytics Get analytics for the specified campaigns in the specified `ad_account_id`, filtered by the specified options. - The token's user_account must either be the Owner of the specified ad account, or have one of the necessary roles granted to them via Business Access: Admin, Analyst, Campaign Manager. - If granularity is not HOUR, you can pull data from up to 90 days before the current date in UTC time, with a maximum time range of 90 days. - If granularity is HOUR, you can pull data from up to 8 days before the current date in UTC time, with a maximum time range of 3 days.

Parameters:

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

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

  • List of Campaign Ids to use to filter the results.

  • Columns to retrieve, encoded as a comma-separated string. NOTE: Any metrics defined as MICRO_DOLLARS returns a value based on the advertiser profile's currency field. For USD, ($1/1,000,000, or $0.000001 - one one-ten-thousandth of a cent). it's microdollars. Otherwise, it's in microunits of the advertiser's currency. For example, if the advertiser's currency is GBP (British pound sterling), all MICRO_DOLLARS fields will be in GBP microunits (1/1,000,000 British pound). If a column has no value, it may not be returned.

  • TOTAL - metrics are aggregated over the specified date range. DAY - metrics are broken down daily. HOUR - metrics are broken down hourly. WEEK - metrics are broken down weekly. MONTH - metrics are broken down monthly

  • Unique identifier of an ad account.

  • (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :click_window_days (Float)

    Number of days to use as the conversion attribution window for a pin click action. Applies to Pinterest Tag conversion metrics. Prior conversion tags use their defined attribution windows. If not specified, defaults to `30` days. (default to 30)

  • :engagement_window_days (Float)

    Number of days to use as the conversion attribution window for an engagement action. Engagements include saves, closeups, link clicks, and carousel card swipes. Applies to Pinterest Tag conversion metrics. Prior conversion tags use their defined attribution windows. If not specified, defaults to `30` days. Note: This parameter no longer returns new data. However, you can still access historic data through Sept 30, 2027. (default to 30)

  • :view_window_days (Float)

    Number of days to use as the conversion attribution window for a view action. Applies to Pinterest Tag conversion metrics. Prior conversion tags use their defined attribution windows. If not specified, defaults to `1` day. (default to 1)

  • :conversion_report_time (String)

    The date by which the conversion metrics returned from this endpoint will be reported. There are two dates associated with a conversion event: the date that the user interacted with the ad, and the date that the user completed a conversion event. (default to 'TIME_OF_AD_ACTION')

  • :aggregate_report_rows (Boolean)

    Determines if report rows should be aggregated across all requested entities. This feature is currently in BETA and is not available to all users. (default to false)

  • :reporting_timezone (ReportingTimeZone)

    Specify the timezone to be applied for the reporting. This feature is currently in BETA and is not available to all users.

Returns:

  • Array data, response status code and response headers



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
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
486
487
488
489
490
491
492
493
494
495
496
# File 'lib/pinterest_sdk/api/campaigns_api.rb', line 386

def campaigns_analytics_with_http_info(start_date, end_date, campaign_ids, columns, granularity, , opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CampaignsApi.campaigns_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 CampaignsApi.campaigns_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 CampaignsApi.campaigns_analytics"
  end
  # verify the required parameter 'campaign_ids' is set
  if @api_client.config.client_side_validation && campaign_ids.nil?
    fail ArgumentError, "Missing the required parameter 'campaign_ids' when calling CampaignsApi.campaigns_analytics"
  end
  if @api_client.config.client_side_validation && campaign_ids.length > 250
    fail ArgumentError, 'invalid value for "campaign_ids" when calling CampaignsApi.campaigns_analytics, number of items must be less than or equal to 250.'
  end

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

  # verify the required parameter 'columns' is set
  if @api_client.config.client_side_validation && columns.nil?
    fail ArgumentError, "Missing the required parameter 'columns' when calling CampaignsApi.campaigns_analytics"
  end
  # verify the required parameter 'granularity' is set
  if @api_client.config.client_side_validation && granularity.nil?
    fail ArgumentError, "Missing the required parameter 'granularity' when calling CampaignsApi.campaigns_analytics"
  end
  # verify the required parameter 'ad_account_id' is set
  if @api_client.config.client_side_validation && .nil?
    fail ArgumentError, "Missing the required parameter 'ad_account_id' when calling CampaignsApi.campaigns_analytics"
  end
  if @api_client.config.client_side_validation && .to_s.length > 18
    fail ArgumentError, 'invalid value for "ad_account_id" when calling CampaignsApi.campaigns_analytics, the character length must be smaller than or equal to 18.'
  end

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

  allowable_values = [0, 1, 7, 14, 30, 60]
  if @api_client.config.client_side_validation && opts[:'click_window_days'] && !allowable_values.include?(opts[:'click_window_days'])
    fail ArgumentError, "invalid value for \"click_window_days\", must be one of #{allowable_values}"
  end
  allowable_values = [0, 1, 7, 14, 30, 60]
  if @api_client.config.client_side_validation && opts[:'engagement_window_days'] && !allowable_values.include?(opts[:'engagement_window_days'])
    fail ArgumentError, "invalid value for \"engagement_window_days\", must be one of #{allowable_values}"
  end
  allowable_values = [0, 1, 7, 14, 30, 60]
  if @api_client.config.client_side_validation && opts[:'view_window_days'] && !allowable_values.include?(opts[:'view_window_days'])
    fail ArgumentError, "invalid value for \"view_window_days\", must be one of #{allowable_values}"
  end
  allowable_values = ["TIME_OF_AD_ACTION", "TIME_OF_CONVERSION"]
  if @api_client.config.client_side_validation && opts[:'conversion_report_time'] && !allowable_values.include?(opts[:'conversion_report_time'])
    fail ArgumentError, "invalid value for \"conversion_report_time\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/ad_accounts/{ad_account_id}/campaigns/analytics'.sub('{ad_account_id}', CGI.escape(.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'start_date'] = start_date
  query_params[:'end_date'] = end_date
  query_params[:'campaign_ids'] = @api_client.build_collection_param(campaign_ids, :multi)
  query_params[:'columns'] = @api_client.build_collection_param(columns, :csv)
  query_params[:'granularity'] = granularity
  query_params[:'click_window_days'] = opts[:'click_window_days'] if !opts[:'click_window_days'].nil?
  query_params[:'engagement_window_days'] = opts[:'engagement_window_days'] if !opts[:'engagement_window_days'].nil?
  query_params[:'view_window_days'] = opts[:'view_window_days'] if !opts[:'view_window_days'].nil?
  query_params[:'conversion_report_time'] = opts[:'conversion_report_time'] if !opts[:'conversion_report_time'].nil?
  query_params[:'aggregate_report_rows'] = opts[:'aggregate_report_rows'] if !opts[:'aggregate_report_rows'].nil?
  query_params[:'reporting_timezone'] = opts[:'reporting_timezone'] if !opts[:'reporting_timezone'].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<CampaignsAnalyticsMetrics>'

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

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

#campaigns_create(ad_account_id, campaign_create_item, opts = {}) ⇒ CampaignBatchWriteResponseModel

Create campaigns Create multiple new campaigns. Every campaign has its own campaign_id and houses one or more ad groups, which contain one or more ads. For more, see Set up your campaign. Note: - The values for lifetime_spend_cap and daily_spend_cap are microcurrency amounts based on the currency field set in the advertiser's profile (e.g. USD). Microcurrency is used to track very small transactions, based on the currency set in the advertiser's profile. A microcurrency unit is 10^(-6) of the standard unit of currency selected in the advertiser's profile. Equivalency equations, using dollars as an example currency: - $1 = 1,000,000 microdollars - 1 microdollar = $0.000001 To convert between currency and microcurrency, using dollars as an example currency: - To convert dollars to microdollars, multiply dollars by 1,000,000 - To convert microdollars to dollars, divide microdollars by 1,000,000

Parameters:

  • Unique identifier of an ad account.

  • (defaults to: {})

    the optional parameters

Returns:



504
505
506
507
# File 'lib/pinterest_sdk/api/campaigns_api.rb', line 504

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

#campaigns_create_with_http_info(ad_account_id, campaign_create_item, opts = {}) ⇒ Array<(CampaignBatchWriteResponseModel, Integer, Hash)>

Create campaigns Create multiple new campaigns. Every campaign has its own campaign_id and houses one or more ad groups, which contain one or more ads. For more, see Set up your campaign. Note: - The values for `lifetime_spend_cap` and `daily_spend_cap` are microcurrency amounts based on the currency field set in the advertiser's profile (e.g. USD). Microcurrency is used to track very small transactions, based on the currency set in the advertiser's profile. A microcurrency unit is 10^(-6) of the standard unit of currency selected in the advertiser's profile. Equivalency equations, using dollars as an example currency: - $1 = 1,000,000 microdollars - 1 microdollar = $0.000001 To convert between currency and microcurrency, using dollars as an example currency: - To convert dollars to microdollars, multiply dollars by 1,000,000 - To convert microdollars to dollars, divide microdollars by 1,000,000

Parameters:

  • Unique identifier of an ad account.

  • (defaults to: {})

    the optional parameters

Returns:

  • CampaignBatchWriteResponseModel data, response status code and response headers



515
516
517
518
519
520
521
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
# File 'lib/pinterest_sdk/api/campaigns_api.rb', line 515

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

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

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

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

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

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

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

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

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

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

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

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

#campaigns_get(campaign_id, ad_account_id, opts = {}) ⇒ Campaign

Get campaign Get a specific campaign given the campaign ID.

Parameters:

  • Campaign ID, must be associated with the ad account ID provided in the path.

  • Unique identifier of an ad account.

  • (defaults to: {})

    the optional parameters

Returns:



595
596
597
598
# File 'lib/pinterest_sdk/api/campaigns_api.rb', line 595

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

#campaigns_get_with_http_info(campaign_id, ad_account_id, opts = {}) ⇒ Array<(Campaign, Integer, Hash)>

Get campaign Get a specific campaign given the campaign ID.

Parameters:

  • Campaign ID, must be associated with the ad account ID provided in the path.

  • Unique identifier of an ad account.

  • (defaults to: {})

    the optional parameters

Returns:

  • Campaign data, response status code and response headers



606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
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
# File 'lib/pinterest_sdk/api/campaigns_api.rb', line 606

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

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

  # verify the required parameter 'ad_account_id' is set
  if @api_client.config.client_side_validation && .nil?
    fail ArgumentError, "Missing the required parameter 'ad_account_id' when calling CampaignsApi.campaigns_get"
  end
  if @api_client.config.client_side_validation && .to_s.length > 18
    fail ArgumentError, 'invalid value for "ad_account_id" when calling CampaignsApi.campaigns_get, the character length must be smaller than or equal to 18.'
  end

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

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

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

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

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

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

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

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

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

#campaigns_list(ad_account_id, opts = {}) ⇒ CampaignsList200Response

List campaigns Get a list of the campaigns in the specified ad_account_id, filtered by the specified options. - The token's user_account must either be the Owner of the specified ad account, or have one of the necessary roles granted to them via Business Access: Admin, Analyst, Campaign Manager.

Parameters:

  • Unique identifier of an ad account.

  • (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :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)

  • :order (PinterestLibPaginationOrder)

    The order in which to sort the items returned: &quot;ASCENDING&quot; or &quot;DESCENDING&quot; by ID. Note that higher-value IDs are associated with more-recently added items.

  • :campaign_ids (Array<String>)

    List of Campaign Ids to use to filter the results.

  • :entity_statuses (Array<EntityStatus>)

    Entity status

Returns:



686
687
688
689
# File 'lib/pinterest_sdk/api/campaigns_api.rb', line 686

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

#campaigns_list_with_http_info(ad_account_id, opts = {}) ⇒ Array<(CampaignsList200Response, Integer, Hash)>

List campaigns Get a list of the campaigns in the specified `ad_account_id`, filtered by the specified options. - The token's user_account must either be the Owner of the specified ad account, or have one of the necessary roles granted to them via Business Access: Admin, Analyst, Campaign Manager.

Parameters:

  • Unique identifier of an ad account.

  • (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :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)

  • :order (PinterestLibPaginationOrder)

    The order in which to sort the items returned: &quot;ASCENDING&quot; or &quot;DESCENDING&quot; by ID. Note that higher-value IDs are associated with more-recently added items.

  • :campaign_ids (Array<String>)

    List of Campaign Ids to use to filter the results.

  • :entity_statuses (Array<EntityStatus>)

    Entity status

Returns:

  • CampaignsList200Response data, response status code and response headers



701
702
703
704
705
706
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/campaigns_api.rb', line 701

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

  pattern = Regexp.new(/^\d+$/)
  if @api_client.config.client_side_validation &&  !~ pattern
    fail ArgumentError, "invalid value for 'ad_account_id' when calling CampaignsApi.campaigns_list, must conform to the pattern #{pattern}."
  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 CampaignsApi.campaigns_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 CampaignsApi.campaigns_list, must be greater than or equal to 1.'
  end

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

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

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

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'bookmark'] = opts[:'bookmark'] if !opts[:'bookmark'].nil?
  query_params[:'page_size'] = opts[:'page_size'] if !opts[:'page_size'].nil?
  query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil?
  query_params[:'campaign_ids'] = @api_client.build_collection_param(opts[:'campaign_ids'], :multi) if !opts[:'campaign_ids'].nil?
  query_params[:'entity_statuses'] = @api_client.build_collection_param(opts[:'entity_statuses'], :multi) if !opts[:'entity_statuses'].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] || 'CampaignsList200Response'

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

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

#campaigns_update(ad_account_id, campaign_batch_update_item, opts = {}) ⇒ CampaignBatchWriteResponseModel

Update campaigns Update multiple ad campaigns based on campaign_ids. Note: - The values for lifetime_spend_cap and daily_spend_cap are microcurrency amounts based on the currency field set in the advertiser's profile (e.g. USD). Microcurrency is used to track very small transactions, based on the currency set in the advertiser's profile. A microcurrency unit is 10^(-6) of the standard unit of currency selected in the advertiser's profile. Equivalency equations, using dollars as an example currency: - $1 = 1,000,000 microdollars - 1 microdollar = $0.000001 To convert between currency and microcurrency, using dollars as an example currency: - To convert dollars to microdollars, multiply dollars by 1,000,000 - To convert microdollars to dollars, divide microdollars by 1,000,000

Parameters:

  • Unique identifier of an ad account.

  • (defaults to: {})

    the optional parameters

Returns:



785
786
787
788
# File 'lib/pinterest_sdk/api/campaigns_api.rb', line 785

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

#campaigns_update_with_http_info(ad_account_id, campaign_batch_update_item, opts = {}) ⇒ Array<(CampaignBatchWriteResponseModel, Integer, Hash)>

Update campaigns Update multiple ad campaigns based on campaign_ids. Note: - The values for `lifetime_spend_cap` and `daily_spend_cap` are microcurrency amounts based on the currency field set in the advertiser's profile (e.g. USD). Microcurrency is used to track very small transactions, based on the currency set in the advertiser's profile. A microcurrency unit is 10^(-6) of the standard unit of currency selected in the advertiser's profile. Equivalency equations, using dollars as an example currency: - $1 = 1,000,000 microdollars - 1 microdollar = $0.000001 To convert between currency and microcurrency, using dollars as an example currency: - To convert dollars to microdollars, multiply dollars by 1,000,000 - To convert microdollars to dollars, divide microdollars by 1,000,000

Parameters:

  • Unique identifier of an ad account.

  • (defaults to: {})

    the optional parameters

Returns:

  • CampaignBatchWriteResponseModel data, response status code and response headers



796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
# File 'lib/pinterest_sdk/api/campaigns_api.rb', line 796

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

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

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

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

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

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

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

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

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

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

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

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

#get_campaign_delivery_estimates(ad_account_id, campaign_delivery_estimates_campaign, opts = {}) ⇒ CampaignDeliveryEstimatesResponse

Get campaign delivery estimates Get delivery estimates for an ads campaign This endpoint is currently in beta and is not available to all apps Learn more.

Parameters:

  • Unique identifier of an ad account.

  • (defaults to: {})

    the optional parameters

Returns:



876
877
878
879
# File 'lib/pinterest_sdk/api/campaigns_api.rb', line 876

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

#get_campaign_delivery_estimates_with_http_info(ad_account_id, campaign_delivery_estimates_campaign, opts = {}) ⇒ Array<(CampaignDeliveryEstimatesResponse, Integer, Hash)>

Get campaign delivery estimates Get delivery estimates for an ads campaign This endpoint is currently in beta and is not available to all apps Learn more.

Parameters:

  • Unique identifier of an ad account.

  • (defaults to: {})

    the optional parameters

Returns:

  • CampaignDeliveryEstimatesResponse data, response status code and response headers



887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
# File 'lib/pinterest_sdk/api/campaigns_api.rb', line 887

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

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

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

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

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

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

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

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

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

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

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

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