patch_ruby 1.11.1 → 1.15.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 +24 -0
- data/Gemfile.lock +1 -1
- data/lib/patch_ruby/api/estimates_api.rb +2 -2
- data/lib/patch_ruby/api/technology_types_api.rb +84 -0
- data/lib/patch_ruby/api_client.rb +1 -1
- data/lib/patch_ruby/models/create_bitcoin_estimate_request.rb +14 -2
- data/lib/patch_ruby/models/create_ethereum_estimate_request.rb +13 -1
- data/lib/patch_ruby/models/create_flight_estimate_request.rb +2 -0
- data/lib/patch_ruby/models/create_mass_estimate_request.rb +2 -0
- data/lib/patch_ruby/models/create_shipping_estimate_request.rb +2 -0
- data/lib/patch_ruby/models/create_vehicle_estimate_request.rb +2 -0
- data/lib/patch_ruby/models/order.rb +11 -1
- data/lib/patch_ruby/models/parent_technology_type.rb +240 -0
- data/lib/patch_ruby/models/project.rb +81 -14
- data/lib/patch_ruby/models/technology_type.rb +259 -0
- data/lib/patch_ruby/models/technology_type_list_response.rb +259 -0
- data/lib/patch_ruby/version.rb +1 -1
- data/lib/patch_ruby.rb +4 -0
- data/spec/api/technology_types_api_spec.rb +46 -0
- data/spec/factories/parent_technology_type.rb +8 -0
- data/spec/factories/projects.rb +7 -0
- data/spec/factories/sdgs.rb +10 -0
- data/spec/factories/technology_type.rb +9 -0
- data/spec/integration/estimates_spec.rb +16 -2
- data/spec/integration/orders_spec.rb +3 -2
- data/spec/integration/projects/technology_types_spec.rb +14 -0
- data/spec/integration/projects_spec.rb +18 -1
- data/spec/models/create_mass_estimate_request_spec.rb +1 -1
- data/spec/models/project_spec.rb +10 -2
- metadata +42 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a338171de1603165ff7c077c2c1607c4ed157718437c2e0b6d1661ab44d122db
|
4
|
+
data.tar.gz: 96f84e3602fb5ad9e6b22ac91873c004dcce0f1da76c93471ba323f24075e5e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c20ecb8c28c1f418814c94c8d9c788658fbda38e6aada43cf909ecb8f80b3a922704ba1d3cd862c5f6f44e84c691cb2e2acc564f69e4332c4394a636fe52e71
|
7
|
+
data.tar.gz: 80e864a530bbc4d422a4c7f28cc6e6dc7471b759e8a6dd443909466214d638e0e11457007fc3349f4a4aade5c9144d33a980e5756c8e41f18be6a263d0c380d0
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,30 @@ 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.0] - 2021-10-04
|
9
|
+
|
10
|
+
### Added
|
11
|
+
|
12
|
+
- Added the ability to fetch project technology types via `Patch::TechnologyType.retrieve_technology_types()`
|
13
|
+
|
14
|
+
## [1.14.0] - 2021-09-21
|
15
|
+
|
16
|
+
### Added
|
17
|
+
|
18
|
+
- Adds mechanism, tagline, state, latitude, longitude, and technology_type to project responses
|
19
|
+
|
20
|
+
## [1.13.0] - 2021-09-10
|
21
|
+
|
22
|
+
### Added
|
23
|
+
|
24
|
+
- Adds ability to create Bitcoin and Ethereum estimates using the daily balance held.
|
25
|
+
|
26
|
+
## [1.12.0] - 2021-09-08
|
27
|
+
|
28
|
+
### Added
|
29
|
+
|
30
|
+
- Adds a `created_at` attribute in all order responses
|
31
|
+
|
8
32
|
## [1.11.1] - 2021-09-07
|
9
33
|
|
10
34
|
### Changed
|
data/Gemfile.lock
CHANGED
@@ -96,7 +96,7 @@ module Patch
|
|
96
96
|
return data, status_code, headers
|
97
97
|
end
|
98
98
|
|
99
|
-
# Create an ethereum estimate
|
99
|
+
# Create an ethereum estimate
|
100
100
|
# Creates an ethereum estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters, linked to the estimate.
|
101
101
|
# @param create_ethereum_estimate_request [CreateEthereumEstimateRequest]
|
102
102
|
# @param [Hash] opts the optional parameters
|
@@ -107,7 +107,7 @@ module Patch
|
|
107
107
|
data
|
108
108
|
end
|
109
109
|
|
110
|
-
# Create an ethereum estimate
|
110
|
+
# Create an ethereum estimate
|
111
111
|
# Creates an ethereum estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters, linked to the estimate.
|
112
112
|
# @param create_ethereum_estimate_request [CreateEthereumEstimateRequest]
|
113
113
|
# @param [Hash] opts the optional parameters
|
@@ -0,0 +1,84 @@
|
|
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 'cgi'
|
14
|
+
|
15
|
+
module Patch
|
16
|
+
class TechnologyTypesApi
|
17
|
+
OPERATIONS = [
|
18
|
+
:retrieve_technology_types,
|
19
|
+
]
|
20
|
+
|
21
|
+
attr_accessor :api_client
|
22
|
+
|
23
|
+
def initialize(api_client = ApiClient.default)
|
24
|
+
@api_client = api_client
|
25
|
+
end
|
26
|
+
# Retrieves the list of technology_types
|
27
|
+
# Retrieves a list of all technology_types.
|
28
|
+
# @param [Hash] opts the optional parameters
|
29
|
+
# @return [TechnologyTypeListResponse]
|
30
|
+
def retrieve_technology_types(opts = {})
|
31
|
+
|
32
|
+
data, _status_code, _headers = retrieve_technology_types_with_http_info(opts)
|
33
|
+
data
|
34
|
+
end
|
35
|
+
|
36
|
+
# Retrieves the list of technology_types
|
37
|
+
# Retrieves a list of all technology_types.
|
38
|
+
# @param [Hash] opts the optional parameters
|
39
|
+
# @return [Array<(TechnologyTypeListResponse, Integer, Hash)>] TechnologyTypeListResponse data, response status code and response headers
|
40
|
+
def retrieve_technology_types_with_http_info(opts = {})
|
41
|
+
if @api_client.config.debugging
|
42
|
+
@api_client.config.logger.debug 'Calling API: TechnologyTypesApi.retrieve_technology_types ...'
|
43
|
+
end
|
44
|
+
# resource path
|
45
|
+
local_var_path = '/v1/projects/technology_types'
|
46
|
+
|
47
|
+
# query parameters
|
48
|
+
query_params = opts[:query_params] || {}
|
49
|
+
|
50
|
+
# header parameters
|
51
|
+
header_params = opts[:header_params] || {}
|
52
|
+
# HTTP header 'Accept' (if needed)
|
53
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
54
|
+
|
55
|
+
# form parameters
|
56
|
+
form_params = opts[:form_params] || {}
|
57
|
+
|
58
|
+
# http body (model)
|
59
|
+
post_body = opts[:debug_body]
|
60
|
+
|
61
|
+
# return_type
|
62
|
+
return_type = opts[:debug_return_type] || 'TechnologyTypeListResponse'
|
63
|
+
|
64
|
+
# auth_names
|
65
|
+
auth_names = opts[:debug_auth_names] || ['bearer_auth']
|
66
|
+
|
67
|
+
new_options = opts.merge(
|
68
|
+
:operation => :"TechnologyTypesApi.retrieve_technology_types",
|
69
|
+
:header_params => header_params,
|
70
|
+
:query_params => query_params,
|
71
|
+
:form_params => form_params,
|
72
|
+
:body => post_body,
|
73
|
+
:auth_names => auth_names,
|
74
|
+
:return_type => return_type
|
75
|
+
)
|
76
|
+
|
77
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
78
|
+
if @api_client.config.debugging
|
79
|
+
@api_client.config.logger.debug "API called: TechnologyTypesApi#retrieve_technology_types\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
80
|
+
end
|
81
|
+
return data, status_code, headers
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -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.15.0"
|
35
35
|
@default_headers = {
|
36
36
|
'Content-Type' => 'application/json',
|
37
37
|
'User-Agent' => @user_agent
|
@@ -19,6 +19,8 @@ module Patch
|
|
19
19
|
|
20
20
|
attr_accessor :transaction_value_btc_sats
|
21
21
|
|
22
|
+
attr_accessor :average_daily_balance_btc_sats
|
23
|
+
|
22
24
|
attr_accessor :project_id
|
23
25
|
|
24
26
|
attr_accessor :create_order
|
@@ -28,6 +30,7 @@ module Patch
|
|
28
30
|
{
|
29
31
|
:'timestamp' => :'timestamp',
|
30
32
|
:'transaction_value_btc_sats' => :'transaction_value_btc_sats',
|
33
|
+
:'average_daily_balance_btc_sats' => :'average_daily_balance_btc_sats',
|
31
34
|
:'project_id' => :'project_id',
|
32
35
|
:'create_order' => :'create_order'
|
33
36
|
}
|
@@ -41,8 +44,9 @@ module Patch
|
|
41
44
|
# Attribute type mapping.
|
42
45
|
def self.openapi_types
|
43
46
|
{
|
44
|
-
:'timestamp' => :'
|
47
|
+
:'timestamp' => :'Time',
|
45
48
|
:'transaction_value_btc_sats' => :'Integer',
|
49
|
+
:'average_daily_balance_btc_sats' => :'Integer',
|
46
50
|
:'project_id' => :'String',
|
47
51
|
:'create_order' => :'Boolean'
|
48
52
|
}
|
@@ -53,6 +57,7 @@ module Patch
|
|
53
57
|
Set.new([
|
54
58
|
:'timestamp',
|
55
59
|
:'transaction_value_btc_sats',
|
60
|
+
:'average_daily_balance_btc_sats',
|
56
61
|
:'project_id',
|
57
62
|
:'create_order'
|
58
63
|
])
|
@@ -93,12 +98,18 @@ module Patch
|
|
93
98
|
self.transaction_value_btc_sats = attributes[:'transaction_value_btc_sats']
|
94
99
|
end
|
95
100
|
|
101
|
+
if attributes.key?(:'average_daily_balance_btc_sats')
|
102
|
+
self.average_daily_balance_btc_sats = attributes[:'average_daily_balance_btc_sats']
|
103
|
+
end
|
104
|
+
|
96
105
|
if attributes.key?(:'project_id')
|
97
106
|
self.project_id = attributes[:'project_id']
|
98
107
|
end
|
99
108
|
|
100
109
|
if attributes.key?(:'create_order')
|
101
110
|
self.create_order = attributes[:'create_order']
|
111
|
+
else
|
112
|
+
self.create_order = false
|
102
113
|
end
|
103
114
|
end
|
104
115
|
|
@@ -122,6 +133,7 @@ module Patch
|
|
122
133
|
self.class == o.class &&
|
123
134
|
timestamp == o.timestamp &&
|
124
135
|
transaction_value_btc_sats == o.transaction_value_btc_sats &&
|
136
|
+
average_daily_balance_btc_sats == o.average_daily_balance_btc_sats &&
|
125
137
|
project_id == o.project_id &&
|
126
138
|
create_order == o.create_order
|
127
139
|
end
|
@@ -135,7 +147,7 @@ module Patch
|
|
135
147
|
# Calculates hash code according to all attributes.
|
136
148
|
# @return [Integer] Hash code
|
137
149
|
def hash
|
138
|
-
[timestamp, transaction_value_btc_sats, project_id, create_order].hash
|
150
|
+
[timestamp, transaction_value_btc_sats, average_daily_balance_btc_sats, project_id, create_order].hash
|
139
151
|
end
|
140
152
|
|
141
153
|
# Builds the object from hash
|
@@ -21,6 +21,8 @@ module Patch
|
|
21
21
|
|
22
22
|
attr_accessor :transaction_value_eth_gwei
|
23
23
|
|
24
|
+
attr_accessor :average_daily_balance_eth_gwei
|
25
|
+
|
24
26
|
attr_accessor :project_id
|
25
27
|
|
26
28
|
attr_accessor :create_order
|
@@ -31,6 +33,7 @@ module Patch
|
|
31
33
|
:'timestamp' => :'timestamp',
|
32
34
|
:'gas_used' => :'gas_used',
|
33
35
|
:'transaction_value_eth_gwei' => :'transaction_value_eth_gwei',
|
36
|
+
:'average_daily_balance_eth_gwei' => :'average_daily_balance_eth_gwei',
|
34
37
|
:'project_id' => :'project_id',
|
35
38
|
:'create_order' => :'create_order'
|
36
39
|
}
|
@@ -47,6 +50,7 @@ module Patch
|
|
47
50
|
:'timestamp' => :'String',
|
48
51
|
:'gas_used' => :'Integer',
|
49
52
|
:'transaction_value_eth_gwei' => :'Integer',
|
53
|
+
:'average_daily_balance_eth_gwei' => :'Integer',
|
50
54
|
:'project_id' => :'String',
|
51
55
|
:'create_order' => :'Boolean'
|
52
56
|
}
|
@@ -58,6 +62,7 @@ module Patch
|
|
58
62
|
:'timestamp',
|
59
63
|
:'gas_used',
|
60
64
|
:'transaction_value_eth_gwei',
|
65
|
+
:'average_daily_balance_eth_gwei',
|
61
66
|
:'project_id',
|
62
67
|
:'create_order'
|
63
68
|
])
|
@@ -102,12 +107,18 @@ module Patch
|
|
102
107
|
self.transaction_value_eth_gwei = attributes[:'transaction_value_eth_gwei']
|
103
108
|
end
|
104
109
|
|
110
|
+
if attributes.key?(:'average_daily_balance_eth_gwei')
|
111
|
+
self.average_daily_balance_eth_gwei = attributes[:'average_daily_balance_eth_gwei']
|
112
|
+
end
|
113
|
+
|
105
114
|
if attributes.key?(:'project_id')
|
106
115
|
self.project_id = attributes[:'project_id']
|
107
116
|
end
|
108
117
|
|
109
118
|
if attributes.key?(:'create_order')
|
110
119
|
self.create_order = attributes[:'create_order']
|
120
|
+
else
|
121
|
+
self.create_order = false
|
111
122
|
end
|
112
123
|
end
|
113
124
|
|
@@ -132,6 +143,7 @@ module Patch
|
|
132
143
|
timestamp == o.timestamp &&
|
133
144
|
gas_used == o.gas_used &&
|
134
145
|
transaction_value_eth_gwei == o.transaction_value_eth_gwei &&
|
146
|
+
average_daily_balance_eth_gwei == o.average_daily_balance_eth_gwei &&
|
135
147
|
project_id == o.project_id &&
|
136
148
|
create_order == o.create_order
|
137
149
|
end
|
@@ -145,7 +157,7 @@ module Patch
|
|
145
157
|
# Calculates hash code according to all attributes.
|
146
158
|
# @return [Integer] Hash code
|
147
159
|
def hash
|
148
|
-
[timestamp, gas_used, transaction_value_eth_gwei, project_id, create_order].hash
|
160
|
+
[timestamp, gas_used, transaction_value_eth_gwei, average_daily_balance_eth_gwei, project_id, create_order].hash
|
149
161
|
end
|
150
162
|
|
151
163
|
# Builds the object from hash
|
@@ -18,6 +18,9 @@ module Patch
|
|
18
18
|
# A unique uid for the record. UIDs will be prepended by ord_prod or ord_test depending on the mode it was created in.
|
19
19
|
attr_accessor :id
|
20
20
|
|
21
|
+
# The timestamp at which the order was created
|
22
|
+
attr_accessor :created_at
|
23
|
+
|
21
24
|
# The amount of carbon offsets in grams purchased through this order.
|
22
25
|
attr_accessor :mass_g
|
23
26
|
|
@@ -71,6 +74,7 @@ module Patch
|
|
71
74
|
def self.attribute_map
|
72
75
|
{
|
73
76
|
:'id' => :'id',
|
77
|
+
:'created_at' => :'created_at',
|
74
78
|
:'mass_g' => :'mass_g',
|
75
79
|
:'production' => :'production',
|
76
80
|
:'state' => :'state',
|
@@ -92,6 +96,7 @@ module Patch
|
|
92
96
|
def self.openapi_types
|
93
97
|
{
|
94
98
|
:'id' => :'String',
|
99
|
+
:'created_at' => :'Time',
|
95
100
|
:'mass_g' => :'Integer',
|
96
101
|
:'production' => :'Boolean',
|
97
102
|
:'state' => :'String',
|
@@ -143,6 +148,10 @@ module Patch
|
|
143
148
|
self.id = attributes[:'id']
|
144
149
|
end
|
145
150
|
|
151
|
+
if attributes.key?(:'created_at')
|
152
|
+
self.created_at = attributes[:'created_at']
|
153
|
+
end
|
154
|
+
|
146
155
|
if attributes.key?(:'mass_g')
|
147
156
|
self.mass_g = attributes[:'mass_g']
|
148
157
|
end
|
@@ -288,6 +297,7 @@ module Patch
|
|
288
297
|
return true if self.equal?(o)
|
289
298
|
self.class == o.class &&
|
290
299
|
id == o.id &&
|
300
|
+
created_at == o.created_at &&
|
291
301
|
mass_g == o.mass_g &&
|
292
302
|
production == o.production &&
|
293
303
|
state == o.state &&
|
@@ -308,7 +318,7 @@ module Patch
|
|
308
318
|
# Calculates hash code according to all attributes.
|
309
319
|
# @return [Integer] Hash code
|
310
320
|
def hash
|
311
|
-
[id, mass_g, production, state, allocation_state, price_cents_usd, patch_fee_cents_usd, allocations, registry_url, metadata].hash
|
321
|
+
[id, created_at, mass_g, production, state, allocation_state, price_cents_usd, patch_fee_cents_usd, allocations, registry_url, metadata].hash
|
312
322
|
end
|
313
323
|
|
314
324
|
# Builds the object from hash
|
@@ -0,0 +1,240 @@
|
|
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
|
+
# An object containing the parent technology type's name and slug.
|
18
|
+
class ParentTechnologyType
|
19
|
+
# Unique identifier for this type of technology.
|
20
|
+
attr_accessor :slug
|
21
|
+
|
22
|
+
# Name of this technology type.
|
23
|
+
attr_accessor :name
|
24
|
+
|
25
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
26
|
+
def self.attribute_map
|
27
|
+
{
|
28
|
+
:'slug' => :'slug',
|
29
|
+
:'name' => :'name'
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
# Returns all the JSON keys this model knows about
|
34
|
+
def self.acceptable_attributes
|
35
|
+
attribute_map.values
|
36
|
+
end
|
37
|
+
|
38
|
+
# Attribute type mapping.
|
39
|
+
def self.openapi_types
|
40
|
+
{
|
41
|
+
:'slug' => :'String',
|
42
|
+
:'name' => :'String'
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
# List of attributes with nullable: true
|
47
|
+
def self.openapi_nullable
|
48
|
+
Set.new([
|
49
|
+
])
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
# Allows models with corresponding API classes to delegate API operations to those API classes
|
54
|
+
# Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
|
55
|
+
# Eg. Order.create_order delegates to OrdersApi.new.create_order
|
56
|
+
def self.method_missing(message, *args, &block)
|
57
|
+
if Object.const_defined?('Patch::ParentTechnologyTypesApi::OPERATIONS') && Patch::ParentTechnologyTypesApi::OPERATIONS.include?(message)
|
58
|
+
Patch::ParentTechnologyTypesApi.new.send(message, *args)
|
59
|
+
else
|
60
|
+
super
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# Initializes the object
|
65
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
66
|
+
def initialize(attributes = {})
|
67
|
+
if (!attributes.is_a?(Hash))
|
68
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::ParentTechnologyType` initialize method"
|
69
|
+
end
|
70
|
+
|
71
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
72
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
73
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
74
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::ParentTechnologyType`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
75
|
+
end
|
76
|
+
h[k.to_sym] = v
|
77
|
+
}
|
78
|
+
|
79
|
+
if attributes.key?(:'slug')
|
80
|
+
self.slug = attributes[:'slug']
|
81
|
+
end
|
82
|
+
|
83
|
+
if attributes.key?(:'name')
|
84
|
+
self.name = attributes[:'name']
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
89
|
+
# @return Array for valid properties with the reasons
|
90
|
+
def list_invalid_properties
|
91
|
+
invalid_properties = Array.new
|
92
|
+
invalid_properties
|
93
|
+
end
|
94
|
+
|
95
|
+
# Check to see if the all the properties in the model are valid
|
96
|
+
# @return true if the model is valid
|
97
|
+
def valid?
|
98
|
+
true
|
99
|
+
end
|
100
|
+
|
101
|
+
# Checks equality by comparing each attribute.
|
102
|
+
# @param [Object] Object to be compared
|
103
|
+
def ==(o)
|
104
|
+
return true if self.equal?(o)
|
105
|
+
self.class == o.class &&
|
106
|
+
slug == o.slug &&
|
107
|
+
name == o.name
|
108
|
+
end
|
109
|
+
|
110
|
+
# @see the `==` method
|
111
|
+
# @param [Object] Object to be compared
|
112
|
+
def eql?(o)
|
113
|
+
self == o
|
114
|
+
end
|
115
|
+
|
116
|
+
# Calculates hash code according to all attributes.
|
117
|
+
# @return [Integer] Hash code
|
118
|
+
def hash
|
119
|
+
[slug, name].hash
|
120
|
+
end
|
121
|
+
|
122
|
+
# Builds the object from hash
|
123
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
124
|
+
# @return [Object] Returns the model itself
|
125
|
+
def self.build_from_hash(attributes)
|
126
|
+
new.build_from_hash(attributes)
|
127
|
+
end
|
128
|
+
|
129
|
+
# Builds the object from hash
|
130
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
131
|
+
# @return [Object] Returns the model itself
|
132
|
+
def build_from_hash(attributes)
|
133
|
+
return nil unless attributes.is_a?(Hash)
|
134
|
+
self.class.openapi_types.each_pair do |key, type|
|
135
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
136
|
+
self.send("#{key}=", nil)
|
137
|
+
elsif type =~ /\AArray<(.*)>/i
|
138
|
+
# check to ensure the input is an array given that the attribute
|
139
|
+
# is documented as an array but the input is not
|
140
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
141
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
142
|
+
end
|
143
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
144
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
self
|
149
|
+
end
|
150
|
+
|
151
|
+
# Deserializes the data based on type
|
152
|
+
# @param string type Data type
|
153
|
+
# @param string value Value to be deserialized
|
154
|
+
# @return [Object] Deserialized data
|
155
|
+
def _deserialize(type, value)
|
156
|
+
case type.to_sym
|
157
|
+
when :Time
|
158
|
+
Time.parse(value)
|
159
|
+
when :Date
|
160
|
+
Date.parse(value)
|
161
|
+
when :String
|
162
|
+
value.to_s
|
163
|
+
when :Integer
|
164
|
+
value.to_i
|
165
|
+
when :Float
|
166
|
+
value.to_f
|
167
|
+
when :Boolean
|
168
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
169
|
+
true
|
170
|
+
else
|
171
|
+
false
|
172
|
+
end
|
173
|
+
when :Object
|
174
|
+
# generic object (usually a Hash), return directly
|
175
|
+
value
|
176
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
177
|
+
inner_type = Regexp.last_match[:inner_type]
|
178
|
+
value.map { |v| _deserialize(inner_type, v) }
|
179
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
180
|
+
k_type = Regexp.last_match[:k_type]
|
181
|
+
v_type = Regexp.last_match[:v_type]
|
182
|
+
{}.tap do |hash|
|
183
|
+
value.each do |k, v|
|
184
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
185
|
+
end
|
186
|
+
end
|
187
|
+
else # model
|
188
|
+
# models (e.g. Pet) or oneOf
|
189
|
+
klass = Patch.const_get(type)
|
190
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
# Returns the string representation of the object
|
195
|
+
# @return [String] String presentation of the object
|
196
|
+
def to_s
|
197
|
+
to_hash.to_s
|
198
|
+
end
|
199
|
+
|
200
|
+
# to_body is an alias to to_hash (backward compatibility)
|
201
|
+
# @return [Hash] Returns the object in the form of hash
|
202
|
+
def to_body
|
203
|
+
to_hash
|
204
|
+
end
|
205
|
+
|
206
|
+
# Returns the object in the form of hash
|
207
|
+
# @return [Hash] Returns the object in the form of hash
|
208
|
+
def to_hash
|
209
|
+
hash = {}
|
210
|
+
self.class.attribute_map.each_pair do |attr, param|
|
211
|
+
value = self.send(attr)
|
212
|
+
if value.nil?
|
213
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
214
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
215
|
+
end
|
216
|
+
|
217
|
+
hash[param] = _to_hash(value)
|
218
|
+
end
|
219
|
+
hash
|
220
|
+
end
|
221
|
+
|
222
|
+
# Outputs non-array value in the form of hash
|
223
|
+
# For object, use to_hash. Otherwise, just return the value
|
224
|
+
# @param [Object] value Any valid value
|
225
|
+
# @return [Hash] Returns the value in the form of hash
|
226
|
+
def _to_hash(value)
|
227
|
+
if value.is_a?(Array)
|
228
|
+
value.compact.map { |v| _to_hash(v) }
|
229
|
+
elsif value.is_a?(Hash)
|
230
|
+
{}.tap do |hash|
|
231
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
232
|
+
end
|
233
|
+
elsif value.respond_to? :to_hash
|
234
|
+
value.to_hash
|
235
|
+
else
|
236
|
+
value
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|