starkinfra 0.5.2 → 0.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 (80) hide show
  1. checksums.yaml +4 -4
  2. data/lib/brcode_preview/brcode_preview.rb +25 -4
  3. data/lib/brcode_preview/subscription.rb +102 -0
  4. data/lib/business_account_request/business_account_request.rb +276 -0
  5. data/lib/business_account_request/log.rb +124 -0
  6. data/lib/business_attachment/business_attachment.rb +189 -0
  7. data/lib/{individual_document → business_attachment}/log.rb +35 -32
  8. data/lib/business_identity/business_identity.rb +228 -0
  9. data/lib/business_identity/log.rb +127 -0
  10. data/lib/credit_holmes/credit_holmes.rb +2 -1
  11. data/lib/credit_holmes/log.rb +125 -0
  12. data/lib/credit_note/credit_note.rb +51 -8
  13. data/lib/credit_note/rule.rb +55 -0
  14. data/lib/credit_note/transfer.rb +1 -1
  15. data/lib/credit_preview/credit_note_preview.rb +10 -2
  16. data/lib/credit_preview/credit_preview.rb +2 -1
  17. data/lib/credit_signer/credit_signer.rb +27 -2
  18. data/lib/dynamic_brcode/dynamic_brcode.rb +5 -2
  19. data/lib/event/event.rb +10 -2
  20. data/lib/individual_account_attachment/individual_account_attachment.rb +178 -0
  21. data/lib/individual_account_attachment/log.rb +124 -0
  22. data/lib/individual_account_request/individual_account_request.rb +271 -0
  23. data/lib/individual_account_request/log.rb +124 -0
  24. data/lib/individual_identity/individual_identity.rb +4 -7
  25. data/lib/issuing_balance/issuing_balance.rb +8 -2
  26. data/lib/issuing_billing_invoice/issuing_billing_invoice.rb +155 -0
  27. data/lib/issuing_billing_transaction/issuing_billing_transaction.rb +142 -0
  28. data/lib/issuing_card/issuing_card.rb +10 -6
  29. data/lib/issuing_design/issuing_design.rb +9 -0
  30. data/lib/issuing_embossing_request/issuing_embossing_request.rb +3 -2
  31. data/lib/issuing_holder/issuing_holder.rb +6 -5
  32. data/lib/issuing_product/issuing_product.rb +6 -3
  33. data/lib/issuing_purchase/issuing_purchase.rb +41 -8
  34. data/lib/issuing_restock/issuing_restock.rb +3 -2
  35. data/lib/issuing_rule/issuing_rule.rb +45 -3
  36. data/lib/issuing_stock/issuing_stock.rb +5 -2
  37. data/lib/issuing_stock_rule/issuing_stock_rule.rb +214 -0
  38. data/lib/issuing_token/issuing_token.rb +309 -0
  39. data/lib/issuing_token/log.rb +127 -0
  40. data/lib/issuing_token_activation/issuing_token_activation.rb +62 -0
  41. data/lib/issuing_token_design/issuing_token_design.rb +118 -0
  42. data/lib/issuing_token_request/issuing_token_request.rb +63 -0
  43. data/lib/issuing_withdrawal/issuing_withdrawal.rb +2 -2
  44. data/lib/ledger/ledger.rb +175 -0
  45. data/lib/ledger/log.rb +122 -0
  46. data/lib/ledger/rule.rb +55 -0
  47. data/lib/ledger_transaction/ledger_transaction.rb +179 -0
  48. data/lib/merchant_category/merchant_category.rb +6 -3
  49. data/lib/pix_balance/pix_balance.rb +1 -1
  50. data/lib/pix_chargeback/pix_chargeback.rb +34 -7
  51. data/lib/pix_claim/pix_claim.rb +14 -6
  52. data/lib/pix_director/pix_director.rb +1 -1
  53. data/lib/pix_dispute/log.rb +127 -0
  54. data/lib/pix_dispute/pix_dispute.rb +210 -0
  55. data/lib/pix_dispute/transaction.rb +91 -0
  56. data/lib/pix_fraud/log.rb +128 -0
  57. data/lib/pix_fraud/pix_fraud.rb +180 -0
  58. data/lib/pix_infraction/pix_infraction.rb +37 -7
  59. data/lib/pix_internal_transaction_report/log.rb +129 -0
  60. data/lib/pix_internal_transaction_report/pix_internal_transaction_report.rb +200 -0
  61. data/lib/pix_key/pix_key.rb +1 -1
  62. data/lib/pix_key_holmes/log.rb +129 -0
  63. data/lib/{individual_document/individual_document.rb → pix_key_holmes/pix_key_holmes.rb} +48 -56
  64. data/lib/pix_pull_request/log.rb +127 -0
  65. data/lib/pix_pull_request/pix_pull_request.rb +268 -0
  66. data/lib/pix_pull_subscription/log.rb +127 -0
  67. data/lib/pix_pull_subscription/pix_pull_subscription.rb +307 -0
  68. data/lib/pix_request/pix_request.rb +19 -6
  69. data/lib/pix_reversal/pix_reversal.rb +14 -8
  70. data/lib/pix_statement/pix_statement.rb +11 -5
  71. data/lib/pix_user/pix_user.rb +52 -0
  72. data/lib/pix_user/statistics.rb +64 -0
  73. data/lib/starkinfra.rb +45 -4
  74. data/lib/static_brcode/static_brcode.rb +8 -4
  75. data/lib/utils/bacen_id.rb +27 -0
  76. data/lib/utils/end_to_end_id.rb +20 -0
  77. data/lib/utils/pix_subscription_bacen_id.rb +21 -0
  78. data/lib/utils/return_id.rb +21 -0
  79. data/lib/webhook/webhook.rb +3 -3
  80. metadata +48 -11
@@ -0,0 +1,127 @@
1
+ # frozen_string_literal: true
2
+
3
+ require('starkcore')
4
+ require_relative('../utils/rest')
5
+ require_relative('business_identity')
6
+
7
+ module StarkInfra
8
+ class BusinessIdentity
9
+ # # BusinessIdentity::Log object
10
+ #
11
+ # Every time a BusinessIdentity entity is updated, a corresponding BusinessIdentity::Log is generated for the entity.
12
+ # This Log is never generated by the user, but it can be retrieved to check additional information on the BusinessIdentity.
13
+ #
14
+ # ## Attributes (return-only):
15
+ # - id [string]: unique id returned when the log is created. ex: '5656565656565656'
16
+ # - identity [BusinessIdentity]: BusinessIdentity entity to which the log refers to.
17
+ # - errors [list of strings]: list of errors linked to this BusinessIdentity event
18
+ # - type [string]: type of the BusinessIdentity event which triggered the log creation. ex: "created", "updated", "canceled", "processing", "success", "failed"
19
+ # - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
20
+ class Log < StarkCore::Utils::Resource
21
+ attr_reader :id, :identity, :errors, :type, :created
22
+ def initialize(id: nil, identity: nil, errors: nil, type: nil, created: nil)
23
+ super(id)
24
+ @identity = identity
25
+ @errors = errors
26
+ @type = type
27
+ @created = StarkCore::Utils::Checks.check_datetime(created)
28
+ end
29
+
30
+ # # Retrieve a specific BusinessIdentity::Log
31
+ #
32
+ # Receive a single BusinessIdentity::Log object previously created by the Stark Infra API by passing its id
33
+ #
34
+ # ## Parameters (required):
35
+ # - id [string]: object unique id. ex: '5656565656565656'
36
+ #
37
+ # ## Parameters (optional):
38
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
39
+ #
40
+ # ## Return:
41
+ # - BusinessIdentity::Log object with updated attributes
42
+ def self.get(id, user: nil)
43
+ StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
44
+ end
45
+
46
+ # # Retrieve BusinessIdentity::Logs
47
+ #
48
+ # Receive a generator of BusinessIdentity::Log objects previously created in the Stark Infra API
49
+ #
50
+ # ## Parameters (optional):
51
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
52
+ # - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
53
+ # - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
54
+ # - types [list of strings, default nil]: filter for log event types. ex: "created", "updated", "canceled", "processing", "success", "failed"
55
+ # - identity_ids [list of strings, default nil]: list of identity ids to filter logs. ex: ['5656565656565656', '4545454545454545']
56
+ # - ids [list of strings, default nil]: Log ids to filter BusinessIdentity Logs. ex: ['5656565656565656']
57
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
58
+ #
59
+ # ## Return:
60
+ # - generator of BusinessIdentity::Log objects with updated attributes
61
+ def self.query(ids: nil, limit: nil, after: nil, before: nil, types: nil, identity_ids: nil, user: nil)
62
+ after = StarkCore::Utils::Checks.check_date(after)
63
+ before = StarkCore::Utils::Checks.check_date(before)
64
+ StarkInfra::Utils::Rest.get_stream(
65
+ ids: ids,
66
+ limit: limit,
67
+ after: after,
68
+ before: before,
69
+ types: types,
70
+ identity_ids: identity_ids,
71
+ user: user,
72
+ **resource
73
+ )
74
+ end
75
+
76
+ # # Retrieve paged BusinessIdentity::Logs
77
+ #
78
+ # Receive a list of up to 100 BusinessIdentity::Log objects previously created in the Stark Infra API and the cursor to the next page.
79
+ # Use this function instead of query if you want to manually page your identities.
80
+ #
81
+ # ## Parameters (optional):
82
+ # - cursor [string, default nil]: cursor returned on the previous page function call
83
+ # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
84
+ # - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
85
+ # - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
86
+ # - types [list of strings, default nil]: filter for log event types. ex: "created", "updated", "canceled", "processing", "success", "failed"
87
+ # - identity_ids [list of strings, default nil]: list of identity ids to filter logs. ex: ['5656565656565656', '4545454545454545']
88
+ # - ids [list of strings, default nil]: Log ids to filter BusinessIdentity Logs. ex: ['5656565656565656']
89
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
90
+ #
91
+ # ## Return:
92
+ # - list of BusinessIdentity::Log objects with updated attributes
93
+ # - cursor to retrieve the next page of Log objects
94
+ def self.page(cursor: nil, ids: nil, limit: nil, after: nil, before: nil, types: nil, identity_ids: nil, user: nil)
95
+ after = StarkCore::Utils::Checks.check_date(after)
96
+ before = StarkCore::Utils::Checks.check_date(before)
97
+ StarkInfra::Utils::Rest.get_page(
98
+ cursor: cursor,
99
+ ids: ids,
100
+ limit: limit,
101
+ after: after,
102
+ before: before,
103
+ types: types,
104
+ identity_ids: identity_ids,
105
+ user: user,
106
+ **resource
107
+ )
108
+ end
109
+
110
+ def self.resource
111
+ request_maker = StarkInfra::BusinessIdentity.resource[:resource_maker]
112
+ {
113
+ resource_name: 'BusinessIdentityLog',
114
+ resource_maker: proc { |json|
115
+ Log.new(
116
+ id: json['id'],
117
+ identity: StarkCore::Utils::API.from_api_json(request_maker, json['identity']),
118
+ errors: json['errors'],
119
+ type: json['type'],
120
+ created: json['created']
121
+ )
122
+ }
123
+ }
124
+ end
125
+ end
126
+ end
127
+ end
@@ -42,7 +42,8 @@ module StarkInfra
42
42
 
43
43
  # # Create CreditHolmes
44
44
  #
45
- # Send a list of CreditHolmes objects for creation at the Stark Infra API
45
+ # Send a list of CreditHolmes objects for creation at the Stark Infra API. You can create up to 100
46
+ # CreditHolmes in a single call.
46
47
  #
47
48
  # ## Parameters (required):
48
49
  # - holmes [list of CreditHolmes objects]: list of CreditHolmes objects to be created in the API.
@@ -0,0 +1,125 @@
1
+ # frozen_string_literal: true
2
+
3
+ require('starkcore')
4
+ require_relative('../utils/rest')
5
+ require_relative('credit_holmes')
6
+
7
+ module StarkInfra
8
+ class CreditHolmes
9
+ # # CreditHolmes::Log object
10
+ #
11
+ # Every time a CreditHolmes entity is updated, a corresponding CreditHolmes::Log
12
+ # is generated for the entity. This log is never generated by the
13
+ # user, but it can be retrieved to check additional information
14
+ # on the CreditHolmes.
15
+ #
16
+ # ## Attributes (return-only):
17
+ # - id [string]: unique id returned when the log is created. ex: '5656565656565656'
18
+ # - holmes [CreditHolmes]: CreditHolmes entity to which the log refers to.
19
+ # - errors [list of strings]: list of errors linked to this CreditHolmes event.
20
+ # - type [string]: type of the CreditHolmes event which triggered the log creation. ex: 'created', 'failed', 'success'
21
+ # - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
22
+ class Log < StarkCore::Utils::Resource
23
+ attr_reader :id, :created, :type, :errors, :holmes
24
+ def initialize(id:, created:, type:, errors:, holmes:)
25
+ super(id)
26
+ @holmes = holmes
27
+ @errors = errors
28
+ @type = type
29
+ @created = StarkCore::Utils::Checks.check_datetime(created)
30
+ end
31
+
32
+ # # Retrieve a specific CreditHolmes::Log
33
+ #
34
+ # Receive a single CreditHolmes::Log object previously created by the Stark Infra API by its id
35
+ #
36
+ # ## Parameters (required):
37
+ # - id [string]: object unique id. ex: '5656565656565656'
38
+ #
39
+ # ## Parameters (optional):
40
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
41
+ #
42
+ # ## Return:
43
+ # - CreditHolmes::Log object with updated attributes
44
+ def self.get(id, user: nil)
45
+ StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
46
+ end
47
+
48
+ # # Retrieve CreditHolmes::Logs
49
+ #
50
+ # Receive a generator of CreditHolmes::Log objects previously created in the Stark Infra API
51
+ #
52
+ # ## Parameters (optional):
53
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
54
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
55
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
56
+ # - types [list of strings, default nil]: filter for log event types. ex: ['created', 'failed', 'success']
57
+ # - holmes_ids [list of strings, default nil]: list of CreditHolmes ids to filter logs. ex: ['5656565656565656', '4545454545454545']
58
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
59
+ #
60
+ # ## Return:
61
+ # - generator of CreditHolmes::Log objects with updated attributes
62
+ def self.query(limit: nil, after: nil, before: nil, types: nil, holmes_ids: nil, user: nil)
63
+ after = StarkCore::Utils::Checks.check_date(after)
64
+ before = StarkCore::Utils::Checks.check_date(before)
65
+ StarkInfra::Utils::Rest.get_stream(
66
+ limit: limit,
67
+ after: after,
68
+ before: before,
69
+ types: types,
70
+ holmes_ids: holmes_ids,
71
+ user: user,
72
+ **resource
73
+ )
74
+ end
75
+
76
+ # # Retrieve paged CreditHolmes::Logs
77
+ #
78
+ # Receive a list of up to 100 CreditHolmes::Log objects previously created in the Stark Infra API and the cursor to the next page.
79
+ # Use this function instead of query if you want to manually page your requests.
80
+ #
81
+ # ## Parameters (optional):
82
+ # - cursor [string, default nil]: cursor returned on the previous page function call
83
+ # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
84
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
85
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
86
+ # - types [list of strings, default nil]: filter for log event types. ex: ['created', 'failed', 'success']
87
+ # - holmes_ids [list of strings, default nil]: list of CreditHolmes ids to filter logs. ex: ['5656565656565656', '4545454545454545']
88
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
89
+ #
90
+ # ## Return:
91
+ # - list of CreditHolmes::Log objects with updated attributes
92
+ # - cursor to retrieve the next page of CreditHolmes::Log objects
93
+ def self.page(cursor: nil, limit: nil, after: nil, before: nil, types: nil, holmes_ids: nil, user: nil)
94
+ after = StarkCore::Utils::Checks.check_date(after)
95
+ before = StarkCore::Utils::Checks.check_date(before)
96
+ StarkInfra::Utils::Rest.get_page(
97
+ cursor: cursor,
98
+ limit: limit,
99
+ after: after,
100
+ before: before,
101
+ types: types,
102
+ holmes_ids: holmes_ids,
103
+ user: user,
104
+ **resource
105
+ )
106
+ end
107
+
108
+ def self.resource
109
+ holmes_maker = StarkInfra::CreditHolmes.resource[:resource_maker]
110
+ {
111
+ resource_name: 'CreditHolmesLog',
112
+ resource_maker: proc { |json|
113
+ Log.new(
114
+ id: json['id'],
115
+ holmes: StarkCore::Utils::API.from_api_json(holmes_maker, json['holmes']),
116
+ errors: json['errors'],
117
+ type: json['type'],
118
+ created: json['created']
119
+ )
120
+ }
121
+ }
122
+ end
123
+ end
124
+ end
125
+ end
@@ -22,9 +22,9 @@ module StarkInfra
22
22
  # - name [string]: credit receiver's full name. ex: 'Edward Stark'
23
23
  # - tax_id [string]: credit receiver's tax ID (CPF or CNPJ). ex: '20.018.183/0001-80'
24
24
  # - scheduled [DateTime, Date or string]: date of transfer execution. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
25
- # - invoices [list of CreditNote::Invoice objects]: list of Invoice objects to be created and sent to the credit receiver. ex: [Invoice.new(), Invoice.new()]
25
+ # - invoices [list of up to 100 CreditNote::Invoice objects]: installments to be paid by the borrower. All invoices in the same CreditNote must share the same fine and interest. ex: [Invoice.new(), Invoice.new()]
26
26
  # - payment [CreditNote::Transfer object]: payment entity to be created and sent to the credit receiver. ex: Transfer.new()
27
- # - signers [list of CreditSigner objects]: signer's name, contact and delivery method for the signature request. ex: [CreditSigner.new(), CreditSigner.new()]
27
+ # - signers [list of up to 10 CreditSigner objects]: signer's name, contact and delivery method for the signature request. ex: [CreditSigner.new(), CreditSigner.new()]
28
28
  # - external_id [string]: a string that must be unique among all your CreditNotes, used to avoid resource duplication. ex: 'my-internal-id-123456'
29
29
  # - street_line_1 [string]: credit receiver main address. ex: 'Av. Paulista, 200'
30
30
  # - street_line_2 [string]: credit receiver address complement. ex: 'Apto. 123'
@@ -42,6 +42,7 @@ module StarkInfra
42
42
  # - rebate_amount [integer, default nil]: credit analysis fee deducted from lent amount. ex: 11234 (= R$ 112.34)
43
43
  # - tags [list of strings, default nil]: list of strings for reference when searching for CreditNotes. ex: ['employees', 'monthly']
44
44
  # - expiration [integer, default 604800]: time interval in seconds between scheduled date and expiration date. ex: 123456789
45
+ # - rules [list of CreditNote::Rule, default []]: list of {key, value} rules modifying the credit note behavior. Currently available key: 'invoiceCreationMode', values 'scheduled' (default - invoice issued a few days before due date), 'instant' (issued as soon as disbursed) or 'never' (not issued automatically).
45
46
  #
46
47
  # ## Attributes (return-only):
47
48
  # - id [string]: unique id returned when the CreditNote is created. ex: '5656565656565656'
@@ -52,19 +53,20 @@ module StarkInfra
52
53
  # - tax_amount [integer]: tax amount included in the CreditNote. ex: 100
53
54
  # - nominal_interest [float]: yearly nominal interest rate of the CreditNote, in percentage. ex: 11.5
54
55
  # - interest [float]: yearly effective interest rate of the credit note, in percentage. ex: 12.5
56
+ # - debtor_workspace_id [string]: ID of the debtor's Workspace, when it differs from the Workspace that generated this CreditNote. ex: '4545454545454545'
55
57
  # - created [DateTime]: creation datetime for the CreditNote. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
56
58
  # - updated [DateTime]: latest update datetime for the CreditNote. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
57
59
  class CreditNote < StarkCore::Utils::Resource
58
60
  attr_reader :template_id, :name, :tax_id, :scheduled, :invoices, :payment, :signers, :external_id,
59
61
  :street_line_1, :street_line_2, :district, :city, :state_code, :zip_code, :payment_type,
60
- :nominal_amount, :amount, :rebate_amount, :tags, :expiration, :id, :document_id, :status,
61
- :transaction_ids, :workspace_id, :tax_amount, :nominal_interest, :interest, :created, :updated
62
+ :nominal_amount, :amount, :rebate_amount, :tags, :expiration, :rules, :id, :document_id, :status,
63
+ :transaction_ids, :workspace_id, :tax_amount, :nominal_interest, :interest, :debtor_workspace_id, :created, :updated
62
64
  def initialize(
63
65
  template_id:, name:, tax_id:, scheduled:, invoices:, payment:, signers:, external_id:,
64
66
  street_line_1:, street_line_2:, district:, city:, state_code:, zip_code:, payment_type: nil,
65
- nominal_amount: nil, amount: nil, rebate_amount: nil, tags: nil, expiration: nil, id: nil,
67
+ nominal_amount: nil, amount: nil, rebate_amount: nil, tags: nil, expiration: nil, rules: nil, id: nil,
66
68
  document_id: nil, status: nil, transaction_ids: nil, workspace_id: nil, tax_amount: nil,
67
- nominal_interest: nil, interest: nil, created: nil, updated: nil
69
+ nominal_interest: nil, interest: nil, debtor_workspace_id: nil, created: nil, updated: nil
68
70
  )
69
71
  super(id)
70
72
  @template_id = template_id
@@ -85,6 +87,7 @@ module StarkInfra
85
87
  @rebate_amount = rebate_amount
86
88
  @tags = tags
87
89
  @expiration = expiration
90
+ @rules = Rule.parse_rules(rules)
88
91
  @document_id = document_id
89
92
  @status = status
90
93
  @transaction_ids = transaction_ids
@@ -92,6 +95,7 @@ module StarkInfra
92
95
  @tax_amount = tax_amount
93
96
  @nominal_interest = nominal_interest
94
97
  @interest = interest
98
+ @debtor_workspace_id = debtor_workspace_id
95
99
  @created = StarkCore::Utils::Checks.check_datetime(created)
96
100
  @updated = StarkCore::Utils::Checks.check_datetime(updated)
97
101
 
@@ -102,7 +106,8 @@ module StarkInfra
102
106
 
103
107
  # # Create CreditNotes
104
108
  #
105
- # Send a list of CreditNote objects for creation in the Stark Infra API
109
+ # Send a list of CreditNote objects for creation in the Stark Infra API. You can create up to 100
110
+ # CreditNotes in a single call.
106
111
  #
107
112
  # ## Parameters (required):
108
113
  # - notes [list of CreditNote objects]: list of CreditNote objects to be created in the API
@@ -198,7 +203,9 @@ module StarkInfra
198
203
 
199
204
  # # Cancel a CreditNote entity
200
205
  #
201
- # Cancel a CreditNote entity previously created in the Stark Infra API
206
+ # Cancel a CreditNote entity previously created in the Stark Infra API. Only CreditNotes with status
207
+ # 'created', 'signed' or 'processing' are actually canceled (which also cancels the signing document);
208
+ # notes already 'success', 'failed', 'expired' or 'canceled' are returned unchanged.
202
209
  #
203
210
  # ## Parameters (required):
204
211
  # - id [string]: object unique id. ex: '5656565656565656'
@@ -212,6 +219,40 @@ module StarkInfra
212
219
  StarkInfra::Utils::Rest.delete_id(id: id, user: user, **resource)
213
220
  end
214
221
 
222
+ # # Retrieve a specific CreditNote pdf file
223
+ #
224
+ # Receive the CCB disbursement pdf file of a CreditNote previously created in the Stark Infra API by its id.
225
+ # Not available for canceled CreditNotes.
226
+ #
227
+ # ## Parameters (required):
228
+ # - id [string]: CreditNote unique id. ex: '5656565656565656'
229
+ #
230
+ # ## Parameters (optional):
231
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
232
+ #
233
+ # ## Return:
234
+ # - CreditNote pdf file
235
+ def self.pdf(id, user: nil)
236
+ StarkInfra::Utils::Rest.get_content(id: id, user: user, sub_resource_name: 'pdf', **resource)
237
+ end
238
+
239
+ # # Retrieve a specific CreditNote payment pdf file
240
+ #
241
+ # Receive the CCB disbursement payment pdf file of a CreditNote previously created in the Stark Infra API by its id.
242
+ # Only CreditNotes with status "success" have a payment pdf.
243
+ #
244
+ # ## Parameters (required):
245
+ # - id [string]: CreditNote unique id. ex: '5656565656565656'
246
+ #
247
+ # ## Parameters (optional):
248
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
249
+ #
250
+ # ## Return:
251
+ # - CreditNote payment pdf file
252
+ def self.payment(id, user: nil)
253
+ StarkInfra::Utils::Rest.get_content(id: id, user: user, sub_resource_name: 'payment/pdf', **resource)
254
+ end
255
+
215
256
  def self.parse_payment(payment, payment_type)
216
257
  resource_maker = { 'transfer' => Transfer.resource[:resource_maker] }
217
258
  if payment.is_a?(Hash)
@@ -261,6 +302,7 @@ module StarkInfra
261
302
  rebate_amount: json['rebate_amount'],
262
303
  tags: json['tags'],
263
304
  expiration: json['expiration'],
305
+ rules: json['rules'],
264
306
  document_id: json['document_id'],
265
307
  status: json['status'],
266
308
  transaction_ids: json['transaction_ids'],
@@ -268,6 +310,7 @@ module StarkInfra
268
310
  tax_amount: json['tax_amount'],
269
311
  nominal_interest: json['nominal_interest'],
270
312
  interest: json['interest'],
313
+ debtor_workspace_id: json['debtor_workspace_id'],
271
314
  created: json['created'],
272
315
  updated: json['updated']
273
316
  )
@@ -0,0 +1,55 @@
1
+ require_relative('../utils/rest')
2
+
3
+ module StarkInfra
4
+ class CreditNote
5
+ # # CreditNote::Rule object
6
+ #
7
+ # The CreditNote::Rule object modifies the behavior of CreditNote objects when passed as an argument upon their creation.
8
+ #
9
+ # ## Parameters (required):
10
+ # - key [string]: Rule to be customized, describes what CreditNote behavior will be altered. ex: 'invoiceCreationMode'
11
+ # - value [string]: value of the rule. ex: 'scheduled', 'instant' or 'never'
12
+ class Rule < StarkCore::Utils::SubResource
13
+ attr_reader :key, :value
14
+ def initialize(key:, value:)
15
+ @key = key
16
+ @value = value
17
+ end
18
+
19
+ # # Parse CreditNote::Rules
20
+ #
21
+ # Converts a list of hashes (or Rule objects) received from the API into a list of CreditNote::Rule objects.
22
+ #
23
+ # ## Parameters (required):
24
+ # - rules [list of hashes or CreditNote::Rule objects]: list to be parsed.
25
+ #
26
+ # ## Return:
27
+ # - list of parsed CreditNote::Rule objects
28
+ def self.parse_rules(rules)
29
+ resource_maker = StarkInfra::CreditNote::Rule.resource[:resource_maker]
30
+ return rules if rules.nil?
31
+
32
+ parsed_rules = []
33
+ rules.each do |rule|
34
+ unless rule.is_a? Rule
35
+ rule = StarkCore::Utils::API.from_api_json(resource_maker, rule)
36
+ end
37
+ parsed_rules << rule
38
+ end
39
+ return parsed_rules
40
+ end
41
+
42
+ def self.resource
43
+ {
44
+ resource_name: 'Rule',
45
+ resource_maker: proc { |json|
46
+ Rule.new(
47
+ key: json['key'],
48
+ value: json['value']
49
+ )
50
+ }
51
+ }
52
+ end
53
+ end
54
+ end
55
+ end
@@ -12,7 +12,7 @@ module StarkInfra
12
12
  # ## Parameters (required):
13
13
  # - name [string]: receiver full name. ex: 'Anthony Edward Stark'
14
14
  # - tax_id [string]: receiver tax ID (CPF or CNPJ) with or without formatting. ex: '01234567890' or '20.018.183/0001-80'
15
- # - bank_code [string]: code of the receiver bank institution in Brazil. ex: '20018183'
15
+ # - bank_code [string]: receiver institution ISPB code, 8 digits. ex: '20018183'
16
16
  # - branch_code [string]: receiver bank account branch. Use '-' in case there is a verifier digit. ex: '1357-9'
17
17
  # - account_number [string]: receiver bank account number. Use '-' before the verifier digit. ex: '876543-2'
18
18
  #
@@ -13,18 +13,26 @@ module StarkInfra
13
13
  # to the Stark Infra API and returns the list of created objects.
14
14
  #
15
15
  # ## Parameters (required):
16
- # - type [string]: table type that defines the amortization system. Options: 'sac', 'price', 'american', 'bullet', 'custom'
16
+ # - type [string]: table type that defines the amortization system. Options: 'sac' (constant amortization), 'price' (fixed installments), 'american' (periodic interest and principal at maturity), 'bullet' (principal and interest at maturity), 'custom' (you provide the invoices and the rates are computed).
17
17
  # - nominal_amount [integer]: amount in cents transferred to the credit receiver, before deductions. ex: 11234 (= R$ 112.34)
18
18
  # - scheduled [DateTime, Date or string]: date of transfer execution. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
19
19
  # - tax_id [string]: credit receiver's tax ID (CPF or CNPJ). ex: '20.018.183/0001-80'
20
20
  #
21
21
  # ## Parameters (conditionally required):
22
+ # - nominal_amount or amount [integer]: provide exactly one; the other is computed from the invoice schedule (not used for type 'custom').
23
+ # - count or initial_amount [integer]: for 'sac' and 'price' types, provide exactly one; the other is computed.
22
24
  # - invoices [list of CreditNote::Invoice objects]: list of CreditNote.Invoice objects to be created and sent to the credit receiver.
23
25
  # - nominal_interest [float]: yearly nominal interest rate of the credit note, in percentage. ex: 12.5
24
26
  # - initial_due [DateTime, Date or string]: date of the first invoice. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0), Date.new(2020, 3, 10) or '2020-03-10'
25
27
  # - count [integer]: quantity of invoices for payment. ex: 12
26
28
  # - initial_amount [integer]: value of the first invoice in cents. ex: 1234 (= R$12.34)
27
- # - interval [string]: interval between invoices. ex: 'year', 'month'
29
+ # - interval [string, default 'month']: interval between invoices. Options: 'day', 'week', 'month', 'quarter', 'semester', 'year'.
30
+ #
31
+ # ## Parameters (conditionally required, by type):
32
+ # - 'sac'/'price': nominal_interest, scheduled, initial_due, tax_id and one of count/initial_amount.
33
+ # - 'american': nominal_interest, scheduled, initial_due, count, tax_id.
34
+ # - 'bullet': nominal_interest, scheduled, initial_due, tax_id.
35
+ # - 'custom': scheduled, tax_id, invoices.
28
36
  #
29
37
  # ## Parameters (optional):
30
38
  # - rebate_amount [integer, default nil]: credit analysis fee deducted from lent amount. ex: 11234 (= R$ 112.34)
@@ -23,7 +23,8 @@ module StarkInfra
23
23
 
24
24
  # # Create CreditPreviews
25
25
  #
26
- # Send a list of CreditPreview objects for processing in the Stark Infra API
26
+ # Send a list of CreditPreview objects for processing in the Stark Infra API. You can create up to 100
27
+ # previews in a single call.
27
28
  #
28
29
  # ## Parameters (required):
29
30
  # - previews [list of CreditPreview objects]: list of CreditPreview objects to be created in the API
@@ -9,8 +9,8 @@ module StarkInfra
9
9
  #
10
10
  # ## Parameters (required):
11
11
  # - name [string]: signer's name. ex: 'Tony Stark'
12
- # - contact [string]: signer's contact information. ex: 'tony@starkindustries.com'
13
- # - method [string]: delivery method for the contract. ex: 'link'
12
+ # - contact [string]: signer contact that receives the signing link or token. Can be an email, a phone number or, for the 'server' and 'organization' methods, a URL. ex: 'tony@starkindustries.com'
13
+ # - method [string]: signing method. Options: 'link' (signing link sent to the contact), 'token' (signing token sent to the contact), 'server' and 'organization' (automatic signatures over URL contacts).
14
14
  #
15
15
  # ## Attributes (return-only):
16
16
  # - id [string]: unique id returned when the CreditSigner is created. ex: '5656565656565656'
@@ -23,6 +23,31 @@ module StarkInfra
23
23
  @method = method
24
24
  end
25
25
 
26
+ # # Resend token to signer
27
+ #
28
+ # Resend token to a specific signer.
29
+ #
30
+ # ## Parameters (required):
31
+ # - id [string]: CreditSigner unique id. ex: '5656565656565656'
32
+ #
33
+ # ## Parameters (optional):
34
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
35
+ #
36
+ # ## Return:
37
+ # - CreditSigner object with updated attributes
38
+ def self.resend_token(id, user: nil)
39
+ StarkInfra::Utils::Rest.patch_id(id: id, is_sent: false, user: user, **resource)
40
+ end
41
+
42
+ # # Parse CreditSigners
43
+ #
44
+ # Converts a list of hashes (or CreditSigner objects) received from the API into a list of CreditSigner objects.
45
+ #
46
+ # ## Parameters (required):
47
+ # - signers [list of hashes or CreditSigner objects]: list to be parsed.
48
+ #
49
+ # ## Return:
50
+ # - list of parsed CreditSigner objects
26
51
  def self.parse_signers(signers)
27
52
  resource_maker = StarkInfra::CreditSigner.resource[:resource_maker]
28
53
  return signers if signers.nil?
@@ -13,6 +13,9 @@ module StarkInfra
13
13
  # in the BR Code. Stark Infra will receive the GET request and forward it to your
14
14
  # registered endpoint with a GET request containing the UUID of the BR Code for
15
15
  # identification.
16
+ # The 'subscription', 'subscriptionAndInstant' and 'dueAndOrSubscription' types let a DynamicBrcode initiate
17
+ # a Pix Automático recurring authorization; subscription reads are answered through PixPullSubscription, not
18
+ # response_due/response_instant.
16
19
  #
17
20
  # When you initialize a DynamicBrcode, the entity will not be automatically
18
21
  # created in the Stark Infra API. The 'create' function sends the objects
@@ -24,7 +27,7 @@ module StarkInfra
24
27
  # - external_id [string]: string that must be unique among all your DynamicBrcodes. Duplicated external ids will cause failures. ex: 'my-internal-id-123456'
25
28
  #
26
29
  # ## Parameters (optional):
27
- # - type [string, default 'instant']: type of the DynamicBrcode. Options: 'instant', 'due'
30
+ # - type [string, default 'instant']: type of the DynamicBrcode. Options: 'instant', 'due', 'subscription', 'subscriptionAndInstant', 'dueAndOrSubscription'.
28
31
  # - tags [list of strings, default nil]: list of strings for tagging. ex: ['travel', 'food']
29
32
  #
30
33
  # ## Attributes (return-only):
@@ -281,7 +284,7 @@ module StarkInfra
281
284
  # ## Return:
282
285
  # - verified Brcode's uuid.
283
286
  def self.verify(uuid:, signature:, user: nil)
284
- StarkCore::Utils::Parse.verify(content: uuid, signature: signature, user: user)
287
+ StarkInfra::Utils::Parse.verify(content: uuid, signature: signature, user: user)
285
288
  end
286
289
 
287
290
  def self.resource
data/lib/event/event.rb CHANGED
@@ -5,8 +5,12 @@ require('starkcore')
5
5
  require_relative('../error')
6
6
  require_relative('../utils/rest')
7
7
  require_relative('../utils/parse')
8
+ require_relative('../pix_pull_request/log')
9
+ require_relative('../pix_pull_subscription/log')
8
10
  require_relative('../pix_request/log')
9
11
  require_relative('../pix_reversal/log')
12
+ require_relative('../pix_dispute/log')
13
+ require_relative('../business_identity/log')
10
14
 
11
15
  module StarkInfra
12
16
  # # Webhook Event object
@@ -36,6 +40,9 @@ module StarkInfra
36
40
  'pix-claim': StarkInfra::PixClaim::Log.resource,
37
41
  'pix-chargeback': StarkInfra::PixChargeback::Log.resource,
38
42
  'pix-infraction': StarkInfra::PixInfraction::Log.resource,
43
+ 'pix-dispute': StarkInfra::PixDispute::Log.resource,
44
+ 'pix-pull-request': StarkInfra::PixPullRequest::Log.resource,
45
+ 'pix-pull-subscription': StarkInfra::PixPullSubscription::Log.resource,
39
46
  'pix-request.in': StarkInfra::PixRequest::Log.resource,
40
47
  'pix-request.out': StarkInfra::PixRequest::Log.resource,
41
48
  'pix-reversal.in': StarkInfra::PixReversal::Log.resource,
@@ -44,6 +51,7 @@ module StarkInfra
44
51
  'issuing-invoice': StarkInfra::IssuingInvoice::Log.resource,
45
52
  'issuing-purchase': StarkInfra::IssuingPurchase::Log.resource,
46
53
  'credit-note': StarkInfra::CreditNote::Log.resource,
54
+ 'business-identity': StarkInfra::BusinessIdentity::Log.resource,
47
55
  }[subscription.to_sym]
48
56
 
49
57
  @log = log
@@ -124,7 +132,7 @@ module StarkInfra
124
132
 
125
133
  # # Delete a notification Event
126
134
  #
127
- # Delete a notification Event entity previously created in the Stark Infra API by its ID
135
+ # Delete a notification Event entity previously created in the Stark Infra API by its ID. This action cannot be undone.
128
136
  #
129
137
  # ## Parameters (required):
130
138
  # - id [string]: Event unique id. ex: '5656565656565656'
@@ -144,7 +152,7 @@ module StarkInfra
144
152
  # If is_delivered is true, the event will no longer be returned on queries with is_delivered=false.
145
153
  #
146
154
  # ## Parameters (required):
147
- # - id [list of strings]: Event unique ids. ex: '5656565656565656'
155
+ # - id [string]: Event unique id. ex: '5656565656565656'
148
156
  # - is_delivered [bool]: If true and event hasn't been delivered already, event will be set as delivered. ex: true
149
157
  #
150
158
  # ## Parameters (optional):