patch_ruby 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -1
- data/Gemfile.lock +3 -3
- data/README.md +18 -0
- data/lib/patch_ruby/api/projects_api.rb +9 -0
- data/lib/patch_ruby/models/project.rb +18 -4
- data/lib/patch_ruby/models/sdg.rb +269 -0
- data/lib/patch_ruby/version.rb +1 -1
- data/spec/integration/estimates_spec.rb +14 -2
- data/spec/integration/orders_spec.rb +1 -1
- data/spec/integration/projects_spec.rb +20 -0
- data/spec/models/project_spec.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01dd6e1760357bf0a43bc0244e3bd6dddb5dbfe30917f5882e78faf8e76b0c70
|
4
|
+
data.tar.gz: be17b49e72c7132fbc7a4b6a5dbe19704eda14fd17ef5dc4a89c7fdbd154547a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04d0e212d6aac27ebf643a1800e2a34ac3b9f2f37c5439e3497bf2d690cf106f01899e59efbafa7b9e6ab01de76b25603e83e469e0462c8a091e81a3e8130acb
|
7
|
+
data.tar.gz: '08d93d9433299ba112efca8ecd0a1838016684cb05a2b3a80d8c44249c2fda6ed7dc6f1684bad9b5f37a3121ab7ab2a60bd91ab0a5566d8c85e4863cd8f7dccc'
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
+
## [1.4.0] - 2021-02-15
|
9
|
+
|
10
|
+
### Added
|
11
|
+
|
12
|
+
- Adds Sustainable Development Goals (SDGs) field to projects
|
13
|
+
- Adds filtering to Projects by country, type, minimum_available_mass
|
14
|
+
|
15
|
+
### Changed
|
16
|
+
|
17
|
+
- vehicle estimates now support optional `make`, `model` and `year` fields.
|
18
|
+
|
8
19
|
## [1.3.0] - 2021-02-08
|
9
20
|
|
10
21
|
### Added
|
@@ -79,4 +90,3 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
79
90
|
|
80
91
|
- Pre-release of v1 Gem
|
81
92
|
- Adds support for Orders, Estimates, Projects and Preferences
|
82
|
-
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
patch_ruby (1.
|
4
|
+
patch_ruby (1.4.0)
|
5
5
|
json (~> 2.1, >= 2.1.0)
|
6
6
|
typhoeus (~> 1.0, >= 1.0.1)
|
7
7
|
|
@@ -23,10 +23,10 @@ GEM
|
|
23
23
|
ffi (>= 1.3.0)
|
24
24
|
factory_bot (6.1.0)
|
25
25
|
activesupport (>= 5.0.0)
|
26
|
-
ffi (1.
|
26
|
+
ffi (1.14.2)
|
27
27
|
i18n (1.8.7)
|
28
28
|
concurrent-ruby (~> 1.0)
|
29
|
-
json (2.
|
29
|
+
json (2.5.1)
|
30
30
|
method_source (1.0.0)
|
31
31
|
minitest (5.14.3)
|
32
32
|
parallel (1.19.2)
|
data/README.md
CHANGED
@@ -144,6 +144,12 @@ Patch::Estimate.retrieve_estimates(page: page)
|
|
144
144
|
### Projects
|
145
145
|
Projects are the ways Patch takes CO2 out of the air. They can represent reforestation, enhanced weathering, direct air carbon capture, etc. When you place an order via Patch, it is allocated to a project.
|
146
146
|
|
147
|
+
When fetching Projects, you can add filters to the query to narrow the result. Currently supported filters are:
|
148
|
+
|
149
|
+
- `country`
|
150
|
+
- `type`
|
151
|
+
- `minimum_available_mass`
|
152
|
+
|
147
153
|
[API Reference](https://docs.usepatch.com/#/?id=projects)
|
148
154
|
|
149
155
|
#### Examples
|
@@ -155,6 +161,18 @@ Patch::Project.retrieve_project(project_id)
|
|
155
161
|
# Retrieve a list of projects
|
156
162
|
page = 1 # Pass in which page of projects you'd like
|
157
163
|
Patch::Project.retrieve_projects(page: page)
|
164
|
+
|
165
|
+
# Retrieve all projects from the United States
|
166
|
+
country = 'US'
|
167
|
+
Patch::Project.retrieve_projects(country: country)
|
168
|
+
|
169
|
+
# Retrieve all biomass projects
|
170
|
+
type = 'biomass'
|
171
|
+
Patch::Project.retrieve_projects(type: type)
|
172
|
+
|
173
|
+
# Retrieve a list of projects with at least 100 grams of available offsets
|
174
|
+
minimum_available_mass = 100
|
175
|
+
Patch::Project.retrieve_projects(minimum_available_mass: minimum_available_mass)
|
158
176
|
```
|
159
177
|
|
160
178
|
### Preferences
|
@@ -90,6 +90,9 @@ module Patch
|
|
90
90
|
# Retrieves a list of projects available for purchase on Patch's platform.
|
91
91
|
# @param [Hash] opts the optional parameters
|
92
92
|
# @option opts [Integer] :page
|
93
|
+
# @option opts [String] :country
|
94
|
+
# @option opts [String] :type
|
95
|
+
# @option opts [Integer] :minimum_available_mass
|
93
96
|
# @return [ProjectListResponse]
|
94
97
|
def retrieve_projects(opts = {})
|
95
98
|
data, _status_code, _headers = retrieve_projects_with_http_info(opts)
|
@@ -100,6 +103,9 @@ module Patch
|
|
100
103
|
# Retrieves a list of projects available for purchase on Patch's platform.
|
101
104
|
# @param [Hash] opts the optional parameters
|
102
105
|
# @option opts [Integer] :page
|
106
|
+
# @option opts [String] :country
|
107
|
+
# @option opts [String] :type
|
108
|
+
# @option opts [Integer] :minimum_available_mass
|
103
109
|
# @return [Array<(ProjectListResponse, Integer, Hash)>] ProjectListResponse data, response status code and response headers
|
104
110
|
def retrieve_projects_with_http_info(opts = {})
|
105
111
|
if @api_client.config.debugging
|
@@ -111,6 +117,9 @@ module Patch
|
|
111
117
|
# query parameters
|
112
118
|
query_params = opts[:query_params] || {}
|
113
119
|
query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
|
120
|
+
query_params[:'country'] = opts[:'country'] if !opts[:'country'].nil?
|
121
|
+
query_params[:'type'] = opts[:'type'] if !opts[:'type'].nil?
|
122
|
+
query_params[:'minimum_available_mass'] = opts[:'minimum_available_mass'] if !opts[:'minimum_available_mass'].nil?
|
114
123
|
|
115
124
|
# header parameters
|
116
125
|
header_params = opts[:header_params] || {}
|
@@ -47,6 +47,9 @@ module Patch
|
|
47
47
|
# An object returning the Standard associated with this project.
|
48
48
|
attr_accessor :standard
|
49
49
|
|
50
|
+
# An array returning the UN Sustainable Development Goals associated with this project.
|
51
|
+
attr_accessor :sdgs
|
52
|
+
|
50
53
|
class EnumAttributeValidator
|
51
54
|
attr_reader :datatype
|
52
55
|
attr_reader :allowable_values
|
@@ -82,7 +85,8 @@ module Patch
|
|
82
85
|
:'photos' => :'photos',
|
83
86
|
:'average_price_per_tonne_cents_usd' => :'average_price_per_tonne_cents_usd',
|
84
87
|
:'remaining_mass_g' => :'remaining_mass_g',
|
85
|
-
:'standard' => :'standard'
|
88
|
+
:'standard' => :'standard',
|
89
|
+
:'sdgs' => :'sdgs'
|
86
90
|
}
|
87
91
|
end
|
88
92
|
|
@@ -99,7 +103,8 @@ module Patch
|
|
99
103
|
:'photos' => :'Array<Photo>',
|
100
104
|
:'average_price_per_tonne_cents_usd' => :'Integer',
|
101
105
|
:'remaining_mass_g' => :'Integer',
|
102
|
-
:'standard' => :'Standard'
|
106
|
+
:'standard' => :'Standard',
|
107
|
+
:'sdgs' => :'Array<Sdg>'
|
103
108
|
}
|
104
109
|
end
|
105
110
|
|
@@ -111,6 +116,8 @@ module Patch
|
|
111
116
|
|
112
117
|
nullable_properties.add("standard")
|
113
118
|
|
119
|
+
nullable_properties.add("sdgs")
|
120
|
+
|
114
121
|
nullable_properties
|
115
122
|
end
|
116
123
|
|
@@ -185,6 +192,12 @@ module Patch
|
|
185
192
|
if attributes.key?(:'standard')
|
186
193
|
self.standard = attributes[:'standard']
|
187
194
|
end
|
195
|
+
|
196
|
+
if attributes.key?(:'sdgs')
|
197
|
+
if (value = attributes[:'sdgs']).is_a?(Array)
|
198
|
+
self.sdgs = value
|
199
|
+
end
|
200
|
+
end
|
188
201
|
end
|
189
202
|
|
190
203
|
# Show invalid properties with the reasons. Usually used together with valid?
|
@@ -267,7 +280,8 @@ module Patch
|
|
267
280
|
photos == o.photos &&
|
268
281
|
average_price_per_tonne_cents_usd == o.average_price_per_tonne_cents_usd &&
|
269
282
|
remaining_mass_g == o.remaining_mass_g &&
|
270
|
-
standard == o.standard
|
283
|
+
standard == o.standard &&
|
284
|
+
sdgs == o.sdgs
|
271
285
|
end
|
272
286
|
|
273
287
|
# @see the `==` method
|
@@ -279,7 +293,7 @@ module Patch
|
|
279
293
|
# Calculates hash code according to all attributes.
|
280
294
|
# @return [Integer] Hash code
|
281
295
|
def hash
|
282
|
-
[id, production, name, description, type, country, developer, photos, average_price_per_tonne_cents_usd, remaining_mass_g, standard].hash
|
296
|
+
[id, production, name, description, type, country, developer, photos, average_price_per_tonne_cents_usd, remaining_mass_g, standard, sdgs].hash
|
283
297
|
end
|
284
298
|
|
285
299
|
# Builds the object from hash
|
@@ -0,0 +1,269 @@
|
|
1
|
+
=begin
|
2
|
+
#Patch API V1
|
3
|
+
|
4
|
+
#The core API used to integrate with Patch's service
|
5
|
+
|
6
|
+
The version of the OpenAPI document: v1
|
7
|
+
Contact: developers@usepatch.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.3.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module Patch
|
16
|
+
class Sdg
|
17
|
+
# The title of the Sustainable Development Goal.
|
18
|
+
attr_accessor :title
|
19
|
+
|
20
|
+
# The Sustainable Development Goal number.
|
21
|
+
attr_accessor :number
|
22
|
+
|
23
|
+
# The description of the Sustainable Development Goal.
|
24
|
+
attr_accessor :description
|
25
|
+
|
26
|
+
# The url to an information page for the Sustainable Development Goal.
|
27
|
+
attr_accessor :url
|
28
|
+
|
29
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
30
|
+
def self.attribute_map
|
31
|
+
{
|
32
|
+
:'title' => :'title',
|
33
|
+
:'number' => :'number',
|
34
|
+
:'description' => :'description',
|
35
|
+
:'url' => :'url'
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
# Attribute type mapping.
|
40
|
+
def self.openapi_types
|
41
|
+
{
|
42
|
+
:'title' => :'String',
|
43
|
+
:'number' => :'Integer',
|
44
|
+
:'description' => :'String',
|
45
|
+
:'url' => :'String'
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
# Set with nullable attributes.
|
50
|
+
def self.openapi_nullable
|
51
|
+
nullable_properties = Set.new
|
52
|
+
|
53
|
+
nullable_properties
|
54
|
+
end
|
55
|
+
|
56
|
+
# Allows models with corresponding API classes to delegate API operations to those API classes
|
57
|
+
# Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
|
58
|
+
# Eg. Order.create_order delegates to OrdersApi.new.create_order
|
59
|
+
def self.method_missing(message, *args, &block)
|
60
|
+
if Object.const_defined?('Patch::SdgsApi::OPERATIONS') && Patch::SdgsApi::OPERATIONS.include?(message)
|
61
|
+
Patch::SdgsApi.new.send(message, *args)
|
62
|
+
else
|
63
|
+
super
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# Initializes the object
|
68
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
69
|
+
def initialize(attributes = {})
|
70
|
+
if (!attributes.is_a?(Hash))
|
71
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::Sdg` initialize method"
|
72
|
+
end
|
73
|
+
|
74
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
75
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
76
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
77
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::Sdg`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
78
|
+
end
|
79
|
+
h[k.to_sym] = v
|
80
|
+
}
|
81
|
+
|
82
|
+
if attributes.key?(:'title')
|
83
|
+
self.title = attributes[:'title']
|
84
|
+
end
|
85
|
+
|
86
|
+
if attributes.key?(:'number')
|
87
|
+
self.number = attributes[:'number']
|
88
|
+
end
|
89
|
+
|
90
|
+
if attributes.key?(:'description')
|
91
|
+
self.description = attributes[:'description']
|
92
|
+
end
|
93
|
+
|
94
|
+
if attributes.key?(:'url')
|
95
|
+
self.url = attributes[:'url']
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
100
|
+
# @return Array for valid properties with the reasons
|
101
|
+
def list_invalid_properties
|
102
|
+
invalid_properties = Array.new
|
103
|
+
if @title.nil?
|
104
|
+
invalid_properties.push('invalid value for "title", title cannot be nil.')
|
105
|
+
end
|
106
|
+
|
107
|
+
if @number.nil?
|
108
|
+
invalid_properties.push('invalid value for "number", number cannot be nil.')
|
109
|
+
end
|
110
|
+
|
111
|
+
if @description.nil?
|
112
|
+
invalid_properties.push('invalid value for "description", description cannot be nil.')
|
113
|
+
end
|
114
|
+
|
115
|
+
if @url.nil?
|
116
|
+
invalid_properties.push('invalid value for "url", url cannot be nil.')
|
117
|
+
end
|
118
|
+
|
119
|
+
invalid_properties
|
120
|
+
end
|
121
|
+
|
122
|
+
# Check to see if the all the properties in the model are valid
|
123
|
+
# @return true if the model is valid
|
124
|
+
def valid?
|
125
|
+
return false if @title.nil?
|
126
|
+
return false if @number.nil?
|
127
|
+
return false if @description.nil?
|
128
|
+
return false if @url.nil?
|
129
|
+
true
|
130
|
+
end
|
131
|
+
|
132
|
+
# Checks equality by comparing each attribute.
|
133
|
+
# @param [Object] Object to be compared
|
134
|
+
def ==(o)
|
135
|
+
return true if self.equal?(o)
|
136
|
+
self.class == o.class &&
|
137
|
+
title == o.title &&
|
138
|
+
number == o.number &&
|
139
|
+
description == o.description &&
|
140
|
+
url == o.url
|
141
|
+
end
|
142
|
+
|
143
|
+
# @see the `==` method
|
144
|
+
# @param [Object] Object to be compared
|
145
|
+
def eql?(o)
|
146
|
+
self == o
|
147
|
+
end
|
148
|
+
|
149
|
+
# Calculates hash code according to all attributes.
|
150
|
+
# @return [Integer] Hash code
|
151
|
+
def hash
|
152
|
+
[title, number, description, url].hash
|
153
|
+
end
|
154
|
+
|
155
|
+
# Builds the object from hash
|
156
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
157
|
+
# @return [Object] Returns the model itself
|
158
|
+
def self.build_from_hash(attributes)
|
159
|
+
new.build_from_hash(attributes)
|
160
|
+
end
|
161
|
+
|
162
|
+
# Builds the object from hash
|
163
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
164
|
+
# @return [Object] Returns the model itself
|
165
|
+
def build_from_hash(attributes)
|
166
|
+
return nil unless attributes.is_a?(Hash)
|
167
|
+
self.class.openapi_types.each_pair do |key, type|
|
168
|
+
if type =~ /\AArray<(.*)>/i
|
169
|
+
# check to ensure the input is an array given that the attribute
|
170
|
+
# is documented as an array but the input is not
|
171
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
172
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
173
|
+
end
|
174
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
175
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
176
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
177
|
+
end
|
178
|
+
|
179
|
+
self
|
180
|
+
end
|
181
|
+
|
182
|
+
# Deserializes the data based on type
|
183
|
+
# @param string type Data type
|
184
|
+
# @param string value Value to be deserialized
|
185
|
+
# @return [Object] Deserialized data
|
186
|
+
def _deserialize(type, value)
|
187
|
+
case type.to_sym
|
188
|
+
when :DateTime
|
189
|
+
DateTime.parse(value)
|
190
|
+
when :Date
|
191
|
+
Date.parse(value)
|
192
|
+
when :String
|
193
|
+
value.to_s
|
194
|
+
when :Integer
|
195
|
+
value.to_i
|
196
|
+
when :Float
|
197
|
+
value.to_f
|
198
|
+
when :Boolean
|
199
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
200
|
+
true
|
201
|
+
else
|
202
|
+
false
|
203
|
+
end
|
204
|
+
when :Object
|
205
|
+
# generic object (usually a Hash), return directly
|
206
|
+
value
|
207
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
208
|
+
inner_type = Regexp.last_match[:inner_type]
|
209
|
+
value.map { |v| _deserialize(inner_type, v) }
|
210
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
211
|
+
k_type = Regexp.last_match[:k_type]
|
212
|
+
v_type = Regexp.last_match[:v_type]
|
213
|
+
{}.tap do |hash|
|
214
|
+
value.each do |k, v|
|
215
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
216
|
+
end
|
217
|
+
end
|
218
|
+
else # model
|
219
|
+
Patch.const_get(type).build_from_hash(value)
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
# Returns the string representation of the object
|
224
|
+
# @return [String] String presentation of the object
|
225
|
+
def to_s
|
226
|
+
to_hash.to_s
|
227
|
+
end
|
228
|
+
|
229
|
+
# to_body is an alias to to_hash (backward compatibility)
|
230
|
+
# @return [Hash] Returns the object in the form of hash
|
231
|
+
def to_body
|
232
|
+
to_hash
|
233
|
+
end
|
234
|
+
|
235
|
+
# Returns the object in the form of hash
|
236
|
+
# @return [Hash] Returns the object in the form of hash
|
237
|
+
def to_hash
|
238
|
+
hash = {}
|
239
|
+
self.class.attribute_map.each_pair do |attr, param|
|
240
|
+
value = self.send(attr)
|
241
|
+
if value.nil?
|
242
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
243
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
244
|
+
end
|
245
|
+
|
246
|
+
hash[param] = _to_hash(value)
|
247
|
+
end
|
248
|
+
hash
|
249
|
+
end
|
250
|
+
|
251
|
+
# Outputs non-array value in the form of hash
|
252
|
+
# For object, use to_hash. Otherwise, just return the value
|
253
|
+
# @param [Object] value Any valid value
|
254
|
+
# @return [Hash] Returns the value in the form of hash
|
255
|
+
def _to_hash(value)
|
256
|
+
if value.is_a?(Array)
|
257
|
+
value.compact.map { |v| _to_hash(v) }
|
258
|
+
elsif value.is_a?(Hash)
|
259
|
+
{}.tap do |hash|
|
260
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
261
|
+
end
|
262
|
+
elsif value.respond_to? :to_hash
|
263
|
+
value.to_hash
|
264
|
+
else
|
265
|
+
value
|
266
|
+
end
|
267
|
+
end
|
268
|
+
end
|
269
|
+
end
|
data/lib/patch_ruby/version.rb
CHANGED
@@ -33,13 +33,13 @@ RSpec.describe 'Estimates Integration' do
|
|
33
33
|
)
|
34
34
|
|
35
35
|
expect(flight_estimate.data.type).to eq 'flight'
|
36
|
-
expect(flight_estimate.data.mass_g).to eq
|
36
|
+
expect(flight_estimate.data.mass_g).to eq 1_031_697
|
37
37
|
end
|
38
38
|
|
39
39
|
it 'supports creating vehicle estimates' do
|
40
40
|
distance_m = 10_000
|
41
41
|
make = "Toyota"
|
42
|
-
model = "
|
42
|
+
model = "Corolla"
|
43
43
|
year = 2000
|
44
44
|
|
45
45
|
vehicle_estimate = Patch::Estimate.create_vehicle_estimate(
|
@@ -50,6 +50,18 @@ RSpec.describe 'Estimates Integration' do
|
|
50
50
|
create_order: false
|
51
51
|
)
|
52
52
|
|
53
|
+
expect(vehicle_estimate.data.type).to eq 'vehicle'
|
54
|
+
expect(vehicle_estimate.data.mass_g).to eq 5_500
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'supports creating vehicle estimates with partial information' do
|
58
|
+
distance_m = 10_000
|
59
|
+
|
60
|
+
vehicle_estimate = Patch::Estimate.create_vehicle_estimate(
|
61
|
+
distance_m: distance_m,
|
62
|
+
create_order: false
|
63
|
+
)
|
64
|
+
|
53
65
|
expect(vehicle_estimate.data.type).to eq 'vehicle'
|
54
66
|
expect(vehicle_estimate.data.mass_g).to eq 2_132
|
55
67
|
end
|
@@ -66,7 +66,7 @@ RSpec.describe 'Orders Integration' do
|
|
66
66
|
|
67
67
|
expect(order.id).not_to be_nil
|
68
68
|
expect(order.mass_g).to eq(5_00_000)
|
69
|
-
expect(order.price_cents_usd
|
69
|
+
expect(order.price_cents_usd).not_to be_empty
|
70
70
|
expect(order.patch_fee_cents_usd).not_to be_empty
|
71
71
|
expect(
|
72
72
|
order.price_cents_usd.to_i + order.patch_fee_cents_usd.to_i
|
@@ -22,6 +22,26 @@ RSpec.describe 'Projects Integration' do
|
|
22
22
|
expect(retrieve_project_response.data.id).to eq project_id
|
23
23
|
end
|
24
24
|
|
25
|
+
it 'supports filtering projects' do
|
26
|
+
country = 'US'
|
27
|
+
projects = Patch::Project.retrieve_projects(country: country)
|
28
|
+
projects.data.map do |project|
|
29
|
+
expect(project.country).to eq country
|
30
|
+
end
|
31
|
+
|
32
|
+
type = 'dac'
|
33
|
+
projects = Patch::Project.retrieve_projects(type: type)
|
34
|
+
projects.data.map do |project|
|
35
|
+
expect(project.type).to eq type
|
36
|
+
end
|
37
|
+
|
38
|
+
minimum_available_mass = 100
|
39
|
+
projects = Patch::Project.retrieve_projects(minimum_available_mass: minimum_available_mass)
|
40
|
+
projects.data.map do |project|
|
41
|
+
expect(project.remaining_mass_g >= minimum_available_mass).to be true
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
25
45
|
describe 'returned fields' do
|
26
46
|
before do
|
27
47
|
@project = Patch::Project.retrieve_projects(page: 1).data.first
|
data/spec/models/project_spec.rb
CHANGED
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.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patch Technology
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02-
|
11
|
+
date: 2021-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|
@@ -110,6 +110,7 @@ files:
|
|
110
110
|
- lib/patch_ruby/models/project.rb
|
111
111
|
- lib/patch_ruby/models/project_list_response.rb
|
112
112
|
- lib/patch_ruby/models/project_response.rb
|
113
|
+
- lib/patch_ruby/models/sdg.rb
|
113
114
|
- lib/patch_ruby/models/standard.rb
|
114
115
|
- lib/patch_ruby/version.rb
|
115
116
|
- patch_ruby.gemspec
|