Class: Printful::ReportsAPIClient
- Inherits:
-
Object
- Object
- Printful::ReportsAPIClient
- Defined in:
- lib/printful_client/api/reports_api_client.rb
Instance Attribute Summary collapse
-
#api_client ⇒ Object
Returns the value of attribute api_client.
Instance Method Summary collapse
-
#get_statistics(date_from, date_to, report_types, opts = {}) ⇒ GetStatistics200Response
Get statistics Returns statistics for specified report types.
-
#get_statistics_with_http_info(date_from, date_to, report_types, opts = {}) ⇒ Array<(GetStatistics200Response, Integer, Hash)>
Get statistics Returns statistics for specified report types.
-
#initialize(api_client = ApiClient.default) ⇒ ReportsAPIClient
constructor
A new instance of ReportsAPIClient.
Constructor Details
#initialize(api_client = ApiClient.default) ⇒ ReportsAPIClient
Returns a new instance of ReportsAPIClient.
19 20 21 |
# File 'lib/printful_client/api/reports_api_client.rb', line 19 def initialize(api_client = ApiClient.default) @api_client = api_client end |
Instance Attribute Details
#api_client ⇒ Object
Returns the value of attribute api_client.
17 18 19 |
# File 'lib/printful_client/api/reports_api_client.rb', line 17 def api_client @api_client end |
Instance Method Details
#get_statistics(date_from, date_to, report_types, opts = {}) ⇒ GetStatistics200Response
Get statistics Returns statistics for specified report types. You need to specify the report types you want to retrieve in the ‘report_types` query parameter as a comma-separated list, e.g. `report_types=sales_and_costs,profit`. Note: You cannot get statistics for a period longer than 6 months. #### Example To get statistics in the default currency of a store for `sales_and_costs` and `profit` reports for August 2022, you can use the following URL: api.printful.com/reports/statistics?report_types=sales_and_costs,profit&date_from=2022-08-01&date_to=2022-08-31. ### Report types Currently, the following report types are available: | Report type | Description | |—————————-|———————————————————-| | `sales_and_costs` | Detailed information on sales and costs grouped by date. | | `sales_and_costs_summary` | Short information on sales and costs grouped by date. | | `printful_costs` | Amount paid to Printful for fulfillment and shipping. | | `profit` | Profit in the specified period. | | `total_paid_orders` | The number of paid orders in the specified period. | | `costs_by_amount` | Information on costs by amount grouped by date. | | `costs_by_product` | Information on costs grouped by product. | | `costs_by_variant` | Information on costs grouped by variant. | | `average_fulfillment_time` | Average time it took Printful to fulfill Your orders. | The response structure for the specific reports is documented in the response schema (`result.store_statistics.`).
31 32 33 34 |
# File 'lib/printful_client/api/reports_api_client.rb', line 31 def get_statistics(date_from, date_to, report_types, opts = {}) data, _status_code, _headers = get_statistics_with_http_info(date_from, date_to, report_types, opts) data end |
#get_statistics_with_http_info(date_from, date_to, report_types, opts = {}) ⇒ Array<(GetStatistics200Response, Integer, Hash)>
Get statistics Returns statistics for specified report types. You need to specify the report types you want to retrieve in the `report_types` query parameter as a comma-separated list, e.g. `report_types=sales_and_costs,profit`. Note: You cannot get statistics for a period longer than 6 months. #### Example To get statistics in the default currency of a store for `sales_and_costs` and `profit` reports for August 2022, you can use the following URL: api.printful.com/reports/statistics?report_types=sales_and_costs,profit&date_from=2022-08-01&date_to=2022-08-31. ### Report types Currently, the following report types are available: | Report type | Description | |—————————-|———————————————————-| | `sales_and_costs` | Detailed information on sales and costs grouped by date. | | `sales_and_costs_summary` | Short information on sales and costs grouped by date. | | `printful_costs` | Amount paid to Printful for fulfillment and shipping. | | `profit` | Profit in the specified period. | | `total_paid_orders` | The number of paid orders in the specified period. | | `costs_by_amount` | Information on costs by amount grouped by date. | | `costs_by_product` | Information on costs grouped by product. | | `costs_by_variant` | Information on costs grouped by variant. | | `average_fulfillment_time` | Average time it took Printful to fulfill Your orders. | The response structure for the specific reports is documented in the response schema (`result.store_statistics.`).
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/printful_client/api/reports_api_client.rb', line 45 def get_statistics_with_http_info(date_from, date_to, report_types, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ReportsAPIClient.get_statistics ...' end # verify the required parameter 'date_from' is set if @api_client.config.client_side_validation && date_from.nil? fail ArgumentError, "Missing the required parameter 'date_from' when calling ReportsAPIClient.get_statistics" end # verify the required parameter 'date_to' is set if @api_client.config.client_side_validation && date_to.nil? fail ArgumentError, "Missing the required parameter 'date_to' when calling ReportsAPIClient.get_statistics" end # verify the required parameter 'report_types' is set if @api_client.config.client_side_validation && report_types.nil? fail ArgumentError, "Missing the required parameter 'report_types' when calling ReportsAPIClient.get_statistics" end # resource path local_var_path = '/reports/statistics' # query parameters query_params = opts[:query_params] || {} query_params[:'date_from'] = date_from query_params[:'date_to'] = date_to query_params[:'report_types'] = report_types query_params[:'currency'] = opts[:'currency'] if !opts[:'currency'].nil? # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) header_params[:'X-PF-Store-Id'] = opts[:'x_pf_store_id'] if !opts[:'x_pf_store_id'].nil? # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'GetStatistics200Response' # auth_names auth_names = opts[:debug_auth_names] || ['OAuth'] = opts.merge( :operation => :"ReportsAPIClient.get_statistics", :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, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: ReportsAPIClient#get_statistics\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |