=begin #Fatture in Cloud API v2 - API Reference #Connect your software with Fatture in Cloud, the invoicing platform chosen by more than 500.000 businesses in Italy. The Fatture in Cloud API is based on REST, and makes possible to interact with the user related data prior authorization via OAuth2 protocol. The version of the OpenAPI document: 2.0.30 Contact: info@fattureincloud.it Generated by: https://openapi-generator.tech OpenAPI Generator version: 7.0.1 =end require 'cgi' module FattureInCloud_Ruby_Sdk class ReceiptsApi attr_accessor :api_client def initialize(api_client = ApiClient.default) @api_client = api_client end # Create Receipt # Creates a new receipt. # @param company_id [Integer] The ID of the company. # @param [Hash] opts the optional parameters # @option opts [CreateReceiptRequest] :create_receipt_request The Receipt to create. # @return [CreateReceiptResponse] def create_receipt(company_id, opts = {}) data, _status_code, _headers = create_receipt_with_http_info(company_id, opts) data end # Create Receipt # Creates a new receipt. # @param company_id [Integer] The ID of the company. # @param [Hash] opts the optional parameters # @option opts [CreateReceiptRequest] :create_receipt_request The Receipt to create. # @return [Array<(CreateReceiptResponse, Integer, Hash)>] CreateReceiptResponse data, response status code and response headers def create_receipt_with_http_info(company_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ReceiptsApi.create_receipt ...' end # verify the required parameter 'company_id' is set if @api_client.config.client_side_validation && company_id.nil? fail ArgumentError, "Missing the required parameter 'company_id' when calling ReceiptsApi.create_receipt" end # resource path local_var_path = '/c/{company_id}/receipts'.sub('{' + 'company_id' + '}', CGI.escape(company_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(opts[:'create_receipt_request']) # return_type return_type = opts[:debug_return_type] || 'CreateReceiptResponse' # auth_names auth_names = opts[:debug_auth_names] || ['OAuth2AuthenticationCodeFlow'] new_options = opts.merge( :operation => :"ReceiptsApi.create_receipt", :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: ReceiptsApi#create_receipt\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Delete Receipt # Deletes the specified receipt. # @param company_id [Integer] The ID of the company. # @param document_id [Integer] The ID of the document. # @param [Hash] opts the optional parameters # @return [nil] def delete_receipt(company_id, document_id, opts = {}) delete_receipt_with_http_info(company_id, document_id, opts) nil end # Delete Receipt # Deletes the specified receipt. # @param company_id [Integer] The ID of the company. # @param document_id [Integer] The ID of the document. # @param [Hash] opts the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers def delete_receipt_with_http_info(company_id, document_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ReceiptsApi.delete_receipt ...' end # verify the required parameter 'company_id' is set if @api_client.config.client_side_validation && company_id.nil? fail ArgumentError, "Missing the required parameter 'company_id' when calling ReceiptsApi.delete_receipt" end # verify the required parameter 'document_id' is set if @api_client.config.client_side_validation && document_id.nil? fail ArgumentError, "Missing the required parameter 'document_id' when calling ReceiptsApi.delete_receipt" end # resource path local_var_path = '/c/{company_id}/receipts/{document_id}'.sub('{' + 'company_id' + '}', CGI.escape(company_id.to_s)).sub('{' + 'document_id' + '}', CGI.escape(document_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] || ['OAuth2AuthenticationCodeFlow'] new_options = opts.merge( :operation => :"ReceiptsApi.delete_receipt", :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: ReceiptsApi#delete_receipt\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Receipt # Gets the specified receipt. # @param company_id [Integer] The ID of the company. # @param document_id [Integer] The ID of the document. # @param [Hash] opts the optional parameters # @option opts [String] :fields List of comma-separated fields. # @option opts [String] :fieldset Name of the fieldset. # @return [GetReceiptResponse] def get_receipt(company_id, document_id, opts = {}) data, _status_code, _headers = get_receipt_with_http_info(company_id, document_id, opts) data end # Get Receipt # Gets the specified receipt. # @param company_id [Integer] The ID of the company. # @param document_id [Integer] The ID of the document. # @param [Hash] opts the optional parameters # @option opts [String] :fields List of comma-separated fields. # @option opts [String] :fieldset Name of the fieldset. # @return [Array<(GetReceiptResponse, Integer, Hash)>] GetReceiptResponse data, response status code and response headers def get_receipt_with_http_info(company_id, document_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ReceiptsApi.get_receipt ...' end # verify the required parameter 'company_id' is set if @api_client.config.client_side_validation && company_id.nil? fail ArgumentError, "Missing the required parameter 'company_id' when calling ReceiptsApi.get_receipt" end # verify the required parameter 'document_id' is set if @api_client.config.client_side_validation && document_id.nil? fail ArgumentError, "Missing the required parameter 'document_id' when calling ReceiptsApi.get_receipt" end allowable_values = ["basic", "detailed"] if @api_client.config.client_side_validation && opts[:'fieldset'] && !allowable_values.include?(opts[:'fieldset']) fail ArgumentError, "invalid value for \"fieldset\", must be one of #{allowable_values}" end # resource path local_var_path = '/c/{company_id}/receipts/{document_id}'.sub('{' + 'company_id' + '}', CGI.escape(company_id.to_s)).sub('{' + 'document_id' + '}', CGI.escape(document_id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'fields'] = opts[:'fields'] if !opts[:'fields'].nil? query_params[:'fieldset'] = opts[:'fieldset'] if !opts[:'fieldset'].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] || 'GetReceiptResponse' # auth_names auth_names = opts[:debug_auth_names] || ['OAuth2AuthenticationCodeFlow'] new_options = opts.merge( :operation => :"ReceiptsApi.get_receipt", :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: ReceiptsApi#get_receipt\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Receipt Pre-Create Info # Retrieves the information useful while creating a new receipt. # @param company_id [Integer] The ID of the company. # @param [Hash] opts the optional parameters # @return [GetReceiptPreCreateInfoResponse] def get_receipt_pre_create_info(company_id, opts = {}) data, _status_code, _headers = get_receipt_pre_create_info_with_http_info(company_id, opts) data end # Get Receipt Pre-Create Info # Retrieves the information useful while creating a new receipt. # @param company_id [Integer] The ID of the company. # @param [Hash] opts the optional parameters # @return [Array<(GetReceiptPreCreateInfoResponse, Integer, Hash)>] GetReceiptPreCreateInfoResponse data, response status code and response headers def get_receipt_pre_create_info_with_http_info(company_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ReceiptsApi.get_receipt_pre_create_info ...' end # verify the required parameter 'company_id' is set if @api_client.config.client_side_validation && company_id.nil? fail ArgumentError, "Missing the required parameter 'company_id' when calling ReceiptsApi.get_receipt_pre_create_info" end # resource path local_var_path = '/c/{company_id}/receipts/info'.sub('{' + 'company_id' + '}', CGI.escape(company_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] || 'GetReceiptPreCreateInfoResponse' # auth_names auth_names = opts[:debug_auth_names] || ['OAuth2AuthenticationCodeFlow'] new_options = opts.merge( :operation => :"ReceiptsApi.get_receipt_pre_create_info", :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: ReceiptsApi#get_receipt_pre_create_info\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Receipts Monthly Totals # Returns the monthly totals by year and receipt type. # @param company_id [Integer] The ID of the company. # @param type [String] Receipt Type # @param year [String] Year for which you want monthly totals # @param [Hash] opts the optional parameters # @return [GetReceiptsMonthlyTotalsResponse] def get_receipts_monthly_totals(company_id, type, year, opts = {}) data, _status_code, _headers = get_receipts_monthly_totals_with_http_info(company_id, type, year, opts) data end # Get Receipts Monthly Totals # Returns the monthly totals by year and receipt type. # @param company_id [Integer] The ID of the company. # @param type [String] Receipt Type # @param year [String] Year for which you want monthly totals # @param [Hash] opts the optional parameters # @return [Array<(GetReceiptsMonthlyTotalsResponse, Integer, Hash)>] GetReceiptsMonthlyTotalsResponse data, response status code and response headers def get_receipts_monthly_totals_with_http_info(company_id, type, year, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ReceiptsApi.get_receipts_monthly_totals ...' end # verify the required parameter 'company_id' is set if @api_client.config.client_side_validation && company_id.nil? fail ArgumentError, "Missing the required parameter 'company_id' when calling ReceiptsApi.get_receipts_monthly_totals" end # verify the required parameter 'type' is set if @api_client.config.client_side_validation && type.nil? fail ArgumentError, "Missing the required parameter 'type' when calling ReceiptsApi.get_receipts_monthly_totals" end # verify enum value allowable_values = ["sales_receipt", "till_receipt"] if @api_client.config.client_side_validation && !allowable_values.include?(type) fail ArgumentError, "invalid value for \"type\", must be one of #{allowable_values}" end # verify the required parameter 'year' is set if @api_client.config.client_side_validation && year.nil? fail ArgumentError, "Missing the required parameter 'year' when calling ReceiptsApi.get_receipts_monthly_totals" end # resource path local_var_path = '/c/{company_id}/receipts/monthly_totals'.sub('{' + 'company_id' + '}', CGI.escape(company_id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'type'] = type query_params[:'year'] = year # 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] || 'GetReceiptsMonthlyTotalsResponse' # auth_names auth_names = opts[:debug_auth_names] || ['OAuth2AuthenticationCodeFlow'] new_options = opts.merge( :operation => :"ReceiptsApi.get_receipts_monthly_totals", :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: ReceiptsApi#get_receipts_monthly_totals\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # List Receipts # Lists the receipts. # @param company_id [Integer] The ID of the company. # @param [Hash] opts the optional parameters # @option opts [String] :fields List of comma-separated fields. # @option opts [String] :fieldset Name of the fieldset. # @option opts [Integer] :page The page to retrieve. (default to 1) # @option opts [Integer] :per_page The size of the page. (default to 5) # @option opts [String] :sort List of comma-separated fields for result sorting (minus for desc sorting). # @option opts [String] :q Query for filtering the results. # @return [ListReceiptsResponse] def list_receipts(company_id, opts = {}) data, _status_code, _headers = list_receipts_with_http_info(company_id, opts) data end # List Receipts # Lists the receipts. # @param company_id [Integer] The ID of the company. # @param [Hash] opts the optional parameters # @option opts [String] :fields List of comma-separated fields. # @option opts [String] :fieldset Name of the fieldset. # @option opts [Integer] :page The page to retrieve. (default to 1) # @option opts [Integer] :per_page The size of the page. (default to 5) # @option opts [String] :sort List of comma-separated fields for result sorting (minus for desc sorting). # @option opts [String] :q Query for filtering the results. # @return [Array<(ListReceiptsResponse, Integer, Hash)>] ListReceiptsResponse data, response status code and response headers def list_receipts_with_http_info(company_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ReceiptsApi.list_receipts ...' end # verify the required parameter 'company_id' is set if @api_client.config.client_side_validation && company_id.nil? fail ArgumentError, "Missing the required parameter 'company_id' when calling ReceiptsApi.list_receipts" end allowable_values = ["basic", "detailed"] if @api_client.config.client_side_validation && opts[:'fieldset'] && !allowable_values.include?(opts[:'fieldset']) fail ArgumentError, "invalid value for \"fieldset\", must be one of #{allowable_values}" end if @api_client.config.client_side_validation && !opts[:'per_page'].nil? && opts[:'per_page'] > 100 fail ArgumentError, 'invalid value for "opts[:"per_page"]" when calling ReceiptsApi.list_receipts, must be smaller than or equal to 100.' end if @api_client.config.client_side_validation && !opts[:'per_page'].nil? && opts[:'per_page'] < 1 fail ArgumentError, 'invalid value for "opts[:"per_page"]" when calling ReceiptsApi.list_receipts, must be greater than or equal to 1.' end # resource path local_var_path = '/c/{company_id}/receipts'.sub('{' + 'company_id' + '}', CGI.escape(company_id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'fields'] = opts[:'fields'] if !opts[:'fields'].nil? query_params[:'fieldset'] = opts[:'fieldset'] if !opts[:'fieldset'].nil? query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? query_params[:'per_page'] = opts[:'per_page'] if !opts[:'per_page'].nil? query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil? query_params[:'q'] = opts[:'q'] if !opts[:'q'].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] || 'ListReceiptsResponse' # auth_names auth_names = opts[:debug_auth_names] || ['OAuth2AuthenticationCodeFlow'] new_options = opts.merge( :operation => :"ReceiptsApi.list_receipts", :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: ReceiptsApi#list_receipts\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Modify Receipt # Modifies the specified receipt. # @param company_id [Integer] The ID of the company. # @param document_id [Integer] The ID of the document. # @param [Hash] opts the optional parameters # @option opts [ModifyReceiptRequest] :modify_receipt_request Modified receipt. # @return [ModifyReceiptResponse] def modify_receipt(company_id, document_id, opts = {}) data, _status_code, _headers = modify_receipt_with_http_info(company_id, document_id, opts) data end # Modify Receipt # Modifies the specified receipt. # @param company_id [Integer] The ID of the company. # @param document_id [Integer] The ID of the document. # @param [Hash] opts the optional parameters # @option opts [ModifyReceiptRequest] :modify_receipt_request Modified receipt. # @return [Array<(ModifyReceiptResponse, Integer, Hash)>] ModifyReceiptResponse data, response status code and response headers def modify_receipt_with_http_info(company_id, document_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: ReceiptsApi.modify_receipt ...' end # verify the required parameter 'company_id' is set if @api_client.config.client_side_validation && company_id.nil? fail ArgumentError, "Missing the required parameter 'company_id' when calling ReceiptsApi.modify_receipt" end # verify the required parameter 'document_id' is set if @api_client.config.client_side_validation && document_id.nil? fail ArgumentError, "Missing the required parameter 'document_id' when calling ReceiptsApi.modify_receipt" end # resource path local_var_path = '/c/{company_id}/receipts/{document_id}'.sub('{' + 'company_id' + '}', CGI.escape(company_id.to_s)).sub('{' + 'document_id' + '}', CGI.escape(document_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(opts[:'modify_receipt_request']) # return_type return_type = opts[:debug_return_type] || 'ModifyReceiptResponse' # auth_names auth_names = opts[:debug_auth_names] || ['OAuth2AuthenticationCodeFlow'] new_options = opts.merge( :operation => :"ReceiptsApi.modify_receipt", :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(:PUT, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: ReceiptsApi#modify_receipt\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end end end