Skip to content

Commit 0cc9890

Browse files
authored
Merge pull request #22 from patch-technology/ta/update
update sdks
2 parents 8f47fce + dcf66be commit 0cc9890

File tree

7 files changed

+315
-11
lines changed

7 files changed

+315
-11
lines changed

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.4.0] - 2021-02-15
9+
10+
### Added
11+
12+
- Adds Sustainable Development Goals (SDGs) field to projects
13+
14+
### Changed
15+
16+
- vehicle estimates now support optional `make`, `model` and `year` fields.
17+
818
## [1.3.0] - 2021-02-08
919

1020
### Added
@@ -79,4 +89,3 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7989

8090
- Pre-release of v1 Gem
8191
- Adds support for Orders, Estimates, Projects and Preferences
82-

Gemfile.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
patch_ruby (1.3.0)
4+
patch_ruby (1.4.0)
55
json (~> 2.1, >= 2.1.0)
66
typhoeus (~> 1.0, >= 1.0.1)
77

@@ -23,10 +23,10 @@ GEM
2323
ffi (>= 1.3.0)
2424
factory_bot (6.1.0)
2525
activesupport (>= 5.0.0)
26-
ffi (1.13.1)
26+
ffi (1.14.2)
2727
i18n (1.8.7)
2828
concurrent-ruby (~> 1.0)
29-
json (2.4.1)
29+
json (2.5.1)
3030
method_source (1.0.0)
3131
minitest (5.14.3)
3232
parallel (1.19.2)

lib/patch_ruby/models/project.rb

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ class Project
4747
# An object returning the Standard associated with this project.
4848
attr_accessor :standard
4949

50+
# An array returning the UN Sustainable Development Goals associated with this project.
51+
attr_accessor :sdgs
52+
5053
class EnumAttributeValidator
5154
attr_reader :datatype
5255
attr_reader :allowable_values
@@ -82,7 +85,8 @@ def self.attribute_map
8285
:'photos' => :'photos',
8386
:'average_price_per_tonne_cents_usd' => :'average_price_per_tonne_cents_usd',
8487
:'remaining_mass_g' => :'remaining_mass_g',
85-
:'standard' => :'standard'
88+
:'standard' => :'standard',
89+
:'sdgs' => :'sdgs'
8690
}
8791
end
8892

@@ -99,7 +103,8 @@ def self.openapi_types
99103
:'photos' => :'Array<Photo>',
100104
:'average_price_per_tonne_cents_usd' => :'Integer',
101105
:'remaining_mass_g' => :'Integer',
102-
:'standard' => :'Standard'
106+
:'standard' => :'Standard',
107+
:'sdgs' => :'Array<Sdg>'
103108
}
104109
end
105110

@@ -111,6 +116,8 @@ def self.openapi_nullable
111116

112117
nullable_properties.add("standard")
113118

119+
nullable_properties.add("sdgs")
120+
114121
nullable_properties
115122
end
116123

@@ -185,6 +192,12 @@ def initialize(attributes = {})
185192
if attributes.key?(:'standard')
186193
self.standard = attributes[:'standard']
187194
end
195+
196+
if attributes.key?(:'sdgs')
197+
if (value = attributes[:'sdgs']).is_a?(Array)
198+
self.sdgs = value
199+
end
200+
end
188201
end
189202

190203
# Show invalid properties with the reasons. Usually used together with valid?
@@ -267,7 +280,8 @@ def ==(o)
267280
photos == o.photos &&
268281
average_price_per_tonne_cents_usd == o.average_price_per_tonne_cents_usd &&
269282
remaining_mass_g == o.remaining_mass_g &&
270-
standard == o.standard
283+
standard == o.standard &&
284+
sdgs == o.sdgs
271285
end
272286

273287
# @see the `==` method
@@ -279,7 +293,7 @@ def eql?(o)
279293
# Calculates hash code according to all attributes.
280294
# @return [Integer] Hash code
281295
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
283297
end
284298

285299
# Builds the object from hash

lib/patch_ruby/models/sdg.rb

Lines changed: 269 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
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

lib/patch_ruby/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
=end
1212

1313
module Patch
14-
VERSION = '1.3.0'
14+
VERSION = '1.4.0'
1515
end

0 commit comments

Comments
 (0)