patch_ruby 1.7.0 → 1.10.1
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 +19 -0
- data/Gemfile +1 -2
- data/Gemfile.lock +20 -25
- data/bin/rspec +29 -0
- data/lib/patch_ruby/api/estimates_api.rb +97 -24
- data/lib/patch_ruby/api/orders_api.rb +30 -16
- data/lib/patch_ruby/api/preferences_api.rb +17 -13
- data/lib/patch_ruby/api/projects_api.rb +9 -7
- data/lib/patch_ruby/api_client.rb +51 -49
- data/lib/patch_ruby/api_error.rb +1 -1
- data/lib/patch_ruby/configuration.rb +38 -9
- data/lib/patch_ruby/models/allocation.rb +21 -11
- data/lib/patch_ruby/models/create_bitcoin_estimate_request.rb +25 -19
- data/lib/patch_ruby/models/create_ethereum_estimate_request.rb +269 -0
- data/lib/patch_ruby/models/create_flight_estimate_request.rb +281 -0
- data/lib/patch_ruby/models/create_mass_estimate_request.rb +22 -13
- data/lib/patch_ruby/models/create_order_request.rb +21 -11
- data/lib/patch_ruby/models/create_preference_request.rb +21 -11
- data/lib/patch_ruby/models/create_shipping_estimate_request.rb +371 -0
- data/lib/patch_ruby/models/create_success_response.rb +247 -0
- data/lib/patch_ruby/models/create_vehicle_estimate_request.rb +326 -0
- data/lib/patch_ruby/models/error_response.rb +22 -13
- data/lib/patch_ruby/models/estimate.rb +23 -14
- data/lib/patch_ruby/models/estimate_list_response.rb +22 -13
- data/lib/patch_ruby/models/estimate_response.rb +22 -13
- data/lib/patch_ruby/models/meta_index_object.rb +23 -15
- data/lib/patch_ruby/models/order.rb +23 -15
- data/lib/patch_ruby/models/order_list_response.rb +22 -13
- data/lib/patch_ruby/models/order_response.rb +22 -13
- data/lib/patch_ruby/models/photo.rb +21 -11
- data/lib/patch_ruby/models/preference.rb +21 -11
- data/lib/patch_ruby/models/preference_list_response.rb +22 -13
- data/lib/patch_ruby/models/preference_response.rb +22 -13
- data/lib/patch_ruby/models/project.rb +24 -17
- data/lib/patch_ruby/models/project_list_response.rb +22 -13
- data/lib/patch_ruby/models/project_response.rb +22 -13
- data/lib/patch_ruby/models/sdg.rb +21 -11
- data/lib/patch_ruby/models/standard.rb +21 -11
- data/lib/patch_ruby/version.rb +2 -2
- data/lib/patch_ruby.rb +6 -1
- data/patch_ruby.gemspec +7 -3
- data/spec/api_client_spec.rb +34 -13
- data/spec/configuration_spec.rb +1 -1
- data/spec/integration/estimates_spec.rb +34 -7
- data/spec/integration/orders_spec.rb +11 -8
- data/spec/integration/preferences_spec.rb +1 -7
- data/spec/integration/projects_spec.rb +5 -17
- data/spec/models/create_mass_estimate_request_spec.rb +1 -1
- data/spec/models/error_response_spec.rb +1 -1
- data/spec/models/estimate_list_response_spec.rb +1 -1
- data/spec/models/estimate_response_spec.rb +1 -1
- data/spec/models/estimate_spec.rb +1 -1
- data/spec/models/meta_index_object_spec.rb +1 -1
- data/spec/models/order_list_response_spec.rb +1 -1
- data/spec/models/order_response_spec.rb +1 -1
- data/spec/models/order_spec.rb +1 -1
- data/spec/models/preference_list_response_spec.rb +1 -1
- data/spec/models/preference_response_spec.rb +1 -1
- data/spec/models/project_list_response_spec.rb +1 -1
- data/spec/models/project_response_spec.rb +1 -1
- data/spec/models/project_spec.rb +1 -1
- data/spec/spec_helper.rb +70 -54
- metadata +41 -41
|
@@ -6,11 +6,12 @@
|
|
|
6
6
|
The version of the OpenAPI document: v1
|
|
7
7
|
Contact: developers@usepatch.com
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
|
-
OpenAPI Generator version:
|
|
9
|
+
OpenAPI Generator version: 5.2.1
|
|
10
10
|
|
|
11
11
|
=end
|
|
12
12
|
|
|
13
13
|
require 'date'
|
|
14
|
+
require 'time'
|
|
14
15
|
|
|
15
16
|
module Patch
|
|
16
17
|
class Sdg
|
|
@@ -36,6 +37,11 @@ module Patch
|
|
|
36
37
|
}
|
|
37
38
|
end
|
|
38
39
|
|
|
40
|
+
# Returns all the JSON keys this model knows about
|
|
41
|
+
def self.acceptable_attributes
|
|
42
|
+
attribute_map.values
|
|
43
|
+
end
|
|
44
|
+
|
|
39
45
|
# Attribute type mapping.
|
|
40
46
|
def self.openapi_types
|
|
41
47
|
{
|
|
@@ -46,13 +52,13 @@ module Patch
|
|
|
46
52
|
}
|
|
47
53
|
end
|
|
48
54
|
|
|
49
|
-
#
|
|
55
|
+
# List of attributes with nullable: true
|
|
50
56
|
def self.openapi_nullable
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
nullable_properties
|
|
57
|
+
Set.new([
|
|
58
|
+
])
|
|
54
59
|
end
|
|
55
60
|
|
|
61
|
+
|
|
56
62
|
# Allows models with corresponding API classes to delegate API operations to those API classes
|
|
57
63
|
# Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
|
|
58
64
|
# Eg. Order.create_order delegates to OrdersApi.new.create_order
|
|
@@ -165,7 +171,9 @@ module Patch
|
|
|
165
171
|
def build_from_hash(attributes)
|
|
166
172
|
return nil unless attributes.is_a?(Hash)
|
|
167
173
|
self.class.openapi_types.each_pair do |key, type|
|
|
168
|
-
if
|
|
174
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
|
175
|
+
self.send("#{key}=", nil)
|
|
176
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
169
177
|
# check to ensure the input is an array given that the attribute
|
|
170
178
|
# is documented as an array but the input is not
|
|
171
179
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
@@ -173,7 +181,7 @@ module Patch
|
|
|
173
181
|
end
|
|
174
182
|
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
175
183
|
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
176
|
-
end
|
|
184
|
+
end
|
|
177
185
|
end
|
|
178
186
|
|
|
179
187
|
self
|
|
@@ -185,8 +193,8 @@ module Patch
|
|
|
185
193
|
# @return [Object] Deserialized data
|
|
186
194
|
def _deserialize(type, value)
|
|
187
195
|
case type.to_sym
|
|
188
|
-
when :
|
|
189
|
-
|
|
196
|
+
when :Time
|
|
197
|
+
Time.parse(value)
|
|
190
198
|
when :Date
|
|
191
199
|
Date.parse(value)
|
|
192
200
|
when :String
|
|
@@ -216,7 +224,9 @@ module Patch
|
|
|
216
224
|
end
|
|
217
225
|
end
|
|
218
226
|
else # model
|
|
219
|
-
|
|
227
|
+
# models (e.g. Pet) or oneOf
|
|
228
|
+
klass = Patch.const_get(type)
|
|
229
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
220
230
|
end
|
|
221
231
|
end
|
|
222
232
|
|
|
@@ -242,7 +252,7 @@ module Patch
|
|
|
242
252
|
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
243
253
|
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
244
254
|
end
|
|
245
|
-
|
|
255
|
+
|
|
246
256
|
hash[param] = _to_hash(value)
|
|
247
257
|
end
|
|
248
258
|
hash
|
|
@@ -6,11 +6,12 @@
|
|
|
6
6
|
The version of the OpenAPI document: v1
|
|
7
7
|
Contact: developers@usepatch.com
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
|
-
OpenAPI Generator version:
|
|
9
|
+
OpenAPI Generator version: 5.2.1
|
|
10
10
|
|
|
11
11
|
=end
|
|
12
12
|
|
|
13
13
|
require 'date'
|
|
14
|
+
require 'time'
|
|
14
15
|
|
|
15
16
|
module Patch
|
|
16
17
|
class Standard
|
|
@@ -32,6 +33,11 @@ module Patch
|
|
|
32
33
|
}
|
|
33
34
|
end
|
|
34
35
|
|
|
36
|
+
# Returns all the JSON keys this model knows about
|
|
37
|
+
def self.acceptable_attributes
|
|
38
|
+
attribute_map.values
|
|
39
|
+
end
|
|
40
|
+
|
|
35
41
|
# Attribute type mapping.
|
|
36
42
|
def self.openapi_types
|
|
37
43
|
{
|
|
@@ -41,13 +47,13 @@ module Patch
|
|
|
41
47
|
}
|
|
42
48
|
end
|
|
43
49
|
|
|
44
|
-
#
|
|
50
|
+
# List of attributes with nullable: true
|
|
45
51
|
def self.openapi_nullable
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
nullable_properties
|
|
52
|
+
Set.new([
|
|
53
|
+
])
|
|
49
54
|
end
|
|
50
55
|
|
|
56
|
+
|
|
51
57
|
# Allows models with corresponding API classes to delegate API operations to those API classes
|
|
52
58
|
# Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
|
|
53
59
|
# Eg. Order.create_order delegates to OrdersApi.new.create_order
|
|
@@ -150,7 +156,9 @@ module Patch
|
|
|
150
156
|
def build_from_hash(attributes)
|
|
151
157
|
return nil unless attributes.is_a?(Hash)
|
|
152
158
|
self.class.openapi_types.each_pair do |key, type|
|
|
153
|
-
if
|
|
159
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
|
160
|
+
self.send("#{key}=", nil)
|
|
161
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
154
162
|
# check to ensure the input is an array given that the attribute
|
|
155
163
|
# is documented as an array but the input is not
|
|
156
164
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
@@ -158,7 +166,7 @@ module Patch
|
|
|
158
166
|
end
|
|
159
167
|
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
160
168
|
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
161
|
-
end
|
|
169
|
+
end
|
|
162
170
|
end
|
|
163
171
|
|
|
164
172
|
self
|
|
@@ -170,8 +178,8 @@ module Patch
|
|
|
170
178
|
# @return [Object] Deserialized data
|
|
171
179
|
def _deserialize(type, value)
|
|
172
180
|
case type.to_sym
|
|
173
|
-
when :
|
|
174
|
-
|
|
181
|
+
when :Time
|
|
182
|
+
Time.parse(value)
|
|
175
183
|
when :Date
|
|
176
184
|
Date.parse(value)
|
|
177
185
|
when :String
|
|
@@ -201,7 +209,9 @@ module Patch
|
|
|
201
209
|
end
|
|
202
210
|
end
|
|
203
211
|
else # model
|
|
204
|
-
|
|
212
|
+
# models (e.g. Pet) or oneOf
|
|
213
|
+
klass = Patch.const_get(type)
|
|
214
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
205
215
|
end
|
|
206
216
|
end
|
|
207
217
|
|
|
@@ -227,7 +237,7 @@ module Patch
|
|
|
227
237
|
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
228
238
|
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
229
239
|
end
|
|
230
|
-
|
|
240
|
+
|
|
231
241
|
hash[param] = _to_hash(value)
|
|
232
242
|
end
|
|
233
243
|
hash
|
data/lib/patch_ruby/version.rb
CHANGED
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
The version of the OpenAPI document: v1
|
|
7
7
|
Contact: developers@usepatch.com
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
|
-
OpenAPI Generator version:
|
|
9
|
+
OpenAPI Generator version: 5.2.1
|
|
10
10
|
|
|
11
11
|
=end
|
|
12
12
|
|
|
13
13
|
module Patch
|
|
14
|
-
VERSION = '1.
|
|
14
|
+
VERSION = '1.10.1'
|
|
15
15
|
end
|
data/lib/patch_ruby.rb
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
The version of the OpenAPI document: v1
|
|
7
7
|
Contact: developers@usepatch.com
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
|
-
OpenAPI Generator version:
|
|
9
|
+
OpenAPI Generator version: 5.2.1
|
|
10
10
|
|
|
11
11
|
=end
|
|
12
12
|
|
|
@@ -19,9 +19,14 @@ require 'patch_ruby/configuration'
|
|
|
19
19
|
# Models
|
|
20
20
|
require 'patch_ruby/models/allocation'
|
|
21
21
|
require 'patch_ruby/models/create_bitcoin_estimate_request'
|
|
22
|
+
require 'patch_ruby/models/create_ethereum_estimate_request'
|
|
23
|
+
require 'patch_ruby/models/create_flight_estimate_request'
|
|
22
24
|
require 'patch_ruby/models/create_mass_estimate_request'
|
|
23
25
|
require 'patch_ruby/models/create_order_request'
|
|
24
26
|
require 'patch_ruby/models/create_preference_request'
|
|
27
|
+
require 'patch_ruby/models/create_shipping_estimate_request'
|
|
28
|
+
require 'patch_ruby/models/create_success_response'
|
|
29
|
+
require 'patch_ruby/models/create_vehicle_estimate_request'
|
|
25
30
|
require 'patch_ruby/models/error_response'
|
|
26
31
|
require 'patch_ruby/models/estimate'
|
|
27
32
|
require 'patch_ruby/models/estimate_list_response'
|
data/patch_ruby.gemspec
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
The version of the OpenAPI document: v1
|
|
9
9
|
Contact: developers@usepatch.com
|
|
10
10
|
Generated by: https://openapi-generator.tech
|
|
11
|
-
OpenAPI Generator version:
|
|
11
|
+
OpenAPI Generator version: 5.2.1
|
|
12
12
|
|
|
13
13
|
=end
|
|
14
14
|
|
|
@@ -24,11 +24,10 @@ Gem::Specification.new do |s|
|
|
|
24
24
|
s.homepage = "https://www.patch.io"
|
|
25
25
|
s.summary = "Ruby wrapper for the Patch API"
|
|
26
26
|
s.description = "Ruby wrapper for the Patch API"
|
|
27
|
-
s.license =
|
|
27
|
+
s.license = "MIT"
|
|
28
28
|
s.required_ruby_version = ">= 1.9"
|
|
29
29
|
|
|
30
30
|
s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
|
|
31
|
-
s.add_runtime_dependency 'json', '~> 2.1', '>= 2.1.0'
|
|
32
31
|
|
|
33
32
|
s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0'
|
|
34
33
|
|
|
@@ -36,4 +35,9 @@ Gem::Specification.new do |s|
|
|
|
36
35
|
s.test_files = `find spec/*`.split("\n")
|
|
37
36
|
s.executables = []
|
|
38
37
|
s.require_paths = ["lib"]
|
|
38
|
+
|
|
39
|
+
# Start custom
|
|
40
|
+
s.add_development_dependency 'factory_bot', '~> 6.2'
|
|
41
|
+
# End custom
|
|
42
|
+
|
|
39
43
|
end
|
data/spec/api_client_spec.rb
CHANGED
|
@@ -6,26 +6,47 @@
|
|
|
6
6
|
The version of the OpenAPI document: v1
|
|
7
7
|
Contact: developers@usepatch.com
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
|
-
OpenAPI Generator version:
|
|
9
|
+
OpenAPI Generator version: 5.2.1
|
|
10
10
|
|
|
11
11
|
=end
|
|
12
12
|
|
|
13
|
+
require 'spec_helper'
|
|
14
|
+
|
|
13
15
|
describe Patch::ApiClient do
|
|
14
16
|
context 'initialization' do
|
|
15
|
-
context '
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
context 'URL stuff' do
|
|
18
|
+
context 'host' do
|
|
19
|
+
it 'removes http from host' do
|
|
20
|
+
Patch.configure { |c| c.host = 'http://example.com' }
|
|
21
|
+
expect(Patch::Configuration.default.host).to eq('example.com')
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'removes https from host' do
|
|
25
|
+
Patch.configure { |c| c.host = 'https://wookiee.com' }
|
|
26
|
+
expect(Patch::ApiClient.default.config.host).to eq('wookiee.com')
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'removes trailing path from host' do
|
|
30
|
+
Patch.configure { |c| c.host = 'hobo.com/v4' }
|
|
31
|
+
expect(Patch::Configuration.default.host).to eq('hobo.com')
|
|
32
|
+
end
|
|
24
33
|
end
|
|
25
34
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
35
|
+
context 'base_path' do
|
|
36
|
+
it "prepends a slash to base_path" do
|
|
37
|
+
Patch.configure { |c| c.base_path = 'v4/dog' }
|
|
38
|
+
expect(Patch::Configuration.default.base_path).to eq('/v4/dog')
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "doesn't prepend a slash if one is already there" do
|
|
42
|
+
Patch.configure { |c| c.base_path = '/v4/dog' }
|
|
43
|
+
expect(Patch::Configuration.default.base_path).to eq('/v4/dog')
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "ends up as a blank string if nil" do
|
|
47
|
+
Patch.configure { |c| c.base_path = nil }
|
|
48
|
+
expect(Patch::Configuration.default.base_path).to eq('')
|
|
49
|
+
end
|
|
29
50
|
end
|
|
30
51
|
end
|
|
31
52
|
end
|
data/spec/configuration_spec.rb
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
RSpec.describe 'Estimates Integration' do
|
|
2
|
-
before do
|
|
3
|
-
Patch.configure do |config|
|
|
4
|
-
config.access_token = ENV['SANDBOX_API_KEY']
|
|
5
|
-
end
|
|
6
|
-
end
|
|
7
|
-
|
|
8
2
|
it 'supports create, retrieve and list' do
|
|
9
3
|
create_estimate_response = Patch::Estimate.create_mass_estimate(mass_g: 100)
|
|
10
4
|
estimate_id = create_estimate_response.data.id
|
|
@@ -33,7 +27,7 @@ RSpec.describe 'Estimates Integration' do
|
|
|
33
27
|
)
|
|
34
28
|
|
|
35
29
|
expect(flight_estimate.data.type).to eq 'flight'
|
|
36
|
-
expect(flight_estimate.data.mass_g).to eq
|
|
30
|
+
expect(flight_estimate.data.mass_g).to eq 1_000_622
|
|
37
31
|
end
|
|
38
32
|
|
|
39
33
|
it 'supports creating vehicle estimates' do
|
|
@@ -99,4 +93,37 @@ RSpec.describe 'Estimates Integration' do
|
|
|
99
93
|
expect(bitcoin_estimate.data.type).to eq 'bitcoin'
|
|
100
94
|
expect(bitcoin_estimate.data.mass_g).to be < bitcoin_estimate_2.data.mass_g
|
|
101
95
|
end
|
|
96
|
+
|
|
97
|
+
it 'supports creating bitcoin estimates with a timestamp' do
|
|
98
|
+
bitcoin_estimate_1 = Patch::Estimate.create_bitcoin_estimate(
|
|
99
|
+
timestamp: '2021-06-01T20:31:18.403Z'
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
bitcoin_estimate_2 = Patch::Estimate.create_bitcoin_estimate(
|
|
103
|
+
timestamp: '2021-07-01T20:31:18.403Z'
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
expect(bitcoin_estimate_1.data.type).to eq 'bitcoin'
|
|
107
|
+
expect(bitcoin_estimate_1.data.mass_g).to be > bitcoin_estimate_2.data.mass_g # Bitcoin was emitting less in July 2021 than in June
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
it 'supports creating ethereum estimates with a gas amount' do
|
|
111
|
+
ethereum_estimate = Patch::Estimate.create_ethereum_estimate(
|
|
112
|
+
gas_used: 100
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
ethereum_estimate_2 = Patch::Estimate.create_ethereum_estimate(
|
|
116
|
+
gas_used: 1000
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
expect(ethereum_estimate.data.type).to eq 'ethereum'
|
|
120
|
+
expect(ethereum_estimate.data.mass_g).to be < ethereum_estimate_2.data.mass_g
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
it 'supports creating ethereum estimates with partial information' do
|
|
124
|
+
ethereum_estimate = Patch::Estimate.create_ethereum_estimate({ create_order: false })
|
|
125
|
+
|
|
126
|
+
expect(ethereum_estimate.data.type).to eq 'ethereum'
|
|
127
|
+
expect(ethereum_estimate.data.mass_g).to be >= 2_000
|
|
128
|
+
end
|
|
102
129
|
end
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
RSpec.describe 'Orders Integration' do
|
|
2
|
-
before do
|
|
3
|
-
Patch.configure do |config|
|
|
4
|
-
config.access_token = ENV['SANDBOX_API_KEY']
|
|
5
|
-
end
|
|
6
|
-
end
|
|
7
|
-
|
|
8
2
|
it 'supports create, place, cancel, retrieve and list' do
|
|
9
3
|
create_order_response = Patch::Order.create_order(mass_g: 100)
|
|
10
4
|
order_id = create_order_response.data.id
|
|
@@ -71,15 +65,24 @@ RSpec.describe 'Orders Integration' do
|
|
|
71
65
|
expect(order.registry_url).not_to be_empty
|
|
72
66
|
end
|
|
73
67
|
|
|
74
|
-
it 'supports
|
|
68
|
+
it 'supports creation with and querying by metadata' do
|
|
75
69
|
metadata = { user: 'john doe' }
|
|
76
70
|
|
|
77
|
-
create_order_response =
|
|
71
|
+
create_order_response =
|
|
72
|
+
Patch::Order.create_order(mass_g: 100, metadata: metadata)
|
|
78
73
|
|
|
79
74
|
expect(create_order_response.success).to eq true
|
|
80
75
|
expect(create_order_response.data.id).not_to be_nil
|
|
81
76
|
expect(create_order_response.data.mass_g).to eq(100)
|
|
82
77
|
expect(create_order_response.data.metadata).to eq(metadata)
|
|
78
|
+
|
|
79
|
+
retrieve_orders_response = Patch::Order.retrieve_orders(
|
|
80
|
+
page: 1, metadata: { user: 'john' }
|
|
81
|
+
)
|
|
82
|
+
expect(retrieve_orders_response.success).to eq true
|
|
83
|
+
expect(retrieve_orders_response.data.count).to be >= 1
|
|
84
|
+
expect(retrieve_orders_response.data.map(&:metadata))
|
|
85
|
+
.to all(have_key(:user))
|
|
83
86
|
end
|
|
84
87
|
|
|
85
88
|
it 'supports place and cancel for orders created via an estimate' do
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
RSpec.describe 'Preferences Integration' do
|
|
2
|
-
before do
|
|
3
|
-
Patch.configure do |config|
|
|
4
|
-
config.access_token = ENV['SANDBOX_API_KEY']
|
|
5
|
-
end
|
|
6
|
-
end
|
|
7
|
-
|
|
8
2
|
it 'supports create, delete, retrieve and list' do
|
|
9
3
|
retrieve_projects_response = Patch::Project.retrieve_projects
|
|
10
4
|
expect(retrieve_projects_response.data.length).not_to be_zero
|
|
@@ -13,7 +7,7 @@ RSpec.describe 'Preferences Integration' do
|
|
|
13
7
|
begin
|
|
14
8
|
create_preference_response = Patch::Preference.create_preference(project_id: project_id)
|
|
15
9
|
preference_id = create_preference_response.data.id
|
|
16
|
-
rescue
|
|
10
|
+
rescue Patch::ApiError => e
|
|
17
11
|
preference_id = Patch::Preference.retrieve_preferences().data.first.id
|
|
18
12
|
end
|
|
19
13
|
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
RSpec.describe 'Projects Integration' do
|
|
2
|
-
Patch.configure do |config|
|
|
3
|
-
config.access_token = ENV['SANDBOX_API_KEY']
|
|
4
|
-
end
|
|
5
|
-
|
|
6
2
|
it 'supports retrieve and list' do
|
|
7
3
|
page_limit = 1
|
|
8
4
|
next_page = 1
|
|
@@ -43,20 +39,12 @@ RSpec.describe 'Projects Integration' do
|
|
|
43
39
|
end
|
|
44
40
|
|
|
45
41
|
describe 'returned fields' do
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
it 'returns photos' do
|
|
51
|
-
expect(@project.photos).to be_an_instance_of(Array)
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
it 'returns average_price_per_tonne_cents_usd' do
|
|
55
|
-
expect(@project.average_price_per_tonne_cents_usd).to be_an_instance_of(Integer)
|
|
56
|
-
end
|
|
42
|
+
it 'returns the expected fields' do
|
|
43
|
+
project = Patch::Project.retrieve_projects(page: 1).data.first
|
|
57
44
|
|
|
58
|
-
|
|
59
|
-
expect(
|
|
45
|
+
expect(project.photos).to be_an_instance_of(Array)
|
|
46
|
+
expect(project.average_price_per_tonne_cents_usd).to be_an_instance_of(Integer)
|
|
47
|
+
expect(project.remaining_mass_g).to be_an_instance_of(Integer)
|
|
60
48
|
end
|
|
61
49
|
end
|
|
62
50
|
end
|