Skip to content

Commit 4c820a7

Browse files
authored
Add new parameter for flights (#41)
* Add new flights * Fix * Update changelog
1 parent a8189b8 commit 4c820a7

File tree

7 files changed

+83
-20
lines changed

7 files changed

+83
-20
lines changed

.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This file is based on https://github.com/rails/rails/blob/master/.rubocop.yml (MIT license)
22
# Automatically generated by OpenAPI Generator (https://openapi-generator.tech)
33
AllCops:
4-
TargetRubyVersion: 2.4
4+
TargetRubyVersion: 2.5
55
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
66
# to ignore them, so only the ones explicitly set in this file are enabled.
77
DisabledByDefault: true

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.11.0] - 2021-09-07
9+
10+
### Added
11+
12+
- Adds support for airports, aircracts, cabin class and passenger count in flight estimates
13+
814
## [1.10.2] - 2021-09-01
915

1016
### Fixed

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
patch_ruby (1.10.2)
4+
patch_ruby (1.11.0)
55
typhoeus (~> 1.0, >= 1.0.1)
66

77
GEM

lib/patch_ruby/api_client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class ApiClient
3131
# @option config [Configuration] Configuration for initializing the object, default to Configuration.default
3232
def initialize(config = Configuration.default)
3333
@config = config
34-
@user_agent = "patch-ruby/1.10.2"
34+
@user_agent = "patch-ruby/1.11.0"
3535
@default_headers = {
3636
'Content-Type' => 'application/json',
3737
'User-Agent' => @user_agent

lib/patch_ruby/models/create_flight_estimate_request.rb

Lines changed: 58 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ module Patch
1717
class CreateFlightEstimateRequest
1818
attr_accessor :distance_m
1919

20+
attr_accessor :origin_airport
21+
22+
attr_accessor :destination_airport
23+
24+
attr_accessor :aircraft_code
25+
26+
attr_accessor :cabin_class
27+
28+
attr_accessor :passenger_count
29+
2030
attr_accessor :project_id
2131

2232
attr_accessor :create_order
@@ -25,6 +35,11 @@ class CreateFlightEstimateRequest
2535
def self.attribute_map
2636
{
2737
:'distance_m' => :'distance_m',
38+
:'origin_airport' => :'origin_airport',
39+
:'destination_airport' => :'destination_airport',
40+
:'aircraft_code' => :'aircraft_code',
41+
:'cabin_class' => :'cabin_class',
42+
:'passenger_count' => :'passenger_count',
2843
:'project_id' => :'project_id',
2944
:'create_order' => :'create_order'
3045
}
@@ -39,6 +54,11 @@ def self.acceptable_attributes
3954
def self.openapi_types
4055
{
4156
:'distance_m' => :'Integer',
57+
:'origin_airport' => :'String',
58+
:'destination_airport' => :'String',
59+
:'aircraft_code' => :'String',
60+
:'cabin_class' => :'String',
61+
:'passenger_count' => :'Integer',
4262
:'project_id' => :'String',
4363
:'create_order' => :'Boolean'
4464
}
@@ -47,6 +67,12 @@ def self.openapi_types
4767
# List of attributes with nullable: true
4868
def self.openapi_nullable
4969
Set.new([
70+
:'distance_m',
71+
:'origin_airport',
72+
:'destination_airport',
73+
:'aircraft_code',
74+
:'cabin_class',
75+
:'passenger_count',
5076
:'project_id',
5177
:'create_order'
5278
])
@@ -83,6 +109,26 @@ def initialize(attributes = {})
83109
self.distance_m = attributes[:'distance_m']
84110
end
85111

112+
if attributes.key?(:'origin_airport')
113+
self.origin_airport = attributes[:'origin_airport']
114+
end
115+
116+
if attributes.key?(:'destination_airport')
117+
self.destination_airport = attributes[:'destination_airport']
118+
end
119+
120+
if attributes.key?(:'aircraft_code')
121+
self.aircraft_code = attributes[:'aircraft_code']
122+
end
123+
124+
if attributes.key?(:'cabin_class')
125+
self.cabin_class = attributes[:'cabin_class']
126+
end
127+
128+
if attributes.key?(:'passenger_count')
129+
self.passenger_count = attributes[:'passenger_count']
130+
end
131+
86132
if attributes.key?(:'project_id')
87133
self.project_id = attributes[:'project_id']
88134
end
@@ -96,15 +142,11 @@ def initialize(attributes = {})
96142
# @return Array for valid properties with the reasons
97143
def list_invalid_properties
98144
invalid_properties = Array.new
99-
if @distance_m.nil?
100-
invalid_properties.push('invalid value for "distance_m", distance_m cannot be nil.')
101-
end
102-
103-
if @distance_m > 400000000
145+
if !@distance_m.nil? && @distance_m > 400000000
104146
invalid_properties.push('invalid value for "distance_m", must be smaller than or equal to 400000000.')
105147
end
106148

107-
if @distance_m < 0
149+
if !@distance_m.nil? && @distance_m < 0
108150
invalid_properties.push('invalid value for "distance_m", must be greater than or equal to 0.')
109151
end
110152

@@ -114,24 +156,19 @@ def list_invalid_properties
114156
# Check to see if the all the properties in the model are valid
115157
# @return true if the model is valid
116158
def valid?
117-
return false if @distance_m.nil?
118-
return false if @distance_m > 400000000
119-
return false if @distance_m < 0
159+
return false if !@distance_m.nil? && @distance_m > 400000000
160+
return false if !@distance_m.nil? && @distance_m < 0
120161
true
121162
end
122163

123164
# Custom attribute writer method with validation
124165
# @param [Object] distance_m Value to be assigned
125166
def distance_m=(distance_m)
126-
if distance_m.nil?
127-
fail ArgumentError, 'distance_m cannot be nil'
128-
end
129-
130-
if distance_m > 400000000
167+
if !distance_m.nil? && distance_m > 400000000
131168
fail ArgumentError, 'invalid value for "distance_m", must be smaller than or equal to 400000000.'
132169
end
133170

134-
if distance_m < 0
171+
if !distance_m.nil? && distance_m < 0
135172
fail ArgumentError, 'invalid value for "distance_m", must be greater than or equal to 0.'
136173
end
137174

@@ -144,6 +181,11 @@ def ==(o)
144181
return true if self.equal?(o)
145182
self.class == o.class &&
146183
distance_m == o.distance_m &&
184+
origin_airport == o.origin_airport &&
185+
destination_airport == o.destination_airport &&
186+
aircraft_code == o.aircraft_code &&
187+
cabin_class == o.cabin_class &&
188+
passenger_count == o.passenger_count &&
147189
project_id == o.project_id &&
148190
create_order == o.create_order
149191
end
@@ -157,7 +199,7 @@ def eql?(o)
157199
# Calculates hash code according to all attributes.
158200
# @return [Integer] Hash code
159201
def hash
160-
[distance_m, project_id, create_order].hash
202+
[distance_m, origin_airport, destination_airport, aircraft_code, cabin_class, passenger_count, project_id, create_order].hash
161203
end
162204

163205
# Builds the object from hash

lib/patch_ruby/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
=end
1212

1313
module Patch
14-
VERSION = '1.10.2'
14+
VERSION = '1.11.0'
1515
end

spec/integration/estimates_spec.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,21 @@
3030
expect(flight_estimate.data.mass_g).to eq 1_000_622
3131
end
3232

33+
it 'supports creating flight estimates with origin and destination' do
34+
flight_estimate = Patch::Estimate.create_flight_estimate(
35+
origin_airport: "SFO",
36+
destination_airport: "LAX"
37+
)
38+
39+
flight_estimate_longer = Patch::Estimate.create_flight_estimate(
40+
origin_airport: "SFO",
41+
destination_airport: "JFK"
42+
)
43+
44+
expect(flight_estimate.data.type).to eq 'flight'
45+
expect(flight_estimate_longer.data.mass_g).to be > 2 * flight_estimate.data.mass_g
46+
end
47+
3348
it 'supports creating vehicle estimates' do
3449
distance_m = 10_000
3550
make = "Toyota"

0 commit comments

Comments
 (0)