Skip to content

Commit 7b154a0

Browse files
authored
Merge pull request #29 from patch-technology/pc/price
Update parameter validation
2 parents 99d7634 + 3cf6dd7 commit 7b154a0

File tree

9 files changed

+36
-27
lines changed

9 files changed

+36
-27
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,5 @@ build/
4242
.openapi-generator-ignore
4343
/.openapi-generator/
4444

45-
.byebug_history
45+
.byebug_history
46+
.DS_Store

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ 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.5.2] - 2021-03-30
9+
10+
### Changed
11+
12+
- Updated the value validation for certain parameters to match the API
13+
- Added the `renewables` type
14+
815
## [1.5.1] - 2021-03-02
916

1017
### Fixed

Gemfile.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
patch_ruby (1.5.1)
4+
patch_ruby (1.5.2)
55
json (~> 2.1, >= 2.1.0)
66
typhoeus (~> 1.0, >= 1.0.1)
77

@@ -23,7 +23,7 @@ GEM
2323
ffi (>= 1.3.0)
2424
factory_bot (6.1.0)
2525
activesupport (>= 5.0.0)
26-
ffi (1.14.2)
26+
ffi (1.15.0)
2727
i18n (1.8.7)
2828
concurrent-ruby (~> 1.0)
2929
json (2.5.1)
@@ -86,4 +86,4 @@ DEPENDENCIES
8686
rubocop
8787

8888
BUNDLED WITH
89-
2.1.4
89+
2.2.14

lib/patch_ruby/models/create_mass_estimate_request.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ def list_invalid_properties
9898
invalid_properties.push('invalid value for "mass_g", must be smaller than or equal to 2000000000.')
9999
end
100100

101-
if @mass_g < 1
102-
invalid_properties.push('invalid value for "mass_g", must be greater than or equal to 1.')
101+
if @mass_g < 0
102+
invalid_properties.push('invalid value for "mass_g", must be greater than or equal to 0.')
103103
end
104104

105105
invalid_properties
@@ -110,7 +110,7 @@ def list_invalid_properties
110110
def valid?
111111
return false if @mass_g.nil?
112112
return false if @mass_g > 2000000000
113-
return false if @mass_g < 1
113+
return false if @mass_g < 0
114114
true
115115
end
116116

@@ -125,8 +125,8 @@ def mass_g=(mass_g)
125125
fail ArgumentError, 'invalid value for "mass_g", must be smaller than or equal to 2000000000.'
126126
end
127127

128-
if mass_g < 1
129-
fail ArgumentError, 'invalid value for "mass_g", must be greater than or equal to 1.'
128+
if mass_g < 0
129+
fail ArgumentError, 'invalid value for "mass_g", must be greater than or equal to 0.'
130130
end
131131

132132
@mass_g = mass_g

lib/patch_ruby/models/create_order_request.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ def list_invalid_properties
100100
invalid_properties.push('invalid value for "mass_g", must be smaller than or equal to 2000000000.')
101101
end
102102

103-
if !@mass_g.nil? && @mass_g < 1
104-
invalid_properties.push('invalid value for "mass_g", must be greater than or equal to 1.')
103+
if !@mass_g.nil? && @mass_g < 0
104+
invalid_properties.push('invalid value for "mass_g", must be greater than or equal to 0.')
105105
end
106106

107107
if !@total_price_cents_usd.nil? && @total_price_cents_usd < 1
@@ -115,7 +115,7 @@ def list_invalid_properties
115115
# @return true if the model is valid
116116
def valid?
117117
return false if !@mass_g.nil? && @mass_g > 2000000000
118-
return false if !@mass_g.nil? && @mass_g < 1
118+
return false if !@mass_g.nil? && @mass_g < 0
119119
return false if !@total_price_cents_usd.nil? && @total_price_cents_usd < 1
120120
true
121121
end
@@ -127,8 +127,8 @@ def mass_g=(mass_g)
127127
fail ArgumentError, 'invalid value for "mass_g", must be smaller than or equal to 2000000000.'
128128
end
129129

130-
if !mass_g.nil? && mass_g < 1
131-
fail ArgumentError, 'invalid value for "mass_g", must be greater than or equal to 1.'
130+
if !mass_g.nil? && mass_g < 0
131+
fail ArgumentError, 'invalid value for "mass_g", must be greater than or equal to 0.'
132132
end
133133

134134
@mass_g = mass_g

lib/patch_ruby/models/order.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ def list_invalid_properties
185185
invalid_properties.push('invalid value for "mass_g", must be smaller than or equal to 2000000000.')
186186
end
187187

188-
if @mass_g < 1
189-
invalid_properties.push('invalid value for "mass_g", must be greater than or equal to 1.')
188+
if @mass_g < 0
189+
invalid_properties.push('invalid value for "mass_g", must be greater than or equal to 0.')
190190
end
191191

192192
if @production.nil?
@@ -218,7 +218,7 @@ def valid?
218218
return false if @id.nil?
219219
return false if @mass_g.nil?
220220
return false if @mass_g > 2000000000
221-
return false if @mass_g < 1
221+
return false if @mass_g < 0
222222
return false if @production.nil?
223223
return false if @state.nil?
224224
state_validator = EnumAttributeValidator.new('String', ["draft", "placed", "complete", "cancelled"])
@@ -242,8 +242,8 @@ def mass_g=(mass_g)
242242
fail ArgumentError, 'invalid value for "mass_g", must be smaller than or equal to 2000000000.'
243243
end
244244

245-
if mass_g < 1
246-
fail ArgumentError, 'invalid value for "mass_g", must be greater than or equal to 1.'
245+
if mass_g < 0
246+
fail ArgumentError, 'invalid value for "mass_g", must be greater than or equal to 0.'
247247
end
248248

249249
@mass_g = mass_g

lib/patch_ruby/models/project.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Project
2626
# The description of the project.
2727
attr_accessor :description
2828

29-
# The type of carbon removal project, currently available project types are Biomass, Dac, Forestry, Mineralization, Ocean, Soil.
29+
# The type of carbon removal project, currently available project types are Biomass, Dac, Forestry, Mineralization, Ocean, Renewables, Soil.
3030
attr_accessor :type
3131

3232
# The country of origin of the project.
@@ -246,7 +246,7 @@ def valid?
246246
return false if @production.nil?
247247
return false if @name.nil?
248248
return false if @description.nil?
249-
type_validator = EnumAttributeValidator.new('String', ["biomass", "dac", "forestry", "mineralization", "ocean", "soil"])
249+
type_validator = EnumAttributeValidator.new('String', ["biomass", "dac", "forestry", "mineralization", "ocean", "renewables", "soil"])
250250
return false unless type_validator.valid?(@type)
251251
return false if @country.nil?
252252
return false if @developer.nil?
@@ -258,7 +258,7 @@ def valid?
258258
# Custom attribute writer method checking allowed values (enum).
259259
# @param [Object] type Object to be assigned
260260
def type=(type)
261-
validator = EnumAttributeValidator.new('String', ["biomass", "dac", "forestry", "mineralization", "ocean", "soil"])
261+
validator = EnumAttributeValidator.new('String', ["biomass", "dac", "forestry", "mineralization", "ocean", "renewables", "soil"])
262262
unless validator.valid?(type)
263263
fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
264264
end

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.5.1'
14+
VERSION = '1.5.2'
1515
end

spec/integration/orders_spec.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,12 @@
4040

4141
create_order_response = Patch::Order.create_order(mass_g: order_mass_g, project_id: project_id)
4242

43+
order = create_order_response.data
4344
expect(create_order_response.success).to eq true
44-
expect(create_order_response.data.id).not_to be_nil
45-
expect(create_order_response.data.mass_g).to eq(order_mass_g)
46-
expect(create_order_response.data.price_cents_usd.to_i).to eq(expected_price)
47-
expect(create_order_response.data.patch_fee_cents_usd).not_to be_empty
45+
expect(order.id).not_to be_nil
46+
expect(order.mass_g).to eq(order_mass_g)
47+
expect(order.price_cents_usd.to_i).to be_between(expected_price - 1, expected_price + 1)
48+
expect(order.patch_fee_cents_usd).not_to be_empty
4849
end
4950

5051
it 'supports create with a total price' do

0 commit comments

Comments
 (0)