Skip to content

Commit

Permalink
Add new parameter for flights (#41)
Browse files Browse the repository at this point in the history
* Add new flights

* Fix

* Update changelog
  • Loading branch information
pcothenet authored Sep 7, 2021
1 parent a8189b8 commit 4c820a7
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
patch_ruby (1.10.2)
patch_ruby (1.11.0)
typhoeus (~> 1.0, >= 1.0.1)

GEM
Expand Down
2 changes: 1 addition & 1 deletion lib/patch_ruby/api_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
74 changes: 58 additions & 16 deletions lib/patch_ruby/models/create_flight_estimate_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
}
Expand All @@ -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'
}
Expand All @@ -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'
])
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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

Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/patch_ruby/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
=end

module Patch
VERSION = '1.10.2'
VERSION = '1.11.0'
end
15 changes: 15 additions & 0 deletions spec/integration/estimates_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 4c820a7

Please sign in to comment.