patch_ruby 1.2.2 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +1 -1
- data/Makefile +10 -0
- data/README.md +2 -2
- data/lib/patch_ruby/models/order.rb +10 -1
- data/lib/patch_ruby/models/photo.rb +5 -0
- data/lib/patch_ruby/version.rb +1 -1
- data/spec/constants.rb +3 -0
- data/spec/integration/estimates_spec.rb +1 -1
- data/spec/integration/orders_spec.rb +16 -5
- data/spec/integration/preferences_spec.rb +1 -1
- data/spec/integration/projects_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -0
- metadata +21 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5a1eec7fccc6caad29eefa746c0318b3ee7c2b52ff3694e999bb1bf8086595a
|
4
|
+
data.tar.gz: f3acf2fe8fdf86c68b9d4bce4b4e399e9137aae7414fac9e89f96ddecd8f25a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e21d7cb2d176d1b5620f1d44a1c2df35cdea882e888ec7a894dbeb1991734508fe54f2b9be71153022d5f29755925d2e06217f9c50c1405471bed819efd4ded
|
7
|
+
data.tar.gz: c10d3372f00070ede5a70b39fe248c5065d8e5fd8fb1ef890add6581fa6ab374487d8594728d437d8aacf34e4b9cba0c71c0de69c89e4eb0259750f55140e621
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/Makefile
ADDED
data/README.md
CHANGED
@@ -38,7 +38,7 @@ require 'patch_ruby'
|
|
38
38
|
|
39
39
|
Patch.configure do |config|
|
40
40
|
# Configure the Patch gem with your API key here
|
41
|
-
config.access_token = ENV['
|
41
|
+
config.access_token = ENV['SANDBOX_API_KEY']
|
42
42
|
end
|
43
43
|
```
|
44
44
|
|
@@ -161,7 +161,7 @@ $ bundle install
|
|
161
161
|
|
162
162
|
Set up required environment variables:
|
163
163
|
```
|
164
|
-
$ export
|
164
|
+
$ export SANDBOX_API_KEY=<SANDBOX API KEY>
|
165
165
|
```
|
166
166
|
|
167
167
|
Run tests:
|
@@ -26,6 +26,8 @@ module Patch
|
|
26
26
|
|
27
27
|
attr_accessor :price_cents_usd
|
28
28
|
|
29
|
+
attr_accessor :patch_fee_cents_usd
|
30
|
+
|
29
31
|
attr_accessor :allocations
|
30
32
|
|
31
33
|
attr_accessor :metadata
|
@@ -61,6 +63,7 @@ module Patch
|
|
61
63
|
:'state' => :'state',
|
62
64
|
:'allocation_state' => :'allocation_state',
|
63
65
|
:'price_cents_usd' => :'price_cents_usd',
|
66
|
+
:'patch_fee_cents_usd' => :'patch_fee_cents_usd',
|
64
67
|
:'allocations' => :'allocations',
|
65
68
|
:'metadata' => :'metadata'
|
66
69
|
}
|
@@ -75,6 +78,7 @@ module Patch
|
|
75
78
|
:'state' => :'String',
|
76
79
|
:'allocation_state' => :'String',
|
77
80
|
:'price_cents_usd' => :'String',
|
81
|
+
:'patch_fee_cents_usd' => :'String',
|
78
82
|
:'allocations' => :'Array<Allocation>',
|
79
83
|
:'metadata' => :'Object'
|
80
84
|
}
|
@@ -130,6 +134,10 @@ module Patch
|
|
130
134
|
self.price_cents_usd = attributes[:'price_cents_usd']
|
131
135
|
end
|
132
136
|
|
137
|
+
if attributes.key?(:'patch_fee_cents_usd')
|
138
|
+
self.patch_fee_cents_usd = attributes[:'patch_fee_cents_usd']
|
139
|
+
end
|
140
|
+
|
133
141
|
if attributes.key?(:'allocations')
|
134
142
|
if (value = attributes[:'allocations']).is_a?(Array)
|
135
143
|
self.allocations = value
|
@@ -252,6 +260,7 @@ module Patch
|
|
252
260
|
state == o.state &&
|
253
261
|
allocation_state == o.allocation_state &&
|
254
262
|
price_cents_usd == o.price_cents_usd &&
|
263
|
+
patch_fee_cents_usd == o.patch_fee_cents_usd &&
|
255
264
|
allocations == o.allocations &&
|
256
265
|
metadata == o.metadata
|
257
266
|
end
|
@@ -265,7 +274,7 @@ module Patch
|
|
265
274
|
# Calculates hash code according to all attributes.
|
266
275
|
# @return [Integer] Hash code
|
267
276
|
def hash
|
268
|
-
[id, mass_g, production, state, allocation_state, price_cents_usd, allocations, metadata].hash
|
277
|
+
[id, mass_g, production, state, allocation_state, price_cents_usd, patch_fee_cents_usd, allocations, metadata].hash
|
269
278
|
end
|
270
279
|
|
271
280
|
# Builds the object from hash
|
@@ -65,12 +65,17 @@ module Patch
|
|
65
65
|
# @return Array for valid properties with the reasons
|
66
66
|
def list_invalid_properties
|
67
67
|
invalid_properties = Array.new
|
68
|
+
if @url.nil?
|
69
|
+
invalid_properties.push('invalid value for "url", url cannot be nil.')
|
70
|
+
end
|
71
|
+
|
68
72
|
invalid_properties
|
69
73
|
end
|
70
74
|
|
71
75
|
# Check to see if the all the properties in the model are valid
|
72
76
|
# @return true if the model is valid
|
73
77
|
def valid?
|
78
|
+
return false if @url.nil?
|
74
79
|
true
|
75
80
|
end
|
76
81
|
|
data/lib/patch_ruby/version.rb
CHANGED
data/spec/constants.rb
ADDED
@@ -1,7 +1,7 @@
|
|
1
1
|
RSpec.describe 'Orders Integration' do
|
2
2
|
before do
|
3
3
|
Patch.configure do |config|
|
4
|
-
config.access_token = ENV['
|
4
|
+
config.access_token = ENV['SANDBOX_API_KEY']
|
5
5
|
end
|
6
6
|
end
|
7
7
|
|
@@ -26,14 +26,25 @@ RSpec.describe 'Orders Integration' do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'supports create with a project-id' do
|
29
|
-
|
30
|
-
|
29
|
+
retrieve_project_response = Patch::Project.retrieve_project(
|
30
|
+
Constants::BIOMASS_TEST_PROJECT_ID
|
31
|
+
)
|
31
32
|
|
32
|
-
|
33
|
+
project_id = retrieve_project_response.data.id
|
34
|
+
average_price_per_tonne_cents_usd = retrieve_project_response.data.average_price_per_tonne_cents_usd
|
35
|
+
|
36
|
+
order_mass_g = 100_000
|
37
|
+
tonne_per_gram = 1_000_000
|
38
|
+
|
39
|
+
expected_price = (average_price_per_tonne_cents_usd.to_f / tonne_per_gram) * order_mass_g
|
40
|
+
|
41
|
+
create_order_response = Patch::Order.create_order(mass_g: order_mass_g, project_id: project_id)
|
33
42
|
|
34
43
|
expect(create_order_response.success).to eq true
|
35
44
|
expect(create_order_response.data.id).not_to be_nil
|
36
|
-
expect(create_order_response.data.mass_g).to eq(
|
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
|
37
48
|
end
|
38
49
|
|
39
50
|
it 'supports create with metadata' do
|
data/spec/spec_helper.rb
CHANGED
@@ -12,6 +12,7 @@ OpenAPI Generator version: 4.3.1
|
|
12
12
|
|
13
13
|
# load the gem
|
14
14
|
require 'patch_ruby'
|
15
|
+
require 'constants'
|
15
16
|
|
16
17
|
# The following was generated by the `rspec --init` command. Conventionally, all
|
17
18
|
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: patch_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patch Technology
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|
@@ -80,6 +80,7 @@ files:
|
|
80
80
|
- CHANGELOG.md
|
81
81
|
- Gemfile
|
82
82
|
- Gemfile.lock
|
83
|
+
- Makefile
|
83
84
|
- README.md
|
84
85
|
- Rakefile
|
85
86
|
- lib/patch_ruby.rb
|
@@ -118,6 +119,7 @@ files:
|
|
118
119
|
- spec/api/projects_api_spec.rb
|
119
120
|
- spec/api_client_spec.rb
|
120
121
|
- spec/configuration_spec.rb
|
122
|
+
- spec/constants.rb
|
121
123
|
- spec/integration/estimates_spec.rb
|
122
124
|
- spec/integration/orders_spec.rb
|
123
125
|
- spec/integration/preferences_spec.rb
|
@@ -165,32 +167,33 @@ signing_key:
|
|
165
167
|
specification_version: 4
|
166
168
|
summary: Ruby wrapper for the Patch API
|
167
169
|
test_files:
|
168
|
-
- spec/api/projects_api_spec.rb
|
169
|
-
- spec/api/estimates_api_spec.rb
|
170
170
|
- spec/api/preferences_api_spec.rb
|
171
|
+
- spec/api/estimates_api_spec.rb
|
171
172
|
- spec/api/orders_api_spec.rb
|
173
|
+
- spec/api/projects_api_spec.rb
|
172
174
|
- spec/api_client_spec.rb
|
173
175
|
- spec/configuration_spec.rb
|
174
|
-
- spec/
|
175
|
-
- spec/integration/preferences_spec.rb
|
176
|
+
- spec/constants.rb
|
176
177
|
- spec/integration/projects_spec.rb
|
178
|
+
- spec/integration/preferences_spec.rb
|
179
|
+
- spec/integration/estimates_spec.rb
|
177
180
|
- spec/integration/orders_spec.rb
|
178
|
-
- spec/models/order_spec.rb
|
179
181
|
- spec/models/order_response_spec.rb
|
180
|
-
- spec/models/create_preference_request_spec.rb
|
181
|
-
- spec/models/allocation_spec.rb
|
182
|
-
- spec/models/project_list_response_spec.rb
|
183
|
-
- spec/models/project_response_spec.rb
|
184
|
-
- spec/models/order_list_response_spec.rb
|
185
|
-
- spec/models/preference_spec.rb
|
186
|
-
- spec/models/estimate_spec.rb
|
187
182
|
- spec/models/estimate_list_response_spec.rb
|
188
|
-
- spec/models/
|
189
|
-
- spec/models/create_order_request_spec.rb
|
183
|
+
- spec/models/project_spec.rb
|
190
184
|
- spec/models/estimate_response_spec.rb
|
185
|
+
- spec/models/project_response_spec.rb
|
186
|
+
- spec/models/error_response_spec.rb
|
187
|
+
- spec/models/estimate_spec.rb
|
191
188
|
- spec/models/create_mass_estimate_request_spec.rb
|
189
|
+
- spec/models/project_list_response_spec.rb
|
190
|
+
- spec/models/preference_spec.rb
|
191
|
+
- spec/models/create_order_request_spec.rb
|
192
|
+
- spec/models/order_list_response_spec.rb
|
192
193
|
- spec/models/preference_list_response_spec.rb
|
193
|
-
- spec/models/
|
194
|
-
- spec/models/
|
194
|
+
- spec/models/preference_response_spec.rb
|
195
|
+
- spec/models/allocation_spec.rb
|
196
|
+
- spec/models/order_spec.rb
|
195
197
|
- spec/models/meta_index_object_spec.rb
|
198
|
+
- spec/models/create_preference_request_spec.rb
|
196
199
|
- spec/spec_helper.rb
|