cryptopay-ruby 1.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +6 -1
  3. data/.rubocop.yml +3 -0
  4. data/README.md +69 -5
  5. data/bin/console +2 -1
  6. data/lib/cryptopay/api/invoices.rb +2 -0
  7. data/lib/cryptopay/api/subscriptions.rb +99 -0
  8. data/lib/cryptopay/client.rb +4 -2
  9. data/lib/cryptopay/models/account.rb +8 -8
  10. data/lib/cryptopay/models/account_list_result.rb +8 -8
  11. data/lib/cryptopay/models/callback.rb +3 -1
  12. data/lib/cryptopay/models/channel.rb +8 -8
  13. data/lib/cryptopay/models/channel_list_result.rb +8 -8
  14. data/lib/cryptopay/models/channel_params.rb +8 -8
  15. data/lib/cryptopay/models/channel_payment.rb +8 -8
  16. data/lib/cryptopay/models/channel_payment_callback.rb +8 -8
  17. data/lib/cryptopay/models/channel_payment_list_result.rb +8 -8
  18. data/lib/cryptopay/models/channel_payment_result.rb +8 -8
  19. data/lib/cryptopay/models/channel_result.rb +8 -8
  20. data/lib/cryptopay/models/channel_update_params.rb +8 -8
  21. data/lib/cryptopay/models/channels_config.rb +8 -8
  22. data/lib/cryptopay/models/coin.rb +8 -8
  23. data/lib/cryptopay/models/coin_destination_tag.rb +8 -8
  24. data/lib/cryptopay/models/coin_list_result.rb +8 -8
  25. data/lib/cryptopay/models/coin_network.rb +8 -8
  26. data/lib/cryptopay/models/coin_withdrawal.rb +8 -8
  27. data/lib/cryptopay/models/coin_withdrawal_callback.rb +8 -8
  28. data/lib/cryptopay/models/coin_withdrawal_list_result.rb +8 -8
  29. data/lib/cryptopay/models/coin_withdrawal_params.rb +8 -8
  30. data/lib/cryptopay/models/coin_withdrawal_result.rb +8 -8
  31. data/lib/cryptopay/models/coin_withdrawals_config.rb +8 -8
  32. data/lib/cryptopay/models/customer.rb +19 -13
  33. data/lib/cryptopay/models/customer_address.rb +83 -0
  34. data/lib/cryptopay/models/customer_list_result.rb +8 -8
  35. data/lib/cryptopay/models/customer_params.rb +19 -13
  36. data/lib/cryptopay/models/customer_result.rb +8 -8
  37. data/lib/cryptopay/models/customer_update_params.rb +22 -14
  38. data/lib/cryptopay/models/exchange.rb +8 -8
  39. data/lib/cryptopay/models/exchange_transfer.rb +8 -8
  40. data/lib/cryptopay/models/exchange_transfer_params.rb +8 -8
  41. data/lib/cryptopay/models/exchange_transfer_result.rb +8 -8
  42. data/lib/cryptopay/models/invoice.rb +15 -8
  43. data/lib/cryptopay/models/invoice_callback.rb +8 -8
  44. data/lib/cryptopay/models/invoice_list_result.rb +8 -8
  45. data/lib/cryptopay/models/invoice_params.rb +17 -10
  46. data/lib/cryptopay/models/invoice_recalculation.rb +8 -8
  47. data/lib/cryptopay/models/invoice_recalculation_params.rb +8 -8
  48. data/lib/cryptopay/models/invoice_recalculation_result.rb +8 -8
  49. data/lib/cryptopay/models/invoice_refund.rb +8 -8
  50. data/lib/cryptopay/models/invoice_refund_list_result.rb +8 -8
  51. data/lib/cryptopay/models/invoice_refund_params.rb +8 -8
  52. data/lib/cryptopay/models/invoice_refund_result.rb +8 -8
  53. data/lib/cryptopay/models/invoice_result.rb +8 -8
  54. data/lib/cryptopay/models/invoice_transaction.rb +8 -8
  55. data/lib/cryptopay/models/invoices_config.rb +8 -8
  56. data/lib/cryptopay/models/network_fee.rb +8 -8
  57. data/lib/cryptopay/models/network_fee_list_result.rb +8 -8
  58. data/lib/cryptopay/models/pagination.rb +8 -8
  59. data/lib/cryptopay/models/rate.rb +8 -8
  60. data/lib/cryptopay/models/rate_result.rb +8 -8
  61. data/lib/cryptopay/models/rates_result.rb +8 -8
  62. data/lib/cryptopay/models/risk.rb +8 -8
  63. data/lib/cryptopay/models/risk_params.rb +8 -8
  64. data/lib/cryptopay/models/risk_result.rb +8 -8
  65. data/lib/cryptopay/models/subscription.rb +222 -0
  66. data/lib/cryptopay/models/subscription_callback.rb +88 -0
  67. data/lib/cryptopay/models/subscription_callback_event.rb +18 -0
  68. data/lib/cryptopay/models/subscription_list_result.rb +82 -0
  69. data/lib/cryptopay/models/subscription_params.rb +159 -0
  70. data/lib/cryptopay/models/subscription_period.rb +20 -0
  71. data/lib/cryptopay/models/subscription_result.rb +68 -0
  72. data/lib/cryptopay/models/subscription_status.rb +18 -0
  73. data/lib/cryptopay/models/transaction.rb +8 -8
  74. data/lib/cryptopay/models/transaction_list_result.rb +8 -8
  75. data/lib/cryptopay/require.rb +10 -0
  76. data/lib/cryptopay/version.rb +1 -1
  77. data/lib/cryptopay.rb +8 -9
  78. metadata +16 -6
@@ -0,0 +1,159 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Auto-generated file
4
+ # DO NOT EDIT
5
+
6
+ module Cryptopay
7
+ class SubscriptionParams
8
+ ENCODER = Encoder.new(
9
+ name: 'Cryptopay::SubscriptionParams',
10
+ attribute_map: {
11
+ 'name': :name,
12
+ 'amount': :amount,
13
+ 'currency': :currency,
14
+ 'period': :period,
15
+ 'period_quantity': :period_quantity,
16
+ 'starts_at': :starts_at,
17
+ 'payer_email': :payer_email,
18
+ 'payer_name': :payer_name,
19
+ 'custom_id': :custom_id,
20
+ 'product_name': :product_name,
21
+ 'product_description': :product_description,
22
+ 'success_redirect_url': :success_redirect_url,
23
+ 'unsuccess_redirect_url': :unsuccess_redirect_url
24
+ },
25
+ types: {
26
+ 'name': :String,
27
+ 'amount': :Decimal,
28
+ 'currency': :String,
29
+ 'period': :SubscriptionPeriod,
30
+ 'period_quantity': :Integer,
31
+ 'starts_at': :Time,
32
+ 'payer_email': :String,
33
+ 'payer_name': :String,
34
+ 'custom_id': :String,
35
+ 'product_name': :String,
36
+ 'product_description': :String,
37
+ 'success_redirect_url': :String,
38
+ 'unsuccess_redirect_url': :String
39
+ },
40
+ nullables: []
41
+ )
42
+ private_constant :ENCODER
43
+
44
+ # Builds the object from hash
45
+ # @param [Hash] attributes Model attributes in the form of hash
46
+ # @return [Cryptopay::SubscriptionParams] Returns the model itself
47
+ def self.build_from_hash(data)
48
+ attributes = ENCODER.build_from_hash(data)
49
+ new(attributes)
50
+ end
51
+
52
+ # Initializes the object
53
+ # @param [Hash] attributes Model attributes in the form of hash
54
+ def initialize(attributes = {})
55
+ @attributes = ENCODER.sanitize(attributes)
56
+ end
57
+
58
+ # Subscription name
59
+ def name
60
+ @attributes[:name]
61
+ end
62
+
63
+ # Subscription amount
64
+ def amount
65
+ @attributes[:amount]
66
+ end
67
+
68
+ # Subscription amount currency
69
+ def currency
70
+ @attributes[:currency]
71
+ end
72
+
73
+ def period
74
+ @attributes[:period]
75
+ end
76
+
77
+ def period_quantity
78
+ @attributes[:period_quantity]
79
+ end
80
+
81
+ def starts_at
82
+ @attributes[:starts_at]
83
+ end
84
+
85
+ # Email of the payer
86
+ def payer_email
87
+ @attributes[:payer_email]
88
+ end
89
+
90
+ # Name of the payer
91
+ def payer_name
92
+ @attributes[:payer_name]
93
+ end
94
+
95
+ # Subscription reference ID in your system
96
+ def custom_id
97
+ @attributes[:custom_id]
98
+ end
99
+
100
+ def product_name
101
+ @attributes[:product_name]
102
+ end
103
+
104
+ def product_description
105
+ @attributes[:product_description]
106
+ end
107
+
108
+ # The URL that the customer will be redirected to upon transaction confirmation
109
+ def success_redirect_url
110
+ @attributes[:success_redirect_url]
111
+ end
112
+
113
+ def unsuccess_redirect_url
114
+ @attributes[:unsuccess_redirect_url]
115
+ end
116
+
117
+ # Show invalid properties with the reasons. Usually used together with valid?
118
+ # @return Array for valid properties with the reasons
119
+ def invalid_properties
120
+ properties = []
121
+
122
+ properties.push('invalid value for "name", name cannot be nil.') if name.nil?
123
+
124
+ properties.push('invalid value for "amount", amount cannot be nil.') if amount.nil?
125
+
126
+ properties.push('invalid value for "currency", currency cannot be nil.') if currency.nil?
127
+
128
+ properties.push('invalid value for "period", period cannot be nil.') if period.nil?
129
+
130
+ if !period.nil? && !%w[day week month year].include?(period)
131
+ properties.push('invalid value for period, must be one of "day", "week", "month", "year"')
132
+ end
133
+
134
+ properties.push('invalid value for "period_quantity", period_quantity cannot be nil.') if period_quantity.nil?
135
+
136
+ properties.push('invalid value for "starts_at", starts_at cannot be nil.') if starts_at.nil?
137
+
138
+ properties.push('invalid value for "payer_email", payer_email cannot be nil.') if payer_email.nil?
139
+
140
+ properties
141
+ end
142
+
143
+ # Check to see if the all the properties in the model are valid
144
+ # @return true if the model is valid
145
+ def valid?
146
+ invalid_properties.empty?
147
+ end
148
+
149
+ # Returns the object in the form of hash
150
+ # @return [Hash] Returns the object in the form of hash
151
+ def to_hash
152
+ ENCODER.to_hash(@attributes)
153
+ end
154
+
155
+ def inspect
156
+ "#<#{self.class}:0x#{object_id.to_s(16)}> JSON: " + JSON.pretty_generate(to_hash)
157
+ end
158
+ end
159
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Auto-generated file
4
+ # DO NOT EDIT
5
+
6
+ module Cryptopay
7
+ module SubscriptionPeriod
8
+ DAY = 'day'
9
+ WEEK = 'week'
10
+ MONTH = 'month'
11
+ YEAR = 'year'
12
+
13
+ # Builds the enum from string
14
+ # @param [String] The enum value in the form of the string
15
+ # @return [String] The enum value
16
+ def self.build_from_hash(value)
17
+ value
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Auto-generated file
4
+ # DO NOT EDIT
5
+
6
+ module Cryptopay
7
+ class SubscriptionResult
8
+ ENCODER = Encoder.new(
9
+ name: 'Cryptopay::SubscriptionResult',
10
+ attribute_map: {
11
+ 'data': :data
12
+ },
13
+ types: {
14
+ 'data': :Subscription
15
+ },
16
+ nullables: []
17
+ )
18
+ private_constant :ENCODER
19
+
20
+ # Builds the object from hash
21
+ # @param [Hash] attributes Model attributes in the form of hash
22
+ # @return [Cryptopay::SubscriptionResult] Returns the model itself
23
+ def self.build_from_hash(data)
24
+ attributes = ENCODER.build_from_hash(data)
25
+ new(attributes)
26
+ end
27
+
28
+ # Initializes the object
29
+ # @param [Hash] attributes Model attributes in the form of hash
30
+ def initialize(attributes = {})
31
+ @attributes = ENCODER.sanitize(attributes)
32
+ end
33
+
34
+ def data
35
+ @attributes[:data]
36
+ end
37
+
38
+ # Show invalid properties with the reasons. Usually used together with valid?
39
+ # @return Array for valid properties with the reasons
40
+ def invalid_properties
41
+ properties = []
42
+
43
+ properties.push('invalid value for "data", data cannot be nil.') if data.nil?
44
+
45
+ data&.invalid_properties&.each do |prop|
46
+ properties.push("invalid value for \"data\": #{prop}")
47
+ end
48
+
49
+ properties
50
+ end
51
+
52
+ # Check to see if the all the properties in the model are valid
53
+ # @return true if the model is valid
54
+ def valid?
55
+ invalid_properties.empty?
56
+ end
57
+
58
+ # Returns the object in the form of hash
59
+ # @return [Hash] Returns the object in the form of hash
60
+ def to_hash
61
+ ENCODER.to_hash(@attributes)
62
+ end
63
+
64
+ def inspect
65
+ "#<#{self.class}:0x#{object_id.to_s(16)}> JSON: " + JSON.pretty_generate(to_hash)
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Auto-generated file
4
+ # DO NOT EDIT
5
+
6
+ module Cryptopay
7
+ module SubscriptionStatus
8
+ ACTIVE = 'active'
9
+ CANCELLED = 'cancelled'
10
+
11
+ # Builds the enum from string
12
+ # @param [String] The enum value in the form of the string
13
+ # @return [String] The enum value
14
+ def self.build_from_hash(value)
15
+ value
16
+ end
17
+ end
18
+ end
@@ -51,6 +51,14 @@ module Cryptopay
51
51
  )
52
52
  private_constant :ENCODER
53
53
 
54
+ # Builds the object from hash
55
+ # @param [Hash] attributes Model attributes in the form of hash
56
+ # @return [Cryptopay::Transaction] Returns the model itself
57
+ def self.build_from_hash(data)
58
+ attributes = ENCODER.build_from_hash(data)
59
+ new(attributes)
60
+ end
61
+
54
62
  # Initializes the object
55
63
  # @param [Hash] attributes Model attributes in the form of hash
56
64
  def initialize(attributes = {})
@@ -166,14 +174,6 @@ module Cryptopay
166
174
  invalid_properties.empty?
167
175
  end
168
176
 
169
- # Builds the object from hash
170
- # @param [Hash] attributes Model attributes in the form of hash
171
- # @return [Cryptopay::Transaction] Returns the model itself
172
- def self.build_from_hash(data)
173
- attributes = ENCODER.build_from_hash(data)
174
- new(attributes)
175
- end
176
-
177
177
  # Returns the object in the form of hash
178
178
  # @return [Hash] Returns the object in the form of hash
179
179
  def to_hash
@@ -19,6 +19,14 @@ module Cryptopay
19
19
  )
20
20
  private_constant :ENCODER
21
21
 
22
+ # Builds the object from hash
23
+ # @param [Hash] attributes Model attributes in the form of hash
24
+ # @return [Cryptopay::TransactionListResult] Returns the model itself
25
+ def self.build_from_hash(data)
26
+ attributes = ENCODER.build_from_hash(data)
27
+ new(attributes)
28
+ end
29
+
22
30
  # Initializes the object
23
31
  # @param [Hash] attributes Model attributes in the form of hash
24
32
  def initialize(attributes = {})
@@ -61,14 +69,6 @@ module Cryptopay
61
69
  invalid_properties.empty?
62
70
  end
63
71
 
64
- # Builds the object from hash
65
- # @param [Hash] attributes Model attributes in the form of hash
66
- # @return [Cryptopay::TransactionListResult] Returns the model itself
67
- def self.build_from_hash(data)
68
- attributes = ENCODER.build_from_hash(data)
69
- new(attributes)
70
- end
71
-
72
72
  # Returns the object in the form of hash
73
73
  # @return [Hash] Returns the object in the form of hash
74
74
  def to_hash
@@ -34,6 +34,7 @@ require 'cryptopay/models/coin_withdrawal_result'
34
34
  require 'cryptopay/models/coin_withdrawal_status'
35
35
  require 'cryptopay/models/coin_withdrawals_config'
36
36
  require 'cryptopay/models/customer'
37
+ require 'cryptopay/models/customer_address'
37
38
  require 'cryptopay/models/customer_list_result'
38
39
  require 'cryptopay/models/customer_params'
39
40
  require 'cryptopay/models/customer_result'
@@ -71,6 +72,14 @@ require 'cryptopay/models/risk_level'
71
72
  require 'cryptopay/models/risk_params'
72
73
  require 'cryptopay/models/risk_result'
73
74
  require 'cryptopay/models/risk_type'
75
+ require 'cryptopay/models/subscription'
76
+ require 'cryptopay/models/subscription_callback'
77
+ require 'cryptopay/models/subscription_callback_event'
78
+ require 'cryptopay/models/subscription_list_result'
79
+ require 'cryptopay/models/subscription_params'
80
+ require 'cryptopay/models/subscription_period'
81
+ require 'cryptopay/models/subscription_result'
82
+ require 'cryptopay/models/subscription_status'
74
83
  require 'cryptopay/models/transaction'
75
84
  require 'cryptopay/models/transaction_list_result'
76
85
  require 'cryptopay/models/transaction_reference_type'
@@ -85,4 +94,5 @@ require 'cryptopay/api/exchange_transfers'
85
94
  require 'cryptopay/api/invoices'
86
95
  require 'cryptopay/api/rates'
87
96
  require 'cryptopay/api/risks'
97
+ require 'cryptopay/api/subscriptions'
88
98
  require 'cryptopay/api/transactions'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cryptopay
4
- VERSION = '1.0.0'
4
+ VERSION = '2.1.0'
5
5
  end
data/lib/cryptopay.rb CHANGED
@@ -2,23 +2,22 @@
2
2
 
3
3
  require 'base64'
4
4
  require 'cgi'
5
+ require 'date'
5
6
  require 'faraday'
6
7
  require 'json'
7
- require 'date'
8
8
  require 'time'
9
9
 
10
- # Common files
11
- require 'cryptopay/version'
12
- require 'cryptopay/encoder'
13
- require 'cryptopay/require'
14
- require 'cryptopay/config'
15
10
  require 'cryptopay/authentication'
16
- require 'cryptopay/connection'
17
- require 'cryptopay/types'
18
- require 'cryptopay/request'
19
11
  require 'cryptopay/callbacks'
20
12
  require 'cryptopay/client'
13
+ require 'cryptopay/config'
14
+ require 'cryptopay/connection'
15
+ require 'cryptopay/encoder'
21
16
  require 'cryptopay/errors'
17
+ require 'cryptopay/request'
18
+ require 'cryptopay/require'
19
+ require 'cryptopay/types'
20
+ require 'cryptopay/version'
22
21
 
23
22
  module Cryptopay
24
23
  PRODUCTION = 'https://business.cryptopay.me'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cryptopay-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cryptopay
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-01 00:00:00.000000000 Z
11
+ date: 2023-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -154,6 +154,7 @@ files:
154
154
  - lib/cryptopay/api/invoices.rb
155
155
  - lib/cryptopay/api/rates.rb
156
156
  - lib/cryptopay/api/risks.rb
157
+ - lib/cryptopay/api/subscriptions.rb
157
158
  - lib/cryptopay/api/transactions.rb
158
159
  - lib/cryptopay/authentication.rb
159
160
  - lib/cryptopay/callbacks.rb
@@ -192,6 +193,7 @@ files:
192
193
  - lib/cryptopay/models/coin_withdrawal_status.rb
193
194
  - lib/cryptopay/models/coin_withdrawals_config.rb
194
195
  - lib/cryptopay/models/customer.rb
196
+ - lib/cryptopay/models/customer_address.rb
195
197
  - lib/cryptopay/models/customer_list_result.rb
196
198
  - lib/cryptopay/models/customer_params.rb
197
199
  - lib/cryptopay/models/customer_result.rb
@@ -229,6 +231,14 @@ files:
229
231
  - lib/cryptopay/models/risk_params.rb
230
232
  - lib/cryptopay/models/risk_result.rb
231
233
  - lib/cryptopay/models/risk_type.rb
234
+ - lib/cryptopay/models/subscription.rb
235
+ - lib/cryptopay/models/subscription_callback.rb
236
+ - lib/cryptopay/models/subscription_callback_event.rb
237
+ - lib/cryptopay/models/subscription_list_result.rb
238
+ - lib/cryptopay/models/subscription_params.rb
239
+ - lib/cryptopay/models/subscription_period.rb
240
+ - lib/cryptopay/models/subscription_result.rb
241
+ - lib/cryptopay/models/subscription_status.rb
232
242
  - lib/cryptopay/models/transaction.rb
233
243
  - lib/cryptopay/models/transaction_list_result.rb
234
244
  - lib/cryptopay/models/transaction_reference_type.rb
@@ -243,7 +253,7 @@ metadata:
243
253
  bug_tracker_uri: https://github.com/cryptopay-dev/cryptopay-ruby/issues
244
254
  source_code_uri: https://github.com/cryptopay-dev/cryptopay-ruby
245
255
  rubygems_mfa_required: 'true'
246
- post_install_message:
256
+ post_install_message:
247
257
  rdoc_options: []
248
258
  require_paths:
249
259
  - lib
@@ -258,8 +268,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
258
268
  - !ruby/object:Gem::Version
259
269
  version: '0'
260
270
  requirements: []
261
- rubygems_version: 3.0.3
262
- signing_key:
271
+ rubygems_version: 3.3.20
272
+ signing_key:
263
273
  specification_version: 4
264
274
  summary: The official Ruby gem for the Cryptopay API
265
275
  test_files: []