From 4c820a75eb2b0b7521fa824326d585e81d35b83c Mon Sep 17 00:00:00 2001 From: Paul Cothenet Date: Tue, 7 Sep 2021 15:02:15 -0700 Subject: [PATCH] Add new parameter for flights (#41) * Add new flights * Fix * Update changelog --- .rubocop.yml | 2 +- CHANGELOG.md | 6 ++ Gemfile.lock | 2 +- lib/patch_ruby/api_client.rb | 2 +- .../models/create_flight_estimate_request.rb | 74 +++++++++++++++---- lib/patch_ruby/version.rb | 2 +- spec/integration/estimates_spec.rb | 15 ++++ 7 files changed, 83 insertions(+), 20 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index d32b2b1..68a80ad 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,7 +1,7 @@ # This file is based on https://github.com/rails/rails/blob/master/.rubocop.yml (MIT license) # Automatically generated by OpenAPI Generator (https://openapi-generator.tech) AllCops: - TargetRubyVersion: 2.4 + TargetRubyVersion: 2.5 # RuboCop has a bunch of cops enabled by default. This setting tells RuboCop # to ignore them, so only the ones explicitly set in this file are enabled. DisabledByDefault: true diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f27c49..2461b5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.11.0] - 2021-09-07 + +### Added + +- Adds support for airports, aircracts, cabin class and passenger count in flight estimates + ## [1.10.2] - 2021-09-01 ### Fixed diff --git a/Gemfile.lock b/Gemfile.lock index 015dd7b..98eb4c4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - patch_ruby (1.10.2) + patch_ruby (1.11.0) typhoeus (~> 1.0, >= 1.0.1) GEM diff --git a/lib/patch_ruby/api_client.rb b/lib/patch_ruby/api_client.rb index 5a0aaa3..f27522c 100644 --- a/lib/patch_ruby/api_client.rb +++ b/lib/patch_ruby/api_client.rb @@ -31,7 +31,7 @@ class ApiClient # @option config [Configuration] Configuration for initializing the object, default to Configuration.default def initialize(config = Configuration.default) @config = config - @user_agent = "patch-ruby/1.10.2" + @user_agent = "patch-ruby/1.11.0" @default_headers = { 'Content-Type' => 'application/json', 'User-Agent' => @user_agent diff --git a/lib/patch_ruby/models/create_flight_estimate_request.rb b/lib/patch_ruby/models/create_flight_estimate_request.rb index 2cc515f..889389d 100644 --- a/lib/patch_ruby/models/create_flight_estimate_request.rb +++ b/lib/patch_ruby/models/create_flight_estimate_request.rb @@ -17,6 +17,16 @@ module Patch class CreateFlightEstimateRequest attr_accessor :distance_m + attr_accessor :origin_airport + + attr_accessor :destination_airport + + attr_accessor :aircraft_code + + attr_accessor :cabin_class + + attr_accessor :passenger_count + attr_accessor :project_id attr_accessor :create_order @@ -25,6 +35,11 @@ class CreateFlightEstimateRequest def self.attribute_map { :'distance_m' => :'distance_m', + :'origin_airport' => :'origin_airport', + :'destination_airport' => :'destination_airport', + :'aircraft_code' => :'aircraft_code', + :'cabin_class' => :'cabin_class', + :'passenger_count' => :'passenger_count', :'project_id' => :'project_id', :'create_order' => :'create_order' } @@ -39,6 +54,11 @@ def self.acceptable_attributes def self.openapi_types { :'distance_m' => :'Integer', + :'origin_airport' => :'String', + :'destination_airport' => :'String', + :'aircraft_code' => :'String', + :'cabin_class' => :'String', + :'passenger_count' => :'Integer', :'project_id' => :'String', :'create_order' => :'Boolean' } @@ -47,6 +67,12 @@ def self.openapi_types # List of attributes with nullable: true def self.openapi_nullable Set.new([ + :'distance_m', + :'origin_airport', + :'destination_airport', + :'aircraft_code', + :'cabin_class', + :'passenger_count', :'project_id', :'create_order' ]) @@ -83,6 +109,26 @@ def initialize(attributes = {}) self.distance_m = attributes[:'distance_m'] end + if attributes.key?(:'origin_airport') + self.origin_airport = attributes[:'origin_airport'] + end + + if attributes.key?(:'destination_airport') + self.destination_airport = attributes[:'destination_airport'] + end + + if attributes.key?(:'aircraft_code') + self.aircraft_code = attributes[:'aircraft_code'] + end + + if attributes.key?(:'cabin_class') + self.cabin_class = attributes[:'cabin_class'] + end + + if attributes.key?(:'passenger_count') + self.passenger_count = attributes[:'passenger_count'] + end + if attributes.key?(:'project_id') self.project_id = attributes[:'project_id'] end @@ -96,15 +142,11 @@ def initialize(attributes = {}) # @return Array for valid properties with the reasons def list_invalid_properties invalid_properties = Array.new - if @distance_m.nil? - invalid_properties.push('invalid value for "distance_m", distance_m cannot be nil.') - end - - if @distance_m > 400000000 + if !@distance_m.nil? && @distance_m > 400000000 invalid_properties.push('invalid value for "distance_m", must be smaller than or equal to 400000000.') end - if @distance_m < 0 + if !@distance_m.nil? && @distance_m < 0 invalid_properties.push('invalid value for "distance_m", must be greater than or equal to 0.') end @@ -114,24 +156,19 @@ def list_invalid_properties # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? - return false if @distance_m.nil? - return false if @distance_m > 400000000 - return false if @distance_m < 0 + return false if !@distance_m.nil? && @distance_m > 400000000 + return false if !@distance_m.nil? && @distance_m < 0 true end # Custom attribute writer method with validation # @param [Object] distance_m Value to be assigned def distance_m=(distance_m) - if distance_m.nil? - fail ArgumentError, 'distance_m cannot be nil' - end - - if distance_m > 400000000 + if !distance_m.nil? && distance_m > 400000000 fail ArgumentError, 'invalid value for "distance_m", must be smaller than or equal to 400000000.' end - if distance_m < 0 + if !distance_m.nil? && distance_m < 0 fail ArgumentError, 'invalid value for "distance_m", must be greater than or equal to 0.' end @@ -144,6 +181,11 @@ def ==(o) return true if self.equal?(o) self.class == o.class && distance_m == o.distance_m && + origin_airport == o.origin_airport && + destination_airport == o.destination_airport && + aircraft_code == o.aircraft_code && + cabin_class == o.cabin_class && + passenger_count == o.passenger_count && project_id == o.project_id && create_order == o.create_order end @@ -157,7 +199,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [distance_m, project_id, create_order].hash + [distance_m, origin_airport, destination_airport, aircraft_code, cabin_class, passenger_count, project_id, create_order].hash end # Builds the object from hash diff --git a/lib/patch_ruby/version.rb b/lib/patch_ruby/version.rb index 88ff784..c3b2552 100644 --- a/lib/patch_ruby/version.rb +++ b/lib/patch_ruby/version.rb @@ -11,5 +11,5 @@ =end module Patch - VERSION = '1.10.2' + VERSION = '1.11.0' end diff --git a/spec/integration/estimates_spec.rb b/spec/integration/estimates_spec.rb index 58f5e08..82c8f65 100644 --- a/spec/integration/estimates_spec.rb +++ b/spec/integration/estimates_spec.rb @@ -30,6 +30,21 @@ expect(flight_estimate.data.mass_g).to eq 1_000_622 end + it 'supports creating flight estimates with origin and destination' do + flight_estimate = Patch::Estimate.create_flight_estimate( + origin_airport: "SFO", + destination_airport: "LAX" + ) + + flight_estimate_longer = Patch::Estimate.create_flight_estimate( + origin_airport: "SFO", + destination_airport: "JFK" + ) + + expect(flight_estimate.data.type).to eq 'flight' + expect(flight_estimate_longer.data.mass_g).to be > 2 * flight_estimate.data.mass_g + end + it 'supports creating vehicle estimates' do distance_m = 10_000 make = "Toyota"