Skip to content

Commit e7d12c9

Browse files
author
Rahul Mody
authored
1.20.0 - create order by vintage year (#60)
* 1.20.0 * add spec * fix nullable order spec * add 1.20.0 changelog
1 parent 2dfc211 commit e7d12c9

File tree

7 files changed

+64
-8
lines changed

7 files changed

+64
-8
lines changed

CHANGELOG.md

+6
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.20.0] - 2022-04-18
9+
10+
### Added
11+
12+
- Adds optional `vintage_year` field to `order` creation
13+
814
## [1.19.0] - 2022-04-05
915

1016
### Added

Gemfile.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
patch_ruby (1.19.0)
4+
patch_ruby (1.20.0)
55
typhoeus (~> 1.0, >= 1.0.1)
66

77
GEM

lib/patch_ruby/api_client.rb

+1-1
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.19.0"
34+
@user_agent = "patch-ruby/1.20.0"
3535
@default_headers = {
3636
'Content-Type' => 'application/json',
3737
'User-Agent' => @user_agent

lib/patch_ruby/models/create_order_request.rb

+43-4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ class CreateOrderRequest
2525

2626
attr_accessor :state
2727

28+
attr_accessor :vintage_year
29+
2830
class EnumAttributeValidator
2931
attr_reader :datatype
3032
attr_reader :allowable_values
@@ -54,7 +56,8 @@ def self.attribute_map
5456
:'total_price_cents_usd' => :'total_price_cents_usd',
5557
:'project_id' => :'project_id',
5658
:'metadata' => :'metadata',
57-
:'state' => :'state'
59+
:'state' => :'state',
60+
:'vintage_year' => :'vintage_year'
5861
}
5962
end
6063

@@ -70,13 +73,20 @@ def self.openapi_types
7073
:'total_price_cents_usd' => :'Integer',
7174
:'project_id' => :'String',
7275
:'metadata' => :'Object',
73-
:'state' => :'String'
76+
:'state' => :'String',
77+
:'vintage_year' => :'Integer'
7478
}
7579
end
7680

7781
# List of attributes with nullable: true
7882
def self.openapi_nullable
7983
Set.new([
84+
:'mass_g',
85+
:'total_price_cents_usd',
86+
:'project_id',
87+
:'metadata',
88+
:'state',
89+
:'vintage_year'
8090
])
8191
end
8292

@@ -126,6 +136,10 @@ def initialize(attributes = {})
126136
if attributes.key?(:'state')
127137
self.state = attributes[:'state']
128138
end
139+
140+
if attributes.key?(:'vintage_year')
141+
self.vintage_year = attributes[:'vintage_year']
142+
end
129143
end
130144

131145
# Show invalid properties with the reasons. Usually used together with valid?
@@ -144,6 +158,14 @@ def list_invalid_properties
144158
invalid_properties.push('invalid value for "total_price_cents_usd", must be greater than or equal to 1.')
145159
end
146160

161+
if !@vintage_year.nil? && @vintage_year > 2100
162+
invalid_properties.push('invalid value for "vintage_year", must be smaller than or equal to 2100.')
163+
end
164+
165+
if !@vintage_year.nil? && @vintage_year < 1900
166+
invalid_properties.push('invalid value for "vintage_year", must be greater than or equal to 1900.')
167+
end
168+
147169
invalid_properties
148170
end
149171

@@ -155,6 +177,8 @@ def valid?
155177
return false if !@total_price_cents_usd.nil? && @total_price_cents_usd < 1
156178
state_validator = EnumAttributeValidator.new('String', ["draft", "placed"])
157179
return false unless state_validator.valid?(@state)
180+
return false if !@vintage_year.nil? && @vintage_year > 2100
181+
return false if !@vintage_year.nil? && @vintage_year < 1900
158182
true
159183
end
160184

@@ -192,6 +216,20 @@ def state=(state)
192216
@state = state
193217
end
194218

219+
# Custom attribute writer method with validation
220+
# @param [Object] vintage_year Value to be assigned
221+
def vintage_year=(vintage_year)
222+
if !vintage_year.nil? && vintage_year > 2100
223+
fail ArgumentError, 'invalid value for "vintage_year", must be smaller than or equal to 2100.'
224+
end
225+
226+
if !vintage_year.nil? && vintage_year < 1900
227+
fail ArgumentError, 'invalid value for "vintage_year", must be greater than or equal to 1900.'
228+
end
229+
230+
@vintage_year = vintage_year
231+
end
232+
195233
# Checks equality by comparing each attribute.
196234
# @param [Object] Object to be compared
197235
def ==(o)
@@ -201,7 +239,8 @@ def ==(o)
201239
total_price_cents_usd == o.total_price_cents_usd &&
202240
project_id == o.project_id &&
203241
metadata == o.metadata &&
204-
state == o.state
242+
state == o.state &&
243+
vintage_year == o.vintage_year
205244
end
206245

207246
# @see the `==` method
@@ -213,7 +252,7 @@ def eql?(o)
213252
# Calculates hash code according to all attributes.
214253
# @return [Integer] Hash code
215254
def hash
216-
[mass_g, total_price_cents_usd, project_id, metadata, state].hash
255+
[mass_g, total_price_cents_usd, project_id, metadata, state, vintage_year].hash
217256
end
218257

219258
# Builds the object from hash

lib/patch_ruby/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
=end
1212

1313
module Patch
14-
VERSION = '1.19.0'
14+
VERSION = '1.20.0'
1515
end

spec/integration/orders_spec.rb

+9
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,13 @@
107107
cancel_order_response = Patch::Order.cancel_order(order_to_cancel_id)
108108
expect(cancel_order_response.data.state).to eq 'cancelled'
109109
end
110+
111+
it 'supports create with a vintage year' do
112+
create_order_response =
113+
Patch::Order.create_order(mass_g: 100, vintage_year: 2022)
114+
115+
expect(create_order_response.success).to eq true
116+
expect(create_order_response.data.id).not_to be_nil
117+
expect(create_order_response.data.mass_g).to eq(100)
118+
end
110119
end

spec/models/create_order_request_spec.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
it_behaves_like "a generated class" do
3131
let(:instance) { @instance }
3232
let(:instance_hash) { { project_id: @instance.project_id, mass_g: @instance.mass_g, total_price_cents_usd: @instance.total_price_cents_usd, metadata: @instance.metadata } }
33-
let(:nullable_properties) { Set.new }
33+
let(:nullable_properties) do
34+
Set.new(%i[mass_g total_price_cents_usd project_id metadata state vintage_year])
35+
end
3436
end
3537

3638
describe 'test an instance of CreateOrderRequest' do

0 commit comments

Comments
 (0)