patch_ruby 1.21.0 → 1.22.0
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 +2 -1
- data/README.md +9 -0
- data/lib/patch_ruby/api/projects_api.rb +6 -0
- data/lib/patch_ruby/api_client.rb +1 -1
- data/lib/patch_ruby/models/project.rb +0 -34
- data/lib/patch_ruby/version.rb +1 -1
- data/spec/integration/projects_spec.rb +43 -35
- metadata +28 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0eedef11df722bf4d3312666ad7fbfb2e965a4c8da613c41bfbaa960008c2f2d
|
4
|
+
data.tar.gz: 71128b74af6e96fc9743d36f63c7fdf6265f68a91b88cfb76730ae811cfcb867
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f5c0bf775d6cfae626fcd983957aaffb1fe8eb1de1b1b75f3a8aee53f6bdb5dfc0901d74e442ab324147e7970e6d673686735572d9c9be97c39c08c3fb48547
|
7
|
+
data.tar.gz: 06d6ff806473a398bbbdff44b0a232428311507f3d22c7140badaf6eaf1512d0d8a660f54efcba39b6147e770cb1b1ad783821c068b5a7581a653eca14bd0a76
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,12 @@ 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.22.0] - 2022-05-16
|
9
|
+
|
10
|
+
### Added
|
11
|
+
|
12
|
+
- Adds support for the `accept_language` option on `projects`, to add support for the `Accept-Language` header.
|
13
|
+
|
8
14
|
## [1.21.0] - 2022-05-03
|
9
15
|
|
10
16
|
### Added
|
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.22.0)
|
5
5
|
typhoeus (~> 1.0, >= 1.0.1)
|
6
6
|
|
7
7
|
GEM
|
@@ -73,6 +73,7 @@ PLATFORMS
|
|
73
73
|
arm64-darwin-20
|
74
74
|
arm64-darwin-21
|
75
75
|
x86_64-darwin-20
|
76
|
+
x86_64-darwin-21
|
76
77
|
x86_64-linux
|
77
78
|
|
78
79
|
DEPENDENCIES
|
data/README.md
CHANGED
@@ -189,6 +189,15 @@ Patch::Project.retrieve_projects(type: type)
|
|
189
189
|
# Retrieve a list of projects with at least 100 grams of available offsets
|
190
190
|
minimum_available_mass = 100
|
191
191
|
Patch::Project.retrieve_projects(minimum_available_mass: minimum_available_mass)
|
192
|
+
|
193
|
+
# Retrieve a project in a different language
|
194
|
+
# See http://docs.patch.test:3000/#/internationalization for more information and support
|
195
|
+
project_id = 'pro_test_1234'
|
196
|
+
Patch::Project.retrieve_project(project_id, accept_language: 'fr')
|
197
|
+
|
198
|
+
# Retrieve a list of projects in a different language
|
199
|
+
# See http://docs.patch.test:3000/#/internationalization for more information and support
|
200
|
+
Patch::Project.retrieve_projects(accept_language: 'fr')
|
192
201
|
```
|
193
202
|
## Contributing
|
194
203
|
|
@@ -28,6 +28,7 @@ module Patch
|
|
28
28
|
# Retrieves a project available on Patch's platform.
|
29
29
|
# @param id [String]
|
30
30
|
# @param [Hash] opts the optional parameters
|
31
|
+
# @option opts [String] :accept_language
|
31
32
|
# @return [ProjectResponse]
|
32
33
|
def retrieve_project(id, opts = {})
|
33
34
|
|
@@ -39,6 +40,7 @@ module Patch
|
|
39
40
|
# Retrieves a project available on Patch's platform.
|
40
41
|
# @param id [String]
|
41
42
|
# @param [Hash] opts the optional parameters
|
43
|
+
# @option opts [String] :accept_language
|
42
44
|
# @return [Array<(ProjectResponse, Integer, Hash)>] ProjectResponse data, response status code and response headers
|
43
45
|
def retrieve_project_with_http_info(id, opts = {})
|
44
46
|
if @api_client.config.debugging
|
@@ -58,6 +60,7 @@ module Patch
|
|
58
60
|
header_params = opts[:header_params] || {}
|
59
61
|
# HTTP header 'Accept' (if needed)
|
60
62
|
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
63
|
+
header_params[:'Accept-Language'] = opts[:'accept_language'] if !opts[:'accept_language'].nil?
|
61
64
|
|
62
65
|
# form parameters
|
63
66
|
form_params = opts[:form_params] || {}
|
@@ -95,6 +98,7 @@ module Patch
|
|
95
98
|
# @option opts [String] :country
|
96
99
|
# @option opts [String] :type
|
97
100
|
# @option opts [Integer] :minimum_available_mass
|
101
|
+
# @option opts [String] :accept_language
|
98
102
|
# @return [ProjectListResponse]
|
99
103
|
def retrieve_projects(opts = {})
|
100
104
|
|
@@ -109,6 +113,7 @@ module Patch
|
|
109
113
|
# @option opts [String] :country
|
110
114
|
# @option opts [String] :type
|
111
115
|
# @option opts [Integer] :minimum_available_mass
|
116
|
+
# @option opts [String] :accept_language
|
112
117
|
# @return [Array<(ProjectListResponse, Integer, Hash)>] ProjectListResponse data, response status code and response headers
|
113
118
|
def retrieve_projects_with_http_info(opts = {})
|
114
119
|
if @api_client.config.debugging
|
@@ -128,6 +133,7 @@ module Patch
|
|
128
133
|
header_params = opts[:header_params] || {}
|
129
134
|
# HTTP header 'Accept' (if needed)
|
130
135
|
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
136
|
+
header_params[:'Accept-Language'] = opts[:'accept_language'] if !opts[:'accept_language'].nil?
|
131
137
|
|
132
138
|
# form parameters
|
133
139
|
form_params = opts[:form_params] || {}
|
@@ -31,7 +31,7 @@ module Patch
|
|
31
31
|
# @option config [Configuration] Configuration for initializing the object, default to Configuration.default
|
32
32
|
def initialize(config = Configuration.default)
|
33
33
|
@config = config
|
34
|
-
@user_agent = "patch-ruby/1.
|
34
|
+
@user_agent = "patch-ruby/1.22.0"
|
35
35
|
@default_headers = {
|
36
36
|
'Content-Type' => 'application/json',
|
37
37
|
'User-Agent' => @user_agent
|
@@ -77,28 +77,6 @@ module Patch
|
|
77
77
|
# An array of objects containing available inventory for a project. Available inventory is grouped by a project's vintage year and returns amount and pricing available for a given vintage year.
|
78
78
|
attr_accessor :inventory
|
79
79
|
|
80
|
-
class EnumAttributeValidator
|
81
|
-
attr_reader :datatype
|
82
|
-
attr_reader :allowable_values
|
83
|
-
|
84
|
-
def initialize(datatype, allowable_values)
|
85
|
-
@allowable_values = allowable_values.map do |value|
|
86
|
-
case datatype.to_s
|
87
|
-
when /Integer/i
|
88
|
-
value.to_i
|
89
|
-
when /Float/i
|
90
|
-
value.to_f
|
91
|
-
else
|
92
|
-
value
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
def valid?(value)
|
98
|
-
!value || allowable_values.include?(value)
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
80
|
# Attribute mapping from ruby-style variable name to JSON key.
|
103
81
|
def self.attribute_map
|
104
82
|
{
|
@@ -351,8 +329,6 @@ module Patch
|
|
351
329
|
return false if @production.nil?
|
352
330
|
return false if @name.nil?
|
353
331
|
return false if @description.nil?
|
354
|
-
mechanism_validator = EnumAttributeValidator.new('String', ["removal", "avoidance"])
|
355
|
-
return false unless mechanism_validator.valid?(@mechanism)
|
356
332
|
return false if @country.nil?
|
357
333
|
return false if @developer.nil?
|
358
334
|
return false if @average_price_per_tonne_cents_usd.nil?
|
@@ -363,16 +339,6 @@ module Patch
|
|
363
339
|
true
|
364
340
|
end
|
365
341
|
|
366
|
-
# Custom attribute writer method checking allowed values (enum).
|
367
|
-
# @param [Object] mechanism Object to be assigned
|
368
|
-
def mechanism=(mechanism)
|
369
|
-
validator = EnumAttributeValidator.new('String', ["removal", "avoidance"])
|
370
|
-
unless validator.valid?(mechanism)
|
371
|
-
fail ArgumentError, "invalid value for \"mechanism\", must be one of #{validator.allowable_values}."
|
372
|
-
end
|
373
|
-
@mechanism = mechanism
|
374
|
-
end
|
375
|
-
|
376
342
|
# Checks equality by comparing each attribute.
|
377
343
|
# @param [Object] Object to be compared
|
378
344
|
def ==(o)
|
data/lib/patch_ruby/version.rb
CHANGED
@@ -38,40 +38,48 @@ RSpec.describe 'Projects Integration' do
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
41
|
+
it 'returns the expected fields' do
|
42
|
+
project = Patch::Project.retrieve_projects(page: 1).data.first
|
43
|
+
|
44
|
+
keys = attributes_for(:project).keys
|
45
|
+
expect(project.to_hash.keys).to include(*keys)
|
46
|
+
|
47
|
+
expect(project.photos).to be_an_instance_of(Array)
|
48
|
+
expect(project.average_price_per_tonne_cents_usd)
|
49
|
+
.to be_an_instance_of(Integer)
|
50
|
+
expect(project.remaining_mass_g).to be_an_instance_of(Integer)
|
51
|
+
expect(project.longitude).to be_an_instance_of(Float)
|
52
|
+
expect(project.latitude).to be_an_instance_of(Float)
|
53
|
+
|
54
|
+
expect(project.technology_type)
|
55
|
+
.to be_an_instance_of(Patch::TechnologyType)
|
56
|
+
expect(project.technology_type.name).to be_an_instance_of(String)
|
57
|
+
expect(project.technology_type.slug).to be_an_instance_of(String)
|
58
|
+
|
59
|
+
parent_type = project.technology_type.parent_technology_type
|
60
|
+
expect(parent_type).to be_an_instance_of(Patch::ParentTechnologyType)
|
61
|
+
expect(parent_type.name).to be_an_instance_of(String)
|
62
|
+
expect(parent_type.slug).to be_an_instance_of(String)
|
63
|
+
|
64
|
+
expect(project.highlights).to be_an_instance_of(Array)
|
65
|
+
|
66
|
+
inventory = project.inventory
|
67
|
+
expect(inventory).to be_an_instance_of(Array)
|
68
|
+
expect(inventory[0]).to be_an_instance_of(Patch::Inventory)
|
69
|
+
expect(inventory[0].vintage_year).to be_an_instance_of(Integer)
|
70
|
+
expect(inventory[0].amount_available).to be_an_instance_of(Integer)
|
71
|
+
expect(inventory[0].price).to be_an_instance_of(Integer)
|
72
|
+
expect(inventory[0].currency).to be_an_instance_of(String)
|
73
|
+
expect(inventory[0].unit).to be_an_instance_of(String)
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'retrieves projects in the requested language' do
|
77
|
+
projects_response = Patch::Project.retrieve_projects(accept_language: 'fr')
|
78
|
+
|
79
|
+
expect(projects_response.data.first.name).to include 'Projet' # French
|
80
|
+
|
81
|
+
project_id = projects_response.data.first.id
|
82
|
+
project_response = Patch::Project.retrieve_project(project_id, accept_language: 'fr')
|
83
|
+
expect(project_response.data.name).to include 'Projet' # Frenc
|
76
84
|
end
|
77
85
|
end
|
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.22.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: 2022-05-
|
11
|
+
date: 2022-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|
@@ -202,48 +202,48 @@ signing_key:
|
|
202
202
|
specification_version: 4
|
203
203
|
summary: Ruby wrapper for the Patch API
|
204
204
|
test_files:
|
205
|
-
- spec/api/technology_types_api_spec.rb
|
206
|
-
- spec/api/orders_api_spec.rb
|
207
205
|
- spec/api/projects_api_spec.rb
|
206
|
+
- spec/api/orders_api_spec.rb
|
208
207
|
- spec/api/estimates_api_spec.rb
|
208
|
+
- spec/api/technology_types_api_spec.rb
|
209
209
|
- spec/api_client_spec.rb
|
210
210
|
- spec/configuration_spec.rb
|
211
211
|
- spec/constants.rb
|
212
|
-
- spec/factories/create_order_requests.rb
|
213
|
-
- spec/factories/estimate_list_responses.rb
|
214
|
-
- spec/factories/sdgs.rb
|
215
|
-
- spec/factories/allocations.rb
|
216
|
-
- spec/factories/parent_technology_type.rb
|
217
|
-
- spec/factories/project_responses.rb
|
218
|
-
- spec/factories/order_responses.rb
|
219
|
-
- spec/factories/project_list_responses.rb
|
220
212
|
- spec/factories/estimates.rb
|
221
|
-
- spec/factories/technology_type.rb
|
222
|
-
- spec/factories/error_responses.rb
|
223
|
-
- spec/factories/orders.rb
|
224
213
|
- spec/factories/meta_index_objects.rb
|
214
|
+
- spec/factories/order_responses.rb
|
215
|
+
- spec/factories/orders.rb
|
216
|
+
- spec/factories/estimate_responses.rb
|
217
|
+
- spec/factories/project_list_responses.rb
|
225
218
|
- spec/factories/projects.rb
|
219
|
+
- spec/factories/allocations.rb
|
220
|
+
- spec/factories/error_responses.rb
|
221
|
+
- spec/factories/project_responses.rb
|
222
|
+
- spec/factories/create_order_requests.rb
|
223
|
+
- spec/factories/technology_type.rb
|
224
|
+
- spec/factories/estimate_list_responses.rb
|
226
225
|
- spec/factories/create_mass_estimate_requests.rb
|
226
|
+
- spec/factories/sdgs.rb
|
227
|
+
- spec/factories/parent_technology_type.rb
|
227
228
|
- spec/factories/order_list_responses.rb
|
228
|
-
- spec/factories/estimate_responses.rb
|
229
|
-
- spec/integration/projects_spec.rb
|
230
|
-
- spec/integration/projects/technology_types_spec.rb
|
231
229
|
- spec/integration/estimates_spec.rb
|
230
|
+
- spec/integration/projects/technology_types_spec.rb
|
231
|
+
- spec/integration/projects_spec.rb
|
232
232
|
- spec/integration/orders_spec.rb
|
233
|
-
- spec/models/estimate_spec.rb
|
234
|
-
- spec/models/create_mass_estimate_request_spec.rb
|
235
|
-
- spec/models/estimate_list_response_spec.rb
|
236
|
-
- spec/models/meta_index_object_spec.rb
|
237
|
-
- spec/models/estimate_response_spec.rb
|
238
|
-
- spec/models/project_response_spec.rb
|
239
|
-
- spec/models/project_spec.rb
|
240
233
|
- spec/models/order_spec.rb
|
234
|
+
- spec/models/project_spec.rb
|
241
235
|
- spec/models/project_list_response_spec.rb
|
242
|
-
- spec/models/
|
236
|
+
- spec/models/project_response_spec.rb
|
237
|
+
- spec/models/estimate_list_response_spec.rb
|
238
|
+
- spec/models/estimate_response_spec.rb
|
239
|
+
- spec/models/order_list_response_spec.rb
|
240
|
+
- spec/models/estimate_spec.rb
|
241
|
+
- spec/models/create_order_request_spec.rb
|
242
|
+
- spec/models/meta_index_object_spec.rb
|
243
|
+
- spec/models/create_mass_estimate_request_spec.rb
|
243
244
|
- spec/models/error_response_spec.rb
|
244
245
|
- spec/models/order_response_spec.rb
|
245
|
-
- spec/models/
|
246
|
-
- spec/models/order_list_response_spec.rb
|
246
|
+
- spec/models/allocation_spec.rb
|
247
247
|
- spec/patch_ruby_spec.rb
|
248
248
|
- spec/spec_helper.rb
|
249
249
|
- spec/support/shared/generated_classes.rb
|