patch_ruby 1.5.2 → 1.9.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 +26 -0
- data/Gemfile.lock +4 -4
- data/README.md +14 -10
- data/bin/rspec +29 -0
- data/lib/patch_ruby.rb +2 -0
- data/lib/patch_ruby/.api_client.rb.un~ +0 -0
- data/lib/patch_ruby/.configuration.rb.un~ +0 -0
- data/lib/patch_ruby/.version.rb.un~ +0 -0
- data/lib/patch_ruby/api/.orders_api.rb.un~ +0 -0
- data/lib/patch_ruby/api/estimates_api.rb +130 -0
- data/lib/patch_ruby/api/orders_api.rb +11 -2
- data/lib/patch_ruby/models/.create_ethereum_estimate_request.rb.un~ +0 -0
- data/lib/patch_ruby/models/create_bitcoin_estimate_request.rb +253 -0
- data/lib/patch_ruby/models/create_ethereum_estimate_request.rb +264 -0
- data/lib/patch_ruby/models/estimate.rb +1 -1
- data/lib/patch_ruby/models/order.rb +15 -5
- data/lib/patch_ruby/version.rb +1 -1
- data/spec/.spec_helper.rb.un~ +0 -0
- data/spec/integration/.estimates_spec.rb.un~ +0 -0
- data/spec/integration/.orders_spec.rb.un~ +0 -0
- data/spec/integration/.preferences_spec.rb.un~ +0 -0
- data/spec/integration/.projects_spec.rb.un~ +0 -0
- data/spec/integration/estimates_spec.rb +54 -7
- data/spec/integration/orders_spec.rb +17 -17
- data/spec/integration/preferences_spec.rb +0 -6
- data/spec/integration/projects_spec.rb +5 -17
- data/spec/spec_helper.rb +15 -6
- metadata +46 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9f4307913b3197f4bf734c1c2f304210445268d022786c5dff9f454d77a9ca2
|
4
|
+
data.tar.gz: f0d29217913cc6d74e14c43a763e2c05b01aa746a4afcab0b9c8baf426c1b420
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e06026d89b14cbdf33ed4f9d3a3bdd9aa4f698044a1fadd5cf46cca7c981aa469f9eac7095a473b360426d2291802fc11de9136773787704832861e2a496edba
|
7
|
+
data.tar.gz: 514089ea6fe7202c394e7a5b1642a070dda9ff5d1168696b8fa337e2d8f16509365ab38dd7f90ee951e227c1655d7a69a7e7b6ac195b767120b8853e955e8fd7
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,32 @@ 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.9.0] - 2021-08-17
|
9
|
+
|
10
|
+
### Added
|
11
|
+
|
12
|
+
- Add support for querying Orders by `metadata`
|
13
|
+
- Added `transaction_value_eth_gwei` as an alternative way to compute transaction level emissions for ethereum
|
14
|
+
|
15
|
+
## [1.8.0] - 2021-07-20
|
16
|
+
|
17
|
+
### Added
|
18
|
+
|
19
|
+
- Add support for Ethereum estimates
|
20
|
+
|
21
|
+
## [1.7.0] - 2021-07-14
|
22
|
+
|
23
|
+
### Changed
|
24
|
+
|
25
|
+
- [BREAKING] Changed `order.price_cents_usd` and `order.patch_fee_cents_usd` from string to integer.
|
26
|
+
|
27
|
+
## [1.6.0] - 2021-07-14
|
28
|
+
|
29
|
+
### Added
|
30
|
+
|
31
|
+
- Order responses return a `registry_url` field
|
32
|
+
- Add support for Bitcoin estimates
|
33
|
+
|
8
34
|
## [1.5.2] - 2021-03-30
|
9
35
|
|
10
36
|
### Changed
|
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.9.0)
|
5
5
|
json (~> 2.1, >= 2.1.0)
|
6
6
|
typhoeus (~> 1.0, >= 1.0.1)
|
7
7
|
|
@@ -19,11 +19,11 @@ GEM
|
|
19
19
|
coderay (1.1.3)
|
20
20
|
concurrent-ruby (1.1.7)
|
21
21
|
diff-lcs (1.4.3)
|
22
|
-
ethon (0.
|
23
|
-
ffi (>= 1.
|
22
|
+
ethon (0.14.0)
|
23
|
+
ffi (>= 1.15.0)
|
24
24
|
factory_bot (6.1.0)
|
25
25
|
activesupport (>= 5.0.0)
|
26
|
-
ffi (1.15.
|
26
|
+
ffi (1.15.3)
|
27
27
|
i18n (1.8.7)
|
28
28
|
concurrent-ruby (~> 1.0)
|
29
29
|
json (2.5.1)
|
data/README.md
CHANGED
@@ -139,6 +139,10 @@ Patch::Estimate.create_vehicle_estimate(
|
|
139
139
|
year: year
|
140
140
|
)
|
141
141
|
|
142
|
+
# Create a flight estimate
|
143
|
+
transaction_value_btc_sats = 1000; # [Optional] Pass in the transaction value in satoshis
|
144
|
+
Patch::Estimate.create_bitcoin_estimate(transaction_value_btc_sats: transaction_value_btc_sats)
|
145
|
+
|
142
146
|
## You can also specify a project-id field (optional) to be used instead of the preferred one
|
143
147
|
project_id = 'pro_test_1234' # Pass in the project's ID
|
144
148
|
Patch::Estimate.create_mass_estimate(mass_g: mass, project_id: project_id)
|
@@ -218,30 +222,30 @@ Patch::Preference.retrieve_preferences(page: page)
|
|
218
222
|
|
219
223
|
To build the gem locally, run:
|
220
224
|
|
221
|
-
```
|
222
|
-
|
225
|
+
```bash
|
226
|
+
gem build patch_ruby.gemspec
|
223
227
|
```
|
224
228
|
|
225
229
|
This will create a .gem file. To install the local gem:
|
226
230
|
|
227
|
-
```
|
228
|
-
|
231
|
+
```bash
|
232
|
+
gem install patch_ruby-1.x.x.gem
|
229
233
|
```
|
230
234
|
|
231
235
|
Install dependencies:
|
232
236
|
|
233
|
-
```
|
234
|
-
|
237
|
+
```bash
|
238
|
+
bundle install
|
235
239
|
```
|
236
240
|
|
237
241
|
Set up required environment variables:
|
238
242
|
|
239
|
-
```
|
240
|
-
|
243
|
+
```bash
|
244
|
+
export SANDBOX_API_KEY=<SANDBOX API KEY>
|
241
245
|
```
|
242
246
|
|
243
247
|
Run tests:
|
244
248
|
|
245
|
-
```
|
246
|
-
|
249
|
+
```bash
|
250
|
+
bundle exec rspec
|
247
251
|
```
|
data/bin/rspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rspec' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rspec-core", "rspec")
|
data/lib/patch_ruby.rb
CHANGED
@@ -18,6 +18,8 @@ require 'patch_ruby/configuration'
|
|
18
18
|
|
19
19
|
# Models
|
20
20
|
require 'patch_ruby/models/allocation'
|
21
|
+
require 'patch_ruby/models/create_bitcoin_estimate_request'
|
22
|
+
require 'patch_ruby/models/create_ethereum_estimate_request'
|
21
23
|
require 'patch_ruby/models/create_mass_estimate_request'
|
22
24
|
require 'patch_ruby/models/create_order_request'
|
23
25
|
require 'patch_ruby/models/create_preference_request'
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -15,6 +15,8 @@ require 'cgi'
|
|
15
15
|
module Patch
|
16
16
|
class EstimatesApi
|
17
17
|
OPERATIONS = [
|
18
|
+
:create_bitcoin_estimate,
|
19
|
+
:create_ethereum_estimate,
|
18
20
|
:create_flight_estimate,
|
19
21
|
:create_mass_estimate,
|
20
22
|
:create_shipping_estimate,
|
@@ -28,6 +30,134 @@ module Patch
|
|
28
30
|
def initialize(api_client = ApiClient.default)
|
29
31
|
@api_client = api_client
|
30
32
|
end
|
33
|
+
# Create a bitcoin estimate given a timestamp and transaction value
|
34
|
+
# Creates a bitcoin 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.
|
35
|
+
# @param create_bitcoin_estimate_request [CreateBitcoinEstimateRequest]
|
36
|
+
# @param [Hash] opts the optional parameters
|
37
|
+
# @return [EstimateResponse]
|
38
|
+
def create_bitcoin_estimate(create_bitcoin_estimate_request, opts = {})
|
39
|
+
data, _status_code, _headers = create_bitcoin_estimate_with_http_info(create_bitcoin_estimate_request, opts)
|
40
|
+
data
|
41
|
+
end
|
42
|
+
|
43
|
+
# Create a bitcoin estimate given a timestamp and transaction value
|
44
|
+
# Creates a bitcoin 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.
|
45
|
+
# @param create_bitcoin_estimate_request [CreateBitcoinEstimateRequest]
|
46
|
+
# @param [Hash] opts the optional parameters
|
47
|
+
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
|
48
|
+
def create_bitcoin_estimate_with_http_info(create_bitcoin_estimate_request, opts = {})
|
49
|
+
if @api_client.config.debugging
|
50
|
+
@api_client.config.logger.debug 'Calling API: EstimatesApi.create_bitcoin_estimate ...'
|
51
|
+
end
|
52
|
+
# verify the required parameter 'create_bitcoin_estimate_request' is set
|
53
|
+
if @api_client.config.client_side_validation && create_bitcoin_estimate_request.nil?
|
54
|
+
fail ArgumentError, "Missing the required parameter 'create_bitcoin_estimate_request' when calling EstimatesApi.create_bitcoin_estimate"
|
55
|
+
end
|
56
|
+
# resource path
|
57
|
+
local_var_path = '/v1/estimates/crypto/btc'
|
58
|
+
|
59
|
+
# query parameters
|
60
|
+
query_params = opts[:query_params] || {}
|
61
|
+
|
62
|
+
# header parameters
|
63
|
+
header_params = opts[:header_params] || {}
|
64
|
+
# HTTP header 'Accept' (if needed)
|
65
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
66
|
+
# HTTP header 'Content-Type'
|
67
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
|
68
|
+
|
69
|
+
# form parameters
|
70
|
+
form_params = opts[:form_params] || {}
|
71
|
+
|
72
|
+
# http body (model)
|
73
|
+
post_body = opts[:body] || @api_client.object_to_http_body(create_bitcoin_estimate_request)
|
74
|
+
|
75
|
+
# return_type
|
76
|
+
return_type = opts[:return_type] || 'EstimateResponse'
|
77
|
+
|
78
|
+
# auth_names
|
79
|
+
auth_names = opts[:auth_names] || ['bearer_auth']
|
80
|
+
|
81
|
+
new_options = opts.merge(
|
82
|
+
:header_params => header_params,
|
83
|
+
:query_params => query_params,
|
84
|
+
:form_params => form_params,
|
85
|
+
:body => post_body,
|
86
|
+
:auth_names => auth_names,
|
87
|
+
:return_type => return_type
|
88
|
+
)
|
89
|
+
|
90
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
91
|
+
if @api_client.config.debugging
|
92
|
+
@api_client.config.logger.debug "API called: EstimatesApi#create_bitcoin_estimate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
93
|
+
end
|
94
|
+
return data, status_code, headers
|
95
|
+
end
|
96
|
+
|
97
|
+
# Create an ethereum estimate given a timestamp and gas used
|
98
|
+
# 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.
|
99
|
+
# @param create_ethereum_estimate_request [CreateEthereumEstimateRequest]
|
100
|
+
# @param [Hash] opts the optional parameters
|
101
|
+
# @return [EstimateResponse]
|
102
|
+
def create_ethereum_estimate(create_ethereum_estimate_request, opts = {})
|
103
|
+
data, _status_code, _headers = create_ethereum_estimate_with_http_info(create_ethereum_estimate_request, opts)
|
104
|
+
data
|
105
|
+
end
|
106
|
+
|
107
|
+
# Create an ethereum estimate given a timestamp and gas used
|
108
|
+
# 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.
|
109
|
+
# @param create_ethereum_estimate_request [CreateEthereumEstimateRequest]
|
110
|
+
# @param [Hash] opts the optional parameters
|
111
|
+
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
|
112
|
+
def create_ethereum_estimate_with_http_info(create_ethereum_estimate_request, opts = {})
|
113
|
+
if @api_client.config.debugging
|
114
|
+
@api_client.config.logger.debug 'Calling API: EstimatesApi.create_ethereum_estimate ...'
|
115
|
+
end
|
116
|
+
# verify the required parameter 'create_ethereum_estimate_request' is set
|
117
|
+
if @api_client.config.client_side_validation && create_ethereum_estimate_request.nil?
|
118
|
+
fail ArgumentError, "Missing the required parameter 'create_ethereum_estimate_request' when calling EstimatesApi.create_ethereum_estimate"
|
119
|
+
end
|
120
|
+
# resource path
|
121
|
+
local_var_path = '/v1/estimates/crypto/eth'
|
122
|
+
|
123
|
+
# query parameters
|
124
|
+
query_params = opts[:query_params] || {}
|
125
|
+
|
126
|
+
# header parameters
|
127
|
+
header_params = opts[:header_params] || {}
|
128
|
+
# HTTP header 'Accept' (if needed)
|
129
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
130
|
+
# HTTP header 'Content-Type'
|
131
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
|
132
|
+
|
133
|
+
# form parameters
|
134
|
+
form_params = opts[:form_params] || {}
|
135
|
+
|
136
|
+
# http body (model)
|
137
|
+
post_body = opts[:body] || @api_client.object_to_http_body(create_ethereum_estimate_request)
|
138
|
+
|
139
|
+
# return_type
|
140
|
+
return_type = opts[:return_type] || 'EstimateResponse'
|
141
|
+
|
142
|
+
# auth_names
|
143
|
+
auth_names = opts[:auth_names] || ['bearer_auth']
|
144
|
+
|
145
|
+
new_options = opts.merge(
|
146
|
+
:header_params => header_params,
|
147
|
+
:query_params => query_params,
|
148
|
+
:form_params => form_params,
|
149
|
+
:body => post_body,
|
150
|
+
:auth_names => auth_names,
|
151
|
+
:return_type => return_type
|
152
|
+
)
|
153
|
+
|
154
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
155
|
+
if @api_client.config.debugging
|
156
|
+
@api_client.config.logger.debug "API called: EstimatesApi#create_ethereum_estimate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
157
|
+
end
|
158
|
+
return data, status_code, headers
|
159
|
+
end
|
160
|
+
|
31
161
|
# Create a flight estimate given the distance traveled in meters
|
32
162
|
# Creates a flight 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.
|
33
163
|
# @param create_flight_estimate_request [CreateFlightEstimateRequest]
|
@@ -28,7 +28,7 @@ module Patch
|
|
28
28
|
@api_client = api_client
|
29
29
|
end
|
30
30
|
# Cancel an order
|
31
|
-
# Cancelling an order removes the associated offset allocation from an order. You will not be charged for cancelled orders. Only orders in the `draft` state can be cancelled.
|
31
|
+
# Cancelling an order removes the associated offset allocation from an order. You will not be charged for cancelled orders. Only orders in the `draft` or `placed` state can be cancelled.
|
32
32
|
# @param id [String]
|
33
33
|
# @param [Hash] opts the optional parameters
|
34
34
|
# @return [OrderResponse]
|
@@ -38,7 +38,7 @@ module Patch
|
|
38
38
|
end
|
39
39
|
|
40
40
|
# Cancel an order
|
41
|
-
# Cancelling an order removes the associated offset allocation from an order. You will not be charged for cancelled orders. Only orders in the `draft` state can be cancelled.
|
41
|
+
# Cancelling an order removes the associated offset allocation from an order. You will not be charged for cancelled orders. Only orders in the `draft` or `placed` state can be cancelled.
|
42
42
|
# @param id [String]
|
43
43
|
# @param [Hash] opts the optional parameters
|
44
44
|
# @return [Array<(OrderResponse, Integer, Hash)>] OrderResponse data, response status code and response headers
|
@@ -281,6 +281,9 @@ module Patch
|
|
281
281
|
# Retrieves a list of orders and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for.
|
282
282
|
# @param [Hash] opts the optional parameters
|
283
283
|
# @option opts [Integer] :page
|
284
|
+
# @option opts [String] :metadata
|
285
|
+
# @option opts [String] :metadata_example1
|
286
|
+
# @option opts [String] :metadata_example2
|
284
287
|
# @return [OrderListResponse]
|
285
288
|
def retrieve_orders(opts = {})
|
286
289
|
data, _status_code, _headers = retrieve_orders_with_http_info(opts)
|
@@ -291,6 +294,9 @@ module Patch
|
|
291
294
|
# Retrieves a list of orders and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for.
|
292
295
|
# @param [Hash] opts the optional parameters
|
293
296
|
# @option opts [Integer] :page
|
297
|
+
# @option opts [String] :metadata
|
298
|
+
# @option opts [String] :metadata_example1
|
299
|
+
# @option opts [String] :metadata_example2
|
294
300
|
# @return [Array<(OrderListResponse, Integer, Hash)>] OrderListResponse data, response status code and response headers
|
295
301
|
def retrieve_orders_with_http_info(opts = {})
|
296
302
|
if @api_client.config.debugging
|
@@ -302,6 +308,9 @@ module Patch
|
|
302
308
|
# query parameters
|
303
309
|
query_params = opts[:query_params] || {}
|
304
310
|
query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
|
311
|
+
query_params[:'metadata'] = opts[:'metadata'] if !opts[:'metadata'].nil?
|
312
|
+
query_params[:'metadata[example1]'] = opts[:'metadata_example1'] if !opts[:'metadata_example1'].nil?
|
313
|
+
query_params[:'metadata[example2]'] = opts[:'metadata_example2'] if !opts[:'metadata_example2'].nil?
|
305
314
|
|
306
315
|
# header parameters
|
307
316
|
header_params = opts[:header_params] || {}
|
Binary file
|
@@ -0,0 +1,253 @@
|
|
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 CreateBitcoinEstimateRequest
|
17
|
+
attr_accessor :timestamp
|
18
|
+
|
19
|
+
attr_accessor :transaction_value_btc_sats
|
20
|
+
|
21
|
+
attr_accessor :project_id
|
22
|
+
|
23
|
+
attr_accessor :create_order
|
24
|
+
|
25
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
26
|
+
def self.attribute_map
|
27
|
+
{
|
28
|
+
:'timestamp' => :'timestamp',
|
29
|
+
:'transaction_value_btc_sats' => :'transaction_value_btc_sats',
|
30
|
+
:'project_id' => :'project_id',
|
31
|
+
:'create_order' => :'create_order'
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
# Attribute type mapping.
|
36
|
+
def self.openapi_types
|
37
|
+
{
|
38
|
+
:'timestamp' => :'String',
|
39
|
+
:'transaction_value_btc_sats' => :'Integer',
|
40
|
+
:'project_id' => :'String',
|
41
|
+
:'create_order' => :'Boolean'
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
# Set with nullable attributes.
|
46
|
+
def self.openapi_nullable
|
47
|
+
nullable_properties = Set.new
|
48
|
+
|
49
|
+
nullable_properties.add("timestamp")
|
50
|
+
|
51
|
+
nullable_properties.add("transaction_value_btc_sats")
|
52
|
+
|
53
|
+
nullable_properties.add("project_id")
|
54
|
+
|
55
|
+
nullable_properties.add("create_order")
|
56
|
+
|
57
|
+
nullable_properties
|
58
|
+
end
|
59
|
+
|
60
|
+
# Allows models with corresponding API classes to delegate API operations to those API classes
|
61
|
+
# Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
|
62
|
+
# Eg. Order.create_order delegates to OrdersApi.new.create_order
|
63
|
+
def self.method_missing(message, *args, &block)
|
64
|
+
if Object.const_defined?('Patch::CreateBitcoinEstimateRequestsApi::OPERATIONS') && Patch::CreateBitcoinEstimateRequestsApi::OPERATIONS.include?(message)
|
65
|
+
Patch::CreateBitcoinEstimateRequestsApi.new.send(message, *args)
|
66
|
+
else
|
67
|
+
super
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
# Initializes the object
|
72
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
73
|
+
def initialize(attributes = {})
|
74
|
+
if (!attributes.is_a?(Hash))
|
75
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::CreateBitcoinEstimateRequest` initialize method"
|
76
|
+
end
|
77
|
+
|
78
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
79
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
80
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
81
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::CreateBitcoinEstimateRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
82
|
+
end
|
83
|
+
h[k.to_sym] = v
|
84
|
+
}
|
85
|
+
|
86
|
+
if attributes.key?(:'timestamp')
|
87
|
+
self.timestamp = attributes[:'timestamp']
|
88
|
+
end
|
89
|
+
|
90
|
+
if attributes.key?(:'transaction_value_btc_sats')
|
91
|
+
self.transaction_value_btc_sats = attributes[:'transaction_value_btc_sats']
|
92
|
+
end
|
93
|
+
|
94
|
+
if attributes.key?(:'project_id')
|
95
|
+
self.project_id = attributes[:'project_id']
|
96
|
+
end
|
97
|
+
|
98
|
+
if attributes.key?(:'create_order')
|
99
|
+
self.create_order = attributes[:'create_order']
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
104
|
+
# @return Array for valid properties with the reasons
|
105
|
+
def list_invalid_properties
|
106
|
+
invalid_properties = Array.new
|
107
|
+
invalid_properties
|
108
|
+
end
|
109
|
+
|
110
|
+
# Check to see if the all the properties in the model are valid
|
111
|
+
# @return true if the model is valid
|
112
|
+
def valid?
|
113
|
+
true
|
114
|
+
end
|
115
|
+
|
116
|
+
# Checks equality by comparing each attribute.
|
117
|
+
# @param [Object] Object to be compared
|
118
|
+
def ==(o)
|
119
|
+
return true if self.equal?(o)
|
120
|
+
self.class == o.class &&
|
121
|
+
timestamp == o.timestamp &&
|
122
|
+
transaction_value_btc_sats == o.transaction_value_btc_sats &&
|
123
|
+
project_id == o.project_id &&
|
124
|
+
create_order == o.create_order
|
125
|
+
end
|
126
|
+
|
127
|
+
# @see the `==` method
|
128
|
+
# @param [Object] Object to be compared
|
129
|
+
def eql?(o)
|
130
|
+
self == o
|
131
|
+
end
|
132
|
+
|
133
|
+
# Calculates hash code according to all attributes.
|
134
|
+
# @return [Integer] Hash code
|
135
|
+
def hash
|
136
|
+
[timestamp, transaction_value_btc_sats, project_id, create_order].hash
|
137
|
+
end
|
138
|
+
|
139
|
+
# Builds the object from hash
|
140
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
141
|
+
# @return [Object] Returns the model itself
|
142
|
+
def self.build_from_hash(attributes)
|
143
|
+
new.build_from_hash(attributes)
|
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 build_from_hash(attributes)
|
150
|
+
return nil unless attributes.is_a?(Hash)
|
151
|
+
self.class.openapi_types.each_pair do |key, type|
|
152
|
+
if type =~ /\AArray<(.*)>/i
|
153
|
+
# check to ensure the input is an array given that the attribute
|
154
|
+
# is documented as an array but the input is not
|
155
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
156
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
157
|
+
end
|
158
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
159
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
160
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
161
|
+
end
|
162
|
+
|
163
|
+
self
|
164
|
+
end
|
165
|
+
|
166
|
+
# Deserializes the data based on type
|
167
|
+
# @param string type Data type
|
168
|
+
# @param string value Value to be deserialized
|
169
|
+
# @return [Object] Deserialized data
|
170
|
+
def _deserialize(type, value)
|
171
|
+
case type.to_sym
|
172
|
+
when :DateTime
|
173
|
+
DateTime.parse(value)
|
174
|
+
when :Date
|
175
|
+
Date.parse(value)
|
176
|
+
when :String
|
177
|
+
value.to_s
|
178
|
+
when :Integer
|
179
|
+
value.to_i
|
180
|
+
when :Float
|
181
|
+
value.to_f
|
182
|
+
when :Boolean
|
183
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
184
|
+
true
|
185
|
+
else
|
186
|
+
false
|
187
|
+
end
|
188
|
+
when :Object
|
189
|
+
# generic object (usually a Hash), return directly
|
190
|
+
value
|
191
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
192
|
+
inner_type = Regexp.last_match[:inner_type]
|
193
|
+
value.map { |v| _deserialize(inner_type, v) }
|
194
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
195
|
+
k_type = Regexp.last_match[:k_type]
|
196
|
+
v_type = Regexp.last_match[:v_type]
|
197
|
+
{}.tap do |hash|
|
198
|
+
value.each do |k, v|
|
199
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
200
|
+
end
|
201
|
+
end
|
202
|
+
else # model
|
203
|
+
Patch.const_get(type).build_from_hash(value)
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
# Returns the string representation of the object
|
208
|
+
# @return [String] String presentation of the object
|
209
|
+
def to_s
|
210
|
+
to_hash.to_s
|
211
|
+
end
|
212
|
+
|
213
|
+
# to_body is an alias to to_hash (backward compatibility)
|
214
|
+
# @return [Hash] Returns the object in the form of hash
|
215
|
+
def to_body
|
216
|
+
to_hash
|
217
|
+
end
|
218
|
+
|
219
|
+
# Returns the object in the form of hash
|
220
|
+
# @return [Hash] Returns the object in the form of hash
|
221
|
+
def to_hash
|
222
|
+
hash = {}
|
223
|
+
self.class.attribute_map.each_pair do |attr, param|
|
224
|
+
value = self.send(attr)
|
225
|
+
if value.nil?
|
226
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
227
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
228
|
+
end
|
229
|
+
|
230
|
+
hash[param] = _to_hash(value)
|
231
|
+
end
|
232
|
+
hash
|
233
|
+
end
|
234
|
+
|
235
|
+
# Outputs non-array value in the form of hash
|
236
|
+
# For object, use to_hash. Otherwise, just return the value
|
237
|
+
# @param [Object] value Any valid value
|
238
|
+
# @return [Hash] Returns the value in the form of hash
|
239
|
+
def _to_hash(value)
|
240
|
+
if value.is_a?(Array)
|
241
|
+
value.compact.map { |v| _to_hash(v) }
|
242
|
+
elsif value.is_a?(Hash)
|
243
|
+
{}.tap do |hash|
|
244
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
245
|
+
end
|
246
|
+
elsif value.respond_to? :to_hash
|
247
|
+
value.to_hash
|
248
|
+
else
|
249
|
+
value
|
250
|
+
end
|
251
|
+
end
|
252
|
+
end
|
253
|
+
end
|