fintoc 1.6.0 → 1.7.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 (73) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/README.md +109 -4
  4. data/fintoc.gemspec +3 -3
  5. data/lib/fintoc/base_client.rb +6 -4
  6. data/lib/fintoc/errors.rb +67 -0
  7. data/lib/fintoc/v1/client/client.rb +80 -0
  8. data/lib/fintoc/v1/managers/accounts_manager.rb +30 -0
  9. data/lib/fintoc/v1/managers/charges_manager.rb +48 -0
  10. data/lib/fintoc/v1/managers/disputes_manager.rb +43 -0
  11. data/lib/fintoc/v1/managers/institutions_manager.rb +19 -0
  12. data/lib/fintoc/v1/managers/invoices_manager.rb +30 -0
  13. data/lib/fintoc/v1/managers/link_intents_manager.rb +25 -0
  14. data/lib/fintoc/v1/managers/links_manager.rb +17 -0
  15. data/lib/fintoc/v1/managers/movements_manager.rb +31 -0
  16. data/lib/fintoc/v1/managers/payment_intents_manager.rb +42 -0
  17. data/lib/fintoc/v1/managers/payment_links_manager.rb +42 -0
  18. data/lib/fintoc/v1/managers/payouts_manager.rb +50 -0
  19. data/lib/fintoc/v1/managers/refresh_intents_manager.rb +39 -0
  20. data/lib/fintoc/v1/managers/refunds_manager.rb +47 -0
  21. data/lib/fintoc/v1/managers/subscription_intents_manager.rb +36 -0
  22. data/lib/fintoc/v1/managers/subscriptions_manager.rb +30 -0
  23. data/lib/fintoc/v1/managers/tax_returns_manager.rb +30 -0
  24. data/lib/fintoc/v1/managers/tax_statements_manager.rb +30 -0
  25. data/lib/fintoc/v1/managers/webhook_endpoints_manager.rb +1 -2
  26. data/lib/fintoc/v1/resources/account.rb +9 -2
  27. data/lib/fintoc/v1/resources/charge.rb +39 -0
  28. data/lib/fintoc/v1/resources/dispute.rb +41 -0
  29. data/lib/fintoc/v1/resources/dispute_document.rb +30 -0
  30. data/lib/fintoc/v1/resources/institution.rb +4 -2
  31. data/lib/fintoc/v1/resources/invoice.rb +43 -0
  32. data/lib/fintoc/v1/resources/link.rb +2 -2
  33. data/lib/fintoc/v1/resources/link_intent.rb +39 -0
  34. data/lib/fintoc/v1/resources/payment_intent.rb +72 -0
  35. data/lib/fintoc/v1/resources/payment_link.rb +43 -0
  36. data/lib/fintoc/v1/resources/payout.rb +37 -0
  37. data/lib/fintoc/v1/resources/refresh_intent.rb +37 -0
  38. data/lib/fintoc/v1/resources/refund.rb +43 -0
  39. data/lib/fintoc/v1/resources/subscription.rb +30 -0
  40. data/lib/fintoc/v1/resources/subscription_intent.rb +39 -0
  41. data/lib/fintoc/v1/resources/tax_return.rb +33 -0
  42. data/lib/fintoc/v1/resources/tax_statement.rb +39 -0
  43. data/lib/fintoc/v1/resources/webhook_endpoint.rb +10 -4
  44. data/lib/fintoc/v2/client/client.rb +45 -0
  45. data/lib/fintoc/v2/managers/checkout_sessions_manager.rb +42 -0
  46. data/lib/fintoc/v2/managers/customers_manager.rb +36 -0
  47. data/lib/fintoc/v2/managers/entities_manager.rb +6 -0
  48. data/lib/fintoc/v2/managers/events_manager.rb +30 -0
  49. data/lib/fintoc/v2/managers/invoice_lines_manager.rb +30 -0
  50. data/lib/fintoc/v2/managers/invoices_manager.rb +78 -0
  51. data/lib/fintoc/v2/managers/onboardings_manager.rb +14 -0
  52. data/lib/fintoc/v2/managers/payment_intents_manager.rb +53 -0
  53. data/lib/fintoc/v2/managers/payment_methods_manager.rb +68 -0
  54. data/lib/fintoc/v2/managers/products_manager.rb +42 -0
  55. data/lib/fintoc/v2/managers/setup_intents_manager.rb +24 -0
  56. data/lib/fintoc/v2/managers/subscription_items_manager.rb +41 -0
  57. data/lib/fintoc/v2/managers/subscriptions_manager.rb +54 -0
  58. data/lib/fintoc/v2/managers/transfers_manager.rb +4 -0
  59. data/lib/fintoc/v2/resources/checkout_session.rb +81 -0
  60. data/lib/fintoc/v2/resources/customer.rb +37 -0
  61. data/lib/fintoc/v2/resources/entity.rb +5 -1
  62. data/lib/fintoc/v2/resources/event.rb +28 -0
  63. data/lib/fintoc/v2/resources/invoice.rb +63 -0
  64. data/lib/fintoc/v2/resources/invoice_line.rb +35 -0
  65. data/lib/fintoc/v2/resources/payment_intent.rb +68 -0
  66. data/lib/fintoc/v2/resources/payment_method.rb +37 -0
  67. data/lib/fintoc/v2/resources/product.rb +32 -0
  68. data/lib/fintoc/v2/resources/settlement_account.rb +30 -0
  69. data/lib/fintoc/v2/resources/setup_intent.rb +24 -0
  70. data/lib/fintoc/v2/resources/subscription.rb +51 -0
  71. data/lib/fintoc/v2/resources/subscription_item.rb +24 -0
  72. data/lib/fintoc/version.rb +1 -1
  73. metadata +54 -1
@@ -0,0 +1,78 @@
1
+ require 'fintoc/v2/resources/invoice'
2
+
3
+ module Fintoc
4
+ module V2
5
+ module Managers
6
+ class InvoicesManager
7
+ def initialize(client)
8
+ @client = client
9
+ end
10
+
11
+ def create(customer:, lines:, idempotency_key: nil, **params)
12
+ data = @client.post(version: :v2, idempotency_key:)
13
+ .call('invoices', customer:, lines:, **params)
14
+ build_invoice(data)
15
+ end
16
+
17
+ def list(**params)
18
+ @client.get(version: :v2).call('invoices', **params).map do |data|
19
+ build_invoice(data)
20
+ end
21
+ end
22
+
23
+ def get(invoice_id)
24
+ data = @client.get(version: :v2).call("invoices/#{invoice_id}")
25
+ build_invoice(data)
26
+ end
27
+
28
+ def update(invoice_id, idempotency_key: nil, **params)
29
+ data = @client.patch(version: :v2, idempotency_key:)
30
+ .call("invoices/#{invoice_id}", **params)
31
+ build_invoice(data)
32
+ end
33
+
34
+ def finalize(invoice_id, idempotency_key: nil)
35
+ data = @client.post(version: :v2, idempotency_key:)
36
+ .call("invoices/#{invoice_id}/finalize")
37
+ build_invoice(data)
38
+ end
39
+
40
+ def pay(invoice_id, idempotency_key: nil, **params)
41
+ data = @client.post(version: :v2, idempotency_key:)
42
+ .call("invoices/#{invoice_id}/pay", **params)
43
+ build_invoice(data)
44
+ end
45
+
46
+ def void(invoice_id, idempotency_key: nil)
47
+ data = @client.post(version: :v2, idempotency_key:)
48
+ .call("invoices/#{invoice_id}/void")
49
+ build_invoice(data)
50
+ end
51
+
52
+ def mark_uncollectible(invoice_id, idempotency_key: nil)
53
+ data = @client.post(version: :v2, idempotency_key:)
54
+ .call("invoices/#{invoice_id}/mark_uncollectible")
55
+ build_invoice(data)
56
+ end
57
+
58
+ def add_lines(invoice_id, lines:, idempotency_key: nil)
59
+ data = @client.post(version: :v2, idempotency_key:)
60
+ .call("invoices/#{invoice_id}/add_lines", lines:)
61
+ build_invoice(data)
62
+ end
63
+
64
+ def remove_lines(invoice_id, lines:, idempotency_key: nil)
65
+ data = @client.post(version: :v2, idempotency_key:)
66
+ .call("invoices/#{invoice_id}/remove_lines", lines:)
67
+ build_invoice(data)
68
+ end
69
+
70
+ private
71
+
72
+ def build_invoice(data)
73
+ Fintoc::V2::Invoice.new(**data, client: @client)
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
@@ -33,6 +33,20 @@ module Fintoc
33
33
  build_onboarding(data)
34
34
  end
35
35
 
36
+ def append_document(onboarding_id, slot_key, file:, idempotency_key: nil)
37
+ data = @client.post(version: :v2, idempotency_key:).call(
38
+ "#{base_path}/#{onboarding_id}/documents/#{slot_key}",
39
+ form: { file: }
40
+ )
41
+ build_onboarding(data)
42
+ end
43
+
44
+ def delete_document(onboarding_id, slot_key, document_id)
45
+ data = @client.delete(version: :v2)
46
+ .call("#{base_path}/#{onboarding_id}/documents/#{slot_key}/#{document_id}")
47
+ build_onboarding(data)
48
+ end
49
+
36
50
  def upload_shareholder_document(onboarding_id, shareholder_id, file:, idempotency_key: nil)
37
51
  data = _upload_shareholder_document(
38
52
  onboarding_id, shareholder_id, file:, idempotency_key:
@@ -0,0 +1,53 @@
1
+ require 'fintoc/v2/resources/payment_intent'
2
+
3
+ module Fintoc
4
+ module V2
5
+ module Managers
6
+ class PaymentIntentsManager
7
+ def initialize(client)
8
+ @client = client
9
+ end
10
+
11
+ def create(amount:, currency:, payment_method:, idempotency_key: nil, **params)
12
+ data = @client.post(version: :v2, idempotency_key:)
13
+ .call('payment_intents', amount:, currency:, payment_method:, **params)
14
+ build_payment_intent(data)
15
+ end
16
+
17
+ def list(**params)
18
+ @client.get(version: :v2).call('payment_intents', **params).map do |data|
19
+ build_payment_intent(data)
20
+ end
21
+ end
22
+
23
+ def get(payment_intent_id)
24
+ data = @client.get(version: :v2).call("payment_intents/#{payment_intent_id}")
25
+ build_payment_intent(data)
26
+ end
27
+
28
+ def cancel(payment_intent_id, idempotency_key: nil)
29
+ data = @client.post(version: :v2, idempotency_key:)
30
+ .call("payment_intents/#{payment_intent_id}/cancel")
31
+ build_payment_intent(data)
32
+ end
33
+
34
+ def check_eligibility(amount:, currency:, sender_account:, idempotency_key: nil, **params)
35
+ @client.post(version: :v2, idempotency_key:).call(
36
+ 'payment_intents/check_eligibility', amount:, currency:, sender_account:, **params
37
+ )
38
+ end
39
+
40
+ def voucher_url(payment_intent_id)
41
+ @client.get(version: :v2)
42
+ .call("payment_intents/#{payment_intent_id}/voucher_url")
43
+ end
44
+
45
+ private
46
+
47
+ def build_payment_intent(data)
48
+ Fintoc::V2::PaymentIntent.new(**data)
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,68 @@
1
+ require 'fintoc/v2/resources/payment_method'
2
+
3
+ module Fintoc
4
+ module V2
5
+ module Managers
6
+ class PaymentMethodsManager
7
+ def initialize(client)
8
+ @client = client
9
+ end
10
+
11
+ def create(type:, customer:, mx_direct_debit:, idempotency_key: nil)
12
+ form = flatten_form({ type:, customer:, mx_direct_debit: })
13
+ .to_h { |name, value| [name, form_part(name, value)] }
14
+ data = @client.post(version: :v2, idempotency_key:).call('payment_methods', form:)
15
+ build_payment_method(data)
16
+ end
17
+
18
+ def list(**params)
19
+ @client.get(version: :v2).call('payment_methods', **flatten_form(params)).map do |data|
20
+ build_payment_method(data)
21
+ end
22
+ end
23
+
24
+ def get(payment_method_id)
25
+ data = @client.get(version: :v2).call("payment_methods/#{payment_method_id}")
26
+ build_payment_method(data)
27
+ end
28
+
29
+ def cancel(payment_method_id, idempotency_key: nil)
30
+ data = @client.post(version: :v2, idempotency_key:)
31
+ .call("payment_methods/#{payment_method_id}/cancel")
32
+ build_payment_method(data)
33
+ end
34
+
35
+ def mandate_document(payment_method_id)
36
+ @client.get(version: :v2).call("payment_methods/#{payment_method_id}/mandate_document")
37
+ end
38
+
39
+ private
40
+
41
+ def flatten_form(fields, prefix = nil)
42
+ fields.each_with_object({}) do |(key, value), form|
43
+ name = prefix ? "#{prefix}[#{key}]" : key.to_s
44
+ if value.is_a?(Hash)
45
+ form.merge!(flatten_form(value, name))
46
+ else
47
+ form[name] = value
48
+ end
49
+ end
50
+ end
51
+
52
+ def form_part(name, value)
53
+ return value if value.is_a?(HTTP::FormData::Part)
54
+
55
+ if name.include?('[consent_documents]')
56
+ HTTP::FormData::File.new(value)
57
+ else
58
+ HTTP::FormData::Part.new(value)
59
+ end
60
+ end
61
+
62
+ def build_payment_method(data)
63
+ Fintoc::V2::PaymentMethod.new(**data)
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,42 @@
1
+ require 'fintoc/v2/resources/product'
2
+
3
+ module Fintoc
4
+ module V2
5
+ module Managers
6
+ class ProductsManager
7
+ def initialize(client)
8
+ @client = client
9
+ end
10
+
11
+ def create(name:, idempotency_key: nil, **params)
12
+ data = @client.post(version: :v2, idempotency_key:)
13
+ .call('products', name:, **params)
14
+ build_product(data)
15
+ end
16
+
17
+ def list(**params)
18
+ @client.get(version: :v2).call('products', **params).map do |data|
19
+ build_product(data)
20
+ end
21
+ end
22
+
23
+ def get(product_id)
24
+ data = @client.get(version: :v2).call("products/#{product_id}")
25
+ build_product(data)
26
+ end
27
+
28
+ def update(product_id, idempotency_key: nil, **params)
29
+ data = @client.patch(version: :v2, idempotency_key:)
30
+ .call("products/#{product_id}", **params)
31
+ build_product(data)
32
+ end
33
+
34
+ private
35
+
36
+ def build_product(data)
37
+ Fintoc::V2::Product.new(**data)
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,24 @@
1
+ require 'fintoc/v2/resources/setup_intent'
2
+
3
+ module Fintoc
4
+ module V2
5
+ module Managers
6
+ class SetupIntentsManager
7
+ def initialize(client)
8
+ @client = client
9
+ end
10
+
11
+ def get(setup_intent_id)
12
+ data = @client.get(version: :v2).call("setup_intents/#{setup_intent_id}")
13
+ build_setup_intent(data)
14
+ end
15
+
16
+ private
17
+
18
+ def build_setup_intent(data)
19
+ Fintoc::V2::SetupIntent.new(**data)
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,41 @@
1
+ require 'fintoc/v2/resources/subscription_item'
2
+
3
+ module Fintoc
4
+ module V2
5
+ module Managers
6
+ class SubscriptionItemsManager
7
+ def initialize(client, subscription_id)
8
+ @client = client
9
+ @subscription_id = subscription_id
10
+ end
11
+
12
+ def create(price_data:, quantity:, idempotency_key: nil, **params)
13
+ data = @client.post(version: :v2, idempotency_key:)
14
+ .call(base_path, price_data:, quantity:, **params)
15
+ build_subscription_item(data)
16
+ end
17
+
18
+ def update(subscription_item_id, idempotency_key: nil, **params)
19
+ data = @client.patch(version: :v2, idempotency_key:)
20
+ .call("#{base_path}/#{subscription_item_id}", **params)
21
+ build_subscription_item(data)
22
+ end
23
+
24
+ def delete(subscription_item_id)
25
+ data = @client.delete(version: :v2).call("#{base_path}/#{subscription_item_id}")
26
+ build_subscription_item(data)
27
+ end
28
+
29
+ private
30
+
31
+ def base_path
32
+ "subscriptions/#{@subscription_id}/items"
33
+ end
34
+
35
+ def build_subscription_item(data)
36
+ Fintoc::V2::SubscriptionItem.new(**data)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,54 @@
1
+ require 'fintoc/v2/resources/subscription'
2
+
3
+ module Fintoc
4
+ module V2
5
+ module Managers
6
+ class SubscriptionsManager
7
+ def initialize(client)
8
+ @client = client
9
+ end
10
+
11
+ def create(customer:, items:, idempotency_key: nil, **params)
12
+ data = @client.post(version: :v2, idempotency_key:)
13
+ .call('subscriptions', customer:, items:, **params)
14
+ build_subscription(data)
15
+ end
16
+
17
+ def list(**params)
18
+ @client.get(version: :v2).call('subscriptions', **params).map do |data|
19
+ build_subscription(data)
20
+ end
21
+ end
22
+
23
+ def get(subscription_id)
24
+ data = @client.get(version: :v2).call("subscriptions/#{subscription_id}")
25
+ build_subscription(data)
26
+ end
27
+
28
+ def update(subscription_id, idempotency_key: nil, **params)
29
+ data = @client.patch(version: :v2, idempotency_key:)
30
+ .call("subscriptions/#{subscription_id}", **params)
31
+ build_subscription(data)
32
+ end
33
+
34
+ def cancel(subscription_id, idempotency_key: nil)
35
+ data = @client.post(version: :v2, idempotency_key:)
36
+ .call("subscriptions/#{subscription_id}/cancel")
37
+ build_subscription(data)
38
+ end
39
+
40
+ def detach_payment_method(subscription_id)
41
+ data = @client.delete(version: :v2)
42
+ .call("subscriptions/#{subscription_id}/payment_method")
43
+ build_subscription(data)
44
+ end
45
+
46
+ private
47
+
48
+ def build_subscription(data)
49
+ Fintoc::V2::Subscription.new(**data, client: @client)
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -29,6 +29,10 @@ module Fintoc
29
29
  build_transfer(data)
30
30
  end
31
31
 
32
+ def receipt(transfer_id)
33
+ @client.get(version: :v2).call("transfers/#{transfer_id}/receipt")
34
+ end
35
+
32
36
  private
33
37
 
34
38
  def _create_transfer(
@@ -0,0 +1,81 @@
1
+ module Fintoc
2
+ module V2
3
+ class CheckoutSession
4
+ attr_reader :id, :object, :amount, :billing_cycle_anchor, :business_profile, :cancel_url,
5
+ :created_at, :currency, :customer, :customer_email, :customer_phone, :expires_at,
6
+ :flow, :line_items, :metadata, :mode, :payment_method, :payment_method_options,
7
+ :payment_method_types, :payment_resource, :redirect_url, :save_payment_method,
8
+ :session_token, :setup_intent, :split, :split_applied, :status, :subscription,
9
+ :success_url, :trial_end
10
+
11
+ def initialize( # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
12
+ id:,
13
+ object:,
14
+ amount: nil,
15
+ billing_cycle_anchor: nil,
16
+ business_profile: nil,
17
+ cancel_url: nil,
18
+ created_at: nil,
19
+ currency: nil,
20
+ customer: nil,
21
+ customer_email: nil,
22
+ customer_phone: nil,
23
+ expires_at: nil,
24
+ flow: nil,
25
+ line_items: nil,
26
+ metadata: nil,
27
+ mode: nil,
28
+ payment_method: nil,
29
+ payment_method_options: nil,
30
+ payment_method_types: nil,
31
+ payment_resource: nil,
32
+ redirect_url: nil,
33
+ save_payment_method: nil,
34
+ session_token: nil,
35
+ setup_intent: nil,
36
+ split: nil,
37
+ split_applied: nil,
38
+ status: nil,
39
+ subscription: nil,
40
+ success_url: nil,
41
+ trial_end: nil,
42
+ **
43
+ )
44
+ @id = id
45
+ @object = object
46
+ @amount = amount
47
+ @billing_cycle_anchor = billing_cycle_anchor
48
+ @business_profile = business_profile
49
+ @cancel_url = cancel_url
50
+ @created_at = created_at
51
+ @currency = currency
52
+ @customer = customer
53
+ @customer_email = customer_email
54
+ @customer_phone = customer_phone
55
+ @expires_at = expires_at
56
+ @flow = flow
57
+ @line_items = line_items
58
+ @metadata = metadata
59
+ @mode = mode
60
+ @payment_method = payment_method
61
+ @payment_method_options = payment_method_options
62
+ @payment_method_types = payment_method_types
63
+ @payment_resource = payment_resource
64
+ @redirect_url = redirect_url
65
+ @save_payment_method = save_payment_method
66
+ @session_token = session_token
67
+ @setup_intent = setup_intent
68
+ @split = split
69
+ @split_applied = split_applied
70
+ @status = status
71
+ @subscription = subscription
72
+ @success_url = success_url
73
+ @trial_end = trial_end
74
+ end
75
+
76
+ def to_s
77
+ "Checkout session (#{@id}) - #{@status}"
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,37 @@
1
+ module Fintoc
2
+ module V2
3
+ class Customer
4
+ attr_reader :id, :object, :address, :created_at, :email, :metadata, :mode, :name, :phone,
5
+ :tax_id
6
+
7
+ def initialize(
8
+ id:,
9
+ object:,
10
+ address: nil,
11
+ created_at: nil,
12
+ email: nil,
13
+ metadata: nil,
14
+ mode: nil,
15
+ name: nil,
16
+ phone: nil,
17
+ tax_id: nil,
18
+ **
19
+ )
20
+ @id = id
21
+ @object = object
22
+ @address = address
23
+ @created_at = created_at
24
+ @email = email
25
+ @metadata = metadata
26
+ @mode = mode
27
+ @name = name
28
+ @phone = phone
29
+ @tax_id = tax_id
30
+ end
31
+
32
+ def to_s
33
+ "Customer (#{@id})"
34
+ end
35
+ end
36
+ end
37
+ end
@@ -3,7 +3,8 @@ require 'fintoc/v2/managers/onboardings_manager'
3
3
  module Fintoc
4
4
  module V2
5
5
  class Entity
6
- attr_reader :object, :mode, :id, :holder_name, :holder_id, :is_root, :status, :country_code
6
+ attr_reader :object, :mode, :id, :holder_name, :holder_id, :is_root, :status, :country_code,
7
+ :capabilities
7
8
 
8
9
  def initialize(
9
10
  object:,
@@ -14,6 +15,7 @@ module Fintoc
14
15
  is_root:,
15
16
  status: nil,
16
17
  country_code: nil,
18
+ capabilities: nil,
17
19
  client: nil,
18
20
  **
19
21
  )
@@ -25,6 +27,7 @@ module Fintoc
25
27
  @is_root = is_root
26
28
  @status = status
27
29
  @country_code = country_code
30
+ @capabilities = capabilities
28
31
  @client = client
29
32
  end
30
33
 
@@ -55,6 +58,7 @@ module Fintoc
55
58
  @is_root = entity.is_root
56
59
  @status = entity.status
57
60
  @country_code = entity.country_code
61
+ @capabilities = entity.capabilities
58
62
 
59
63
  self
60
64
  end
@@ -0,0 +1,28 @@
1
+ module Fintoc
2
+ module V2
3
+ class Event
4
+ attr_reader :id, :object, :created_at, :data, :mode, :type
5
+
6
+ def initialize(
7
+ id:,
8
+ object:,
9
+ created_at: nil,
10
+ data: nil,
11
+ mode: nil,
12
+ type: nil,
13
+ **
14
+ )
15
+ @id = id
16
+ @object = object
17
+ @created_at = created_at
18
+ @data = data
19
+ @mode = mode
20
+ @type = type
21
+ end
22
+
23
+ def to_s
24
+ "Event (#{@id})"
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,63 @@
1
+ require 'fintoc/v2/managers/invoice_lines_manager'
2
+
3
+ module Fintoc
4
+ module V2
5
+ class Invoice
6
+ attr_reader :id, :object, :attempt_count, :collection_method, :created_at, :currency,
7
+ :customer, :default_payment_method, :external_payment, :hosted_invoice_url,
8
+ :lines, :metadata, :mode, :next_payment_attempt_at, :payments, :status,
9
+ :subscription, :total
10
+
11
+ def initialize( # rubocop:disable Metrics/MethodLength
12
+ id:,
13
+ object:,
14
+ attempt_count: nil,
15
+ collection_method: nil,
16
+ created_at: nil,
17
+ currency: nil,
18
+ customer: nil,
19
+ default_payment_method: nil,
20
+ external_payment: nil,
21
+ hosted_invoice_url: nil,
22
+ lines: nil,
23
+ metadata: nil,
24
+ mode: nil,
25
+ next_payment_attempt_at: nil,
26
+ payments: nil,
27
+ status: nil,
28
+ subscription: nil,
29
+ total: nil,
30
+ client: nil,
31
+ **
32
+ )
33
+ @id = id
34
+ @object = object
35
+ @attempt_count = attempt_count
36
+ @collection_method = collection_method
37
+ @created_at = created_at
38
+ @currency = currency
39
+ @customer = customer
40
+ @default_payment_method = default_payment_method
41
+ @external_payment = external_payment
42
+ @hosted_invoice_url = hosted_invoice_url
43
+ @lines = lines
44
+ @metadata = metadata
45
+ @mode = mode
46
+ @next_payment_attempt_at = next_payment_attempt_at
47
+ @payments = payments
48
+ @status = status
49
+ @subscription = subscription
50
+ @total = total
51
+ @client = client
52
+ end
53
+
54
+ def to_s
55
+ "Invoice (#{@id}) - #{@status}"
56
+ end
57
+
58
+ def invoice_lines
59
+ @invoice_lines ||= Managers::InvoiceLinesManager.new(@client, @id)
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,35 @@
1
+ module Fintoc
2
+ module V2
3
+ class InvoiceLine
4
+ attr_reader :id, :object, :amount, :currency, :description, :name, :period_end, :period_start,
5
+ :quantity
6
+
7
+ def initialize(
8
+ id:,
9
+ object:,
10
+ amount: nil,
11
+ currency: nil,
12
+ description: nil,
13
+ name: nil,
14
+ period_end: nil,
15
+ period_start: nil,
16
+ quantity: nil,
17
+ **
18
+ )
19
+ @id = id
20
+ @object = object
21
+ @amount = amount
22
+ @currency = currency
23
+ @description = description
24
+ @name = name
25
+ @period_end = period_end
26
+ @period_start = period_start
27
+ @quantity = quantity
28
+ end
29
+
30
+ def to_s
31
+ "Invoice line (#{@id})"
32
+ end
33
+ end
34
+ end
35
+ end