=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 UserAccountApi attr_accessor :api_client def initialize(api_client = ApiClient.default) @api_client = api_client end # Get user account analytics # Get analytics for the \"operation user_account\" - By default, the \"operation user_account\" is the token user_account. Optional: Business Access: Specify an ad_account_id to use the owner of that ad_account as the \"operation user_account\". # @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 [Hash] opts the optional parameters # @option opts [String] :from_claimed_content Filter on Pins that match your claimed domain. (default to 'BOTH') # @option opts [String] :pin_format Pin formats to get data for, default is all. (default to 'ALL') # @option opts [String] :app_types Apps or devices to get data for, default is all. (default to 'ALL') # @option opts [Array] :metric_types Metric types to get data for, default is all. # @option opts [String] :split_field How to split the data into groups. Not including this param means data won't be split. (default to 'NO_SPLIT') # @option opts [String] :ad_account_id Unique identifier of an ad account. # @return [Hash] def user_account_analytics(start_date, end_date, opts = {}) data, _status_code, _headers = user_account_analytics_with_http_info(start_date, end_date, opts) data end # Get user account analytics # Get analytics for the \"operation user_account\" - By default, the \"operation user_account\" is the token user_account. Optional: Business Access: Specify an ad_account_id to use the owner of that ad_account as the \"operation user_account\". # @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 [Hash] opts the optional parameters # @option opts [String] :from_claimed_content Filter on Pins that match your claimed domain. # @option opts [String] :pin_format Pin formats to get data for, default is all. # @option opts [String] :app_types Apps or devices to get data for, default is all. # @option opts [Array] :metric_types Metric types to get data for, default is all. # @option opts [String] :split_field How to split the data into groups. Not including this param means data won't be split. # @option opts [String] :ad_account_id Unique identifier of an ad account. # @return [Array<(Hash, Integer, Hash)>] Hash data, response status code and response headers def user_account_analytics_with_http_info(start_date, end_date, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: UserAccountApi.user_account_analytics ...' end # verify the required parameter 'start_date' is set if @api_client.config.client_side_validation && start_date.nil? fail ArgumentError, "Missing the required parameter 'start_date' when calling UserAccountApi.user_account_analytics" end # verify the required parameter 'end_date' is set if @api_client.config.client_side_validation && end_date.nil? fail ArgumentError, "Missing the required parameter 'end_date' when calling UserAccountApi.user_account_analytics" end allowable_values = ["OTHER", "CLAIMED", "BOTH"] if @api_client.config.client_side_validation && opts[:'from_claimed_content'] && !allowable_values.include?(opts[:'from_claimed_content']) fail ArgumentError, "invalid value for \"from_claimed_content\", must be one of #{allowable_values}" end allowable_values = ["ALL", "PRODUCT", "REGULAR", "VIDEO"] if @api_client.config.client_side_validation && opts[:'pin_format'] && !allowable_values.include?(opts[:'pin_format']) fail ArgumentError, "invalid value for \"pin_format\", must be one of #{allowable_values}" end allowable_values = ["ALL", "MOBILE", "TABLET", "WEB"] if @api_client.config.client_side_validation && opts[:'app_types'] && !allowable_values.include?(opts[:'app_types']) fail ArgumentError, "invalid value for \"app_types\", must be one of #{allowable_values}" end allowable_values = ["ENGAGEMENT", "ENGAGEMENT_RATE", "IMPRESSION", "OUTBOUND_CLICK", "OUTBOUND_CLICK_RATE", "PIN_CLICK", "PIN_CLICK_RATE", "SAVE", "SAVE_RATE"] if @api_client.config.client_side_validation && opts[:'metric_types'] && !opts[:'metric_types'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"metric_types\", must include one of #{allowable_values}" end allowable_values = ["NO_SPLIT", "APP_TYPE", "OWNED_CONTENT", "PIN_FORMAT"] if @api_client.config.client_side_validation && opts[:'split_field'] && !allowable_values.include?(opts[:'split_field']) fail ArgumentError, "invalid value for \"split_field\", must be one of #{allowable_values}" end pattern = Regexp.new(/^\d+$/) if @api_client.config.client_side_validation && !opts[:'ad_account_id'].nil? && opts[:'ad_account_id'] !~ pattern fail ArgumentError, "invalid value for 'opts[:\"ad_account_id\"]' when calling UserAccountApi.user_account_analytics, must conform to the pattern #{pattern}." end # resource path local_var_path = '/user_account/analytics' # query parameters query_params = opts[:query_params] || {} query_params[:'start_date'] = start_date query_params[:'end_date'] = end_date query_params[:'from_claimed_content'] = opts[:'from_claimed_content'] if !opts[:'from_claimed_content'].nil? query_params[:'pin_format'] = opts[:'pin_format'] if !opts[:'pin_format'].nil? query_params[:'app_types'] = opts[:'app_types'] if !opts[:'app_types'].nil? query_params[:'metric_types'] = @api_client.build_collection_param(opts[:'metric_types'], :csv) if !opts[:'metric_types'].nil? query_params[:'split_field'] = opts[:'split_field'] if !opts[:'split_field'].nil? query_params[:'ad_account_id'] = opts[:'ad_account_id'] if !opts[:'ad_account_id'].nil? # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Hash' # auth_names auth_names = opts[:debug_auth_names] || ['pinterest_oauth2'] new_options = opts.merge( :operation => :"UserAccountApi.user_account_analytics", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: UserAccountApi#user_account_analytics\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get user account # Get account information for the \"operation user_account\" - By default, the \"operation user_account\" is the token user_account. If using Business Access: Specify an ad_account_id to use the owner of that ad_account as the \"operation user_account\". See Understanding Business Access for more information. # @param [Hash] opts the optional parameters # @option opts [String] :ad_account_id Unique identifier of an ad account. # @return [Account] def user_account_get(opts = {}) data, _status_code, _headers = user_account_get_with_http_info(opts) data end # Get user account # Get account information for the \"operation user_account\" - By default, the \"operation user_account\" is the token user_account. If using Business Access: Specify an ad_account_id to use the owner of that ad_account as the \"operation user_account\". See <a href='/docs/api/v5/#tag/Understanding-business-access'>Understanding Business Access</a> for more information. # @param [Hash] opts the optional parameters # @option opts [String] :ad_account_id Unique identifier of an ad account. # @return [Array<(Account, Integer, Hash)>] Account data, response status code and response headers def user_account_get_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: UserAccountApi.user_account_get ...' end pattern = Regexp.new(/^\d+$/) if @api_client.config.client_side_validation && !opts[:'ad_account_id'].nil? && opts[:'ad_account_id'] !~ pattern fail ArgumentError, "invalid value for 'opts[:\"ad_account_id\"]' when calling UserAccountApi.user_account_get, must conform to the pattern #{pattern}." end # resource path local_var_path = '/user_account' # query parameters query_params = opts[:query_params] || {} query_params[:'ad_account_id'] = opts[:'ad_account_id'] if !opts[:'ad_account_id'].nil? # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'Account' # auth_names auth_names = opts[:debug_auth_names] || ['pinterest_oauth2'] new_options = opts.merge( :operation => :"UserAccountApi.user_account_get", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: UserAccountApi#user_account_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end end end