bleumi_pay_sdk_ruby 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +105 -0
  4. data/Rakefile +10 -0
  5. data/bleumi_pay_sdk_ruby.gemspec +39 -0
  6. data/docs/BadRequest.md +17 -0
  7. data/docs/Erc20PaymentsApi.md +318 -0
  8. data/docs/EthAddress.md +17 -0
  9. data/docs/EthNetwork.md +16 -0
  10. data/docs/PaginatedWalletOperations.md +8 -0
  11. data/docs/PaginatedWallets.md +8 -0
  12. data/docs/Wallet.md +29 -0
  13. data/docs/WalletBalance.md +23 -0
  14. data/docs/WalletCreateInput.md +21 -0
  15. data/docs/WalletCreateOutput.md +19 -0
  16. data/docs/WalletInputs.md +12 -0
  17. data/docs/WalletOperation.md +12 -0
  18. data/docs/WalletOperationInputs.md +21 -0
  19. data/docs/WalletOperationOutput.md +15 -0
  20. data/docs/WalletRefundOperationInput.md +15 -0
  21. data/docs/WalletSettleOperationInput.md +19 -0
  22. data/lib/bleumi_pay_sdk_ruby.rb +55 -0
  23. data/lib/bleumi_pay_sdk_ruby/api/erc20_payments_api.rb +482 -0
  24. data/lib/bleumi_pay_sdk_ruby/api_client.rb +386 -0
  25. data/lib/bleumi_pay_sdk_ruby/api_error.rb +57 -0
  26. data/lib/bleumi_pay_sdk_ruby/configuration.rb +248 -0
  27. data/lib/bleumi_pay_sdk_ruby/models/bad_request.rb +213 -0
  28. data/lib/bleumi_pay_sdk_ruby/models/eth_address.rb +208 -0
  29. data/lib/bleumi_pay_sdk_ruby/models/eth_network.rb +39 -0
  30. data/lib/bleumi_pay_sdk_ruby/models/paginated_wallet_operations.rb +214 -0
  31. data/lib/bleumi_pay_sdk_ruby/models/paginated_wallets.rb +214 -0
  32. data/lib/bleumi_pay_sdk_ruby/models/wallet.rb +293 -0
  33. data/lib/bleumi_pay_sdk_ruby/models/wallet_balance.rb +247 -0
  34. data/lib/bleumi_pay_sdk_ruby/models/wallet_create_input.rb +230 -0
  35. data/lib/bleumi_pay_sdk_ruby/models/wallet_create_output.rb +216 -0
  36. data/lib/bleumi_pay_sdk_ruby/models/wallet_inputs.rb +262 -0
  37. data/lib/bleumi_pay_sdk_ruby/models/wallet_operation.rb +256 -0
  38. data/lib/bleumi_pay_sdk_ruby/models/wallet_operation_inputs.rb +246 -0
  39. data/lib/bleumi_pay_sdk_ruby/models/wallet_operation_output.rb +202 -0
  40. data/lib/bleumi_pay_sdk_ruby/models/wallet_refund_operation_input.rb +201 -0
  41. data/lib/bleumi_pay_sdk_ruby/models/wallet_settle_operation_input.rb +216 -0
  42. data/lib/bleumi_pay_sdk_ruby/version.rb +15 -0
  43. data/spec/api/erc20_payments_api_spec.rb +120 -0
  44. data/spec/api_client_spec.rb +226 -0
  45. data/spec/configuration_spec.rb +42 -0
  46. data/spec/models/bad_request_spec.rb +47 -0
  47. data/spec/models/eth_address_spec.rb +41 -0
  48. data/spec/models/eth_network_spec.rb +35 -0
  49. data/spec/models/paginated_wallet_operations_spec.rb +47 -0
  50. data/spec/models/paginated_wallets_spec.rb +47 -0
  51. data/spec/models/wallet_balance_spec.rb +59 -0
  52. data/spec/models/wallet_create_input_spec.rb +53 -0
  53. data/spec/models/wallet_create_output_spec.rb +47 -0
  54. data/spec/models/wallet_inputs_spec.rb +65 -0
  55. data/spec/models/wallet_operation_inputs_spec.rb +59 -0
  56. data/spec/models/wallet_operation_output_spec.rb +41 -0
  57. data/spec/models/wallet_operation_spec.rb +65 -0
  58. data/spec/models/wallet_refund_operation_input_spec.rb +41 -0
  59. data/spec/models/wallet_settle_operation_input_spec.rb +47 -0
  60. data/spec/models/wallet_spec.rb +77 -0
  61. data/spec/spec_helper.rb +111 -0
  62. metadata +184 -0
@@ -0,0 +1,213 @@
1
+ =begin
2
+ #Bleumi Pay API
3
+
4
+ #A simple and powerful REST API to integrate ERC20 payments into your business or application
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: info@bleumi.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.2.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module BleumiPay
16
+ # Request does not meet API specifications
17
+ class BadRequest
18
+ # Code for error class. Complete list of error codes is available [here](https://pay.bleumi.com/docs/#errors)
19
+ attr_accessor :error_code
20
+
21
+ # Error description
22
+ attr_accessor :error_message
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'error_code' => :'errorCode',
28
+ :'error_message' => :'errorMessage'
29
+ }
30
+ end
31
+
32
+ # Attribute type mapping.
33
+ def self.openapi_types
34
+ {
35
+ :'error_code' => :'String',
36
+ :'error_message' => :'String'
37
+ }
38
+ end
39
+
40
+ # Initializes the object
41
+ # @param [Hash] attributes Model attributes in the form of hash
42
+ def initialize(attributes = {})
43
+ if (!attributes.is_a?(Hash))
44
+ fail ArgumentError, "The input argument (attributes) must be a hash in `BleumiPay::BadRequest` initialize method"
45
+ end
46
+
47
+ # check to see if the attribute exists and convert string to symbol for hash key
48
+ attributes = attributes.each_with_object({}) { |(k, v), h|
49
+ if (!self.class.attribute_map.key?(k.to_sym))
50
+ fail ArgumentError, "`#{k}` is not a valid attribute in `BleumiPay::BadRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
51
+ end
52
+ h[k.to_sym] = v
53
+ }
54
+
55
+ if attributes.key?(:'error_code')
56
+ self.error_code = attributes[:'error_code']
57
+ end
58
+
59
+ if attributes.key?(:'error_message')
60
+ self.error_message = attributes[:'error_message']
61
+ end
62
+ end
63
+
64
+ # Show invalid properties with the reasons. Usually used together with valid?
65
+ # @return Array for valid properties with the reasons
66
+ def list_invalid_properties
67
+ invalid_properties = Array.new
68
+ if @error_code.nil?
69
+ invalid_properties.push('invalid value for "error_code", error_code cannot be nil.')
70
+ end
71
+
72
+ invalid_properties
73
+ end
74
+
75
+ # Check to see if the all the properties in the model are valid
76
+ # @return true if the model is valid
77
+ def valid?
78
+ return false if @error_code.nil?
79
+ true
80
+ end
81
+
82
+ # Checks equality by comparing each attribute.
83
+ # @param [Object] Object to be compared
84
+ def ==(o)
85
+ return true if self.equal?(o)
86
+ self.class == o.class &&
87
+ error_code == o.error_code &&
88
+ error_message == o.error_message
89
+ end
90
+
91
+ # @see the `==` method
92
+ # @param [Object] Object to be compared
93
+ def eql?(o)
94
+ self == o
95
+ end
96
+
97
+ # Calculates hash code according to all attributes.
98
+ # @return [Integer] Hash code
99
+ def hash
100
+ [error_code, error_message].hash
101
+ end
102
+
103
+ # Builds the object from hash
104
+ # @param [Hash] attributes Model attributes in the form of hash
105
+ # @return [Object] Returns the model itself
106
+ def self.build_from_hash(attributes)
107
+ new.build_from_hash(attributes)
108
+ end
109
+
110
+ # Builds the object from hash
111
+ # @param [Hash] attributes Model attributes in the form of hash
112
+ # @return [Object] Returns the model itself
113
+ def build_from_hash(attributes)
114
+ return nil unless attributes.is_a?(Hash)
115
+ self.class.openapi_types.each_pair do |key, type|
116
+ if type =~ /\AArray<(.*)>/i
117
+ # check to ensure the input is an array given that the attribute
118
+ # is documented as an array but the input is not
119
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
120
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
121
+ end
122
+ elsif !attributes[self.class.attribute_map[key]].nil?
123
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
124
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
125
+ end
126
+
127
+ self
128
+ end
129
+
130
+ # Deserializes the data based on type
131
+ # @param string type Data type
132
+ # @param string value Value to be deserialized
133
+ # @return [Object] Deserialized data
134
+ def _deserialize(type, value)
135
+ case type.to_sym
136
+ when :DateTime
137
+ DateTime.parse(value)
138
+ when :Date
139
+ Date.parse(value)
140
+ when :String
141
+ value.to_s
142
+ when :Integer
143
+ value.to_i
144
+ when :Float
145
+ value.to_f
146
+ when :Boolean
147
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
148
+ true
149
+ else
150
+ false
151
+ end
152
+ when :Object
153
+ # generic object (usually a Hash), return directly
154
+ value
155
+ when /\AArray<(?<inner_type>.+)>\z/
156
+ inner_type = Regexp.last_match[:inner_type]
157
+ value.map { |v| _deserialize(inner_type, v) }
158
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
159
+ k_type = Regexp.last_match[:k_type]
160
+ v_type = Regexp.last_match[:v_type]
161
+ {}.tap do |hash|
162
+ value.each do |k, v|
163
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
164
+ end
165
+ end
166
+ else # model
167
+ BleumiPay.const_get(type).build_from_hash(value)
168
+ end
169
+ end
170
+
171
+ # Returns the string representation of the object
172
+ # @return [String] String presentation of the object
173
+ def to_s
174
+ to_hash.to_s
175
+ end
176
+
177
+ # to_body is an alias to to_hash (backward compatibility)
178
+ # @return [Hash] Returns the object in the form of hash
179
+ def to_body
180
+ to_hash
181
+ end
182
+
183
+ # Returns the object in the form of hash
184
+ # @return [Hash] Returns the object in the form of hash
185
+ def to_hash
186
+ hash = {}
187
+ self.class.attribute_map.each_pair do |attr, param|
188
+ value = self.send(attr)
189
+ next if value.nil?
190
+ hash[param] = _to_hash(value)
191
+ end
192
+ hash
193
+ end
194
+
195
+ # Outputs non-array value in the form of hash
196
+ # For object, use to_hash. Otherwise, just return the value
197
+ # @param [Object] value Any valid value
198
+ # @return [Hash] Returns the value in the form of hash
199
+ def _to_hash(value)
200
+ if value.is_a?(Array)
201
+ value.compact.map { |v| _to_hash(v) }
202
+ elsif value.is_a?(Hash)
203
+ {}.tap do |hash|
204
+ value.each { |k, v| hash[k] = _to_hash(v) }
205
+ end
206
+ elsif value.respond_to? :to_hash
207
+ value.to_hash
208
+ else
209
+ value
210
+ end
211
+ end
212
+ end
213
+ end
@@ -0,0 +1,208 @@
1
+ =begin
2
+ #Bleumi Pay API
3
+
4
+ #A simple and powerful REST API to integrate ERC20 payments into your business or application
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: info@bleumi.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.2.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module BleumiPay
16
+ class EthAddress
17
+ # Valid Ethereum address string should pass validation pattern
18
+ attr_accessor :addr
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :'addr' => :'addr'
24
+ }
25
+ end
26
+
27
+ # Attribute type mapping.
28
+ def self.openapi_types
29
+ {
30
+ :'addr' => :'String'
31
+ }
32
+ end
33
+
34
+ def eth_address?(str)
35
+ # We use !! to convert the return value to a boolean
36
+ !!(str =~ /^0x[a-fA-F0-9]{40}$/)
37
+ end
38
+
39
+ # Initializes the object
40
+ # @param [Hash] attributes Model attributes in the form of hash
41
+ def initialize(value)
42
+
43
+ if (!eth_address?(value))
44
+ fail ArgumentError, "`#{value}` The input argument must be valid Ethereum Address `BleumiPay::EthAddress` initialize method"
45
+ end
46
+
47
+ self.addr = value
48
+
49
+ end
50
+
51
+ # validation for updating addr using setter of addr
52
+ def addr=(new_addr)
53
+ if (!eth_address?(new_addr))
54
+ fail ArgumentError, "`#{new_addr}` The input argument must be valid Ethereum Address `BleumiPay::EthAddress` initialize method"
55
+ end
56
+ @addr = new_addr
57
+ end
58
+
59
+ # Show invalid properties with the reasons. Usually used together with valid?
60
+ # @return Array for valid properties with the reasons
61
+ def list_invalid_properties
62
+ invalid_properties = Array.new
63
+ if @addr.nil?
64
+ invalid_properties.push('invalid value for "addr", addr cannot be nil.')
65
+ end
66
+
67
+ invalid_properties
68
+ end
69
+
70
+ # Check to see if the all the properties in the model are valid
71
+ # @return true if the model is valid
72
+ def valid?
73
+ return false if @addr.nil?
74
+ true
75
+ end
76
+
77
+ # Checks equality by comparing each attribute.
78
+ # @param [Object] Object to be compared
79
+ def ==(o)
80
+ return true if self.equal?(o)
81
+ self.class == o.class &&
82
+ addr == o.addr
83
+ end
84
+
85
+ # @see the `==` method
86
+ # @param [Object] Object to be compared
87
+ def eql?(o)
88
+ self == o
89
+ end
90
+
91
+ # Calculates hash code according to all attributes.
92
+ # @return [Integer] Hash code
93
+ def hash
94
+ [addr].hash
95
+ end
96
+
97
+ # Builds the object from hash
98
+ # @param [Hash] attributes Model attributes in the form of hash
99
+ # @return [Object] Returns the model itself
100
+ def self.build_from_hash(attributes)
101
+ new.build_from_hash(attributes)
102
+ end
103
+
104
+ # Builds the object from hash
105
+ # @param [Hash] attributes Model attributes in the form of hash
106
+ # @return [Object] Returns the model itself
107
+ def build_from_hash(attributes)
108
+ return nil unless attributes.is_a?(Hash)
109
+ self.class.openapi_types.each_pair do |key, type|
110
+ if type =~ /\AArray<(.*)>/i
111
+ # check to ensure the input is an array given that the attribute
112
+ # is documented as an array but the input is not
113
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
114
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
115
+ end
116
+ elsif !attributes[self.class.attribute_map[key]].nil?
117
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
118
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
119
+ end
120
+
121
+ self
122
+ end
123
+
124
+ # Deserializes the data based on type
125
+ # @param string type Data type
126
+ # @param string value Value to be deserialized
127
+ # @return [Object] Deserialized data
128
+ def _deserialize(type, value)
129
+ case type.to_sym
130
+ when :DateTime
131
+ DateTime.parse(value)
132
+ when :Date
133
+ Date.parse(value)
134
+ when :String
135
+ value.to_s
136
+ when :Integer
137
+ value.to_i
138
+ when :Float
139
+ value.to_f
140
+ when :Boolean
141
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
142
+ true
143
+ else
144
+ false
145
+ end
146
+ when :Object
147
+ # generic object (usually a Hash), return directly
148
+ value
149
+ when /\AArray<(?<inner_type>.+)>\z/
150
+ inner_type = Regexp.last_match[:inner_type]
151
+ value.map { |v| _deserialize(inner_type, v) }
152
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
153
+ k_type = Regexp.last_match[:k_type]
154
+ v_type = Regexp.last_match[:v_type]
155
+ {}.tap do |hash|
156
+ value.each do |k, v|
157
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
158
+ end
159
+ end
160
+ else # model
161
+ BleumiPay.const_get(type).build_from_hash(value)
162
+ end
163
+ end
164
+
165
+ # Returns the string representation of the object
166
+ # @return [String] String presentation of the object
167
+ def to_s
168
+ to_hash.to_s
169
+ end
170
+
171
+ # to_body is an alias to to_hash (backward compatibility)
172
+ # @return [Hash] Returns the object in the form of hash
173
+ def to_body
174
+ to_hash
175
+ end
176
+
177
+ # Returns the object in the form of hash
178
+ # @return [Hash] Returns the object in the form of hash
179
+ def to_hash
180
+ # hash = {}
181
+ # self.class.attribute_map.each_pair do |attr, param|
182
+ # value = self.send(attr)
183
+ # next if value.nil?
184
+ # hash[param] = _to_hash(value)
185
+ # end
186
+ # hash
187
+ addr
188
+ end
189
+
190
+ # Outputs non-array value in the form of hash
191
+ # For object, use to_hash. Otherwise, just return the value
192
+ # @param [Object] value Any valid value
193
+ # @return [Hash] Returns the value in the form of hash
194
+ def _to_hash(value)
195
+ if value.is_a?(Array)
196
+ value.compact.map { |v| _to_hash(v) }
197
+ elsif value.is_a?(Hash)
198
+ {}.tap do |hash|
199
+ value.each { |k, v| hash[k] = _to_hash(v) }
200
+ end
201
+ elsif value.respond_to? :to_hash
202
+ value.to_hash
203
+ else
204
+ value
205
+ end
206
+ end
207
+ end
208
+ end
@@ -0,0 +1,39 @@
1
+ =begin
2
+ #Bleumi Pay API
3
+
4
+ #A simple and powerful REST API to integrate ERC20 payments into your business or application
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: info@bleumi.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.2.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module BleumiPay
16
+ class EthNetwork
17
+ MAINNET = "mainnet".freeze
18
+ ROPSTEN = "ropsten".freeze
19
+ GOERLI = "goerli".freeze
20
+ KOVAN = "kovan".freeze
21
+ RINKEBY = "rinkeby".freeze
22
+
23
+ # Builds the enum from string
24
+ # @param [String] The enum value in the form of the string
25
+ # @return [String] The enum value
26
+ def self.build_from_hash(value)
27
+ new.build_from_hash(value)
28
+ end
29
+
30
+ # Builds the enum from string
31
+ # @param [String] The enum value in the form of the string
32
+ # @return [String] The enum value
33
+ def build_from_hash(value)
34
+ constantValues = EthNetwork.constants.select { |c| EthNetwork::const_get(c) == value }
35
+ raise "Invalid ENUM value #{value} for class #EthNetwork" if constantValues.empty?
36
+ value
37
+ end
38
+ end
39
+ end