=begin #Pinterest REST API #Pinterest's REST API The version of the OpenAPI document: 5.3.0 Contact: blah@cliffano.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.4.0 =end require 'cgi' module PinterestSdkClient class AdAccountsApi attr_accessor :api_client def initialize(api_client = ApiClient.default) @api_client = api_client end # Get ad account analytics # Get analytics for the specified <code>ad_account_id</code>, 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 <a href=\"https://help.pinterest.com/en/business/article/share-and-manage-access-to-your-ad-accounts\">Business Access</a>: Admin, Analyst, Campaign Manager. # @param ad_account_id [String] Unique identifier of an ad account. # @param start_date [Date] Metric report start date (UTC). Format: YYYY-MM-DD # @param end_date [Date] Metric report end date (UTC). Format: YYYY-MM-DD # @param columns [Array<String>] Columns to retrieve. **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.<br/>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).<br/>If a column has no value, it may not be returned # @param granularity [Granularity] Granularity # @param [Hash] opts the optional parameters # @option opts [Integer] :click_window_days 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) # @option opts [Integer] :engagement_window_days 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. (default to 30) # @option opts [Integer] :view_window_days 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) # @option opts [String] :conversion_report_time 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') # @return [Array<Hash<String, Object>>] def ad_account_analytics(ad_account_id, start_date, end_date, columns, granularity, opts = {}) data, _status_code, _headers = ad_account_analytics_with_http_info(ad_account_id, start_date, end_date, columns, granularity, opts) data end # Get ad account analytics # Get analytics for the specified <code>ad_account_id</code>, 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 <a href=\"https://help.pinterest.com/en/business/article/share-and-manage-access-to-your-ad-accounts\">Business Access</a>: Admin, Analyst, Campaign Manager. # @param ad_account_id [String] Unique identifier of an ad account. # @param start_date [Date] Metric report start date (UTC). Format: YYYY-MM-DD # @param end_date [Date] Metric report end date (UTC). Format: YYYY-MM-DD # @param columns [Array<String>] Columns to retrieve. **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.<br/>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).<br/>If a column has no value, it may not be returned # @param granularity [Granularity] Granularity # @param [Hash] opts the optional parameters # @option opts [Integer] :click_window_days 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. # @option opts [Integer] :engagement_window_days 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. # @option opts [Integer] :view_window_days 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. # @option opts [String] :conversion_report_time 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. # @return [Array<(Array<Hash<String, Object>>, Integer, Hash)>] Array<Hash<String, Object>> data, response status code and response headers def ad_account_analytics_with_http_info(ad_account_id, start_date, end_date, columns, granularity, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: AdAccountsApi.ad_account_analytics ...' end # verify the required parameter 'ad_account_id' is set if @api_client.config.client_side_validation && ad_account_id.nil? fail ArgumentError, "Missing the required parameter 'ad_account_id' when calling AdAccountsApi.ad_account_analytics" end pattern = Regexp.new(/^\d+$/) if @api_client.config.client_side_validation && ad_account_id !~ pattern fail ArgumentError, "invalid value for 'ad_account_id' when calling AdAccountsApi.ad_account_analytics, must conform to the pattern #{pattern}." 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 AdAccountsApi.ad_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 AdAccountsApi.ad_account_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 AdAccountsApi.ad_account_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 AdAccountsApi.ad_account_analytics" end allowable_values = [1, 7, 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 = [1, 7, 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 = [1, 7, 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}/analytics'.sub('{' + 'ad_account_id' + '}', CGI.escape(ad_account_id.to_s)) # query parameters query_params = opts[:query_params] || {} 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']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Array<Hash<String, Object>>' # auth_names auth_names = opts[:debug_auth_names] || ['pinterest_oauth2'] new_options = opts.merge( :operation => :"AdAccountsApi.ad_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: AdAccountsApi#ad_account_analytics\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # List ad accounts # Get a list of the ad_accounts that the \"operation user_account\" has access to. - This includes ad_accounts they own and ad_accounts that are owned by others who have granted them <a href=\"https://help.pinterest.com/en/business/article/share-and-manage-access-to-your-ad-accounts\">Business Access</a>. # @param [Hash] opts the optional parameters # @option opts [String] :bookmark Cursor used to fetch the next page of items # @option opts [Integer] :page_size Maximum number of items to include in a single page of the response. See documentation on <a href='/docs/api/v5/#tag/Pagination'>Pagination</a> for more information. (default to 25) # @option opts [Boolean] :include_shared_accounts Include shared ad accounts (default to true) # @return [Paginated] def ad_accounts_list(opts = {}) data, _status_code, _headers = ad_accounts_list_with_http_info(opts) data end # List ad accounts # Get a list of the ad_accounts that the \"operation user_account\" has access to. - This includes ad_accounts they own and ad_accounts that are owned by others who have granted them <a href=\"https://help.pinterest.com/en/business/article/share-and-manage-access-to-your-ad-accounts\">Business Access</a>. # @param [Hash] opts the optional parameters # @option opts [String] :bookmark Cursor used to fetch the next page of items # @option opts [Integer] :page_size Maximum number of items to include in a single page of the response. See documentation on <a href='/docs/api/v5/#tag/Pagination'>Pagination</a> for more information. # @option opts [Boolean] :include_shared_accounts Include shared ad accounts # @return [Array<(Paginated, Integer, Hash)>] Paginated data, response status code and response headers def ad_accounts_list_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: AdAccountsApi.ad_accounts_list ...' end if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 100 fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling AdAccountsApi.ad_accounts_list, must be smaller than or equal to 100.' 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 AdAccountsApi.ad_accounts_list, must be greater than or equal to 1.' end # resource path local_var_path = '/ad_accounts' # 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[:'include_shared_accounts'] = opts[:'include_shared_accounts'] if !opts[:'include_shared_accounts'].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] || 'Paginated' # auth_names auth_names = opts[:debug_auth_names] || ['pinterest_oauth2'] new_options = opts.merge( :operation => :"AdAccountsApi.ad_accounts_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: AdAccountsApi#ad_accounts_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get ad group analytics # Get analytics for the specified ad groups in the specified <code>ad_account_id</code>, 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 <a href=\"https://help.pinterest.com/en/business/article/share-and-manage-access-to-your-ad-accounts\">Business Access</a>: Admin, Analyst, Campaign Manager. # @param ad_account_id [String] Unique identifier of an ad account. # @param start_date [Date] Metric report start date (UTC). Format: YYYY-MM-DD # @param end_date [Date] Metric report end date (UTC). Format: YYYY-MM-DD # @param ad_group_ids [Array<String>] List of Ad group Ids to use to filter the results. # @param columns [Array<String>] Columns to retrieve. **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.<br/>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).<br/>If a column has no value, it may not be returned # @param granularity [Granularity] Granularity # @param [Hash] opts the optional parameters # @option opts [Integer] :click_window_days 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) # @option opts [Integer] :engagement_window_days 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. (default to 30) # @option opts [Integer] :view_window_days 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) # @option opts [String] :conversion_report_time 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') # @return [Array<Hash<String, Object>>] def ad_groups_analytics(ad_account_id, start_date, end_date, ad_group_ids, columns, granularity, opts = {}) data, _status_code, _headers = ad_groups_analytics_with_http_info(ad_account_id, start_date, end_date, ad_group_ids, columns, granularity, opts) data end # Get ad group analytics # Get analytics for the specified ad groups in the specified <code>ad_account_id</code>, 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 <a href=\"https://help.pinterest.com/en/business/article/share-and-manage-access-to-your-ad-accounts\">Business Access</a>: Admin, Analyst, Campaign Manager. # @param ad_account_id [String] Unique identifier of an ad account. # @param start_date [Date] Metric report start date (UTC). Format: YYYY-MM-DD # @param end_date [Date] Metric report end date (UTC). Format: YYYY-MM-DD # @param ad_group_ids [Array<String>] List of Ad group Ids to use to filter the results. # @param columns [Array<String>] Columns to retrieve. **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.<br/>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).<br/>If a column has no value, it may not be returned # @param granularity [Granularity] Granularity # @param [Hash] opts the optional parameters # @option opts [Integer] :click_window_days 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. # @option opts [Integer] :engagement_window_days 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. # @option opts [Integer] :view_window_days 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. # @option opts [String] :conversion_report_time 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. # @return [Array<(Array<Hash<String, Object>>, Integer, Hash)>] Array<Hash<String, Object>> data, response status code and response headers def ad_groups_analytics_with_http_info(ad_account_id, start_date, end_date, ad_group_ids, columns, granularity, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: AdAccountsApi.ad_groups_analytics ...' end # verify the required parameter 'ad_account_id' is set if @api_client.config.client_side_validation && ad_account_id.nil? fail ArgumentError, "Missing the required parameter 'ad_account_id' when calling AdAccountsApi.ad_groups_analytics" end pattern = Regexp.new(/^\d+$/) if @api_client.config.client_side_validation && ad_account_id !~ pattern fail ArgumentError, "invalid value for 'ad_account_id' when calling AdAccountsApi.ad_groups_analytics, must conform to the pattern #{pattern}." 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 AdAccountsApi.ad_groups_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 AdAccountsApi.ad_groups_analytics" end # verify the required parameter 'ad_group_ids' is set if @api_client.config.client_side_validation && ad_group_ids.nil? fail ArgumentError, "Missing the required parameter 'ad_group_ids' when calling AdAccountsApi.ad_groups_analytics" end if @api_client.config.client_side_validation && ad_group_ids.length > 100 fail ArgumentError, 'invalid value for "ad_group_ids" when calling AdAccountsApi.ad_groups_analytics, number of items must be less than or equal to 100.' end if @api_client.config.client_side_validation && ad_group_ids.length < 1 fail ArgumentError, 'invalid value for "ad_group_ids" when calling AdAccountsApi.ad_groups_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 AdAccountsApi.ad_groups_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 AdAccountsApi.ad_groups_analytics" end allowable_values = [1, 7, 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 = [1, 7, 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 = [1, 7, 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}/ad_groups/analytics'.sub('{' + 'ad_account_id' + '}', CGI.escape(ad_account_id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'start_date'] = start_date query_params[:'end_date'] = end_date query_params[:'ad_group_ids'] = @api_client.build_collection_param(ad_group_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? # 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] || 'Array<Hash<String, Object>>' # auth_names auth_names = opts[:debug_auth_names] || ['pinterest_oauth2'] new_options = opts.merge( :operation => :"AdAccountsApi.ad_groups_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: AdAccountsApi#ad_groups_analytics\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # List ad groups # Get a list of the ad groups in the specified <code>ad_account_id</code>, 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 <a href=\"https://help.pinterest.com/en/business/article/share-and-manage-access-to-your-ad-accounts\">Business Access</a>: Admin, Analyst, Campaign Manager. # @param ad_account_id [String] Unique identifier of an ad account. # @param [Hash] opts the optional parameters # @option opts [Array<String>] :campaign_ids List of Campaign Ids to use to filter the results. # @option opts [Array<String>] :ad_group_ids List of Ad group Ids to use to filter the results. # @option opts [Array<String>] :entity_statuses Entity status # @option opts [Integer] :page_size Maximum number of items to include in a single page of the response. See documentation on <a href='/docs/api/v5/#tag/Pagination'>Pagination</a> for more information. (default to 25) # @option opts [String] :order The order in which to sort the items returned: “ASCENDING” or “DESCENDING” by ID. Note that higher-value IDs are associated with more-recently added items. # @option opts [String] :bookmark Cursor used to fetch the next page of items # @option opts [Boolean] :translate_interests_to_names Return interests as text names (if value is true) rather than topic IDs. (default to false) # @return [Paginated] def ad_groups_list(ad_account_id, opts = {}) data, _status_code, _headers = ad_groups_list_with_http_info(ad_account_id, opts) data end # List ad groups # Get a list of the ad groups in the specified <code>ad_account_id</code>, 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 <a href=\"https://help.pinterest.com/en/business/article/share-and-manage-access-to-your-ad-accounts\">Business Access</a>: Admin, Analyst, Campaign Manager. # @param ad_account_id [String] Unique identifier of an ad account. # @param [Hash] opts the optional parameters # @option opts [Array<String>] :campaign_ids List of Campaign Ids to use to filter the results. # @option opts [Array<String>] :ad_group_ids List of Ad group Ids to use to filter the results. # @option opts [Array<String>] :entity_statuses Entity status # @option opts [Integer] :page_size Maximum number of items to include in a single page of the response. See documentation on <a href='/docs/api/v5/#tag/Pagination'>Pagination</a> for more information. # @option opts [String] :order The order in which to sort the items returned: “ASCENDING” or “DESCENDING” by ID. Note that higher-value IDs are associated with more-recently added items. # @option opts [String] :bookmark Cursor used to fetch the next page of items # @option opts [Boolean] :translate_interests_to_names Return interests as text names (if value is true) rather than topic IDs. # @return [Array<(Paginated, Integer, Hash)>] Paginated data, response status code and response headers def ad_groups_list_with_http_info(ad_account_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: AdAccountsApi.ad_groups_list ...' end # verify the required parameter 'ad_account_id' is set if @api_client.config.client_side_validation && ad_account_id.nil? fail ArgumentError, "Missing the required parameter 'ad_account_id' when calling AdAccountsApi.ad_groups_list" end pattern = Regexp.new(/^\d+$/) if @api_client.config.client_side_validation && ad_account_id !~ pattern fail ArgumentError, "invalid value for 'ad_account_id' when calling AdAccountsApi.ad_groups_list, must conform to the pattern #{pattern}." end if @api_client.config.client_side_validation && !opts[:'campaign_ids'].nil? && opts[:'campaign_ids'].length > 100 fail ArgumentError, 'invalid value for "opts[:"campaign_ids"]" when calling AdAccountsApi.ad_groups_list, number of items must be less than or equal to 100.' 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 AdAccountsApi.ad_groups_list, number of items must be greater than or equal to 1.' end if @api_client.config.client_side_validation && !opts[:'ad_group_ids'].nil? && opts[:'ad_group_ids'].length > 100 fail ArgumentError, 'invalid value for "opts[:"ad_group_ids"]" when calling AdAccountsApi.ad_groups_list, number of items must be less than or equal to 100.' end if @api_client.config.client_side_validation && !opts[:'ad_group_ids'].nil? && opts[:'ad_group_ids'].length < 1 fail ArgumentError, 'invalid value for "opts[:"ad_group_ids"]" when calling AdAccountsApi.ad_groups_list, number of items must be greater than or equal to 1.' end allowable_values = ["ACTIVE", "PAUSED", "ARCHIVED"] if @api_client.config.client_side_validation && opts[:'entity_statuses'] && !opts[:'entity_statuses'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"entity_statuses\", must include one of #{allowable_values}" end if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 100 fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling AdAccountsApi.ad_groups_list, must be smaller than or equal to 100.' 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 AdAccountsApi.ad_groups_list, must be greater than or equal to 1.' end allowable_values = ["ASCENDING", "DESCENDING"] if @api_client.config.client_side_validation && opts[:'order'] && !allowable_values.include?(opts[:'order']) fail ArgumentError, "invalid value for \"order\", must be one of #{allowable_values}" end # resource path local_var_path = '/ad_accounts/{ad_account_id}/ad_groups'.sub('{' + 'ad_account_id' + '}', CGI.escape(ad_account_id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'campaign_ids'] = @api_client.build_collection_param(opts[:'campaign_ids'], :multi) if !opts[:'campaign_ids'].nil? query_params[:'ad_group_ids'] = @api_client.build_collection_param(opts[:'ad_group_ids'], :multi) if !opts[:'ad_group_ids'].nil? query_params[:'entity_statuses'] = @api_client.build_collection_param(opts[:'entity_statuses'], :multi) if !opts[:'entity_statuses'].nil? query_params[:'page_size'] = opts[:'page_size'] if !opts[:'page_size'].nil? query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil? query_params[:'bookmark'] = opts[:'bookmark'] if !opts[:'bookmark'].nil? query_params[:'translate_interests_to_names'] = opts[:'translate_interests_to_names'] if !opts[:'translate_interests_to_names'].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] || 'Paginated' # auth_names auth_names = opts[:debug_auth_names] || ['pinterest_oauth2'] new_options = opts.merge( :operation => :"AdAccountsApi.ad_groups_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: AdAccountsApi#ad_groups_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get ad analytics # Get analytics for the specified ads in the specified <code>ad_account_id</code>, 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 <a href=\"https://help.pinterest.com/en/business/article/share-and-manage-access-to-your-ad-accounts\">Business Access</a>: Admin, Analyst, Campaign Manager. # @param ad_account_id [String] Unique identifier of an ad account. # @param start_date [Date] Metric report start date (UTC). Format: YYYY-MM-DD # @param end_date [Date] Metric report end date (UTC). Format: YYYY-MM-DD # @param ad_ids [Array<String>] List of Ad Ids to use to filter the results. # @param columns [Array<String>] Columns to retrieve. **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.<br/>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).<br/>If a column has no value, it may not be returned # @param granularity [Granularity] Granularity # @param [Hash] opts the optional parameters # @option opts [Integer] :click_window_days 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) # @option opts [Integer] :engagement_window_days 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. (default to 30) # @option opts [Integer] :view_window_days 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) # @option opts [String] :conversion_report_time 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') # @return [Array<Hash<String, Object>>] def ads_analytics(ad_account_id, start_date, end_date, ad_ids, columns, granularity, opts = {}) data, _status_code, _headers = ads_analytics_with_http_info(ad_account_id, start_date, end_date, ad_ids, columns, granularity, opts) data end # Get ad analytics # Get analytics for the specified ads in the specified <code>ad_account_id</code>, 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 <a href=\"https://help.pinterest.com/en/business/article/share-and-manage-access-to-your-ad-accounts\">Business Access</a>: Admin, Analyst, Campaign Manager. # @param ad_account_id [String] Unique identifier of an ad account. # @param start_date [Date] Metric report start date (UTC). Format: YYYY-MM-DD # @param end_date [Date] Metric report end date (UTC). Format: YYYY-MM-DD # @param ad_ids [Array<String>] List of Ad Ids to use to filter the results. # @param columns [Array<String>] Columns to retrieve. **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.<br/>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).<br/>If a column has no value, it may not be returned # @param granularity [Granularity] Granularity # @param [Hash] opts the optional parameters # @option opts [Integer] :click_window_days 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. # @option opts [Integer] :engagement_window_days 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. # @option opts [Integer] :view_window_days 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. # @option opts [String] :conversion_report_time 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. # @return [Array<(Array<Hash<String, Object>>, Integer, Hash)>] Array<Hash<String, Object>> data, response status code and response headers def ads_analytics_with_http_info(ad_account_id, start_date, end_date, ad_ids, columns, granularity, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: AdAccountsApi.ads_analytics ...' end # verify the required parameter 'ad_account_id' is set if @api_client.config.client_side_validation && ad_account_id.nil? fail ArgumentError, "Missing the required parameter 'ad_account_id' when calling AdAccountsApi.ads_analytics" end pattern = Regexp.new(/^\d+$/) if @api_client.config.client_side_validation && ad_account_id !~ pattern fail ArgumentError, "invalid value for 'ad_account_id' when calling AdAccountsApi.ads_analytics, must conform to the pattern #{pattern}." 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 AdAccountsApi.ads_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 AdAccountsApi.ads_analytics" end # verify the required parameter 'ad_ids' is set if @api_client.config.client_side_validation && ad_ids.nil? fail ArgumentError, "Missing the required parameter 'ad_ids' when calling AdAccountsApi.ads_analytics" end if @api_client.config.client_side_validation && ad_ids.length > 100 fail ArgumentError, 'invalid value for "ad_ids" when calling AdAccountsApi.ads_analytics, number of items must be less than or equal to 100.' end if @api_client.config.client_side_validation && ad_ids.length < 1 fail ArgumentError, 'invalid value for "ad_ids" when calling AdAccountsApi.ads_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 AdAccountsApi.ads_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 AdAccountsApi.ads_analytics" end allowable_values = [1, 7, 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 = [1, 7, 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 = [1, 7, 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}/ads/analytics'.sub('{' + 'ad_account_id' + '}', CGI.escape(ad_account_id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'start_date'] = start_date query_params[:'end_date'] = end_date query_params[:'ad_ids'] = @api_client.build_collection_param(ad_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? # 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] || 'Array<Hash<String, Object>>' # auth_names auth_names = opts[:debug_auth_names] || ['pinterest_oauth2'] new_options = opts.merge( :operation => :"AdAccountsApi.ads_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: AdAccountsApi#ads_analytics\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # List ads # Get a list of the ads in the specified <code>ad_account_id</code>, 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 <a href=\"https://help.pinterest.com/en/business/article/share-and-manage-access-to-your-ad-accounts\">Business Access</a>: Admin, Analyst, Campaign Manager. # @param ad_account_id [String] Unique identifier of an ad account. # @param [Hash] opts the optional parameters # @option opts [Array<String>] :campaign_ids List of Campaign Ids to use to filter the results. # @option opts [Array<String>] :ad_group_ids List of Ad group Ids to use to filter the results. # @option opts [Array<String>] :ad_ids List of Ad Ids to use to filter the results. # @option opts [Array<String>] :entity_statuses Entity status # @option opts [Integer] :page_size Maximum number of items to include in a single page of the response. See documentation on <a href='/docs/api/v5/#tag/Pagination'>Pagination</a> for more information. (default to 25) # @option opts [String] :order The order in which to sort the items returned: “ASCENDING” or “DESCENDING” by ID. Note that higher-value IDs are associated with more-recently added items. # @option opts [String] :bookmark Cursor used to fetch the next page of items # @return [Paginated] def ads_list(ad_account_id, opts = {}) data, _status_code, _headers = ads_list_with_http_info(ad_account_id, opts) data end # List ads # Get a list of the ads in the specified <code>ad_account_id</code>, 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 <a href=\"https://help.pinterest.com/en/business/article/share-and-manage-access-to-your-ad-accounts\">Business Access</a>: Admin, Analyst, Campaign Manager. # @param ad_account_id [String] Unique identifier of an ad account. # @param [Hash] opts the optional parameters # @option opts [Array<String>] :campaign_ids List of Campaign Ids to use to filter the results. # @option opts [Array<String>] :ad_group_ids List of Ad group Ids to use to filter the results. # @option opts [Array<String>] :ad_ids List of Ad Ids to use to filter the results. # @option opts [Array<String>] :entity_statuses Entity status # @option opts [Integer] :page_size Maximum number of items to include in a single page of the response. See documentation on <a href='/docs/api/v5/#tag/Pagination'>Pagination</a> for more information. # @option opts [String] :order The order in which to sort the items returned: “ASCENDING” or “DESCENDING” by ID. Note that higher-value IDs are associated with more-recently added items. # @option opts [String] :bookmark Cursor used to fetch the next page of items # @return [Array<(Paginated, Integer, Hash)>] Paginated data, response status code and response headers def ads_list_with_http_info(ad_account_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: AdAccountsApi.ads_list ...' end # verify the required parameter 'ad_account_id' is set if @api_client.config.client_side_validation && ad_account_id.nil? fail ArgumentError, "Missing the required parameter 'ad_account_id' when calling AdAccountsApi.ads_list" end pattern = Regexp.new(/^\d+$/) if @api_client.config.client_side_validation && ad_account_id !~ pattern fail ArgumentError, "invalid value for 'ad_account_id' when calling AdAccountsApi.ads_list, must conform to the pattern #{pattern}." end if @api_client.config.client_side_validation && !opts[:'campaign_ids'].nil? && opts[:'campaign_ids'].length > 100 fail ArgumentError, 'invalid value for "opts[:"campaign_ids"]" when calling AdAccountsApi.ads_list, number of items must be less than or equal to 100.' 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 AdAccountsApi.ads_list, number of items must be greater than or equal to 1.' end if @api_client.config.client_side_validation && !opts[:'ad_group_ids'].nil? && opts[:'ad_group_ids'].length > 100 fail ArgumentError, 'invalid value for "opts[:"ad_group_ids"]" when calling AdAccountsApi.ads_list, number of items must be less than or equal to 100.' end if @api_client.config.client_side_validation && !opts[:'ad_group_ids'].nil? && opts[:'ad_group_ids'].length < 1 fail ArgumentError, 'invalid value for "opts[:"ad_group_ids"]" when calling AdAccountsApi.ads_list, number of items must be greater than or equal to 1.' end if @api_client.config.client_side_validation && !opts[:'ad_ids'].nil? && opts[:'ad_ids'].length > 100 fail ArgumentError, 'invalid value for "opts[:"ad_ids"]" when calling AdAccountsApi.ads_list, number of items must be less than or equal to 100.' end if @api_client.config.client_side_validation && !opts[:'ad_ids'].nil? && opts[:'ad_ids'].length < 1 fail ArgumentError, 'invalid value for "opts[:"ad_ids"]" when calling AdAccountsApi.ads_list, number of items must be greater than or equal to 1.' end allowable_values = ["ACTIVE", "PAUSED", "ARCHIVED"] if @api_client.config.client_side_validation && opts[:'entity_statuses'] && !opts[:'entity_statuses'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"entity_statuses\", must include one of #{allowable_values}" end if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 100 fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling AdAccountsApi.ads_list, must be smaller than or equal to 100.' 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 AdAccountsApi.ads_list, must be greater than or equal to 1.' end allowable_values = ["ASCENDING", "DESCENDING"] if @api_client.config.client_side_validation && opts[:'order'] && !allowable_values.include?(opts[:'order']) fail ArgumentError, "invalid value for \"order\", must be one of #{allowable_values}" end # resource path local_var_path = '/ad_accounts/{ad_account_id}/ads'.sub('{' + 'ad_account_id' + '}', CGI.escape(ad_account_id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'campaign_ids'] = @api_client.build_collection_param(opts[:'campaign_ids'], :multi) if !opts[:'campaign_ids'].nil? query_params[:'ad_group_ids'] = @api_client.build_collection_param(opts[:'ad_group_ids'], :multi) if !opts[:'ad_group_ids'].nil? query_params[:'ad_ids'] = @api_client.build_collection_param(opts[:'ad_ids'], :multi) if !opts[:'ad_ids'].nil? query_params[:'entity_statuses'] = @api_client.build_collection_param(opts[:'entity_statuses'], :multi) if !opts[:'entity_statuses'].nil? query_params[:'page_size'] = opts[:'page_size'] if !opts[:'page_size'].nil? query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil? query_params[:'bookmark'] = opts[:'bookmark'] if !opts[:'bookmark'].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] || 'Paginated' # auth_names auth_names = opts[:debug_auth_names] || ['pinterest_oauth2'] new_options = opts.merge( :operation => :"AdAccountsApi.ads_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: AdAccountsApi#ads_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Create async request for an account analytics report # This returns a token that you can use to download the report when it is ready. Note that this endpoint requires the parameters to be passed as JSON-formatted in the request body. This endpoint does not support URL query parameters. - 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 <a href=\"https://help.pinterest.com/en/business/article/share-and-manage-access-to-your-ad-accounts\">Business Access</a>: Admin, Analyst, Campaign Manager. # @param ad_account_id [String] Unique identifier of an ad account. # @param ads_analytics_create_async_request [AdsAnalyticsCreateAsyncRequest] # @param [Hash] opts the optional parameters # @return [AdsAnalyticsCreateAsyncResponse] def analytics_create_report(ad_account_id, ads_analytics_create_async_request, opts = {}) data, _status_code, _headers = analytics_create_report_with_http_info(ad_account_id, ads_analytics_create_async_request, opts) data end # Create async request for an account analytics report # This returns a token that you can use to download the report when it is ready. Note that this endpoint requires the parameters to be passed as JSON-formatted in the request body. This endpoint does not support URL query parameters. - 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 <a href=\"https://help.pinterest.com/en/business/article/share-and-manage-access-to-your-ad-accounts\">Business Access</a>: Admin, Analyst, Campaign Manager. # @param ad_account_id [String] Unique identifier of an ad account. # @param ads_analytics_create_async_request [AdsAnalyticsCreateAsyncRequest] # @param [Hash] opts the optional parameters # @return [Array<(AdsAnalyticsCreateAsyncResponse, Integer, Hash)>] AdsAnalyticsCreateAsyncResponse data, response status code and response headers def analytics_create_report_with_http_info(ad_account_id, ads_analytics_create_async_request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: AdAccountsApi.analytics_create_report ...' end # verify the required parameter 'ad_account_id' is set if @api_client.config.client_side_validation && ad_account_id.nil? fail ArgumentError, "Missing the required parameter 'ad_account_id' when calling AdAccountsApi.analytics_create_report" end pattern = Regexp.new(/^\d+$/) if @api_client.config.client_side_validation && ad_account_id !~ pattern fail ArgumentError, "invalid value for 'ad_account_id' when calling AdAccountsApi.analytics_create_report, must conform to the pattern #{pattern}." end # verify the required parameter 'ads_analytics_create_async_request' is set if @api_client.config.client_side_validation && ads_analytics_create_async_request.nil? fail ArgumentError, "Missing the required parameter 'ads_analytics_create_async_request' when calling AdAccountsApi.analytics_create_report" end # resource path local_var_path = '/ad_accounts/{ad_account_id}/reports'.sub('{' + 'ad_account_id' + '}', CGI.escape(ad_account_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']) # 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(ads_analytics_create_async_request) # return_type return_type = opts[:debug_return_type] || 'AdsAnalyticsCreateAsyncResponse' # auth_names auth_names = opts[:debug_auth_names] || ['pinterest_oauth2'] new_options = opts.merge( :operation => :"AdAccountsApi.analytics_create_report", :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: AdAccountsApi#analytics_create_report\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get the account analytics report created by the async call # This returns a URL to an analytics report given a token returned from the post request report creation call. You can use the URL to download the report and it's valid for an hour. - 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 <a href=\"https://help.pinterest.com/en/business/article/share-and-manage-access-to-your-ad-accounts\">Business Access</a>: Admin, Analyst, Campaign Manager. # @param ad_account_id [String] Unique identifier of an ad account. # @param token [String] Token returned from the post request creation call # @param [Hash] opts the optional parameters # @return [AdsAnalyticsGetAsyncResponse] def analytics_get_report(ad_account_id, token, opts = {}) data, _status_code, _headers = analytics_get_report_with_http_info(ad_account_id, token, opts) data end # Get the account analytics report created by the async call # This returns a URL to an analytics report given a token returned from the post request report creation call. You can use the URL to download the report and it's valid for an hour. - 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 <a href=\"https://help.pinterest.com/en/business/article/share-and-manage-access-to-your-ad-accounts\">Business Access</a>: Admin, Analyst, Campaign Manager. # @param ad_account_id [String] Unique identifier of an ad account. # @param token [String] Token returned from the post request creation call # @param [Hash] opts the optional parameters # @return [Array<(AdsAnalyticsGetAsyncResponse, Integer, Hash)>] AdsAnalyticsGetAsyncResponse data, response status code and response headers def analytics_get_report_with_http_info(ad_account_id, token, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: AdAccountsApi.analytics_get_report ...' end # verify the required parameter 'ad_account_id' is set if @api_client.config.client_side_validation && ad_account_id.nil? fail ArgumentError, "Missing the required parameter 'ad_account_id' when calling AdAccountsApi.analytics_get_report" end pattern = Regexp.new(/^\d+$/) if @api_client.config.client_side_validation && ad_account_id !~ pattern fail ArgumentError, "invalid value for 'ad_account_id' when calling AdAccountsApi.analytics_get_report, must conform to the pattern #{pattern}." end # verify the required parameter 'token' is set if @api_client.config.client_side_validation && token.nil? fail ArgumentError, "Missing the required parameter 'token' when calling AdAccountsApi.analytics_get_report" end # resource path local_var_path = '/ad_accounts/{ad_account_id}/reports'.sub('{' + 'ad_account_id' + '}', CGI.escape(ad_account_id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'token'] = token # 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] || 'AdsAnalyticsGetAsyncResponse' # auth_names auth_names = opts[:debug_auth_names] || ['pinterest_oauth2'] new_options = opts.merge( :operation => :"AdAccountsApi.analytics_get_report", :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: AdAccountsApi#analytics_get_report\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get campaign analytics # Get analytics for the specified campaigns in the specified <code>ad_account_id</code>, 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 <a href=\"https://help.pinterest.com/en/business/article/share-and-manage-access-to-your-ad-accounts\">Business Access</a>: Admin, Analyst, Campaign Manager. # @param ad_account_id [String] Unique identifier of an ad account. # @param start_date [Date] Metric report start date (UTC). Format: YYYY-MM-DD # @param end_date [Date] Metric report end date (UTC). Format: YYYY-MM-DD # @param campaign_ids [Array<String>] List of Campaign Ids to use to filter the results. # @param columns [Array<String>] Columns to retrieve. **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.<br/>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).<br/>If a column has no value, it may not be returned # @param granularity [Granularity] Granularity # @param [Hash] opts the optional parameters # @option opts [Integer] :click_window_days 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) # @option opts [Integer] :engagement_window_days 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. (default to 30) # @option opts [Integer] :view_window_days 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) # @option opts [String] :conversion_report_time 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') # @return [Array<Hash<String, Object>>] def campaigns_analytics(ad_account_id, start_date, end_date, campaign_ids, columns, granularity, opts = {}) data, _status_code, _headers = campaigns_analytics_with_http_info(ad_account_id, start_date, end_date, campaign_ids, columns, granularity, opts) data end # Get campaign analytics # Get analytics for the specified campaigns in the specified <code>ad_account_id</code>, 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 <a href=\"https://help.pinterest.com/en/business/article/share-and-manage-access-to-your-ad-accounts\">Business Access</a>: Admin, Analyst, Campaign Manager. # @param ad_account_id [String] Unique identifier of an ad account. # @param start_date [Date] Metric report start date (UTC). Format: YYYY-MM-DD # @param end_date [Date] Metric report end date (UTC). Format: YYYY-MM-DD # @param campaign_ids [Array<String>] List of Campaign Ids to use to filter the results. # @param columns [Array<String>] Columns to retrieve. **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.<br/>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).<br/>If a column has no value, it may not be returned # @param granularity [Granularity] Granularity # @param [Hash] opts the optional parameters # @option opts [Integer] :click_window_days 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. # @option opts [Integer] :engagement_window_days 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. # @option opts [Integer] :view_window_days 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. # @option opts [String] :conversion_report_time 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. # @return [Array<(Array<Hash<String, Object>>, Integer, Hash)>] Array<Hash<String, Object>> data, response status code and response headers def campaigns_analytics_with_http_info(ad_account_id, start_date, end_date, campaign_ids, columns, granularity, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: AdAccountsApi.campaigns_analytics ...' end # verify the required parameter 'ad_account_id' is set if @api_client.config.client_side_validation && ad_account_id.nil? fail ArgumentError, "Missing the required parameter 'ad_account_id' when calling AdAccountsApi.campaigns_analytics" end pattern = Regexp.new(/^\d+$/) if @api_client.config.client_side_validation && ad_account_id !~ pattern fail ArgumentError, "invalid value for 'ad_account_id' when calling AdAccountsApi.campaigns_analytics, must conform to the pattern #{pattern}." 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 AdAccountsApi.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 AdAccountsApi.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 AdAccountsApi.campaigns_analytics" end if @api_client.config.client_side_validation && campaign_ids.length > 100 fail ArgumentError, 'invalid value for "campaign_ids" when calling AdAccountsApi.campaigns_analytics, number of items must be less than or equal to 100.' end if @api_client.config.client_side_validation && campaign_ids.length < 1 fail ArgumentError, 'invalid value for "campaign_ids" when calling AdAccountsApi.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 AdAccountsApi.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 AdAccountsApi.campaigns_analytics" end allowable_values = [1, 7, 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 = [1, 7, 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 = [1, 7, 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(ad_account_id.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? # 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] || 'Array<Hash<String, Object>>' # auth_names auth_names = opts[:debug_auth_names] || ['pinterest_oauth2'] new_options = opts.merge( :operation => :"AdAccountsApi.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: AdAccountsApi#campaigns_analytics\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # List campaigns # Get a list of the campaigns in the specified <code>ad_account_id</code>, 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 <a href=\"https://help.pinterest.com/en/business/article/share-and-manage-access-to-your-ad-accounts\">Business Access</a>: Admin, Analyst, Campaign Manager. # @param ad_account_id [String] Unique identifier of an ad account. # @param [Hash] opts the optional parameters # @option opts [Array<String>] :campaign_ids List of Campaign Ids to use to filter the results. # @option opts [Array<String>] :entity_statuses Entity status # @option opts [Integer] :page_size Maximum number of items to include in a single page of the response. See documentation on <a href='/docs/api/v5/#tag/Pagination'>Pagination</a> for more information. (default to 25) # @option opts [String] :order The order in which to sort the items returned: “ASCENDING” or “DESCENDING” by ID. Note that higher-value IDs are associated with more-recently added items. # @option opts [String] :bookmark Cursor used to fetch the next page of items # @return [Paginated] def campaigns_list(ad_account_id, opts = {}) data, _status_code, _headers = campaigns_list_with_http_info(ad_account_id, opts) data end # List campaigns # Get a list of the campaigns in the specified <code>ad_account_id</code>, 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 <a href=\"https://help.pinterest.com/en/business/article/share-and-manage-access-to-your-ad-accounts\">Business Access</a>: Admin, Analyst, Campaign Manager. # @param ad_account_id [String] Unique identifier of an ad account. # @param [Hash] opts the optional parameters # @option opts [Array<String>] :campaign_ids List of Campaign Ids to use to filter the results. # @option opts [Array<String>] :entity_statuses Entity status # @option opts [Integer] :page_size Maximum number of items to include in a single page of the response. See documentation on <a href='/docs/api/v5/#tag/Pagination'>Pagination</a> for more information. # @option opts [String] :order The order in which to sort the items returned: “ASCENDING” or “DESCENDING” by ID. Note that higher-value IDs are associated with more-recently added items. # @option opts [String] :bookmark Cursor used to fetch the next page of items # @return [Array<(Paginated, Integer, Hash)>] Paginated data, response status code and response headers def campaigns_list_with_http_info(ad_account_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: AdAccountsApi.campaigns_list ...' end # verify the required parameter 'ad_account_id' is set if @api_client.config.client_side_validation && ad_account_id.nil? fail ArgumentError, "Missing the required parameter 'ad_account_id' when calling AdAccountsApi.campaigns_list" end pattern = Regexp.new(/^\d+$/) if @api_client.config.client_side_validation && ad_account_id !~ pattern fail ArgumentError, "invalid value for 'ad_account_id' when calling AdAccountsApi.campaigns_list, must conform to the pattern #{pattern}." end if @api_client.config.client_side_validation && !opts[:'campaign_ids'].nil? && opts[:'campaign_ids'].length > 100 fail ArgumentError, 'invalid value for "opts[:"campaign_ids"]" when calling AdAccountsApi.campaigns_list, number of items must be less than or equal to 100.' 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 AdAccountsApi.campaigns_list, number of items must be greater than or equal to 1.' end allowable_values = ["ACTIVE", "PAUSED", "ARCHIVED"] if @api_client.config.client_side_validation && opts[:'entity_statuses'] && !opts[:'entity_statuses'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"entity_statuses\", must include one of #{allowable_values}" end if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 100 fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling AdAccountsApi.campaigns_list, must be smaller than or equal to 100.' 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 AdAccountsApi.campaigns_list, must be greater than or equal to 1.' end allowable_values = ["ASCENDING", "DESCENDING"] if @api_client.config.client_side_validation && opts[:'order'] && !allowable_values.include?(opts[:'order']) fail ArgumentError, "invalid value for \"order\", must be one of #{allowable_values}" end # resource path local_var_path = '/ad_accounts/{ad_account_id}/campaigns'.sub('{' + 'ad_account_id' + '}', CGI.escape(ad_account_id.to_s)) # query parameters query_params = opts[:query_params] || {} 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? query_params[:'page_size'] = opts[:'page_size'] if !opts[:'page_size'].nil? query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil? query_params[:'bookmark'] = opts[:'bookmark'] if !opts[:'bookmark'].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] || 'Paginated' # auth_names auth_names = opts[:debug_auth_names] || ['pinterest_oauth2'] new_options = opts.merge( :operation => :"AdAccountsApi.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: AdAccountsApi#campaigns_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get product group analytics # Get analytics for the specified product groups in the specified <code>ad_account_id</code>, 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 <a href=\"https://help.pinterest.com/en/business/article/share-and-manage-access-to-your-ad-accounts\">Business Access</a>: Admin, Analyst, Campaign Manager. # @param ad_account_id [String] Unique identifier of an ad account. # @param start_date [Date] Metric report start date (UTC). Format: YYYY-MM-DD # @param end_date [Date] Metric report end date (UTC). Format: YYYY-MM-DD # @param product_group_ids [Array<String>] List of Product group Ids to use to filter the results. # @param columns [Array<String>] Columns to retrieve. **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.<br/>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).<br/>If a column has no value, it may not be returned # @param granularity [Granularity] Granularity # @param [Hash] opts the optional parameters # @option opts [Integer] :click_window_days 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) # @option opts [Integer] :engagement_window_days 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. (default to 30) # @option opts [Integer] :view_window_days 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) # @option opts [String] :conversion_report_time 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') # @return [Array<Hash<String, Object>>] def product_groups_analytics(ad_account_id, start_date, end_date, product_group_ids, columns, granularity, opts = {}) data, _status_code, _headers = product_groups_analytics_with_http_info(ad_account_id, start_date, end_date, product_group_ids, columns, granularity, opts) data end # Get product group analytics # Get analytics for the specified product groups in the specified <code>ad_account_id</code>, 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 <a href=\"https://help.pinterest.com/en/business/article/share-and-manage-access-to-your-ad-accounts\">Business Access</a>: Admin, Analyst, Campaign Manager. # @param ad_account_id [String] Unique identifier of an ad account. # @param start_date [Date] Metric report start date (UTC). Format: YYYY-MM-DD # @param end_date [Date] Metric report end date (UTC). Format: YYYY-MM-DD # @param product_group_ids [Array<String>] List of Product group Ids to use to filter the results. # @param columns [Array<String>] Columns to retrieve. **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.<br/>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).<br/>If a column has no value, it may not be returned # @param granularity [Granularity] Granularity # @param [Hash] opts the optional parameters # @option opts [Integer] :click_window_days 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. # @option opts [Integer] :engagement_window_days 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. # @option opts [Integer] :view_window_days 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. # @option opts [String] :conversion_report_time 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. # @return [Array<(Array<Hash<String, Object>>, Integer, Hash)>] Array<Hash<String, Object>> data, response status code and response headers def product_groups_analytics_with_http_info(ad_account_id, start_date, end_date, product_group_ids, columns, granularity, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: AdAccountsApi.product_groups_analytics ...' end # verify the required parameter 'ad_account_id' is set if @api_client.config.client_side_validation && ad_account_id.nil? fail ArgumentError, "Missing the required parameter 'ad_account_id' when calling AdAccountsApi.product_groups_analytics" end pattern = Regexp.new(/^\d+$/) if @api_client.config.client_side_validation && ad_account_id !~ pattern fail ArgumentError, "invalid value for 'ad_account_id' when calling AdAccountsApi.product_groups_analytics, must conform to the pattern #{pattern}." 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 AdAccountsApi.product_groups_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 AdAccountsApi.product_groups_analytics" end # verify the required parameter 'product_group_ids' is set if @api_client.config.client_side_validation && product_group_ids.nil? fail ArgumentError, "Missing the required parameter 'product_group_ids' when calling AdAccountsApi.product_groups_analytics" end if @api_client.config.client_side_validation && product_group_ids.length > 100 fail ArgumentError, 'invalid value for "product_group_ids" when calling AdAccountsApi.product_groups_analytics, number of items must be less than or equal to 100.' end if @api_client.config.client_side_validation && product_group_ids.length < 1 fail ArgumentError, 'invalid value for "product_group_ids" when calling AdAccountsApi.product_groups_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 AdAccountsApi.product_groups_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 AdAccountsApi.product_groups_analytics" end allowable_values = [1, 7, 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 = [1, 7, 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 = [1, 7, 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}/product_groups/analytics'.sub('{' + 'ad_account_id' + '}', CGI.escape(ad_account_id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'start_date'] = start_date query_params[:'end_date'] = end_date query_params[:'product_group_ids'] = @api_client.build_collection_param(product_group_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? # 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] || 'Array<Hash<String, Object>>' # auth_names auth_names = opts[:debug_auth_names] || ['pinterest_oauth2'] new_options = opts.merge( :operation => :"AdAccountsApi.product_groups_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: AdAccountsApi#product_groups_analytics\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end end end