patch_ruby 1.15.1 → 1.15.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d306d8bd83ffdd48383cdc925e8c0a8ee37db778d519d8541b8ee57e999b18d6
4
- data.tar.gz: b107f76975cb46cc0598481ffdc8f8ba4de6a02f6d467009686b29517c391182
3
+ metadata.gz: 3c1030fc4a287d8dc68aefe8ba6e240506b31a22f8066202cf1ada2104159f4f
4
+ data.tar.gz: 931c2ff23b6323b3410dbebb6c9f65c1e9e77af9bfb498061b264a6b346c35c3
5
5
  SHA512:
6
- metadata.gz: bf3c7d236266c4df42832a9f7312951e90785d9bd4ba6a76a58b36b7ab41612bef0e9e13493657a6898a836e8e0f746156205e39da9c4a4b6f15acf4ee906eec
7
- data.tar.gz: 874b7efa8ddd9dbd677a9a54f35651d13178aeec2b21ec0094e0a7c91b19593d9c7405fb9f9cdf959afac0de7353744ac854a1a0797dde37fd000c71e50fa749
6
+ metadata.gz: 4399537cffce6cf8beafe1050ecf655b23ca1e8229b19c025d411f96346a23cc425f98289ae02addb496ff624b1d8f2e6fc8bf87ccf604c2081653d2be5041e2
7
+ data.tar.gz: b8798208043ec070f062cf91c6ec0fb7a4c0a4d0ad6b039b8ca61cd1b6d35d2e732cb6aeea100cc278369661b50aefed046506befa63bf86d7daef498da63ccb
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.15.2] - 2021-11-08
9
+
10
+ ### Added
11
+
12
+ - Adds highlights to project responses
13
+
8
14
  ## [1.15.1] - 2021-11-04
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.15.1)
4
+ patch_ruby (1.15.2)
5
5
  typhoeus (~> 1.0, >= 1.0.1)
6
6
 
7
7
  GEM
@@ -70,6 +70,7 @@ GEM
70
70
  zeitwerk (2.4.2)
71
71
 
72
72
  PLATFORMS
73
+ arm64-darwin-20
73
74
  x86_64-darwin-20
74
75
 
75
76
  DEPENDENCIES
data/README.md CHANGED
@@ -53,9 +53,6 @@ end
53
53
 
54
54
  In Patch, orders represent a purchase of carbon offsets or negative emissions by mass. Place orders directly if you know the amount of carbon dioxide you would like to sequester. If you do not know how much to purchase, use an estimate.
55
55
 
56
- In Patch, orders represent a purchase of carbon offsets or negative emissions by mass.
57
- Place orders directly if you know the amount of carbon dioxide you would like to sequester.
58
- If you do not know how much to purchase, use an estimate.
59
56
  You can also create an order with a maximum desired price, and we'll allocate enough mass to
60
57
  fulfill the order for you.
61
58
 
@@ -218,7 +215,13 @@ page = 1 # Pass in which page of preferences you'd like
218
215
  Patch::Preference.retrieve_preferences(page: page)
219
216
  ```
220
217
 
221
- ## Development
218
+ ## Contributing
219
+
220
+ While we value open-source contributions to this SDK, the core of this library is generated programmatically. Complex additions made directly to the library would have to be moved over to our generation code, otherwise they would be overwritten upon the next generated release. Feel free to open a PR as a proof of concept, but know that we will not be able to merge it as-is. We suggest opening an issue first to discuss with us!
221
+
222
+ On the other hand, contributions to the README, as well as new test cases are always very welcome!
223
+
224
+ ### Testing locally
222
225
 
223
226
  To build the gem locally, run:
224
227
 
@@ -232,20 +235,16 @@ This will create a .gem file. To install the local gem:
232
235
  gem install patch_ruby-1.x.x.gem
233
236
  ```
234
237
 
235
- Install dependencies:
236
-
237
- ```bash
238
- bundle install
239
- ```
238
+ ### Running tests
240
239
 
241
- Set up required environment variables:
240
+ Set up the required environment variable.
242
241
 
243
242
  ```bash
244
243
  export SANDBOX_API_KEY=<SANDBOX API KEY>
245
244
  ```
246
245
 
247
- Run tests:
246
+ then run the tests:
248
247
 
249
248
  ```bash
250
- bundle exec rspec
249
+ make test
251
250
  ```
@@ -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.15.1"
34
+ @user_agent = "patch-ruby/1.15.2"
35
35
  @default_headers = {
36
36
  'Content-Type' => 'application/json',
37
37
  'User-Agent' => @user_agent
@@ -0,0 +1,264 @@
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: 5.2.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Patch
17
+ class Highlight
18
+ # A unique identifier for each highlight.
19
+ attr_accessor :slug
20
+
21
+ # A short string that spotlights a characteristic about the project.
22
+ attr_accessor :title
23
+
24
+ # A URL for the corresponding icon.
25
+ attr_accessor :icon_url
26
+
27
+ # Attribute mapping from ruby-style variable name to JSON key.
28
+ def self.attribute_map
29
+ {
30
+ :'slug' => :'slug',
31
+ :'title' => :'title',
32
+ :'icon_url' => :'icon_url'
33
+ }
34
+ end
35
+
36
+ # Returns all the JSON keys this model knows about
37
+ def self.acceptable_attributes
38
+ attribute_map.values
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.openapi_types
43
+ {
44
+ :'slug' => :'String',
45
+ :'title' => :'String',
46
+ :'icon_url' => :'String'
47
+ }
48
+ end
49
+
50
+ # List of attributes with nullable: true
51
+ def self.openapi_nullable
52
+ Set.new([
53
+ ])
54
+ end
55
+
56
+
57
+ # Allows models with corresponding API classes to delegate API operations to those API classes
58
+ # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
59
+ # Eg. Order.create_order delegates to OrdersApi.new.create_order
60
+ def self.method_missing(message, *args, &block)
61
+ if Object.const_defined?('Patch::HighlightsApi::OPERATIONS') && Patch::HighlightsApi::OPERATIONS.include?(message)
62
+ Patch::HighlightsApi.new.send(message, *args)
63
+ else
64
+ super
65
+ end
66
+ end
67
+
68
+ # Initializes the object
69
+ # @param [Hash] attributes Model attributes in the form of hash
70
+ def initialize(attributes = {})
71
+ if (!attributes.is_a?(Hash))
72
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::Highlight` initialize method"
73
+ end
74
+
75
+ # check to see if the attribute exists and convert string to symbol for hash key
76
+ attributes = attributes.each_with_object({}) { |(k, v), h|
77
+ if (!self.class.attribute_map.key?(k.to_sym))
78
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::Highlight`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
79
+ end
80
+ h[k.to_sym] = v
81
+ }
82
+
83
+ if attributes.key?(:'slug')
84
+ self.slug = attributes[:'slug']
85
+ end
86
+
87
+ if attributes.key?(:'title')
88
+ self.title = attributes[:'title']
89
+ end
90
+
91
+ if attributes.key?(:'icon_url')
92
+ self.icon_url = attributes[:'icon_url']
93
+ end
94
+ end
95
+
96
+ # Show invalid properties with the reasons. Usually used together with valid?
97
+ # @return Array for valid properties with the reasons
98
+ def list_invalid_properties
99
+ invalid_properties = Array.new
100
+ if @slug.nil?
101
+ invalid_properties.push('invalid value for "slug", slug cannot be nil.')
102
+ end
103
+
104
+ if @title.nil?
105
+ invalid_properties.push('invalid value for "title", title cannot be nil.')
106
+ end
107
+
108
+ if @icon_url.nil?
109
+ invalid_properties.push('invalid value for "icon_url", icon_url cannot be nil.')
110
+ end
111
+
112
+ invalid_properties
113
+ end
114
+
115
+ # Check to see if the all the properties in the model are valid
116
+ # @return true if the model is valid
117
+ def valid?
118
+ return false if @slug.nil?
119
+ return false if @title.nil?
120
+ return false if @icon_url.nil?
121
+ true
122
+ end
123
+
124
+ # Checks equality by comparing each attribute.
125
+ # @param [Object] Object to be compared
126
+ def ==(o)
127
+ return true if self.equal?(o)
128
+ self.class == o.class &&
129
+ slug == o.slug &&
130
+ title == o.title &&
131
+ icon_url == o.icon_url
132
+ end
133
+
134
+ # @see the `==` method
135
+ # @param [Object] Object to be compared
136
+ def eql?(o)
137
+ self == o
138
+ end
139
+
140
+ # Calculates hash code according to all attributes.
141
+ # @return [Integer] Hash code
142
+ def hash
143
+ [slug, title, icon_url].hash
144
+ end
145
+
146
+ # Builds the object from hash
147
+ # @param [Hash] attributes Model attributes in the form of hash
148
+ # @return [Object] Returns the model itself
149
+ def self.build_from_hash(attributes)
150
+ new.build_from_hash(attributes)
151
+ end
152
+
153
+ # Builds the object from hash
154
+ # @param [Hash] attributes Model attributes in the form of hash
155
+ # @return [Object] Returns the model itself
156
+ def build_from_hash(attributes)
157
+ return nil unless attributes.is_a?(Hash)
158
+ self.class.openapi_types.each_pair do |key, type|
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
162
+ # check to ensure the input is an array given that the attribute
163
+ # is documented as an array but the input is not
164
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
165
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
166
+ end
167
+ elsif !attributes[self.class.attribute_map[key]].nil?
168
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
169
+ end
170
+ end
171
+
172
+ self
173
+ end
174
+
175
+ # Deserializes the data based on type
176
+ # @param string type Data type
177
+ # @param string value Value to be deserialized
178
+ # @return [Object] Deserialized data
179
+ def _deserialize(type, value)
180
+ case type.to_sym
181
+ when :Time
182
+ Time.parse(value)
183
+ when :Date
184
+ Date.parse(value)
185
+ when :String
186
+ value.to_s
187
+ when :Integer
188
+ value.to_i
189
+ when :Float
190
+ value.to_f
191
+ when :Boolean
192
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
193
+ true
194
+ else
195
+ false
196
+ end
197
+ when :Object
198
+ # generic object (usually a Hash), return directly
199
+ value
200
+ when /\AArray<(?<inner_type>.+)>\z/
201
+ inner_type = Regexp.last_match[:inner_type]
202
+ value.map { |v| _deserialize(inner_type, v) }
203
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
204
+ k_type = Regexp.last_match[:k_type]
205
+ v_type = Regexp.last_match[:v_type]
206
+ {}.tap do |hash|
207
+ value.each do |k, v|
208
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
209
+ end
210
+ end
211
+ else # model
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)
215
+ end
216
+ end
217
+
218
+ # Returns the string representation of the object
219
+ # @return [String] String presentation of the object
220
+ def to_s
221
+ to_hash.to_s
222
+ end
223
+
224
+ # to_body is an alias to to_hash (backward compatibility)
225
+ # @return [Hash] Returns the object in the form of hash
226
+ def to_body
227
+ to_hash
228
+ end
229
+
230
+ # Returns the object in the form of hash
231
+ # @return [Hash] Returns the object in the form of hash
232
+ def to_hash
233
+ hash = {}
234
+ self.class.attribute_map.each_pair do |attr, param|
235
+ value = self.send(attr)
236
+ if value.nil?
237
+ is_nullable = self.class.openapi_nullable.include?(attr)
238
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
239
+ end
240
+
241
+ hash[param] = _to_hash(value)
242
+ end
243
+ hash
244
+ end
245
+
246
+ # Outputs non-array value in the form of hash
247
+ # For object, use to_hash. Otherwise, just return the value
248
+ # @param [Object] value Any valid value
249
+ # @return [Hash] Returns the value in the form of hash
250
+ def _to_hash(value)
251
+ if value.is_a?(Array)
252
+ value.compact.map { |v| _to_hash(v) }
253
+ elsif value.is_a?(Hash)
254
+ {}.tap do |hash|
255
+ value.each { |k, v| hash[k] = _to_hash(v) }
256
+ end
257
+ elsif value.respond_to? :to_hash
258
+ value.to_hash
259
+ else
260
+ value
261
+ end
262
+ end
263
+ end
264
+ end
@@ -71,6 +71,9 @@ module Patch
71
71
 
72
72
  attr_accessor :technology_type
73
73
 
74
+ # An array of objects containing the highlight's slug and title. A highlight's title is a short string that spotlights a characteristic about the project.
75
+ attr_accessor :highlights
76
+
74
77
  class EnumAttributeValidator
75
78
  attr_reader :datatype
76
79
  attr_reader :allowable_values
@@ -114,7 +117,8 @@ module Patch
114
117
  :'standard' => :'standard',
115
118
  :'sdgs' => :'sdgs',
116
119
  :'tagline' => :'tagline',
117
- :'technology_type' => :'technology_type'
120
+ :'technology_type' => :'technology_type',
121
+ :'highlights' => :'highlights'
118
122
  }
119
123
  end
120
124
 
@@ -144,7 +148,8 @@ module Patch
144
148
  :'standard' => :'Standard',
145
149
  :'sdgs' => :'Array<Sdg>',
146
150
  :'tagline' => :'String',
147
- :'technology_type' => :'TechnologyType'
151
+ :'technology_type' => :'TechnologyType',
152
+ :'highlights' => :'Array<Highlight>'
148
153
  }
149
154
  end
150
155
 
@@ -266,6 +271,12 @@ module Patch
266
271
  if attributes.key?(:'technology_type')
267
272
  self.technology_type = attributes[:'technology_type']
268
273
  end
274
+
275
+ if attributes.key?(:'highlights')
276
+ if (value = attributes[:'highlights']).is_a?(Array)
277
+ self.highlights = value
278
+ end
279
+ end
269
280
  end
270
281
 
271
282
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -308,6 +319,10 @@ module Patch
308
319
  invalid_properties.push('invalid value for "technology_type", technology_type cannot be nil.')
309
320
  end
310
321
 
322
+ if @highlights.nil?
323
+ invalid_properties.push('invalid value for "highlights", highlights cannot be nil.')
324
+ end
325
+
311
326
  invalid_properties
312
327
  end
313
328
 
@@ -325,6 +340,7 @@ module Patch
325
340
  return false if @average_price_per_tonne_cents_usd.nil?
326
341
  return false if @remaining_mass_g.nil?
327
342
  return false if @technology_type.nil?
343
+ return false if @highlights.nil?
328
344
  true
329
345
  end
330
346
 
@@ -361,7 +377,8 @@ module Patch
361
377
  standard == o.standard &&
362
378
  sdgs == o.sdgs &&
363
379
  tagline == o.tagline &&
364
- technology_type == o.technology_type
380
+ technology_type == o.technology_type &&
381
+ highlights == o.highlights
365
382
  end
366
383
 
367
384
  # @see the `==` method
@@ -373,7 +390,7 @@ module Patch
373
390
  # Calculates hash code according to all attributes.
374
391
  # @return [Integer] Hash code
375
392
  def hash
376
- [id, production, name, description, type, mechanism, country, state, latitude, longitude, developer, photos, average_price_per_tonne_cents_usd, remaining_mass_g, verifier, standard, sdgs, tagline, technology_type].hash
393
+ [id, production, name, description, type, mechanism, country, state, latitude, longitude, developer, photos, average_price_per_tonne_cents_usd, remaining_mass_g, verifier, standard, sdgs, tagline, technology_type, highlights].hash
377
394
  end
378
395
 
379
396
  # Builds the object from hash
@@ -11,5 +11,5 @@ OpenAPI Generator version: 5.2.1
11
11
  =end
12
12
 
13
13
  module Patch
14
- VERSION = '1.15.1'
14
+ VERSION = '1.15.2'
15
15
  end
data/lib/patch_ruby.rb CHANGED
@@ -31,6 +31,7 @@ require 'patch_ruby/models/error_response'
31
31
  require 'patch_ruby/models/estimate'
32
32
  require 'patch_ruby/models/estimate_list_response'
33
33
  require 'patch_ruby/models/estimate_response'
34
+ require 'patch_ruby/models/highlight'
34
35
  require 'patch_ruby/models/meta_index_object'
35
36
  require 'patch_ruby/models/order'
36
37
  require 'patch_ruby/models/order_list_response'
@@ -61,6 +61,8 @@ RSpec.describe 'Projects Integration' do
61
61
  expect(parent_type).to be_an_instance_of(Patch::ParentTechnologyType)
62
62
  expect(parent_type.name).to be_an_instance_of(String)
63
63
  expect(parent_type.slug).to be_an_instance_of(String)
64
+
65
+ expect(project.highlights).to be_an_instance_of(Array)
64
66
  end
65
67
  end
66
68
  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.15.1
4
+ version: 1.15.2
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-11-04 00:00:00.000000000 Z
11
+ date: 2021-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus
@@ -115,6 +115,7 @@ files:
115
115
  - lib/patch_ruby/models/estimate.rb
116
116
  - lib/patch_ruby/models/estimate_list_response.rb
117
117
  - lib/patch_ruby/models/estimate_response.rb
118
+ - lib/patch_ruby/models/highlight.rb
118
119
  - lib/patch_ruby/models/meta_index_object.rb
119
120
  - lib/patch_ruby/models/order.rb
120
121
  - lib/patch_ruby/models/order_list_response.rb