pago-sdk 1.0.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 (49) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/README.md +131 -0
  4. data/lib/pago/base_client.rb +116 -0
  5. data/lib/pago/errors.rb +83 -0
  6. data/lib/pago/http.rb +78 -0
  7. data/lib/pago/model.rb +86 -0
  8. data/lib/pago/paginator.rb +67 -0
  9. data/lib/pago/serde.rb +186 -0
  10. data/lib/pago/service.rb +17 -0
  11. data/lib/pago/v2026_04/client.rb +124 -0
  12. data/lib/pago/v2026_04/enums.rb +4552 -0
  13. data/lib/pago/v2026_04/errors.rb +1121 -0
  14. data/lib/pago/v2026_04/models.rb +46344 -0
  15. data/lib/pago/v2026_04/services/benefit_grants.rb +48 -0
  16. data/lib/pago/v2026_04/services/benefits.rb +179 -0
  17. data/lib/pago/v2026_04/services/checkout_links.rb +131 -0
  18. data/lib/pago/v2026_04/services/checkouts.rb +185 -0
  19. data/lib/pago/v2026_04/services/custom_fields.rb +132 -0
  20. data/lib/pago/v2026_04/services/customer_meters.rb +69 -0
  21. data/lib/pago/v2026_04/services/customer_portal.rb +1181 -0
  22. data/lib/pago/v2026_04/services/customer_seats.rb +137 -0
  23. data/lib/pago/v2026_04/services/customer_sessions.rb +35 -0
  24. data/lib/pago/v2026_04/services/customers.rb +556 -0
  25. data/lib/pago/v2026_04/services/discounts.rb +131 -0
  26. data/lib/pago/v2026_04/services/disputes.rb +93 -0
  27. data/lib/pago/v2026_04/services/event_types.rb +74 -0
  28. data/lib/pago/v2026_04/services/events.rb +126 -0
  29. data/lib/pago/v2026_04/services/files.rb +135 -0
  30. data/lib/pago/v2026_04/services/license_keys.rb +183 -0
  31. data/lib/pago/v2026_04/services/members.rb +47 -0
  32. data/lib/pago/v2026_04/services/meters.rb +142 -0
  33. data/lib/pago/v2026_04/services/metrics.rb +188 -0
  34. data/lib/pago/v2026_04/services/oauth2.rb +175 -0
  35. data/lib/pago/v2026_04/services/orders.rb +238 -0
  36. data/lib/pago/v2026_04/services/organizations.rb +113 -0
  37. data/lib/pago/v2026_04/services/payments.rb +72 -0
  38. data/lib/pago/v2026_04/services/products.rb +142 -0
  39. data/lib/pago/v2026_04/services/refunds.rb +73 -0
  40. data/lib/pago/v2026_04/services/subscriptions.rb +171 -0
  41. data/lib/pago/v2026_04/services/webhooks.rb +212 -0
  42. data/lib/pago/v2026_04/unions.rb +739 -0
  43. data/lib/pago/v2026_04/webhooks.rb +86 -0
  44. data/lib/pago/version.rb +5 -0
  45. data/lib/pago/webhooks.rb +159 -0
  46. data/lib/pago.rb +39 -0
  47. data/sig/pago/v2026_04/generated.rbs +12401 -0
  48. data/sig/pago.rbs +204 -0
  49. metadata +91 -0
@@ -0,0 +1,739 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pago
4
+ module V2026_04
5
+ # Polymorphic schemas of the 2026-04 API.
6
+ #
7
+ # Ruby has no union type, so a union is a factory module instead: call
8
+ # `.from_json` and get back the concrete model the payload describes.
9
+ # Tagged unions dispatch on their discriminator property; untagged ones fall
10
+ # back to matching the payload against the declared keys of each variant.
11
+ # An unrecognised payload is returned as a plain `Hash` rather than raising.
12
+ module Unions
13
+ # Variants: Models::BenefitCustom, Models::BenefitDiscord, Models::BenefitGitHubRepository, Models::BenefitDownloadables, Models::BenefitLicenseKeys, Models::BenefitMeterCredit, Models::BenefitFeatureFlag, Models::BenefitSlackSharedChannel.
14
+ module Benefit
15
+ DISCRIMINATOR = "type"
16
+
17
+ # @return [Hash{String => Class}] discriminator value to model class.
18
+ def self.mapping
19
+ @mapping ||= {
20
+ "custom" => Models::BenefitCustom,
21
+ "discord" => Models::BenefitDiscord,
22
+ "downloadables" => Models::BenefitDownloadables,
23
+ "feature_flag" => Models::BenefitFeatureFlag,
24
+ "github_repository" => Models::BenefitGitHubRepository,
25
+ "license_keys" => Models::BenefitLicenseKeys,
26
+ "meter_credit" => Models::BenefitMeterCredit,
27
+ "slack_shared_channel" => Models::BenefitSlackSharedChannel
28
+ }.freeze
29
+ end
30
+
31
+ # @return [Array<Class>] every model this union can resolve to.
32
+ def self.variants
33
+ @variants ||= [Models::BenefitCustom, Models::BenefitDiscord, Models::BenefitGitHubRepository, Models::BenefitDownloadables, Models::BenefitLicenseKeys, Models::BenefitMeterCredit, Models::BenefitFeatureFlag, Models::BenefitSlackSharedChannel].freeze
34
+ end
35
+
36
+ # @param data [Hash, String, nil]
37
+ # @return [Object, nil] the resolved variant, or the raw payload.
38
+ def self.from_json(data)
39
+ data = ::JSON.parse(data) if data.is_a?(String)
40
+ ::Pago::Serde.union(data, discriminator: DISCRIMINATOR, mapping: mapping, variants: variants)
41
+ end
42
+ end
43
+
44
+ # Variants: Models::BenefitCustomCreate, Models::BenefitDiscordCreate, Models::BenefitGitHubRepositoryCreate, Models::BenefitDownloadablesCreate, Models::BenefitLicenseKeysCreate, Models::BenefitMeterCreditCreate, Models::BenefitFeatureFlagCreate, Models::BenefitSlackSharedChannelCreate.
45
+ module BenefitCreate
46
+ DISCRIMINATOR = "type"
47
+
48
+ # @return [Hash{String => Class}] discriminator value to model class.
49
+ def self.mapping
50
+ @mapping ||= {
51
+ "custom" => Models::BenefitCustomCreate,
52
+ "discord" => Models::BenefitDiscordCreate,
53
+ "downloadables" => Models::BenefitDownloadablesCreate,
54
+ "feature_flag" => Models::BenefitFeatureFlagCreate,
55
+ "github_repository" => Models::BenefitGitHubRepositoryCreate,
56
+ "license_keys" => Models::BenefitLicenseKeysCreate,
57
+ "meter_credit" => Models::BenefitMeterCreditCreate,
58
+ "slack_shared_channel" => Models::BenefitSlackSharedChannelCreate
59
+ }.freeze
60
+ end
61
+
62
+ # @return [Array<Class>] every model this union can resolve to.
63
+ def self.variants
64
+ @variants ||= [Models::BenefitCustomCreate, Models::BenefitDiscordCreate, Models::BenefitGitHubRepositoryCreate, Models::BenefitDownloadablesCreate, Models::BenefitLicenseKeysCreate, Models::BenefitMeterCreditCreate, Models::BenefitFeatureFlagCreate, Models::BenefitSlackSharedChannelCreate].freeze
65
+ end
66
+
67
+ # @param data [Hash, String, nil]
68
+ # @return [Object, nil] the resolved variant, or the raw payload.
69
+ def self.from_json(data)
70
+ data = ::JSON.parse(data) if data.is_a?(String)
71
+ ::Pago::Serde.union(data, discriminator: DISCRIMINATOR, mapping: mapping, variants: variants)
72
+ end
73
+ end
74
+
75
+ # Variants: Models::BenefitGrantDiscordWebhook, Models::BenefitGrantCustomWebhook, Models::BenefitGrantGitHubRepositoryWebhook, Models::BenefitGrantDownloadablesWebhook, Models::BenefitGrantLicenseKeysWebhook, Models::BenefitGrantMeterCreditWebhook, Models::BenefitGrantFeatureFlagWebhook, Models::BenefitGrantSlackSharedChannelWebhook.
76
+ module BenefitGrantWebhook
77
+ DISCRIMINATOR = nil
78
+
79
+ # @return [nil] this union carries no usable discriminator mapping.
80
+ def self.mapping = nil
81
+
82
+ # @return [Array<Class>] every model this union can resolve to.
83
+ def self.variants
84
+ @variants ||= [Models::BenefitGrantDiscordWebhook, Models::BenefitGrantCustomWebhook, Models::BenefitGrantGitHubRepositoryWebhook, Models::BenefitGrantDownloadablesWebhook, Models::BenefitGrantLicenseKeysWebhook, Models::BenefitGrantMeterCreditWebhook, Models::BenefitGrantFeatureFlagWebhook, Models::BenefitGrantSlackSharedChannelWebhook].freeze
85
+ end
86
+
87
+ # @param data [Hash, String, nil]
88
+ # @return [Object, nil] the resolved variant, or the raw payload.
89
+ def self.from_json(data)
90
+ data = ::JSON.parse(data) if data.is_a?(String)
91
+ ::Pago::Serde.union(data, discriminator: DISCRIMINATOR, mapping: mapping, variants: variants)
92
+ end
93
+ end
94
+
95
+ # Variants: Models::AlreadyActiveSubscriptionError, Models::NotOpenCheckout, Models::PaymentNotReady, Models::TrialAlreadyRedeemed.
96
+ module CheckoutForbiddenError
97
+ DISCRIMINATOR = nil
98
+
99
+ # @return [nil] this union carries no usable discriminator mapping.
100
+ def self.mapping = nil
101
+
102
+ # @return [Array<Class>] every model this union can resolve to.
103
+ def self.variants
104
+ @variants ||= [Models::AlreadyActiveSubscriptionError, Models::NotOpenCheckout, Models::PaymentNotReady, Models::TrialAlreadyRedeemed].freeze
105
+ end
106
+
107
+ # @param data [Hash, String, nil]
108
+ # @return [Object, nil] the resolved variant, or the raw payload.
109
+ def self.from_json(data)
110
+ data = ::JSON.parse(data) if data.is_a?(String)
111
+ ::Pago::Serde.union(data, discriminator: DISCRIMINATOR, mapping: mapping, variants: variants)
112
+ end
113
+ end
114
+
115
+ # Variants: Models::CheckoutLinkCreateProductPrice, Models::CheckoutLinkCreateProduct, Models::CheckoutLinkCreateProducts.
116
+ module CheckoutLinkCreate
117
+ DISCRIMINATOR = nil
118
+
119
+ # @return [nil] this union carries no usable discriminator mapping.
120
+ def self.mapping = nil
121
+
122
+ # @return [Array<Class>] every model this union can resolve to.
123
+ def self.variants
124
+ @variants ||= [Models::CheckoutLinkCreateProductPrice, Models::CheckoutLinkCreateProduct, Models::CheckoutLinkCreateProducts].freeze
125
+ end
126
+
127
+ # @param data [Hash, String, nil]
128
+ # @return [Object, nil] the resolved variant, or the raw payload.
129
+ def self.from_json(data)
130
+ data = ::JSON.parse(data) if data.is_a?(String)
131
+ ::Pago::Serde.union(data, discriminator: DISCRIMINATOR, mapping: mapping, variants: variants)
132
+ end
133
+ end
134
+
135
+ # Variants: Models::CustomFieldText, Models::CustomFieldNumber, Models::CustomFieldDate, Models::CustomFieldCheckbox, Models::CustomFieldSelect.
136
+ module CustomField
137
+ DISCRIMINATOR = "type"
138
+
139
+ # @return [Hash{String => Class}] discriminator value to model class.
140
+ def self.mapping
141
+ @mapping ||= {
142
+ "checkbox" => Models::CustomFieldCheckbox,
143
+ "date" => Models::CustomFieldDate,
144
+ "number" => Models::CustomFieldNumber,
145
+ "select" => Models::CustomFieldSelect,
146
+ "text" => Models::CustomFieldText
147
+ }.freeze
148
+ end
149
+
150
+ # @return [Array<Class>] every model this union can resolve to.
151
+ def self.variants
152
+ @variants ||= [Models::CustomFieldText, Models::CustomFieldNumber, Models::CustomFieldDate, Models::CustomFieldCheckbox, Models::CustomFieldSelect].freeze
153
+ end
154
+
155
+ # @param data [Hash, String, nil]
156
+ # @return [Object, nil] the resolved variant, or the raw payload.
157
+ def self.from_json(data)
158
+ data = ::JSON.parse(data) if data.is_a?(String)
159
+ ::Pago::Serde.union(data, discriminator: DISCRIMINATOR, mapping: mapping, variants: variants)
160
+ end
161
+ end
162
+
163
+ # Variants: Models::CustomFieldCreateText, Models::CustomFieldCreateNumber, Models::CustomFieldCreateDate, Models::CustomFieldCreateCheckbox, Models::CustomFieldCreateSelect.
164
+ module CustomFieldCreate
165
+ DISCRIMINATOR = "type"
166
+
167
+ # @return [Hash{String => Class}] discriminator value to model class.
168
+ def self.mapping
169
+ @mapping ||= {
170
+ "checkbox" => Models::CustomFieldCreateCheckbox,
171
+ "date" => Models::CustomFieldCreateDate,
172
+ "number" => Models::CustomFieldCreateNumber,
173
+ "select" => Models::CustomFieldCreateSelect,
174
+ "text" => Models::CustomFieldCreateText
175
+ }.freeze
176
+ end
177
+
178
+ # @return [Array<Class>] every model this union can resolve to.
179
+ def self.variants
180
+ @variants ||= [Models::CustomFieldCreateText, Models::CustomFieldCreateNumber, Models::CustomFieldCreateDate, Models::CustomFieldCreateCheckbox, Models::CustomFieldCreateSelect].freeze
181
+ end
182
+
183
+ # @param data [Hash, String, nil]
184
+ # @return [Object, nil] the resolved variant, or the raw payload.
185
+ def self.from_json(data)
186
+ data = ::JSON.parse(data) if data.is_a?(String)
187
+ ::Pago::Serde.union(data, discriminator: DISCRIMINATOR, mapping: mapping, variants: variants)
188
+ end
189
+ end
190
+
191
+ # Variants: Models::CustomFieldUpdateText, Models::CustomFieldUpdateNumber, Models::CustomFieldUpdateDate, Models::CustomFieldUpdateCheckbox, Models::CustomFieldUpdateSelect.
192
+ module CustomFieldUpdate
193
+ DISCRIMINATOR = "type"
194
+
195
+ # @return [Hash{String => Class}] discriminator value to model class.
196
+ def self.mapping
197
+ @mapping ||= {
198
+ "checkbox" => Models::CustomFieldUpdateCheckbox,
199
+ "date" => Models::CustomFieldUpdateDate,
200
+ "number" => Models::CustomFieldUpdateNumber,
201
+ "select" => Models::CustomFieldUpdateSelect,
202
+ "text" => Models::CustomFieldUpdateText
203
+ }.freeze
204
+ end
205
+
206
+ # @return [Array<Class>] every model this union can resolve to.
207
+ def self.variants
208
+ @variants ||= [Models::CustomFieldUpdateText, Models::CustomFieldUpdateNumber, Models::CustomFieldUpdateDate, Models::CustomFieldUpdateCheckbox, Models::CustomFieldUpdateSelect].freeze
209
+ end
210
+
211
+ # @param data [Hash, String, nil]
212
+ # @return [Object, nil] the resolved variant, or the raw payload.
213
+ def self.from_json(data)
214
+ data = ::JSON.parse(data) if data.is_a?(String)
215
+ ::Pago::Serde.union(data, discriminator: DISCRIMINATOR, mapping: mapping, variants: variants)
216
+ end
217
+ end
218
+
219
+ # Variants: Models::CustomerIndividual, Models::CustomerTeam.
220
+ module Customer
221
+ DISCRIMINATOR = "type"
222
+
223
+ # @return [Hash{String => Class}] discriminator value to model class.
224
+ def self.mapping
225
+ @mapping ||= {
226
+ "individual" => Models::CustomerIndividual,
227
+ "team" => Models::CustomerTeam
228
+ }.freeze
229
+ end
230
+
231
+ # @return [Array<Class>] every model this union can resolve to.
232
+ def self.variants
233
+ @variants ||= [Models::CustomerIndividual, Models::CustomerTeam].freeze
234
+ end
235
+
236
+ # @param data [Hash, String, nil]
237
+ # @return [Object, nil] the resolved variant, or the raw payload.
238
+ def self.from_json(data)
239
+ data = ::JSON.parse(data) if data.is_a?(String)
240
+ ::Pago::Serde.union(data, discriminator: DISCRIMINATOR, mapping: mapping, variants: variants)
241
+ end
242
+ end
243
+
244
+ # Variants: Models::CustomerBenefitGrantDiscord, Models::CustomerBenefitGrantGitHubRepository, Models::CustomerBenefitGrantDownloadables, Models::CustomerBenefitGrantLicenseKeys, Models::CustomerBenefitGrantCustom, Models::CustomerBenefitGrantMeterCredit, Models::CustomerBenefitGrantFeatureFlag, Models::CustomerBenefitGrantSlackSharedChannel.
245
+ module CustomerBenefitGrant
246
+ DISCRIMINATOR = nil
247
+
248
+ # @return [nil] this union carries no usable discriminator mapping.
249
+ def self.mapping = nil
250
+
251
+ # @return [Array<Class>] every model this union can resolve to.
252
+ def self.variants
253
+ @variants ||= [Models::CustomerBenefitGrantDiscord, Models::CustomerBenefitGrantGitHubRepository, Models::CustomerBenefitGrantDownloadables, Models::CustomerBenefitGrantLicenseKeys, Models::CustomerBenefitGrantCustom, Models::CustomerBenefitGrantMeterCredit, Models::CustomerBenefitGrantFeatureFlag, Models::CustomerBenefitGrantSlackSharedChannel].freeze
254
+ end
255
+
256
+ # @param data [Hash, String, nil]
257
+ # @return [Object, nil] the resolved variant, or the raw payload.
258
+ def self.from_json(data)
259
+ data = ::JSON.parse(data) if data.is_a?(String)
260
+ ::Pago::Serde.union(data, discriminator: DISCRIMINATOR, mapping: mapping, variants: variants)
261
+ end
262
+ end
263
+
264
+ # Variants: Models::CustomerBenefitGrantDiscordUpdate, Models::CustomerBenefitGrantGitHubRepositoryUpdate, Models::CustomerBenefitGrantDownloadablesUpdate, Models::CustomerBenefitGrantLicenseKeysUpdate, Models::CustomerBenefitGrantCustomUpdate, Models::CustomerBenefitGrantMeterCreditUpdate, Models::CustomerBenefitGrantFeatureFlagUpdate, Models::CustomerBenefitGrantSlackSharedChannelUpdate.
265
+ module CustomerBenefitGrantUpdate
266
+ DISCRIMINATOR = "benefit_type"
267
+
268
+ # @return [Hash{String => Class}] discriminator value to model class.
269
+ def self.mapping
270
+ @mapping ||= {
271
+ "custom" => Models::CustomerBenefitGrantCustomUpdate,
272
+ "discord" => Models::CustomerBenefitGrantDiscordUpdate,
273
+ "downloadables" => Models::CustomerBenefitGrantDownloadablesUpdate,
274
+ "feature_flag" => Models::CustomerBenefitGrantFeatureFlagUpdate,
275
+ "github_repository" => Models::CustomerBenefitGrantGitHubRepositoryUpdate,
276
+ "license_keys" => Models::CustomerBenefitGrantLicenseKeysUpdate,
277
+ "meter_credit" => Models::CustomerBenefitGrantMeterCreditUpdate,
278
+ "slack_shared_channel" => Models::CustomerBenefitGrantSlackSharedChannelUpdate
279
+ }.freeze
280
+ end
281
+
282
+ # @return [Array<Class>] every model this union can resolve to.
283
+ def self.variants
284
+ @variants ||= [Models::CustomerBenefitGrantDiscordUpdate, Models::CustomerBenefitGrantGitHubRepositoryUpdate, Models::CustomerBenefitGrantDownloadablesUpdate, Models::CustomerBenefitGrantLicenseKeysUpdate, Models::CustomerBenefitGrantCustomUpdate, Models::CustomerBenefitGrantMeterCreditUpdate, Models::CustomerBenefitGrantFeatureFlagUpdate, Models::CustomerBenefitGrantSlackSharedChannelUpdate].freeze
285
+ end
286
+
287
+ # @param data [Hash, String, nil]
288
+ # @return [Object, nil] the resolved variant, or the raw payload.
289
+ def self.from_json(data)
290
+ data = ::JSON.parse(data) if data.is_a?(String)
291
+ ::Pago::Serde.union(data, discriminator: DISCRIMINATOR, mapping: mapping, variants: variants)
292
+ end
293
+ end
294
+
295
+ # Variants: Models::CustomerIndividualCreate, Models::CustomerTeamCreate.
296
+ module CustomerCreate
297
+ DISCRIMINATOR = nil
298
+
299
+ # @return [nil] this union carries no usable discriminator mapping.
300
+ def self.mapping = nil
301
+
302
+ # @return [Array<Class>] every model this union can resolve to.
303
+ def self.variants
304
+ @variants ||= [Models::CustomerIndividualCreate, Models::CustomerTeamCreate].freeze
305
+ end
306
+
307
+ # @param data [Hash, String, nil]
308
+ # @return [Object, nil] the resolved variant, or the raw payload.
309
+ def self.from_json(data)
310
+ data = ::JSON.parse(data) if data.is_a?(String)
311
+ ::Pago::Serde.union(data, discriminator: DISCRIMINATOR, mapping: mapping, variants: variants)
312
+ end
313
+ end
314
+
315
+ # Variants: Models::PaymentMethodCard, Models::PaymentMethodGeneric.
316
+ module CustomerPaymentMethod
317
+ DISCRIMINATOR = nil
318
+
319
+ # @return [nil] this union carries no usable discriminator mapping.
320
+ def self.mapping = nil
321
+
322
+ # @return [Array<Class>] every model this union can resolve to.
323
+ def self.variants
324
+ @variants ||= [Models::PaymentMethodCard, Models::PaymentMethodGeneric].freeze
325
+ end
326
+
327
+ # @param data [Hash, String, nil]
328
+ # @return [Object, nil] the resolved variant, or the raw payload.
329
+ def self.from_json(data)
330
+ data = ::JSON.parse(data) if data.is_a?(String)
331
+ ::Pago::Serde.union(data, discriminator: DISCRIMINATOR, mapping: mapping, variants: variants)
332
+ end
333
+ end
334
+
335
+ # Variants: Models::CustomerPaymentMethodCreateSucceededResponse, Models::CustomerPaymentMethodCreateRequiresActionResponse.
336
+ module CustomerPaymentMethodCreateResponse
337
+ DISCRIMINATOR = "status"
338
+
339
+ # @return [Hash{String => Class}] discriminator value to model class.
340
+ def self.mapping
341
+ @mapping ||= {
342
+ "requires_action" => Models::CustomerPaymentMethodCreateRequiresActionResponse,
343
+ "succeeded" => Models::CustomerPaymentMethodCreateSucceededResponse
344
+ }.freeze
345
+ end
346
+
347
+ # @return [Array<Class>] every model this union can resolve to.
348
+ def self.variants
349
+ @variants ||= [Models::CustomerPaymentMethodCreateSucceededResponse, Models::CustomerPaymentMethodCreateRequiresActionResponse].freeze
350
+ end
351
+
352
+ # @param data [Hash, String, nil]
353
+ # @return [Object, nil] the resolved variant, or the raw payload.
354
+ def self.from_json(data)
355
+ data = ::JSON.parse(data) if data.is_a?(String)
356
+ ::Pago::Serde.union(data, discriminator: DISCRIMINATOR, mapping: mapping, variants: variants)
357
+ end
358
+ end
359
+
360
+ # Variants: Models::CustomerStateIndividual, Models::CustomerStateTeam.
361
+ module CustomerState
362
+ DISCRIMINATOR = "type"
363
+
364
+ # @return [Hash{String => Class}] discriminator value to model class.
365
+ def self.mapping
366
+ @mapping ||= {
367
+ "individual" => Models::CustomerStateIndividual,
368
+ "team" => Models::CustomerStateTeam
369
+ }.freeze
370
+ end
371
+
372
+ # @return [Array<Class>] every model this union can resolve to.
373
+ def self.variants
374
+ @variants ||= [Models::CustomerStateIndividual, Models::CustomerStateTeam].freeze
375
+ end
376
+
377
+ # @param data [Hash, String, nil]
378
+ # @return [Object, nil] the resolved variant, or the raw payload.
379
+ def self.from_json(data)
380
+ data = ::JSON.parse(data) if data.is_a?(String)
381
+ ::Pago::Serde.union(data, discriminator: DISCRIMINATOR, mapping: mapping, variants: variants)
382
+ end
383
+ end
384
+
385
+ # Variants: Models::CustomerSubscriptionUpdateProduct, Models::CustomerSubscriptionUpdateSeats, Models::CustomerSubscriptionCancel, Models::CustomerSubscriptionPause, Models::CustomerSubscriptionResume, Models::CustomerSubscriptionUpdateClear.
386
+ module CustomerSubscriptionUpdate
387
+ DISCRIMINATOR = nil
388
+
389
+ # @return [nil] this union carries no usable discriminator mapping.
390
+ def self.mapping = nil
391
+
392
+ # @return [Array<Class>] every model this union can resolve to.
393
+ def self.variants
394
+ @variants ||= [Models::CustomerSubscriptionUpdateProduct, Models::CustomerSubscriptionUpdateSeats, Models::CustomerSubscriptionCancel, Models::CustomerSubscriptionPause, Models::CustomerSubscriptionResume, Models::CustomerSubscriptionUpdateClear].freeze
395
+ end
396
+
397
+ # @param data [Hash, String, nil]
398
+ # @return [Object, nil] the resolved variant, or the raw payload.
399
+ def self.from_json(data)
400
+ data = ::JSON.parse(data) if data.is_a?(String)
401
+ ::Pago::Serde.union(data, discriminator: DISCRIMINATOR, mapping: mapping, variants: variants)
402
+ end
403
+ end
404
+
405
+ # Variants: Models::DiscountFixedOnceForeverDuration, Models::DiscountFixedRepeatDuration, Models::DiscountPercentageOnceForeverDuration, Models::DiscountPercentageRepeatDuration.
406
+ module Discount
407
+ DISCRIMINATOR = nil
408
+
409
+ # @return [nil] this union carries no usable discriminator mapping.
410
+ def self.mapping = nil
411
+
412
+ # @return [Array<Class>] every model this union can resolve to.
413
+ def self.variants
414
+ @variants ||= [Models::DiscountFixedOnceForeverDuration, Models::DiscountFixedRepeatDuration, Models::DiscountPercentageOnceForeverDuration, Models::DiscountPercentageRepeatDuration].freeze
415
+ end
416
+
417
+ # @param data [Hash, String, nil]
418
+ # @return [Object, nil] the resolved variant, or the raw payload.
419
+ def self.from_json(data)
420
+ data = ::JSON.parse(data) if data.is_a?(String)
421
+ ::Pago::Serde.union(data, discriminator: DISCRIMINATOR, mapping: mapping, variants: variants)
422
+ end
423
+ end
424
+
425
+ # Variants: Models::DiscountFixedCreate, Models::DiscountPercentageCreate.
426
+ module DiscountCreate
427
+ DISCRIMINATOR = "type"
428
+
429
+ # @return [Hash{String => Class}] discriminator value to model class.
430
+ def self.mapping
431
+ @mapping ||= {
432
+ "fixed" => Models::DiscountFixedCreate,
433
+ "percentage" => Models::DiscountPercentageCreate
434
+ }.freeze
435
+ end
436
+
437
+ # @return [Array<Class>] every model this union can resolve to.
438
+ def self.variants
439
+ @variants ||= [Models::DiscountFixedCreate, Models::DiscountPercentageCreate].freeze
440
+ end
441
+
442
+ # @param data [Hash, String, nil]
443
+ # @return [Object, nil] the resolved variant, or the raw payload.
444
+ def self.from_json(data)
445
+ data = ::JSON.parse(data) if data.is_a?(String)
446
+ ::Pago::Serde.union(data, discriminator: DISCRIMINATOR, mapping: mapping, variants: variants)
447
+ end
448
+ end
449
+
450
+ # Variants: Object, Models::UserEvent.
451
+ module Event
452
+ DISCRIMINATOR = "source"
453
+
454
+ # @return [Hash{String => Class}] discriminator value to model class.
455
+ def self.mapping
456
+ @mapping ||= {
457
+ "system" => Unions::SystemEvent,
458
+ "user" => Models::UserEvent
459
+ }.freeze
460
+ end
461
+
462
+ # @return [Array<Class>] every model this union can resolve to.
463
+ def self.variants
464
+ @variants ||= [Unions::SystemEvent, Models::UserEvent].freeze
465
+ end
466
+
467
+ # @param data [Hash, String, nil]
468
+ # @return [Object, nil] the resolved variant, or the raw payload.
469
+ def self.from_json(data)
470
+ data = ::JSON.parse(data) if data.is_a?(String)
471
+ ::Pago::Serde.union(data, discriminator: DISCRIMINATOR, mapping: mapping, variants: variants)
472
+ end
473
+ end
474
+
475
+ # Variants: Models::DownloadableFileCreate, Models::ProductMediaFileCreate, Models::OrganizationAvatarFileCreate, Models::SupportCaseAttachmentFileCreate.
476
+ module FileCreate
477
+ DISCRIMINATOR = "service"
478
+
479
+ # @return [Hash{String => Class}] discriminator value to model class.
480
+ def self.mapping
481
+ @mapping ||= {
482
+ "downloadable" => Models::DownloadableFileCreate,
483
+ "organization_avatar" => Models::OrganizationAvatarFileCreate,
484
+ "product_media" => Models::ProductMediaFileCreate,
485
+ "support_case_attachment" => Models::SupportCaseAttachmentFileCreate
486
+ }.freeze
487
+ end
488
+
489
+ # @return [Array<Class>] every model this union can resolve to.
490
+ def self.variants
491
+ @variants ||= [Models::DownloadableFileCreate, Models::ProductMediaFileCreate, Models::OrganizationAvatarFileCreate, Models::SupportCaseAttachmentFileCreate].freeze
492
+ end
493
+
494
+ # @param data [Hash, String, nil]
495
+ # @return [Object, nil] the resolved variant, or the raw payload.
496
+ def self.from_json(data)
497
+ data = ::JSON.parse(data) if data.is_a?(String)
498
+ ::Pago::Serde.union(data, discriminator: DISCRIMINATOR, mapping: mapping, variants: variants)
499
+ end
500
+ end
501
+
502
+ # Variants: Models::DownloadableFileRead, Models::ProductMediaFileRead, Models::OrganizationAvatarFileRead, Models::SupportCaseAttachmentFileRead.
503
+ module FileRead
504
+ DISCRIMINATOR = "service"
505
+
506
+ # @return [Hash{String => Class}] discriminator value to model class.
507
+ def self.mapping
508
+ @mapping ||= {
509
+ "downloadable" => Models::DownloadableFileRead,
510
+ "organization_avatar" => Models::OrganizationAvatarFileRead,
511
+ "product_media" => Models::ProductMediaFileRead,
512
+ "support_case_attachment" => Models::SupportCaseAttachmentFileRead
513
+ }.freeze
514
+ end
515
+
516
+ # @return [Array<Class>] every model this union can resolve to.
517
+ def self.variants
518
+ @variants ||= [Models::DownloadableFileRead, Models::ProductMediaFileRead, Models::OrganizationAvatarFileRead, Models::SupportCaseAttachmentFileRead].freeze
519
+ end
520
+
521
+ # @param data [Hash, String, nil]
522
+ # @return [Object, nil] the resolved variant, or the raw payload.
523
+ def self.from_json(data)
524
+ data = ::JSON.parse(data) if data.is_a?(String)
525
+ ::Pago::Serde.union(data, discriminator: DISCRIMINATOR, mapping: mapping, variants: variants)
526
+ end
527
+ end
528
+
529
+ # Variants: Models::LegacyRecurringProductPriceFixed, Models::LegacyRecurringProductPriceCustom.
530
+ module LegacyRecurringProductPrice
531
+ DISCRIMINATOR = "amount_type"
532
+
533
+ # @return [Hash{String => Class}] discriminator value to model class.
534
+ def self.mapping
535
+ @mapping ||= {
536
+ "custom" => Models::LegacyRecurringProductPriceCustom,
537
+ "fixed" => Models::LegacyRecurringProductPriceFixed
538
+ }.freeze
539
+ end
540
+
541
+ # @return [Array<Class>] every model this union can resolve to.
542
+ def self.variants
543
+ @variants ||= [Models::LegacyRecurringProductPriceFixed, Models::LegacyRecurringProductPriceCustom].freeze
544
+ end
545
+
546
+ # @param data [Hash, String, nil]
547
+ # @return [Object, nil] the resolved variant, or the raw payload.
548
+ def self.from_json(data)
549
+ data = ::JSON.parse(data) if data.is_a?(String)
550
+ ::Pago::Serde.union(data, discriminator: DISCRIMINATOR, mapping: mapping, variants: variants)
551
+ end
552
+ end
553
+
554
+ # Variants: Hash{String => String, Integer, Boolean, Array<String>, Array<Integer>, Array<Boolean>}, nil.
555
+ module MetadataQuery
556
+ DISCRIMINATOR = nil
557
+
558
+ # @return [nil] this union carries no usable discriminator mapping.
559
+ def self.mapping = nil
560
+
561
+ # @return [Array<Class>] every model this union can resolve to.
562
+ def self.variants
563
+ @variants ||= [].freeze
564
+ end
565
+
566
+ # @param data [Hash, String, nil]
567
+ # @return [Object, nil] the resolved variant, or the raw payload.
568
+ def self.from_json(data)
569
+ data = ::JSON.parse(data) if data.is_a?(String)
570
+ ::Pago::Serde.union(data, discriminator: DISCRIMINATOR, mapping: mapping, variants: variants)
571
+ end
572
+ end
573
+
574
+ # Variants: Models::CardPayment, Models::GenericPayment.
575
+ module Payment
576
+ DISCRIMINATOR = nil
577
+
578
+ # @return [nil] this union carries no usable discriminator mapping.
579
+ def self.mapping = nil
580
+
581
+ # @return [Array<Class>] every model this union can resolve to.
582
+ def self.variants
583
+ @variants ||= [Models::CardPayment, Models::GenericPayment].freeze
584
+ end
585
+
586
+ # @param data [Hash, String, nil]
587
+ # @return [Object, nil] the resolved variant, or the raw payload.
588
+ def self.from_json(data)
589
+ data = ::JSON.parse(data) if data.is_a?(String)
590
+ ::Pago::Serde.union(data, discriminator: DISCRIMINATOR, mapping: mapping, variants: variants)
591
+ end
592
+ end
593
+
594
+ # Variants: Models::CustomerPaymentMethodCard, Models::CustomerPaymentMethodGeneric.
595
+ module PaymentMethod
596
+ DISCRIMINATOR = nil
597
+
598
+ # @return [nil] this union carries no usable discriminator mapping.
599
+ def self.mapping = nil
600
+
601
+ # @return [Array<Class>] every model this union can resolve to.
602
+ def self.variants
603
+ @variants ||= [Models::CustomerPaymentMethodCard, Models::CustomerPaymentMethodGeneric].freeze
604
+ end
605
+
606
+ # @param data [Hash, String, nil]
607
+ # @return [Object, nil] the resolved variant, or the raw payload.
608
+ def self.from_json(data)
609
+ data = ::JSON.parse(data) if data.is_a?(String)
610
+ ::Pago::Serde.union(data, discriminator: DISCRIMINATOR, mapping: mapping, variants: variants)
611
+ end
612
+ end
613
+
614
+ # Variants: Models::ProductCreateRecurring, Models::ProductCreateOneTime.
615
+ module ProductCreate
616
+ DISCRIMINATOR = nil
617
+
618
+ # @return [nil] this union carries no usable discriminator mapping.
619
+ def self.mapping = nil
620
+
621
+ # @return [Array<Class>] every model this union can resolve to.
622
+ def self.variants
623
+ @variants ||= [Models::ProductCreateRecurring, Models::ProductCreateOneTime].freeze
624
+ end
625
+
626
+ # @param data [Hash, String, nil]
627
+ # @return [Object, nil] the resolved variant, or the raw payload.
628
+ def self.from_json(data)
629
+ data = ::JSON.parse(data) if data.is_a?(String)
630
+ ::Pago::Serde.union(data, discriminator: DISCRIMINATOR, mapping: mapping, variants: variants)
631
+ end
632
+ end
633
+
634
+ # Variants: Models::ProductPriceFixed, Models::ProductPriceCustom, Models::ProductPriceSeatBased, Models::ProductPriceMeteredUnit.
635
+ module ProductPrice
636
+ DISCRIMINATOR = "amount_type"
637
+
638
+ # @return [Hash{String => Class}] discriminator value to model class.
639
+ def self.mapping
640
+ @mapping ||= {
641
+ "custom" => Models::ProductPriceCustom,
642
+ "fixed" => Models::ProductPriceFixed,
643
+ "metered_unit" => Models::ProductPriceMeteredUnit,
644
+ "seat_based" => Models::ProductPriceSeatBased
645
+ }.freeze
646
+ end
647
+
648
+ # @return [Array<Class>] every model this union can resolve to.
649
+ def self.variants
650
+ @variants ||= [Models::ProductPriceFixed, Models::ProductPriceCustom, Models::ProductPriceSeatBased, Models::ProductPriceMeteredUnit].freeze
651
+ end
652
+
653
+ # @param data [Hash, String, nil]
654
+ # @return [Object, nil] the resolved variant, or the raw payload.
655
+ def self.from_json(data)
656
+ data = ::JSON.parse(data) if data.is_a?(String)
657
+ ::Pago::Serde.union(data, discriminator: DISCRIMINATOR, mapping: mapping, variants: variants)
658
+ end
659
+ end
660
+
661
+ # Variants: Models::SubscriptionUpdateBase, Models::SubscriptionUpdateSeats, Models::SubscriptionUpdateBillingPeriod, Models::SubscriptionCancel, Models::SubscriptionRevoke, Models::SubscriptionPause, Models::SubscriptionResume, Models::SubscriptionUpdateClear.
662
+ module SubscriptionUpdate
663
+ DISCRIMINATOR = nil
664
+
665
+ # @return [nil] this union carries no usable discriminator mapping.
666
+ def self.mapping = nil
667
+
668
+ # @return [Array<Class>] every model this union can resolve to.
669
+ def self.variants
670
+ @variants ||= [Models::SubscriptionUpdateBase, Models::SubscriptionUpdateSeats, Models::SubscriptionUpdateBillingPeriod, Models::SubscriptionCancel, Models::SubscriptionRevoke, Models::SubscriptionPause, Models::SubscriptionResume, Models::SubscriptionUpdateClear].freeze
671
+ end
672
+
673
+ # @param data [Hash, String, nil]
674
+ # @return [Object, nil] the resolved variant, or the raw payload.
675
+ def self.from_json(data)
676
+ data = ::JSON.parse(data) if data.is_a?(String)
677
+ ::Pago::Serde.union(data, discriminator: DISCRIMINATOR, mapping: mapping, variants: variants)
678
+ end
679
+ end
680
+
681
+ # Variants: Models::MeterCreditEvent, Models::MeterResetEvent, Models::BenefitGrantedEvent, Models::BenefitCycledEvent, Models::BenefitUpdatedEvent, Models::BenefitRevokedEvent, Models::SubscriptionCreatedEvent, Models::SubscriptionUpdatedEvent, Models::SubscriptionCycledEvent, Models::SubscriptionCanceledEvent, Models::SubscriptionRevokedEvent, Models::SubscriptionPastDueEvent, Models::SubscriptionReactivatedEvent, Models::SubscriptionPausedEvent, Models::SubscriptionResumedEvent, Models::SubscriptionUncanceledEvent, Models::SubscriptionProductUpdatedEvent, Models::SubscriptionSeatsUpdatedEvent, Models::SubscriptionBillingPeriodUpdatedEvent, Models::SubscriptionUpdateClearedEvent, Models::OrderPaidEvent, Models::OrderRefundedEvent, Models::OrderVoidedEvent, Models::CheckoutCreatedEvent, Models::CustomerCreatedEvent, Models::CustomerUpdatedEvent, Models::CustomerDeletedEvent, Models::BalanceOrderEvent, Models::BalanceCreditOrderEvent, Models::BalanceRefundEvent, Models::BalanceRefundReversalEvent, Models::BalanceDisputeEvent, Models::BalanceDisputeReversalEvent.
682
+ module SystemEvent
683
+ DISCRIMINATOR = "name"
684
+
685
+ # @return [Hash{String => Class}] discriminator value to model class.
686
+ def self.mapping
687
+ @mapping ||= {
688
+ "balance.credit_order" => Models::BalanceCreditOrderEvent,
689
+ "balance.dispute" => Models::BalanceDisputeEvent,
690
+ "balance.dispute_reversal" => Models::BalanceDisputeReversalEvent,
691
+ "balance.order" => Models::BalanceOrderEvent,
692
+ "balance.refund" => Models::BalanceRefundEvent,
693
+ "balance.refund_reversal" => Models::BalanceRefundReversalEvent,
694
+ "benefit.cycled" => Models::BenefitCycledEvent,
695
+ "benefit.granted" => Models::BenefitGrantedEvent,
696
+ "benefit.revoked" => Models::BenefitRevokedEvent,
697
+ "benefit.updated" => Models::BenefitUpdatedEvent,
698
+ "checkout.created" => Models::CheckoutCreatedEvent,
699
+ "customer.created" => Models::CustomerCreatedEvent,
700
+ "customer.deleted" => Models::CustomerDeletedEvent,
701
+ "customer.updated" => Models::CustomerUpdatedEvent,
702
+ "meter.credited" => Models::MeterCreditEvent,
703
+ "meter.reset" => Models::MeterResetEvent,
704
+ "order.paid" => Models::OrderPaidEvent,
705
+ "order.refunded" => Models::OrderRefundedEvent,
706
+ "order.voided" => Models::OrderVoidedEvent,
707
+ "subscription.billing_period_updated" => Models::SubscriptionBillingPeriodUpdatedEvent,
708
+ "subscription.canceled" => Models::SubscriptionCanceledEvent,
709
+ "subscription.created" => Models::SubscriptionCreatedEvent,
710
+ "subscription.cycled" => Models::SubscriptionCycledEvent,
711
+ "subscription.past_due" => Models::SubscriptionPastDueEvent,
712
+ "subscription.paused" => Models::SubscriptionPausedEvent,
713
+ "subscription.product_updated" => Models::SubscriptionProductUpdatedEvent,
714
+ "subscription.reactivated" => Models::SubscriptionReactivatedEvent,
715
+ "subscription.resumed" => Models::SubscriptionResumedEvent,
716
+ "subscription.revoked" => Models::SubscriptionRevokedEvent,
717
+ "subscription.seats_updated" => Models::SubscriptionSeatsUpdatedEvent,
718
+ "subscription.uncanceled" => Models::SubscriptionUncanceledEvent,
719
+ "subscription.update_cleared" => Models::SubscriptionUpdateClearedEvent,
720
+ "subscription.updated" => Models::SubscriptionUpdatedEvent
721
+ }.freeze
722
+ end
723
+
724
+ # @return [Array<Class>] every model this union can resolve to.
725
+ def self.variants
726
+ @variants ||= [Models::MeterCreditEvent, Models::MeterResetEvent, Models::BenefitGrantedEvent, Models::BenefitCycledEvent, Models::BenefitUpdatedEvent, Models::BenefitRevokedEvent, Models::SubscriptionCreatedEvent, Models::SubscriptionUpdatedEvent, Models::SubscriptionCycledEvent, Models::SubscriptionCanceledEvent, Models::SubscriptionRevokedEvent, Models::SubscriptionPastDueEvent, Models::SubscriptionReactivatedEvent, Models::SubscriptionPausedEvent, Models::SubscriptionResumedEvent, Models::SubscriptionUncanceledEvent, Models::SubscriptionProductUpdatedEvent, Models::SubscriptionSeatsUpdatedEvent, Models::SubscriptionBillingPeriodUpdatedEvent, Models::SubscriptionUpdateClearedEvent, Models::OrderPaidEvent, Models::OrderRefundedEvent, Models::OrderVoidedEvent, Models::CheckoutCreatedEvent, Models::CustomerCreatedEvent, Models::CustomerUpdatedEvent, Models::CustomerDeletedEvent, Models::BalanceOrderEvent, Models::BalanceCreditOrderEvent, Models::BalanceRefundEvent, Models::BalanceRefundReversalEvent, Models::BalanceDisputeEvent, Models::BalanceDisputeReversalEvent].freeze
727
+ end
728
+
729
+ # @param data [Hash, String, nil]
730
+ # @return [Object, nil] the resolved variant, or the raw payload.
731
+ def self.from_json(data)
732
+ data = ::JSON.parse(data) if data.is_a?(String)
733
+ ::Pago::Serde.union(data, discriminator: DISCRIMINATOR, mapping: mapping, variants: variants)
734
+ end
735
+ end
736
+
737
+ end
738
+ end
739
+ end