=begin #Voucherify API #Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. The version of the OpenAPI document: v2018-08-01 Contact: support@voucherify.io Generated by: https://openapi-generator.tech OpenAPI Generator version: 7.0.1 =end require 'cgi' module VoucherifySdk class ExportsApi attr_accessor :api_client def initialize(api_client = ApiClient.default) @api_client = api_client end # Create Export # Create export object. The export can be any of the following types: voucher, redemption, publication, customer, order, points_expiration, or voucher_transactions. # Defaults If you only specify the object type in the request body without specifying the fields, the API will return the following fields per export object: # Fetching particular data sets Using the parameters body parameter, you can narrow down which fields to export and how to filter the results. The fields are an array of strings containing the data that you would like to export. These fields define the headers in the CSV file. The array can be a combintation of any of the following available fields: # Orders # Vouchers # Publications # Redemptions # Customers # Points Expirations # Gift Card Transactions # Loyalty Card Transactions # @param [Hash] opts the optional parameters # @option opts [ExportsCreateRequestBody] :exports_create_request_body Specify the details of the export that you would like to create. # @return [ExportsCreateResponseBody] def create_export(opts = {}) data, _status_code, _headers = create_export_with_http_info(opts) data end # Create Export # Create export object. The export can be any of the following types: voucher, redemption, publication, customer, order, points_expiration, or voucher_transactions. # Defaults If you only specify the object type in the request body without specifying the fields, the API will return the following fields per export object: # Fetching particular data sets Using the parameters body parameter, you can narrow down which fields to export and how to filter the results. The fields are an array of strings containing the data that you would like to export. These fields define the headers in the CSV file. The array can be a combintation of any of the following available fields: # Orders # Vouchers # Publications # Redemptions # Customers # Points Expirations # Gift Card Transactions # Loyalty Card Transactions # @param [Hash] opts the optional parameters # @option opts [ExportsCreateRequestBody] :exports_create_request_body Specify the details of the export that you would like to create. # @return [Array<(ExportsCreateResponseBody, Integer, Hash)>] ExportsCreateResponseBody data, response status code and response headers private def create_export_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ExportsApi.create_export ...' end # resource path local_var_path = '/v1/exports' # 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(opts[:'exports_create_request_body']) # return_type return_type = opts[:debug_return_type] || 'ExportsCreateResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"ExportsApi.create_export", :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: ExportsApi#create_export\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Delete Export # This method deletes a previously created export object. # @param export_id [String] Unique export object ID of previously created export. This object can be a: voucher, redemption, publication, customer, order, points_expiration, or voucher_transactions. # @param [Hash] opts the optional parameters # @return [nil] def delete_export(export_id, opts = {}) delete_export_with_http_info(export_id, opts) nil end # Delete Export # This method deletes a previously created export object. # @param export_id [String] Unique export object ID of previously created export. This object can be a: voucher, redemption, publication, customer, order, points_expiration, or voucher_transactions. # @param [Hash] opts the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers private def delete_export_with_http_info(export_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ExportsApi.delete_export ...' end # verify the required parameter 'export_id' is set if @api_client.config.client_side_validation && export_id.nil? fail ArgumentError, "Missing the required parameter 'export_id' when calling ExportsApi.delete_export" end # resource path local_var_path = '/v1/exports/{exportId}'.sub('{' + 'exportId' + '}', CGI.escape(export_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"ExportsApi.delete_export", :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(:DELETE, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: ExportsApi#delete_export\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Download Export # Download the contents of the exported CSV file. 📘 Important notes **Base URL:** - https://download.voucherify.io (Europe) - https://us1.download.voucherify.io (US) - https://as1.download.voucherify.io (Asia) **Token:** Can be found within the result parameter of the Get Export method response. # @param export_id [String] Unique export object ID. # @param [Hash] opts the optional parameters # @option opts [String] :token Token that was issued to the export, to get this token, get the export first # @return [String] def download_export(export_id, opts = {}) data, _status_code, _headers = download_export_with_http_info(export_id, opts) data end # Download Export # Download the contents of the exported CSV file. 📘 Important notes **Base URL:** - https://download.voucherify.io (Europe) - https://us1.download.voucherify.io (US) - https://as1.download.voucherify.io (Asia) **Token:** Can be found within the result parameter of the Get Export method response. # @param export_id [String] Unique export object ID. # @param [Hash] opts the optional parameters # @option opts [String] :token Token that was issued to the export, to get this token, get the export first # @return [Array<(String, Integer, Hash)>] String data, response status code and response headers private def download_export_with_http_info(export_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ExportsApi.download_export ...' end # verify the required parameter 'export_id' is set if @api_client.config.client_side_validation && export_id.nil? fail ArgumentError, "Missing the required parameter 'export_id' when calling ExportsApi.download_export" end # resource path local_var_path = '/v1/exports/{export_Id}'.sub('{' + 'export_Id' + '}', CGI.escape(export_id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'token'] = opts[:'token'] if !opts[:'token'].nil? # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['text/plain']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'String' # auth_names auth_names = opts[:debug_auth_names] || [] new_options = opts.merge( :operation => :"ExportsApi.download_export", :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: ExportsApi#download_export\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Export # Retrieves the URL of the downloadable file, which was generated via the Create Export method. # @param export_id [String] Unique export object ID of previously created export. This object can be a: voucher, redemption, publication, customer, order, points_expiration, or voucher_transactions. # @param [Hash] opts the optional parameters # @return [ExportsGetResponseBody] def get_export(export_id, opts = {}) data, _status_code, _headers = get_export_with_http_info(export_id, opts) data end # Get Export # Retrieves the URL of the downloadable file, which was generated via the Create Export method. # @param export_id [String] Unique export object ID of previously created export. This object can be a: voucher, redemption, publication, customer, order, points_expiration, or voucher_transactions. # @param [Hash] opts the optional parameters # @return [Array<(ExportsGetResponseBody, Integer, Hash)>] ExportsGetResponseBody data, response status code and response headers private def get_export_with_http_info(export_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ExportsApi.get_export ...' end # verify the required parameter 'export_id' is set if @api_client.config.client_side_validation && export_id.nil? fail ArgumentError, "Missing the required parameter 'export_id' when calling ExportsApi.get_export" end # resource path local_var_path = '/v1/exports/{exportId}'.sub('{' + 'exportId' + '}', CGI.escape(export_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']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'ExportsGetResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"ExportsApi.get_export", :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: ExportsApi#get_export\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # List Exports # List all exports. # @param [Hash] opts the optional parameters # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. # @option opts [Integer] :page Which page of results to return. # @option opts [ParameterOrderListExports] :order Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. # @return [ExportsListResponseBody] def list_exports(opts = {}) data, _status_code, _headers = list_exports_with_http_info(opts) data end # List Exports # List all exports. # @param [Hash] opts the optional parameters # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. # @option opts [Integer] :page Which page of results to return. # @option opts [ParameterOrderListExports] :order Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. # @return [Array<(ExportsListResponseBody, Integer, Hash)>] ExportsListResponseBody data, response status code and response headers private def list_exports_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ExportsApi.list_exports ...' end if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100 fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ExportsApi.list_exports, must be smaller than or equal to 100.' end if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1 fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ExportsApi.list_exports, must be greater than or equal to 1.' end if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] > 100 fail ArgumentError, 'invalid value for "opts[:"page"]" when calling ExportsApi.list_exports, must be smaller than or equal to 100.' end # resource path local_var_path = '/v1/exports' # query parameters query_params = opts[:query_params] || {} query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? query_params[:'order'] = opts[:'order'] if !opts[:'order'].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] || 'ExportsListResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"ExportsApi.list_exports", :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: ExportsApi#list_exports\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end end end