patch_ruby 1.2.5 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/Gemfile.lock +1 -1
- data/README.md +27 -1
- data/lib/patch_ruby/api/estimates_api.rb +195 -0
- data/lib/patch_ruby/models/create_mass_estimate_request.rb +12 -1
- data/lib/patch_ruby/models/estimate.rb +13 -3
- data/lib/patch_ruby/models/photo.rb +4 -0
- data/lib/patch_ruby/version.rb +1 -1
- data/spec/integration/estimates_spec.rb +43 -0
- data/spec/integration/preferences_spec.rb +6 -2
- data/spec/models/create_mass_estimate_request_spec.rb +1 -1
- metadata +29 -29
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 1dfa80bf469d57550d91fd6347ecc9b98ea263ea3f07c634f1ad8ad5a0061fef
         | 
| 4 | 
            +
              data.tar.gz: 2464d81c7fb0256e66ac82957c0e1c4915f1f519b711434fa058d165fba225ec
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: eedc8a08e6518436a8c275b6d9abd27391f16d18cc83d1301b1234bc118e51bd25b0b650b064325aa3d8ec94b0d11a91a35040d31f36d52bf4ce55332a96e14f
         | 
| 7 | 
            +
              data.tar.gz: 48bf74563009752e9696617c3134d2716c2e75ba28264f2f7af729c3146767ffcf8020b9904fbe35b83d66f685a0d6b0c018ccb2d9c5ece29231cccf476546fa
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    | @@ -5,7 +5,11 @@ All notable changes to this project will be documented in this file. | |
| 5 5 | 
             
            The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
         | 
| 6 6 | 
             
            and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
         | 
| 7 7 |  | 
| 8 | 
            -
            ## [ | 
| 8 | 
            +
            ## [1.3.0] - 2021-02-08
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            ### Added
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            - Adds support for creating carbon emission estimates for flights, shipping, and vehicles. See the [docs](https://docs.usepatch.com/#/?id=estimates) for more information.
         | 
| 9 13 |  | 
| 10 14 | 
             
            ## [1.2.5] - 2020-01-08
         | 
| 11 15 |  | 
    
        data/Gemfile.lock
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | @@ -98,10 +98,36 @@ Estimates allow API users to get a quote for the cost of compensating a certain | |
| 98 98 |  | 
| 99 99 | 
             
            #### Examples
         | 
| 100 100 | 
             
            ```ruby
         | 
| 101 | 
            -
            # Create  | 
| 101 | 
            +
            # Create a mass estimate
         | 
| 102 102 | 
             
            mass = 1_000_000 # Pass in the mass in grams (i.e. 1 metric tonne)
         | 
| 103 103 | 
             
            Patch::Estimate.create_mass_estimate(mass_g: mass)
         | 
| 104 104 |  | 
| 105 | 
            +
            # Create a flight estimate
         | 
| 106 | 
            +
            distance_m = 1_000_000 # Pass in the distance traveled in meters
         | 
| 107 | 
            +
            Patch::Estimate.create_flight_estimate(distance_m: distance_m)
         | 
| 108 | 
            +
             | 
| 109 | 
            +
            # Create a shipping estimate
         | 
| 110 | 
            +
            distance_m = 1_000_000 # Pass in the shipping distance in meters
         | 
| 111 | 
            +
            package_mass_g = 10_000 # Pass in the weight of the package shipped in grams
         | 
| 112 | 
            +
            transportation_method = "air" # Pass in the transportation method (air, rail, road, sea)
         | 
| 113 | 
            +
            Patch::Estimate.create_shipping_estimate(
         | 
| 114 | 
            +
              distance_m: distance_m,
         | 
| 115 | 
            +
              package_mass_g: package_mass_g,
         | 
| 116 | 
            +
              transportation_method: transportation_method
         | 
| 117 | 
            +
            )
         | 
| 118 | 
            +
             | 
| 119 | 
            +
            # Create a vehicle estimate
         | 
| 120 | 
            +
            distance_m = 1_000_000 # Pass in the shipping distance in meters
         | 
| 121 | 
            +
            make = "Toyota" # Pass in the car make
         | 
| 122 | 
            +
            model = "Corolla" # Pass in the car model
         | 
| 123 | 
            +
            year = 2000 # Pass in the car year
         | 
| 124 | 
            +
            Patch::Estimate.create_vehicle_estimate(
         | 
| 125 | 
            +
              distance_m: distance_m,
         | 
| 126 | 
            +
              make: make,
         | 
| 127 | 
            +
              model: model,
         | 
| 128 | 
            +
              year: year
         | 
| 129 | 
            +
            )
         | 
| 130 | 
            +
             | 
| 105 131 | 
             
            ## You can also specify a project-id field (optional) to be used instead of the preferred one
         | 
| 106 132 | 
             
            project_id = 'pro_test_1234' # Pass in the project's ID
         | 
| 107 133 | 
             
            Patch::Estimate.create_mass_estimate(mass_g: mass, project_id: project_id)
         | 
| @@ -15,7 +15,10 @@ require 'cgi' | |
| 15 15 | 
             
            module Patch
         | 
| 16 16 | 
             
              class EstimatesApi
         | 
| 17 17 | 
             
                OPERATIONS = [
         | 
| 18 | 
            +
                  :create_flight_estimate,
         | 
| 18 19 | 
             
                  :create_mass_estimate,
         | 
| 20 | 
            +
                  :create_shipping_estimate,
         | 
| 21 | 
            +
                  :create_vehicle_estimate,
         | 
| 19 22 | 
             
                  :retrieve_estimate,
         | 
| 20 23 | 
             
                  :retrieve_estimates,
         | 
| 21 24 | 
             
                ]
         | 
| @@ -25,6 +28,70 @@ module Patch | |
| 25 28 | 
             
                def initialize(api_client = ApiClient.default)
         | 
| 26 29 | 
             
                  @api_client = api_client
         | 
| 27 30 | 
             
                end
         | 
| 31 | 
            +
                # Create a flight estimate given the distance traveled in meters
         | 
| 32 | 
            +
                # Creates a flight estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters, linked to the estimate. 
         | 
| 33 | 
            +
                # @param create_flight_estimate_request [CreateFlightEstimateRequest] 
         | 
| 34 | 
            +
                # @param [Hash] opts the optional parameters
         | 
| 35 | 
            +
                # @return [EstimateResponse]
         | 
| 36 | 
            +
                def create_flight_estimate(create_flight_estimate_request, opts = {})
         | 
| 37 | 
            +
                  data, _status_code, _headers = create_flight_estimate_with_http_info(create_flight_estimate_request, opts)
         | 
| 38 | 
            +
                  data
         | 
| 39 | 
            +
                end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                # Create a flight estimate given the distance traveled in meters
         | 
| 42 | 
            +
                # Creates a flight estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters, linked to the estimate. 
         | 
| 43 | 
            +
                # @param create_flight_estimate_request [CreateFlightEstimateRequest] 
         | 
| 44 | 
            +
                # @param [Hash] opts the optional parameters
         | 
| 45 | 
            +
                # @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
         | 
| 46 | 
            +
                def create_flight_estimate_with_http_info(create_flight_estimate_request, opts = {})
         | 
| 47 | 
            +
                  if @api_client.config.debugging
         | 
| 48 | 
            +
                    @api_client.config.logger.debug 'Calling API: EstimatesApi.create_flight_estimate ...'
         | 
| 49 | 
            +
                  end
         | 
| 50 | 
            +
                  # verify the required parameter 'create_flight_estimate_request' is set
         | 
| 51 | 
            +
                  if @api_client.config.client_side_validation && create_flight_estimate_request.nil?
         | 
| 52 | 
            +
                    fail ArgumentError, "Missing the required parameter 'create_flight_estimate_request' when calling EstimatesApi.create_flight_estimate"
         | 
| 53 | 
            +
                  end
         | 
| 54 | 
            +
                  # resource path
         | 
| 55 | 
            +
                  local_var_path = '/v1/estimates/flight'
         | 
| 56 | 
            +
             | 
| 57 | 
            +
                  # query parameters
         | 
| 58 | 
            +
                  query_params = opts[:query_params] || {}
         | 
| 59 | 
            +
             | 
| 60 | 
            +
                  # header parameters
         | 
| 61 | 
            +
                  header_params = opts[:header_params] || {}
         | 
| 62 | 
            +
                  # HTTP header 'Accept' (if needed)
         | 
| 63 | 
            +
                  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
         | 
| 64 | 
            +
                  # HTTP header 'Content-Type'
         | 
| 65 | 
            +
                  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                  # form parameters
         | 
| 68 | 
            +
                  form_params = opts[:form_params] || {}
         | 
| 69 | 
            +
             | 
| 70 | 
            +
                  # http body (model)
         | 
| 71 | 
            +
                  post_body = opts[:body] || @api_client.object_to_http_body(create_flight_estimate_request) 
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                  # return_type
         | 
| 74 | 
            +
                  return_type = opts[:return_type] || 'EstimateResponse' 
         | 
| 75 | 
            +
             | 
| 76 | 
            +
                  # auth_names
         | 
| 77 | 
            +
                  auth_names = opts[:auth_names] || ['bearer_auth']
         | 
| 78 | 
            +
             | 
| 79 | 
            +
                  new_options = opts.merge(
         | 
| 80 | 
            +
                    :header_params => header_params,
         | 
| 81 | 
            +
                    :query_params => query_params,
         | 
| 82 | 
            +
                    :form_params => form_params,
         | 
| 83 | 
            +
                    :body => post_body,
         | 
| 84 | 
            +
                    :auth_names => auth_names,
         | 
| 85 | 
            +
                    :return_type => return_type
         | 
| 86 | 
            +
                  )
         | 
| 87 | 
            +
             | 
| 88 | 
            +
                  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
         | 
| 89 | 
            +
                  if @api_client.config.debugging
         | 
| 90 | 
            +
                    @api_client.config.logger.debug "API called: EstimatesApi#create_flight_estimate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
         | 
| 91 | 
            +
                  end
         | 
| 92 | 
            +
                  return data, status_code, headers
         | 
| 93 | 
            +
                end
         | 
| 94 | 
            +
             | 
| 28 95 | 
             
                # Create an estimate based on mass of CO2
         | 
| 29 96 | 
             
                # 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 97 | 
             
                # @param create_mass_estimate_request [CreateMassEstimateRequest] 
         | 
| @@ -89,6 +156,134 @@ module Patch | |
| 89 156 | 
             
                  return data, status_code, headers
         | 
| 90 157 | 
             
                end
         | 
| 91 158 |  | 
| 159 | 
            +
                # Create a shipping estimate given the distance traveled in meters, package weight, and transportation method.
         | 
| 160 | 
            +
                # Creates a shipping estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters. 
         | 
| 161 | 
            +
                # @param create_shipping_estimate_request [CreateShippingEstimateRequest] 
         | 
| 162 | 
            +
                # @param [Hash] opts the optional parameters
         | 
| 163 | 
            +
                # @return [EstimateResponse]
         | 
| 164 | 
            +
                def create_shipping_estimate(create_shipping_estimate_request, opts = {})
         | 
| 165 | 
            +
                  data, _status_code, _headers = create_shipping_estimate_with_http_info(create_shipping_estimate_request, opts)
         | 
| 166 | 
            +
                  data
         | 
| 167 | 
            +
                end
         | 
| 168 | 
            +
             | 
| 169 | 
            +
                # Create a shipping estimate given the distance traveled in meters, package weight, and transportation method.
         | 
| 170 | 
            +
                # Creates a shipping estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters. 
         | 
| 171 | 
            +
                # @param create_shipping_estimate_request [CreateShippingEstimateRequest] 
         | 
| 172 | 
            +
                # @param [Hash] opts the optional parameters
         | 
| 173 | 
            +
                # @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
         | 
| 174 | 
            +
                def create_shipping_estimate_with_http_info(create_shipping_estimate_request, opts = {})
         | 
| 175 | 
            +
                  if @api_client.config.debugging
         | 
| 176 | 
            +
                    @api_client.config.logger.debug 'Calling API: EstimatesApi.create_shipping_estimate ...'
         | 
| 177 | 
            +
                  end
         | 
| 178 | 
            +
                  # verify the required parameter 'create_shipping_estimate_request' is set
         | 
| 179 | 
            +
                  if @api_client.config.client_side_validation && create_shipping_estimate_request.nil?
         | 
| 180 | 
            +
                    fail ArgumentError, "Missing the required parameter 'create_shipping_estimate_request' when calling EstimatesApi.create_shipping_estimate"
         | 
| 181 | 
            +
                  end
         | 
| 182 | 
            +
                  # resource path
         | 
| 183 | 
            +
                  local_var_path = '/v1/estimates/shipping'
         | 
| 184 | 
            +
             | 
| 185 | 
            +
                  # query parameters
         | 
| 186 | 
            +
                  query_params = opts[:query_params] || {}
         | 
| 187 | 
            +
             | 
| 188 | 
            +
                  # header parameters
         | 
| 189 | 
            +
                  header_params = opts[:header_params] || {}
         | 
| 190 | 
            +
                  # HTTP header 'Accept' (if needed)
         | 
| 191 | 
            +
                  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
         | 
| 192 | 
            +
                  # HTTP header 'Content-Type'
         | 
| 193 | 
            +
                  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
         | 
| 194 | 
            +
             | 
| 195 | 
            +
                  # form parameters
         | 
| 196 | 
            +
                  form_params = opts[:form_params] || {}
         | 
| 197 | 
            +
             | 
| 198 | 
            +
                  # http body (model)
         | 
| 199 | 
            +
                  post_body = opts[:body] || @api_client.object_to_http_body(create_shipping_estimate_request) 
         | 
| 200 | 
            +
             | 
| 201 | 
            +
                  # return_type
         | 
| 202 | 
            +
                  return_type = opts[:return_type] || 'EstimateResponse' 
         | 
| 203 | 
            +
             | 
| 204 | 
            +
                  # auth_names
         | 
| 205 | 
            +
                  auth_names = opts[:auth_names] || ['bearer_auth']
         | 
| 206 | 
            +
             | 
| 207 | 
            +
                  new_options = opts.merge(
         | 
| 208 | 
            +
                    :header_params => header_params,
         | 
| 209 | 
            +
                    :query_params => query_params,
         | 
| 210 | 
            +
                    :form_params => form_params,
         | 
| 211 | 
            +
                    :body => post_body,
         | 
| 212 | 
            +
                    :auth_names => auth_names,
         | 
| 213 | 
            +
                    :return_type => return_type
         | 
| 214 | 
            +
                  )
         | 
| 215 | 
            +
             | 
| 216 | 
            +
                  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
         | 
| 217 | 
            +
                  if @api_client.config.debugging
         | 
| 218 | 
            +
                    @api_client.config.logger.debug "API called: EstimatesApi#create_shipping_estimate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
         | 
| 219 | 
            +
                  end
         | 
| 220 | 
            +
                  return data, status_code, headers
         | 
| 221 | 
            +
                end
         | 
| 222 | 
            +
             | 
| 223 | 
            +
                # Create a vehicle estimate given the distance traveled in meters and the type of vehicle
         | 
| 224 | 
            +
                # Creates an estimate and calculates the amount of CO2 to be compensated depending on the distance and the vehicle. An order in the `draft` state may be created based on the parameters, linked to the estimate. 
         | 
| 225 | 
            +
                # @param create_vehicle_estimate_request [CreateVehicleEstimateRequest] 
         | 
| 226 | 
            +
                # @param [Hash] opts the optional parameters
         | 
| 227 | 
            +
                # @return [EstimateResponse]
         | 
| 228 | 
            +
                def create_vehicle_estimate(create_vehicle_estimate_request, opts = {})
         | 
| 229 | 
            +
                  data, _status_code, _headers = create_vehicle_estimate_with_http_info(create_vehicle_estimate_request, opts)
         | 
| 230 | 
            +
                  data
         | 
| 231 | 
            +
                end
         | 
| 232 | 
            +
             | 
| 233 | 
            +
                # Create a vehicle estimate given the distance traveled in meters and the type of vehicle
         | 
| 234 | 
            +
                # Creates an estimate and calculates the amount of CO2 to be compensated depending on the distance and the vehicle. An order in the `draft` state may be created based on the parameters, linked to the estimate. 
         | 
| 235 | 
            +
                # @param create_vehicle_estimate_request [CreateVehicleEstimateRequest] 
         | 
| 236 | 
            +
                # @param [Hash] opts the optional parameters
         | 
| 237 | 
            +
                # @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
         | 
| 238 | 
            +
                def create_vehicle_estimate_with_http_info(create_vehicle_estimate_request, opts = {})
         | 
| 239 | 
            +
                  if @api_client.config.debugging
         | 
| 240 | 
            +
                    @api_client.config.logger.debug 'Calling API: EstimatesApi.create_vehicle_estimate ...'
         | 
| 241 | 
            +
                  end
         | 
| 242 | 
            +
                  # verify the required parameter 'create_vehicle_estimate_request' is set
         | 
| 243 | 
            +
                  if @api_client.config.client_side_validation && create_vehicle_estimate_request.nil?
         | 
| 244 | 
            +
                    fail ArgumentError, "Missing the required parameter 'create_vehicle_estimate_request' when calling EstimatesApi.create_vehicle_estimate"
         | 
| 245 | 
            +
                  end
         | 
| 246 | 
            +
                  # resource path
         | 
| 247 | 
            +
                  local_var_path = '/v1/estimates/vehicle'
         | 
| 248 | 
            +
             | 
| 249 | 
            +
                  # query parameters
         | 
| 250 | 
            +
                  query_params = opts[:query_params] || {}
         | 
| 251 | 
            +
             | 
| 252 | 
            +
                  # header parameters
         | 
| 253 | 
            +
                  header_params = opts[:header_params] || {}
         | 
| 254 | 
            +
                  # HTTP header 'Accept' (if needed)
         | 
| 255 | 
            +
                  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
         | 
| 256 | 
            +
                  # HTTP header 'Content-Type'
         | 
| 257 | 
            +
                  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
         | 
| 258 | 
            +
             | 
| 259 | 
            +
                  # form parameters
         | 
| 260 | 
            +
                  form_params = opts[:form_params] || {}
         | 
| 261 | 
            +
             | 
| 262 | 
            +
                  # http body (model)
         | 
| 263 | 
            +
                  post_body = opts[:body] || @api_client.object_to_http_body(create_vehicle_estimate_request) 
         | 
| 264 | 
            +
             | 
| 265 | 
            +
                  # return_type
         | 
| 266 | 
            +
                  return_type = opts[:return_type] || 'EstimateResponse' 
         | 
| 267 | 
            +
             | 
| 268 | 
            +
                  # auth_names
         | 
| 269 | 
            +
                  auth_names = opts[:auth_names] || ['bearer_auth']
         | 
| 270 | 
            +
             | 
| 271 | 
            +
                  new_options = opts.merge(
         | 
| 272 | 
            +
                    :header_params => header_params,
         | 
| 273 | 
            +
                    :query_params => query_params,
         | 
| 274 | 
            +
                    :form_params => form_params,
         | 
| 275 | 
            +
                    :body => post_body,
         | 
| 276 | 
            +
                    :auth_names => auth_names,
         | 
| 277 | 
            +
                    :return_type => return_type
         | 
| 278 | 
            +
                  )
         | 
| 279 | 
            +
             | 
| 280 | 
            +
                  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
         | 
| 281 | 
            +
                  if @api_client.config.debugging
         | 
| 282 | 
            +
                    @api_client.config.logger.debug "API called: EstimatesApi#create_vehicle_estimate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
         | 
| 283 | 
            +
                  end
         | 
| 284 | 
            +
                  return data, status_code, headers
         | 
| 285 | 
            +
                end
         | 
| 286 | 
            +
             | 
| 92 287 | 
             
                # Retrieves an estimate
         | 
| 93 288 | 
             
                # Retrieves a given estimate and its associated order. You can only retrieve estimates associated with the organization you are querying for. 
         | 
| 94 289 | 
             
                # @param id [String] 
         | 
| @@ -16,12 +16,15 @@ module Patch | |
| 16 16 | 
             
              class CreateMassEstimateRequest
         | 
| 17 17 | 
             
                attr_accessor :mass_g
         | 
| 18 18 |  | 
| 19 | 
            +
                attr_accessor :create_order
         | 
| 20 | 
            +
             | 
| 19 21 | 
             
                attr_accessor :project_id
         | 
| 20 22 |  | 
| 21 23 | 
             
                # Attribute mapping from ruby-style variable name to JSON key.
         | 
| 22 24 | 
             
                def self.attribute_map
         | 
| 23 25 | 
             
                  {
         | 
| 24 26 | 
             
                    :'mass_g' => :'mass_g',
         | 
| 27 | 
            +
                    :'create_order' => :'create_order',
         | 
| 25 28 | 
             
                    :'project_id' => :'project_id'
         | 
| 26 29 | 
             
                  }
         | 
| 27 30 | 
             
                end
         | 
| @@ -30,6 +33,7 @@ module Patch | |
| 30 33 | 
             
                def self.openapi_types
         | 
| 31 34 | 
             
                  {
         | 
| 32 35 | 
             
                    :'mass_g' => :'Integer',
         | 
| 36 | 
            +
                    :'create_order' => :'Boolean',
         | 
| 33 37 | 
             
                    :'project_id' => :'String'
         | 
| 34 38 | 
             
                  }
         | 
| 35 39 | 
             
                end
         | 
| @@ -38,6 +42,8 @@ module Patch | |
| 38 42 | 
             
                def self.openapi_nullable
         | 
| 39 43 | 
             
                  nullable_properties = Set.new
         | 
| 40 44 |  | 
| 45 | 
            +
                  nullable_properties.add("create_order")
         | 
| 46 | 
            +
             | 
| 41 47 | 
             
                  nullable_properties
         | 
| 42 48 | 
             
                end
         | 
| 43 49 |  | 
| @@ -71,6 +77,10 @@ module Patch | |
| 71 77 | 
             
                    self.mass_g = attributes[:'mass_g']
         | 
| 72 78 | 
             
                  end
         | 
| 73 79 |  | 
| 80 | 
            +
                  if attributes.key?(:'create_order')
         | 
| 81 | 
            +
                    self.create_order = attributes[:'create_order']
         | 
| 82 | 
            +
                  end
         | 
| 83 | 
            +
             | 
| 74 84 | 
             
                  if attributes.key?(:'project_id')
         | 
| 75 85 | 
             
                    self.project_id = attributes[:'project_id']
         | 
| 76 86 | 
             
                  end
         | 
| @@ -128,6 +138,7 @@ module Patch | |
| 128 138 | 
             
                  return true if self.equal?(o)
         | 
| 129 139 | 
             
                  self.class == o.class &&
         | 
| 130 140 | 
             
                      mass_g == o.mass_g &&
         | 
| 141 | 
            +
                      create_order == o.create_order &&
         | 
| 131 142 | 
             
                      project_id == o.project_id
         | 
| 132 143 | 
             
                end
         | 
| 133 144 |  | 
| @@ -140,7 +151,7 @@ module Patch | |
| 140 151 | 
             
                # Calculates hash code according to all attributes.
         | 
| 141 152 | 
             
                # @return [Integer] Hash code
         | 
| 142 153 | 
             
                def hash
         | 
| 143 | 
            -
                  [mass_g, project_id].hash
         | 
| 154 | 
            +
                  [mass_g, create_order, project_id].hash
         | 
| 144 155 | 
             
                end
         | 
| 145 156 |  | 
| 146 157 | 
             
                # Builds the object from hash
         | 
| @@ -20,9 +20,12 @@ module Patch | |
| 20 20 | 
             
                # A boolean indicating if this estimate is a production or test mode estimate.
         | 
| 21 21 | 
             
                attr_accessor :production
         | 
| 22 22 |  | 
| 23 | 
            -
                # The type of estimate.  | 
| 23 | 
            +
                # The type of estimate. Available types are mass, flight, shipping, and vehicle.
         | 
| 24 24 | 
             
                attr_accessor :type
         | 
| 25 25 |  | 
| 26 | 
            +
                # The estimated mass in grams for this estimate.
         | 
| 27 | 
            +
                attr_accessor :mass_g
         | 
| 28 | 
            +
             | 
| 26 29 | 
             
                # An object returning the order associated with this estimate. See the [Order section](/?id=orders) for the full schema.
         | 
| 27 30 | 
             
                attr_accessor :order
         | 
| 28 31 |  | 
| @@ -32,6 +35,7 @@ module Patch | |
| 32 35 | 
             
                    :'id' => :'id',
         | 
| 33 36 | 
             
                    :'production' => :'production',
         | 
| 34 37 | 
             
                    :'type' => :'type',
         | 
| 38 | 
            +
                    :'mass_g' => :'mass_g',
         | 
| 35 39 | 
             
                    :'order' => :'order'
         | 
| 36 40 | 
             
                  }
         | 
| 37 41 | 
             
                end
         | 
| @@ -42,6 +46,7 @@ module Patch | |
| 42 46 | 
             
                    :'id' => :'String',
         | 
| 43 47 | 
             
                    :'production' => :'Boolean',
         | 
| 44 48 | 
             
                    :'type' => :'String',
         | 
| 49 | 
            +
                    :'mass_g' => :'Integer',
         | 
| 45 50 | 
             
                    :'order' => :'Order'
         | 
| 46 51 | 
             
                  }
         | 
| 47 52 | 
             
                end
         | 
| @@ -93,6 +98,10 @@ module Patch | |
| 93 98 | 
             
                    self.type = attributes[:'type']
         | 
| 94 99 | 
             
                  end
         | 
| 95 100 |  | 
| 101 | 
            +
                  if attributes.key?(:'mass_g')
         | 
| 102 | 
            +
                    self.mass_g = attributes[:'mass_g']
         | 
| 103 | 
            +
                  end
         | 
| 104 | 
            +
             | 
| 96 105 | 
             
                  if attributes.key?(:'order')
         | 
| 97 106 | 
             
                    self.order = attributes[:'order']
         | 
| 98 107 | 
             
                  end
         | 
| @@ -134,6 +143,7 @@ module Patch | |
| 134 143 | 
             
                      id == o.id &&
         | 
| 135 144 | 
             
                      production == o.production &&
         | 
| 136 145 | 
             
                      type == o.type &&
         | 
| 146 | 
            +
                      mass_g == o.mass_g &&
         | 
| 137 147 | 
             
                      order == o.order
         | 
| 138 148 | 
             
                end
         | 
| 139 149 |  | 
| @@ -146,7 +156,7 @@ module Patch | |
| 146 156 | 
             
                # Calculates hash code according to all attributes.
         | 
| 147 157 | 
             
                # @return [Integer] Hash code
         | 
| 148 158 | 
             
                def hash
         | 
| 149 | 
            -
                  [id, production, type, order].hash
         | 
| 159 | 
            +
                  [id, production, type, mass_g, order].hash
         | 
| 150 160 | 
             
                end
         | 
| 151 161 |  | 
| 152 162 | 
             
                # Builds the object from hash
         | 
| @@ -239,7 +249,7 @@ module Patch | |
| 239 249 | 
             
                      is_nullable = self.class.openapi_nullable.include?(attr)
         | 
| 240 250 | 
             
                      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
         | 
| 241 251 | 
             
                    end
         | 
| 242 | 
            -
             | 
| 252 | 
            +
                    
         | 
| 243 253 | 
             
                    hash[param] = _to_hash(value)
         | 
| 244 254 | 
             
                  end
         | 
| 245 255 | 
             
                  hash
         | 
    
        data/lib/patch_ruby/version.rb
    CHANGED
    
    
| @@ -24,4 +24,47 @@ RSpec.describe 'Estimates Integration' do | |
| 24 24 |  | 
| 25 25 | 
             
                expect(estimates.length).not_to be_zero
         | 
| 26 26 | 
             
              end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
              it 'supports creating flight estimates' do
         | 
| 29 | 
            +
                distance_m = 10_000_000
         | 
| 30 | 
            +
                flight_estimate = Patch::Estimate.create_flight_estimate(
         | 
| 31 | 
            +
                  distance_m: distance_m,
         | 
| 32 | 
            +
                  create_order: false
         | 
| 33 | 
            +
                )
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                expect(flight_estimate.data.type).to eq 'flight'
         | 
| 36 | 
            +
                expect(flight_estimate.data.mass_g).to eq 1_032_000
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
              it 'supports creating vehicle estimates' do
         | 
| 40 | 
            +
                distance_m = 10_000
         | 
| 41 | 
            +
                make = "Toyota"
         | 
| 42 | 
            +
                model = "Prius"
         | 
| 43 | 
            +
                year = 2000
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                vehicle_estimate = Patch::Estimate.create_vehicle_estimate(
         | 
| 46 | 
            +
                  distance_m: distance_m,
         | 
| 47 | 
            +
                  make: make,
         | 
| 48 | 
            +
                  model: model,
         | 
| 49 | 
            +
                  year: year,
         | 
| 50 | 
            +
                  create_order: false
         | 
| 51 | 
            +
                )
         | 
| 52 | 
            +
             | 
| 53 | 
            +
                expect(vehicle_estimate.data.type).to eq 'vehicle'
         | 
| 54 | 
            +
                expect(vehicle_estimate.data.mass_g).to eq 2_132
         | 
| 55 | 
            +
              end
         | 
| 56 | 
            +
             | 
| 57 | 
            +
              it 'supports creating shipping estimates' do
         | 
| 58 | 
            +
                distance_m = 100_000_000
         | 
| 59 | 
            +
                package_mass_g = 10_000
         | 
| 60 | 
            +
                create_estimate_response = Patch::Estimate.create_shipping_estimate(
         | 
| 61 | 
            +
                  distance_m: distance_m,
         | 
| 62 | 
            +
                  package_mass_g: package_mass_g,
         | 
| 63 | 
            +
                  transportation_method: 'rail',
         | 
| 64 | 
            +
                  create_order: false
         | 
| 65 | 
            +
                )
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                expect(create_estimate_response.data.type).to eq 'shipping'
         | 
| 68 | 
            +
                expect(create_estimate_response.data.mass_g).to eq 12_431
         | 
| 69 | 
            +
              end
         | 
| 27 70 | 
             
            end
         | 
| @@ -10,8 +10,12 @@ RSpec.describe 'Preferences Integration' do | |
| 10 10 | 
             
                expect(retrieve_projects_response.data.length).not_to be_zero
         | 
| 11 11 | 
             
                project_id = retrieve_projects_response.data.first.id
         | 
| 12 12 |  | 
| 13 | 
            -
                 | 
| 14 | 
            -
             | 
| 13 | 
            +
                begin
         | 
| 14 | 
            +
                  create_preference_response = Patch::Preference.create_preference(project_id: project_id)
         | 
| 15 | 
            +
                  preference_id = create_preference_response.data.id
         | 
| 16 | 
            +
                rescue => Patch::ApiError
         | 
| 17 | 
            +
                  preference_id = Patch::Preference.retrieve_preferences().data.first.id
         | 
| 18 | 
            +
                end
         | 
| 15 19 |  | 
| 16 20 | 
             
                retrieve_preference_response = Patch::Preference.retrieve_preference(preference_id)
         | 
| 17 21 | 
             
                expect(retrieve_preference_response.data.id).to eq preference_id
         | 
| @@ -30,7 +30,7 @@ describe 'CreateMassEstimateRequest' do | |
| 30 30 | 
             
              it_behaves_like "a generated class" do
         | 
| 31 31 | 
             
                let(:instance) { @instance }
         | 
| 32 32 | 
             
                let(:instance_hash) { { project_id: @instance.project_id, mass_g: @instance.mass_g } }
         | 
| 33 | 
            -
                let(:nullable_properties) { Set.new }
         | 
| 33 | 
            +
                let(:nullable_properties) { Set.new(["create_order"]) }
         | 
| 34 34 | 
             
              end
         | 
| 35 35 |  | 
| 36 36 | 
             
              describe 'test an instance of CreateMassEstimateRequest' do
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: patch_ruby
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1. | 
| 4 | 
            +
              version: 1.3.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Patch Technology
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2021- | 
| 11 | 
            +
            date: 2021-02-09 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: typhoeus
         | 
| @@ -186,52 +186,52 @@ signing_key: | |
| 186 186 | 
             
            specification_version: 4
         | 
| 187 187 | 
             
            summary: Ruby wrapper for the Patch API
         | 
| 188 188 | 
             
            test_files:
         | 
| 189 | 
            -
            - spec/api/projects_api_spec.rb
         | 
| 190 189 | 
             
            - spec/api/orders_api_spec.rb
         | 
| 191 | 
            -
            - spec/api/ | 
| 190 | 
            +
            - spec/api/projects_api_spec.rb
         | 
| 192 191 | 
             
            - spec/api/estimates_api_spec.rb
         | 
| 192 | 
            +
            - spec/api/preferences_api_spec.rb
         | 
| 193 193 | 
             
            - spec/api_client_spec.rb
         | 
| 194 194 | 
             
            - spec/configuration_spec.rb
         | 
| 195 195 | 
             
            - spec/constants.rb
         | 
| 196 | 
            -
            - spec/factories/ | 
| 197 | 
            -
            - spec/factories/ | 
| 198 | 
            -
            - spec/factories/ | 
| 196 | 
            +
            - spec/factories/project_responses.rb
         | 
| 197 | 
            +
            - spec/factories/create_preference_requests.rb
         | 
| 198 | 
            +
            - spec/factories/meta_index_objects.rb
         | 
| 199 199 | 
             
            - spec/factories/project_list_responses.rb
         | 
| 200 | 
            +
            - spec/factories/orders.rb
         | 
| 200 201 | 
             
            - spec/factories/order_list_responses.rb
         | 
| 201 | 
            -
            - spec/factories/estimate_responses.rb
         | 
| 202 | 
            -
            - spec/factories/error_responses.rb
         | 
| 203 | 
            -
            - spec/factories/preference_list_responses.rb
         | 
| 204 | 
            -
            - spec/factories/preference_responses.rb
         | 
| 205 | 
            -
            - spec/factories/meta_index_objects.rb
         | 
| 206 202 | 
             
            - spec/factories/order_responses.rb
         | 
| 207 203 | 
             
            - spec/factories/preferences.rb
         | 
| 208 | 
            -
            - spec/factories/ | 
| 209 | 
            -
            - spec/factories/ | 
| 210 | 
            -
            - spec/factories/ | 
| 204 | 
            +
            - spec/factories/preference_responses.rb
         | 
| 205 | 
            +
            - spec/factories/error_responses.rb
         | 
| 206 | 
            +
            - spec/factories/estimates.rb
         | 
| 207 | 
            +
            - spec/factories/estimate_list_responses.rb
         | 
| 208 | 
            +
            - spec/factories/create_order_requests.rb
         | 
| 209 | 
            +
            - spec/factories/allocations.rb
         | 
| 211 210 | 
             
            - spec/factories/projects.rb
         | 
| 211 | 
            +
            - spec/factories/estimate_responses.rb
         | 
| 212 | 
            +
            - spec/factories/preference_list_responses.rb
         | 
| 212 213 | 
             
            - spec/factories/create_mass_estimate_requests.rb
         | 
| 213 | 
            -
            - spec/factories/allocations.rb
         | 
| 214 | 
            -
            - spec/integration/orders_spec.rb
         | 
| 215 214 | 
             
            - spec/integration/estimates_spec.rb
         | 
| 216 215 | 
             
            - spec/integration/preferences_spec.rb
         | 
| 216 | 
            +
            - spec/integration/orders_spec.rb
         | 
| 217 217 | 
             
            - spec/integration/projects_spec.rb
         | 
| 218 | 
            -
            - spec/models/error_response_spec.rb
         | 
| 219 | 
            -
            - spec/models/preference_list_response_spec.rb
         | 
| 220 | 
            -
            - spec/models/preference_spec.rb
         | 
| 221 | 
            -
            - spec/models/project_response_spec.rb
         | 
| 222 | 
            -
            - spec/models/project_spec.rb
         | 
| 223 | 
            -
            - spec/models/create_preference_request_spec.rb
         | 
| 224 | 
            -
            - spec/models/order_response_spec.rb
         | 
| 225 218 | 
             
            - spec/models/order_list_response_spec.rb
         | 
| 226 219 | 
             
            - spec/models/allocation_spec.rb
         | 
| 220 | 
            +
            - spec/models/order_response_spec.rb
         | 
| 221 | 
            +
            - spec/models/preference_list_response_spec.rb
         | 
| 222 | 
            +
            - spec/models/create_preference_request_spec.rb
         | 
| 223 | 
            +
            - spec/models/estimate_list_response_spec.rb
         | 
| 224 | 
            +
            - spec/models/project_spec.rb
         | 
| 225 | 
            +
            - spec/models/project_list_response_spec.rb
         | 
| 227 226 | 
             
            - spec/models/estimate_response_spec.rb
         | 
| 227 | 
            +
            - spec/models/preference_spec.rb
         | 
| 228 | 
            +
            - spec/models/create_order_request_spec.rb
         | 
| 229 | 
            +
            - spec/models/create_mass_estimate_request_spec.rb
         | 
| 230 | 
            +
            - spec/models/project_response_spec.rb
         | 
| 228 231 | 
             
            - spec/models/order_spec.rb
         | 
| 232 | 
            +
            - spec/models/error_response_spec.rb
         | 
| 233 | 
            +
            - spec/models/estimate_spec.rb
         | 
| 229 234 | 
             
            - spec/models/meta_index_object_spec.rb
         | 
| 230 | 
            -
            - spec/models/project_list_response_spec.rb
         | 
| 231 235 | 
             
            - spec/models/preference_response_spec.rb
         | 
| 232 | 
            -
            - spec/models/estimate_spec.rb
         | 
| 233 | 
            -
            - spec/models/create_mass_estimate_request_spec.rb
         | 
| 234 | 
            -
            - spec/models/estimate_list_response_spec.rb
         | 
| 235 | 
            -
            - spec/models/create_order_request_spec.rb
         | 
| 236 236 | 
             
            - spec/spec_helper.rb
         | 
| 237 237 | 
             
            - spec/support/shared/generated_classes.rb
         |