|
| 1 | +=begin |
| 2 | +#Patch API V1 |
| 3 | +
|
| 4 | +#The core API used to integrate with Patch's service |
| 5 | +
|
| 6 | +The version of the OpenAPI document: v1 |
| 7 | + |
| 8 | +Generated by: https://openapi-generator.tech |
| 9 | +OpenAPI Generator version: 4.3.1 |
| 10 | +
|
| 11 | +=end |
| 12 | + |
| 13 | +require 'cgi' |
| 14 | + |
| 15 | +module Patch |
| 16 | + class EstimatesApi |
| 17 | + OPERATIONS = [ |
| 18 | + :create_mass_estimate, |
| 19 | + :retrieve_estimate, |
| 20 | + :retrieve_estimates, |
| 21 | + ] |
| 22 | + |
| 23 | + attr_accessor :api_client |
| 24 | + |
| 25 | + def initialize(api_client = ApiClient.default) |
| 26 | + @api_client = api_client |
| 27 | + end |
| 28 | + # Create an estimate based on mass of CO2 |
| 29 | + # Creates an estimate for the mass of CO2 to be compensated. An order in the `draft` state will also be created, linked to the estimate. |
| 30 | + # @param create_mass_estimate_request [CreateMassEstimateRequest] |
| 31 | + # @param [Hash] opts the optional parameters |
| 32 | + # @return [EstimateResponse] |
| 33 | + def create_mass_estimate(create_mass_estimate_request, opts = {}) |
| 34 | + data, _status_code, _headers = create_mass_estimate_with_http_info(create_mass_estimate_request, opts) |
| 35 | + data |
| 36 | + end |
| 37 | + |
| 38 | + # Create an estimate based on mass of CO2 |
| 39 | + # Creates an estimate for the mass of CO2 to be compensated. An order in the `draft` state will also be created, linked to the estimate. |
| 40 | + # @param create_mass_estimate_request [CreateMassEstimateRequest] |
| 41 | + # @param [Hash] opts the optional parameters |
| 42 | + # @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers |
| 43 | + def create_mass_estimate_with_http_info(create_mass_estimate_request, opts = {}) |
| 44 | + if @api_client.config.debugging |
| 45 | + @api_client.config.logger.debug 'Calling API: EstimatesApi.create_mass_estimate ...' |
| 46 | + end |
| 47 | + # verify the required parameter 'create_mass_estimate_request' is set |
| 48 | + if @api_client.config.client_side_validation && create_mass_estimate_request.nil? |
| 49 | + fail ArgumentError, "Missing the required parameter 'create_mass_estimate_request' when calling EstimatesApi.create_mass_estimate" |
| 50 | + end |
| 51 | + # resource path |
| 52 | + local_var_path = '/v1/estimates/mass' |
| 53 | + |
| 54 | + # query parameters |
| 55 | + query_params = opts[:query_params] || {} |
| 56 | + |
| 57 | + # header parameters |
| 58 | + header_params = opts[:header_params] || {} |
| 59 | + # HTTP header 'Accept' (if needed) |
| 60 | + header_params['Accept'] = @api_client.select_header_accept(['application/json']) |
| 61 | + # HTTP header 'Content-Type' |
| 62 | + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) |
| 63 | + |
| 64 | + # form parameters |
| 65 | + form_params = opts[:form_params] || {} |
| 66 | + |
| 67 | + # http body (model) |
| 68 | + post_body = opts[:body] || @api_client.object_to_http_body(create_mass_estimate_request) |
| 69 | + |
| 70 | + # return_type |
| 71 | + return_type = opts[:return_type] || 'EstimateResponse' |
| 72 | + |
| 73 | + # auth_names |
| 74 | + auth_names = opts[:auth_names] || ['bearer_auth'] |
| 75 | + |
| 76 | + new_options = opts.merge( |
| 77 | + :header_params => header_params, |
| 78 | + :query_params => query_params, |
| 79 | + :form_params => form_params, |
| 80 | + :body => post_body, |
| 81 | + :auth_names => auth_names, |
| 82 | + :return_type => return_type |
| 83 | + ) |
| 84 | + |
| 85 | + data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) |
| 86 | + if @api_client.config.debugging |
| 87 | + @api_client.config.logger.debug "API called: EstimatesApi#create_mass_estimate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" |
| 88 | + end |
| 89 | + return data, status_code, headers |
| 90 | + end |
| 91 | + |
| 92 | + # Retrieves an estimate |
| 93 | + # Retrieves a given estimate and its associated order. You can only retrieve estimates associated with the organization you are querying for. |
| 94 | + # @param id [String] |
| 95 | + # @param [Hash] opts the optional parameters |
| 96 | + # @return [EstimateResponse] |
| 97 | + def retrieve_estimate(id, opts = {}) |
| 98 | + data, _status_code, _headers = retrieve_estimate_with_http_info(id, opts) |
| 99 | + data |
| 100 | + end |
| 101 | + |
| 102 | + # Retrieves an estimate |
| 103 | + # Retrieves a given estimate and its associated order. You can only retrieve estimates associated with the organization you are querying for. |
| 104 | + # @param id [String] |
| 105 | + # @param [Hash] opts the optional parameters |
| 106 | + # @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers |
| 107 | + def retrieve_estimate_with_http_info(id, opts = {}) |
| 108 | + if @api_client.config.debugging |
| 109 | + @api_client.config.logger.debug 'Calling API: EstimatesApi.retrieve_estimate ...' |
| 110 | + end |
| 111 | + # verify the required parameter 'id' is set |
| 112 | + if @api_client.config.client_side_validation && id.nil? |
| 113 | + fail ArgumentError, "Missing the required parameter 'id' when calling EstimatesApi.retrieve_estimate" |
| 114 | + end |
| 115 | + # resource path |
| 116 | + local_var_path = '/v1/estimates/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s)) |
| 117 | + |
| 118 | + # query parameters |
| 119 | + query_params = opts[:query_params] || {} |
| 120 | + |
| 121 | + # header parameters |
| 122 | + header_params = opts[:header_params] || {} |
| 123 | + # HTTP header 'Accept' (if needed) |
| 124 | + header_params['Accept'] = @api_client.select_header_accept(['application/json']) |
| 125 | + |
| 126 | + # form parameters |
| 127 | + form_params = opts[:form_params] || {} |
| 128 | + |
| 129 | + # http body (model) |
| 130 | + post_body = opts[:body] |
| 131 | + |
| 132 | + # return_type |
| 133 | + return_type = opts[:return_type] || 'EstimateResponse' |
| 134 | + |
| 135 | + # auth_names |
| 136 | + auth_names = opts[:auth_names] || ['bearer_auth'] |
| 137 | + |
| 138 | + new_options = opts.merge( |
| 139 | + :header_params => header_params, |
| 140 | + :query_params => query_params, |
| 141 | + :form_params => form_params, |
| 142 | + :body => post_body, |
| 143 | + :auth_names => auth_names, |
| 144 | + :return_type => return_type |
| 145 | + ) |
| 146 | + |
| 147 | + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) |
| 148 | + if @api_client.config.debugging |
| 149 | + @api_client.config.logger.debug "API called: EstimatesApi#retrieve_estimate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" |
| 150 | + end |
| 151 | + return data, status_code, headers |
| 152 | + end |
| 153 | + |
| 154 | + # Retrieves a list of estimates |
| 155 | + # Retrieves a list of estimates and their associated orders. You can only retrieve estimates associated with the organization you are querying for. |
| 156 | + # @param [Hash] opts the optional parameters |
| 157 | + # @option opts [Integer] :page |
| 158 | + # @return [EstimateListResponse] |
| 159 | + def retrieve_estimates(opts = {}) |
| 160 | + data, _status_code, _headers = retrieve_estimates_with_http_info(opts) |
| 161 | + data |
| 162 | + end |
| 163 | + |
| 164 | + # Retrieves a list of estimates |
| 165 | + # Retrieves a list of estimates and their associated orders. You can only retrieve estimates associated with the organization you are querying for. |
| 166 | + # @param [Hash] opts the optional parameters |
| 167 | + # @option opts [Integer] :page |
| 168 | + # @return [Array<(EstimateListResponse, Integer, Hash)>] EstimateListResponse data, response status code and response headers |
| 169 | + def retrieve_estimates_with_http_info(opts = {}) |
| 170 | + if @api_client.config.debugging |
| 171 | + @api_client.config.logger.debug 'Calling API: EstimatesApi.retrieve_estimates ...' |
| 172 | + end |
| 173 | + # resource path |
| 174 | + local_var_path = '/v1/estimates' |
| 175 | + |
| 176 | + # query parameters |
| 177 | + query_params = opts[:query_params] || {} |
| 178 | + query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? |
| 179 | + |
| 180 | + # header parameters |
| 181 | + header_params = opts[:header_params] || {} |
| 182 | + # HTTP header 'Accept' (if needed) |
| 183 | + header_params['Accept'] = @api_client.select_header_accept(['application/json']) |
| 184 | + |
| 185 | + # form parameters |
| 186 | + form_params = opts[:form_params] || {} |
| 187 | + |
| 188 | + # http body (model) |
| 189 | + post_body = opts[:body] |
| 190 | + |
| 191 | + # return_type |
| 192 | + return_type = opts[:return_type] || 'EstimateListResponse' |
| 193 | + |
| 194 | + # auth_names |
| 195 | + auth_names = opts[:auth_names] || ['bearer_auth'] |
| 196 | + |
| 197 | + new_options = opts.merge( |
| 198 | + :header_params => header_params, |
| 199 | + :query_params => query_params, |
| 200 | + :form_params => form_params, |
| 201 | + :body => post_body, |
| 202 | + :auth_names => auth_names, |
| 203 | + :return_type => return_type |
| 204 | + ) |
| 205 | + |
| 206 | + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) |
| 207 | + if @api_client.config.debugging |
| 208 | + @api_client.config.logger.debug "API called: EstimatesApi#retrieve_estimates\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" |
| 209 | + end |
| 210 | + return data, status_code, headers |
| 211 | + end |
| 212 | + end |
| 213 | +end |
0 commit comments