cryptopay-ruby 2.0.0 → 2.2.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.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +6 -1
  3. data/.rubocop.yml +6 -0
  4. data/README.md +51 -10
  5. data/lib/cryptopay/api/coin_withdrawals.rb +1 -0
  6. data/lib/cryptopay/api/invoices.rb +2 -0
  7. data/lib/cryptopay/api/subscriptions.rb +99 -0
  8. data/lib/cryptopay/client.rb +3 -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/beneficiary.rb +97 -0
  12. data/lib/cryptopay/models/beneficiary_address.rb +113 -0
  13. data/lib/cryptopay/models/beneficiary_type.rb +18 -0
  14. data/lib/cryptopay/models/callback.rb +3 -1
  15. data/lib/cryptopay/models/channel.rb +8 -8
  16. data/lib/cryptopay/models/channel_list_result.rb +8 -8
  17. data/lib/cryptopay/models/channel_params.rb +8 -8
  18. data/lib/cryptopay/models/channel_payment.rb +8 -8
  19. data/lib/cryptopay/models/channel_payment_callback.rb +8 -8
  20. data/lib/cryptopay/models/channel_payment_list_result.rb +8 -8
  21. data/lib/cryptopay/models/channel_payment_result.rb +8 -8
  22. data/lib/cryptopay/models/channel_result.rb +8 -8
  23. data/lib/cryptopay/models/channel_update_params.rb +8 -8
  24. data/lib/cryptopay/models/channels_config.rb +8 -8
  25. data/lib/cryptopay/models/coin.rb +8 -8
  26. data/lib/cryptopay/models/coin_destination_tag.rb +8 -8
  27. data/lib/cryptopay/models/coin_list_result.rb +8 -8
  28. data/lib/cryptopay/models/coin_network.rb +8 -8
  29. data/lib/cryptopay/models/coin_withdrawal.rb +8 -8
  30. data/lib/cryptopay/models/coin_withdrawal_callback.rb +8 -8
  31. data/lib/cryptopay/models/coin_withdrawal_list_result.rb +8 -8
  32. data/lib/cryptopay/models/coin_withdrawal_params.rb +30 -13
  33. data/lib/cryptopay/models/coin_withdrawal_result.rb +8 -8
  34. data/lib/cryptopay/models/coin_withdrawals_config.rb +8 -8
  35. data/lib/cryptopay/models/customer.rb +8 -8
  36. data/lib/cryptopay/models/customer_address.rb +8 -8
  37. data/lib/cryptopay/models/customer_list_result.rb +8 -8
  38. data/lib/cryptopay/models/customer_params.rb +8 -8
  39. data/lib/cryptopay/models/customer_result.rb +8 -8
  40. data/lib/cryptopay/models/customer_update_params.rb +8 -8
  41. data/lib/cryptopay/models/exchange.rb +8 -8
  42. data/lib/cryptopay/models/exchange_transfer.rb +8 -8
  43. data/lib/cryptopay/models/exchange_transfer_params.rb +8 -8
  44. data/lib/cryptopay/models/exchange_transfer_result.rb +8 -8
  45. data/lib/cryptopay/models/invoice.rb +15 -8
  46. data/lib/cryptopay/models/invoice_callback.rb +8 -8
  47. data/lib/cryptopay/models/invoice_list_result.rb +8 -8
  48. data/lib/cryptopay/models/invoice_params.rb +17 -10
  49. data/lib/cryptopay/models/invoice_recalculation.rb +8 -8
  50. data/lib/cryptopay/models/invoice_recalculation_params.rb +8 -8
  51. data/lib/cryptopay/models/invoice_recalculation_result.rb +8 -8
  52. data/lib/cryptopay/models/invoice_refund.rb +8 -8
  53. data/lib/cryptopay/models/invoice_refund_list_result.rb +8 -8
  54. data/lib/cryptopay/models/invoice_refund_params.rb +8 -8
  55. data/lib/cryptopay/models/invoice_refund_result.rb +8 -8
  56. data/lib/cryptopay/models/invoice_result.rb +8 -8
  57. data/lib/cryptopay/models/invoice_transaction.rb +8 -8
  58. data/lib/cryptopay/models/invoices_config.rb +8 -8
  59. data/lib/cryptopay/models/network_fee.rb +8 -8
  60. data/lib/cryptopay/models/network_fee_list_result.rb +8 -8
  61. data/lib/cryptopay/models/pagination.rb +8 -8
  62. data/lib/cryptopay/models/rate.rb +8 -8
  63. data/lib/cryptopay/models/rate_result.rb +8 -8
  64. data/lib/cryptopay/models/rates_result.rb +8 -8
  65. data/lib/cryptopay/models/risk.rb +8 -8
  66. data/lib/cryptopay/models/risk_params.rb +8 -8
  67. data/lib/cryptopay/models/risk_result.rb +8 -8
  68. data/lib/cryptopay/models/subscription.rb +222 -0
  69. data/lib/cryptopay/models/subscription_callback.rb +88 -0
  70. data/lib/cryptopay/models/subscription_callback_event.rb +18 -0
  71. data/lib/cryptopay/models/subscription_list_result.rb +82 -0
  72. data/lib/cryptopay/models/subscription_params.rb +159 -0
  73. data/lib/cryptopay/models/subscription_period.rb +20 -0
  74. data/lib/cryptopay/models/subscription_result.rb +68 -0
  75. data/lib/cryptopay/models/subscription_status.rb +18 -0
  76. data/lib/cryptopay/models/transaction.rb +8 -8
  77. data/lib/cryptopay/models/transaction_list_result.rb +8 -8
  78. data/lib/cryptopay/require.rb +12 -4
  79. data/lib/cryptopay/version.rb +1 -1
  80. metadata +18 -6
@@ -17,6 +17,14 @@ module Cryptopay
17
17
  )
18
18
  private_constant :ENCODER
19
19
 
20
+ # Builds the object from hash
21
+ # @param [Hash] attributes Model attributes in the form of hash
22
+ # @return [Cryptopay::InvoicesConfig] Returns the model itself
23
+ def self.build_from_hash(data)
24
+ attributes = ENCODER.build_from_hash(data)
25
+ new(attributes)
26
+ end
27
+
20
28
  # Initializes the object
21
29
  # @param [Hash] attributes Model attributes in the form of hash
22
30
  def initialize(attributes = {})
@@ -43,14 +51,6 @@ module Cryptopay
43
51
  invalid_properties.empty?
44
52
  end
45
53
 
46
- # Builds the object from hash
47
- # @param [Hash] attributes Model attributes in the form of hash
48
- # @return [Cryptopay::InvoicesConfig] Returns the model itself
49
- def self.build_from_hash(data)
50
- attributes = ENCODER.build_from_hash(data)
51
- new(attributes)
52
- end
53
-
54
54
  # Returns the object in the form of hash
55
55
  # @return [Hash] Returns the object in the form of hash
56
56
  def to_hash
@@ -23,6 +23,14 @@ module Cryptopay
23
23
  )
24
24
  private_constant :ENCODER
25
25
 
26
+ # Builds the object from hash
27
+ # @param [Hash] attributes Model attributes in the form of hash
28
+ # @return [Cryptopay::NetworkFee] Returns the model itself
29
+ def self.build_from_hash(data)
30
+ attributes = ENCODER.build_from_hash(data)
31
+ new(attributes)
32
+ end
33
+
26
34
  # Initializes the object
27
35
  # @param [Hash] attributes Model attributes in the form of hash
28
36
  def initialize(attributes = {})
@@ -71,14 +79,6 @@ module Cryptopay
71
79
  invalid_properties.empty?
72
80
  end
73
81
 
74
- # Builds the object from hash
75
- # @param [Hash] attributes Model attributes in the form of hash
76
- # @return [Cryptopay::NetworkFee] Returns the model itself
77
- def self.build_from_hash(data)
78
- attributes = ENCODER.build_from_hash(data)
79
- new(attributes)
80
- end
81
-
82
82
  # Returns the object in the form of hash
83
83
  # @return [Hash] Returns the object in the form of hash
84
84
  def to_hash
@@ -17,6 +17,14 @@ module Cryptopay
17
17
  )
18
18
  private_constant :ENCODER
19
19
 
20
+ # Builds the object from hash
21
+ # @param [Hash] attributes Model attributes in the form of hash
22
+ # @return [Cryptopay::NetworkFeeListResult] Returns the model itself
23
+ def self.build_from_hash(data)
24
+ attributes = ENCODER.build_from_hash(data)
25
+ new(attributes)
26
+ end
27
+
20
28
  # Initializes the object
21
29
  # @param [Hash] attributes Model attributes in the form of hash
22
30
  def initialize(attributes = {})
@@ -49,14 +57,6 @@ module Cryptopay
49
57
  invalid_properties.empty?
50
58
  end
51
59
 
52
- # Builds the object from hash
53
- # @param [Hash] attributes Model attributes in the form of hash
54
- # @return [Cryptopay::NetworkFeeListResult] Returns the model itself
55
- def self.build_from_hash(data)
56
- attributes = ENCODER.build_from_hash(data)
57
- new(attributes)
58
- end
59
-
60
60
  # Returns the object in the form of hash
61
61
  # @return [Hash] Returns the object in the form of hash
62
62
  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::Pagination] 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 = {})
@@ -51,14 +59,6 @@ module Cryptopay
51
59
  invalid_properties.empty?
52
60
  end
53
61
 
54
- # Builds the object from hash
55
- # @param [Hash] attributes Model attributes in the form of hash
56
- # @return [Cryptopay::Pagination] Returns the model itself
57
- def self.build_from_hash(data)
58
- attributes = ENCODER.build_from_hash(data)
59
- new(attributes)
60
- end
61
-
62
62
  # Returns the object in the form of hash
63
63
  # @return [Hash] Returns the object in the form of hash
64
64
  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::Rate] 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 = {})
@@ -53,14 +61,6 @@ module Cryptopay
53
61
  invalid_properties.empty?
54
62
  end
55
63
 
56
- # Builds the object from hash
57
- # @param [Hash] attributes Model attributes in the form of hash
58
- # @return [Cryptopay::Rate] Returns the model itself
59
- def self.build_from_hash(data)
60
- attributes = ENCODER.build_from_hash(data)
61
- new(attributes)
62
- end
63
-
64
64
  # Returns the object in the form of hash
65
65
  # @return [Hash] Returns the object in the form of hash
66
66
  def to_hash
@@ -17,6 +17,14 @@ module Cryptopay
17
17
  )
18
18
  private_constant :ENCODER
19
19
 
20
+ # Builds the object from hash
21
+ # @param [Hash] attributes Model attributes in the form of hash
22
+ # @return [Cryptopay::RateResult] Returns the model itself
23
+ def self.build_from_hash(data)
24
+ attributes = ENCODER.build_from_hash(data)
25
+ new(attributes)
26
+ end
27
+
20
28
  # Initializes the object
21
29
  # @param [Hash] attributes Model attributes in the form of hash
22
30
  def initialize(attributes = {})
@@ -47,14 +55,6 @@ module Cryptopay
47
55
  invalid_properties.empty?
48
56
  end
49
57
 
50
- # Builds the object from hash
51
- # @param [Hash] attributes Model attributes in the form of hash
52
- # @return [Cryptopay::RateResult] Returns the model itself
53
- def self.build_from_hash(data)
54
- attributes = ENCODER.build_from_hash(data)
55
- new(attributes)
56
- end
57
-
58
58
  # Returns the object in the form of hash
59
59
  # @return [Hash] Returns the object in the form of hash
60
60
  def to_hash
@@ -17,6 +17,14 @@ module Cryptopay
17
17
  )
18
18
  private_constant :ENCODER
19
19
 
20
+ # Builds the object from hash
21
+ # @param [Hash] attributes Model attributes in the form of hash
22
+ # @return [Cryptopay::RatesResult] Returns the model itself
23
+ def self.build_from_hash(data)
24
+ attributes = ENCODER.build_from_hash(data)
25
+ new(attributes)
26
+ end
27
+
20
28
  # Initializes the object
21
29
  # @param [Hash] attributes Model attributes in the form of hash
22
30
  def initialize(attributes = {})
@@ -43,14 +51,6 @@ module Cryptopay
43
51
  invalid_properties.empty?
44
52
  end
45
53
 
46
- # Builds the object from hash
47
- # @param [Hash] attributes Model attributes in the form of hash
48
- # @return [Cryptopay::RatesResult] Returns the model itself
49
- def self.build_from_hash(data)
50
- attributes = ENCODER.build_from_hash(data)
51
- new(attributes)
52
- end
53
-
54
54
  # Returns the object in the form of hash
55
55
  # @return [Hash] Returns the object in the form of hash
56
56
  def to_hash
@@ -24,6 +24,14 @@ module Cryptopay
24
24
  )
25
25
  private_constant :ENCODER
26
26
 
27
+ # Builds the object from hash
28
+ # @param [Hash] attributes Model attributes in the form of hash
29
+ # @return [Cryptopay::Risk] Returns the model itself
30
+ def self.build_from_hash(data)
31
+ attributes = ENCODER.build_from_hash(data)
32
+ new(attributes)
33
+ end
34
+
27
35
  # Initializes the object
28
36
  # @param [Hash] attributes Model attributes in the form of hash
29
37
  def initialize(attributes = {})
@@ -77,14 +85,6 @@ module Cryptopay
77
85
  invalid_properties.empty?
78
86
  end
79
87
 
80
- # Builds the object from hash
81
- # @param [Hash] attributes Model attributes in the form of hash
82
- # @return [Cryptopay::Risk] Returns the model itself
83
- def self.build_from_hash(data)
84
- attributes = ENCODER.build_from_hash(data)
85
- new(attributes)
86
- end
87
-
88
88
  # Returns the object in the form of hash
89
89
  # @return [Hash] Returns the object in the form of hash
90
90
  def to_hash
@@ -21,6 +21,14 @@ module Cryptopay
21
21
  )
22
22
  private_constant :ENCODER
23
23
 
24
+ # Builds the object from hash
25
+ # @param [Hash] attributes Model attributes in the form of hash
26
+ # @return [Cryptopay::RiskParams] Returns the model itself
27
+ def self.build_from_hash(data)
28
+ attributes = ENCODER.build_from_hash(data)
29
+ new(attributes)
30
+ end
31
+
24
32
  # Initializes the object
25
33
  # @param [Hash] attributes Model attributes in the form of hash
26
34
  def initialize(attributes = {})
@@ -65,14 +73,6 @@ module Cryptopay
65
73
  invalid_properties.empty?
66
74
  end
67
75
 
68
- # Builds the object from hash
69
- # @param [Hash] attributes Model attributes in the form of hash
70
- # @return [Cryptopay::RiskParams] Returns the model itself
71
- def self.build_from_hash(data)
72
- attributes = ENCODER.build_from_hash(data)
73
- new(attributes)
74
- end
75
-
76
76
  # Returns the object in the form of hash
77
77
  # @return [Hash] Returns the object in the form of hash
78
78
  def to_hash
@@ -17,6 +17,14 @@ module Cryptopay
17
17
  )
18
18
  private_constant :ENCODER
19
19
 
20
+ # Builds the object from hash
21
+ # @param [Hash] attributes Model attributes in the form of hash
22
+ # @return [Cryptopay::RiskResult] Returns the model itself
23
+ def self.build_from_hash(data)
24
+ attributes = ENCODER.build_from_hash(data)
25
+ new(attributes)
26
+ end
27
+
20
28
  # Initializes the object
21
29
  # @param [Hash] attributes Model attributes in the form of hash
22
30
  def initialize(attributes = {})
@@ -47,14 +55,6 @@ module Cryptopay
47
55
  invalid_properties.empty?
48
56
  end
49
57
 
50
- # Builds the object from hash
51
- # @param [Hash] attributes Model attributes in the form of hash
52
- # @return [Cryptopay::RiskResult] Returns the model itself
53
- def self.build_from_hash(data)
54
- attributes = ENCODER.build_from_hash(data)
55
- new(attributes)
56
- end
57
-
58
58
  # Returns the object in the form of hash
59
59
  # @return [Hash] Returns the object in the form of hash
60
60
  def to_hash
@@ -0,0 +1,222 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Auto-generated file
4
+ # DO NOT EDIT
5
+
6
+ module Cryptopay
7
+ class Subscription
8
+ ENCODER = Encoder.new(
9
+ name: 'Cryptopay::Subscription',
10
+ attribute_map: {
11
+ 'id': :id,
12
+ 'status': :status,
13
+ 'custom_id': :custom_id,
14
+ 'name': :name,
15
+ 'amount': :amount,
16
+ 'currency': :currency,
17
+ 'period': :period,
18
+ 'period_quantity': :period_quantity,
19
+ 'current_period_starts_at': :current_period_starts_at,
20
+ 'current_period_ends_at': :current_period_ends_at,
21
+ 'current_period_paid': :current_period_paid,
22
+ 'payer_email': :payer_email,
23
+ 'payer_name': :payer_name,
24
+ 'product_name': :product_name,
25
+ 'product_description': :product_description,
26
+ 'success_redirect_url': :success_redirect_url,
27
+ 'unsuccess_redirect_url': :unsuccess_redirect_url,
28
+ 'created_at': :created_at,
29
+ 'cancelled_at': :cancelled_at
30
+ },
31
+ types: {
32
+ 'id': :String,
33
+ 'status': :SubscriptionStatus,
34
+ 'custom_id': :String,
35
+ 'name': :String,
36
+ 'amount': :Decimal,
37
+ 'currency': :String,
38
+ 'period': :SubscriptionPeriod,
39
+ 'period_quantity': :Integer,
40
+ 'current_period_starts_at': :Time,
41
+ 'current_period_ends_at': :Time,
42
+ 'current_period_paid': :Boolean,
43
+ 'payer_email': :String,
44
+ 'payer_name': :String,
45
+ 'product_name': :String,
46
+ 'product_description': :String,
47
+ 'success_redirect_url': :String,
48
+ 'unsuccess_redirect_url': :String,
49
+ 'created_at': :Time,
50
+ 'cancelled_at': :Time
51
+ },
52
+ nullables: %i[
53
+ custom_id
54
+ payer_name
55
+ product_name
56
+ product_description
57
+ success_redirect_url
58
+ unsuccess_redirect_url
59
+ cancelled_at
60
+ ]
61
+ )
62
+ private_constant :ENCODER
63
+
64
+ # Builds the object from hash
65
+ # @param [Hash] attributes Model attributes in the form of hash
66
+ # @return [Cryptopay::Subscription] 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
+ # Initializes the object
73
+ # @param [Hash] attributes Model attributes in the form of hash
74
+ def initialize(attributes = {})
75
+ @attributes = ENCODER.sanitize(attributes)
76
+ end
77
+
78
+ # Subscription ID
79
+ def id
80
+ @attributes[:id]
81
+ end
82
+
83
+ def status
84
+ @attributes[:status]
85
+ end
86
+
87
+ # Subscription reference ID in your system
88
+ def custom_id
89
+ @attributes[:custom_id]
90
+ end
91
+
92
+ # Subscription name
93
+ def name
94
+ @attributes[:name]
95
+ end
96
+
97
+ # Subscription amount
98
+ def amount
99
+ @attributes[:amount]
100
+ end
101
+
102
+ # Subscription amount currency
103
+ def currency
104
+ @attributes[:currency]
105
+ end
106
+
107
+ def period
108
+ @attributes[:period]
109
+ end
110
+
111
+ def period_quantity
112
+ @attributes[:period_quantity]
113
+ end
114
+
115
+ def current_period_starts_at
116
+ @attributes[:current_period_starts_at]
117
+ end
118
+
119
+ def current_period_ends_at
120
+ @attributes[:current_period_ends_at]
121
+ end
122
+
123
+ def current_period_paid
124
+ @attributes[:current_period_paid]
125
+ end
126
+
127
+ def payer_email
128
+ @attributes[:payer_email]
129
+ end
130
+
131
+ def payer_name
132
+ @attributes[:payer_name]
133
+ end
134
+
135
+ def product_name
136
+ @attributes[:product_name]
137
+ end
138
+
139
+ def product_description
140
+ @attributes[:product_description]
141
+ end
142
+
143
+ # The URL that the customer will be redirected to upon transaction confirmation
144
+ def success_redirect_url
145
+ @attributes[:success_redirect_url]
146
+ end
147
+
148
+ def unsuccess_redirect_url
149
+ @attributes[:unsuccess_redirect_url]
150
+ end
151
+
152
+ def created_at
153
+ @attributes[:created_at]
154
+ end
155
+
156
+ def cancelled_at
157
+ @attributes[:cancelled_at]
158
+ end
159
+
160
+ # Show invalid properties with the reasons. Usually used together with valid?
161
+ # @return Array for valid properties with the reasons
162
+ def invalid_properties
163
+ properties = []
164
+
165
+ properties.push('invalid value for "id", id cannot be nil.') if id.nil?
166
+
167
+ properties.push('invalid value for "status", status cannot be nil.') if status.nil?
168
+
169
+ if !status.nil? && !%w[active cancelled].include?(status)
170
+ properties.push('invalid value for status, must be one of "active", "cancelled"')
171
+ end
172
+
173
+ properties.push('invalid value for "name", name cannot be nil.') if name.nil?
174
+
175
+ properties.push('invalid value for "amount", amount cannot be nil.') if amount.nil?
176
+
177
+ properties.push('invalid value for "currency", currency cannot be nil.') if currency.nil?
178
+
179
+ properties.push('invalid value for "period", period cannot be nil.') if period.nil?
180
+
181
+ if !period.nil? && !%w[day week month year].include?(period)
182
+ properties.push('invalid value for period, must be one of "day", "week", "month", "year"')
183
+ end
184
+
185
+ properties.push('invalid value for "period_quantity", period_quantity cannot be nil.') if period_quantity.nil?
186
+
187
+ if current_period_starts_at.nil?
188
+ properties.push('invalid value for "current_period_starts_at", current_period_starts_at cannot be nil.')
189
+ end
190
+
191
+ if current_period_ends_at.nil?
192
+ properties.push('invalid value for "current_period_ends_at", current_period_ends_at cannot be nil.')
193
+ end
194
+
195
+ if current_period_paid.nil?
196
+ properties.push('invalid value for "current_period_paid", current_period_paid cannot be nil.')
197
+ end
198
+
199
+ properties.push('invalid value for "payer_email", payer_email cannot be nil.') if payer_email.nil?
200
+
201
+ properties.push('invalid value for "created_at", created_at cannot be nil.') if created_at.nil?
202
+
203
+ properties
204
+ end
205
+
206
+ # Check to see if the all the properties in the model are valid
207
+ # @return true if the model is valid
208
+ def valid?
209
+ invalid_properties.empty?
210
+ end
211
+
212
+ # Returns the object in the form of hash
213
+ # @return [Hash] Returns the object in the form of hash
214
+ def to_hash
215
+ ENCODER.to_hash(@attributes)
216
+ end
217
+
218
+ def inspect
219
+ "#<#{self.class}:0x#{object_id.to_s(16)}> JSON: " + JSON.pretty_generate(to_hash)
220
+ end
221
+ end
222
+ end
@@ -0,0 +1,88 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Auto-generated file
4
+ # DO NOT EDIT
5
+
6
+ module Cryptopay
7
+ class SubscriptionCallback
8
+ ENCODER = Encoder.new(
9
+ name: 'Cryptopay::SubscriptionCallback',
10
+ attribute_map: {
11
+ 'type': :type,
12
+ 'event': :event,
13
+ 'data': :data
14
+ },
15
+ types: {
16
+ 'type': :String,
17
+ 'event': :SubscriptionCallbackEvent,
18
+ 'data': :Subscription
19
+ },
20
+ nullables: []
21
+ )
22
+ private_constant :ENCODER
23
+
24
+ # Builds the object from hash
25
+ # @param [Hash] attributes Model attributes in the form of hash
26
+ # @return [Cryptopay::SubscriptionCallback] Returns the model itself
27
+ def self.build_from_hash(data)
28
+ attributes = ENCODER.build_from_hash(data)
29
+ new(attributes)
30
+ end
31
+
32
+ # Initializes the object
33
+ # @param [Hash] attributes Model attributes in the form of hash
34
+ def initialize(attributes = {})
35
+ @attributes = ENCODER.sanitize(attributes)
36
+ end
37
+
38
+ def type
39
+ @attributes[:type]
40
+ end
41
+
42
+ def event
43
+ @attributes[:event]
44
+ end
45
+
46
+ def data
47
+ @attributes[:data]
48
+ end
49
+
50
+ # Show invalid properties with the reasons. Usually used together with valid?
51
+ # @return Array for valid properties with the reasons
52
+ def invalid_properties
53
+ properties = []
54
+
55
+ properties.push('invalid value for "type", type cannot be nil.') if type.nil?
56
+
57
+ properties.push('invalid value for "event", event cannot be nil.') if event.nil?
58
+
59
+ if !event.nil? && !%w[paid cancelled].include?(event)
60
+ properties.push('invalid value for event, must be one of "paid", "cancelled"')
61
+ end
62
+
63
+ properties.push('invalid value for "data", data cannot be nil.') if data.nil?
64
+
65
+ data&.invalid_properties&.each do |prop|
66
+ properties.push("invalid value for \"data\": #{prop}")
67
+ end
68
+
69
+ properties
70
+ end
71
+
72
+ # Check to see if the all the properties in the model are valid
73
+ # @return true if the model is valid
74
+ def valid?
75
+ invalid_properties.empty?
76
+ end
77
+
78
+ # Returns the object in the form of hash
79
+ # @return [Hash] Returns the object in the form of hash
80
+ def to_hash
81
+ ENCODER.to_hash(@attributes)
82
+ end
83
+
84
+ def inspect
85
+ "#<#{self.class}:0x#{object_id.to_s(16)}> JSON: " + JSON.pretty_generate(to_hash)
86
+ end
87
+ end
88
+ 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 SubscriptionCallbackEvent
8
+ PAID = 'paid'
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