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,200 @@
1
+ # frozen_string_literal: true
2
+
3
+ require('starkcore')
4
+ require_relative('../utils/rest')
5
+
6
+
7
+ module StarkInfra
8
+ # # PixInternalTransactionReport object
9
+ #
10
+ # Transactions that happen internally — outside of the SPI — must be reported to
11
+ # the Central Bank so they are reflected in the participant's statements. A
12
+ # PixInternalTransactionReport is the report you create for each such transaction.
13
+ #
14
+ # When you initialize a PixInternalTransactionReport, the entity will not be
15
+ # automatically created in the Stark Infra API. The 'create' function sends the
16
+ # objects to the Stark Infra API and returns the list of created objects.
17
+ #
18
+ # ## Parameters (required):
19
+ # - amount [integer]: amount in cents of the reported transaction. ex: 1234 (= R$ 12.34)
20
+ # - created [DateTime or string]: datetime when the reported transaction occurred. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
21
+ # - end_to_end_id [string]: central bank's unique transaction id. ex: 'E20018183202201201213u34sav898j'
22
+ # - method [string]: execution method of the transaction. ex: 'contactless', 'dict', 'dynamicQrcode', 'initiator', 'manual', 'payerQrcode', 'staticContactless', 'staticQrcode' or 'subscription'
23
+ # - reference_type [string]: type of the reported transaction. ex: 'request' or 'reversal'
24
+ # - sender_account_number [string]: sender's bank account number. ex: '876543-2'
25
+ # - sender_branch_code [string]: sender's bank account branch code. ex: '1357-9'
26
+ # - sender_account_type [string]: sender's bank account type. ex: 'checking', 'savings', 'salary' or 'payment'
27
+ # - sender_bank_code [string]: sender's participant code (ISPB). ex: '20018183'
28
+ # - sender_tax_id [string]: sender's tax ID (CPF or CNPJ) with or without formatting. ex: '01234567890' or '20.018.183/0001-80'
29
+ # - receiver_account_number [string]: receiver's bank account number. ex: '876543-2'
30
+ # - receiver_branch_code [string]: receiver's bank account branch code. ex: '1357-9'
31
+ # - receiver_account_type [string]: receiver's bank account type. ex: 'checking', 'savings', 'salary' or 'payment'
32
+ # - receiver_bank_code [string]: receiver's participant code (ISPB). ex: '20018183'
33
+ # - receiver_tax_id [string]: receiver's tax ID (CPF or CNPJ) with or without formatting. ex: '01234567890' or '20.018.183/0001-80'
34
+ #
35
+ # ## Parameters (conditionally-required):
36
+ # - return_id [string, default nil]: central bank's unique reversal id. Required when reference_type is 'reversal'. ex: 'D20018183202201201213u34sav898j'
37
+ #
38
+ # ## Parameters (optional):
39
+ # - receiver_key_id [string, default nil]: receiver's Pix key. ex: '+5511989898989'
40
+ #
41
+ # ## Attributes (return-only):
42
+ # - id [string]: unique id returned when the PixInternalTransactionReport is created. ex: '5656565656565656'
43
+ # - status [string]: current PixInternalTransactionReport status. Options: 'created', 'processing', 'success', 'failed'.
44
+ # - updated [DateTime]: latest update datetime for the PixInternalTransactionReport. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
45
+ class PixInternalTransactionReport < StarkCore::Utils::Resource
46
+ attr_reader :amount, :created, :end_to_end_id, :method, :reference_type, :sender_account_number,
47
+ :sender_branch_code, :sender_account_type, :sender_bank_code, :sender_tax_id,
48
+ :receiver_account_number, :receiver_branch_code, :receiver_account_type, :receiver_bank_code,
49
+ :receiver_tax_id, :receiver_key_id, :return_id, :id, :status, :updated
50
+ def initialize(
51
+ amount:, created:, end_to_end_id:, method:, reference_type:, sender_account_number:, sender_branch_code:,
52
+ sender_account_type:, sender_bank_code:, sender_tax_id:, receiver_account_number:, receiver_branch_code:,
53
+ receiver_account_type:, receiver_bank_code:, receiver_tax_id:, receiver_key_id: nil, return_id: nil,
54
+ id: nil, status: nil, updated: nil
55
+ )
56
+ super(id)
57
+ @amount = amount
58
+ @created = StarkCore::Utils::Checks.check_datetime(created)
59
+ @end_to_end_id = end_to_end_id
60
+ @method = method
61
+ @reference_type = reference_type
62
+ @sender_account_number = sender_account_number
63
+ @sender_branch_code = sender_branch_code
64
+ @sender_account_type = sender_account_type
65
+ @sender_bank_code = sender_bank_code
66
+ @sender_tax_id = sender_tax_id
67
+ @receiver_account_number = receiver_account_number
68
+ @receiver_branch_code = receiver_branch_code
69
+ @receiver_account_type = receiver_account_type
70
+ @receiver_bank_code = receiver_bank_code
71
+ @receiver_tax_id = receiver_tax_id
72
+ @receiver_key_id = receiver_key_id
73
+ @return_id = return_id
74
+ @status = status
75
+ @updated = StarkCore::Utils::Checks.check_datetime(updated)
76
+ end
77
+
78
+ # # Create PixInternalTransactionReports
79
+ #
80
+ # Send a list of PixInternalTransactionReport objects for creation in the Stark Infra API
81
+ #
82
+ # ## Parameters (required):
83
+ # - reports [list of PixInternalTransactionReport objects]: list of PixInternalTransactionReport objects to be created in the API
84
+ #
85
+ # ## Parameters (optional):
86
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
87
+ #
88
+ # ## Return:
89
+ # - list of PixInternalTransactionReport objects with updated attributes
90
+ def self.create(reports, user: nil)
91
+ StarkInfra::Utils::Rest.post(entities: reports, user: user, **resource)
92
+ end
93
+
94
+ # # Retrieve a specific PixInternalTransactionReport
95
+ #
96
+ # Receive a single PixInternalTransactionReport object previously created in the Stark Infra API by passing its id
97
+ #
98
+ # ## Parameters (required):
99
+ # - id [string]: object unique id. ex: '5656565656565656'
100
+ #
101
+ # ## Parameters (optional):
102
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
103
+ #
104
+ # ## Return:
105
+ # - PixInternalTransactionReport object with updated attributes
106
+ def self.get(id, user: nil)
107
+ StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
108
+ end
109
+
110
+ # # Retrieve PixInternalTransactionReports
111
+ #
112
+ # Receive a generator of PixInternalTransactionReport objects previously created in the Stark Infra API
113
+ #
114
+ # ## Parameters (optional):
115
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
116
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
117
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
118
+ # - status [list of strings, default nil]: filter for status of retrieved objects. ex: ['success'] or ['sent', 'failed']
119
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
120
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
121
+ #
122
+ # ## Return:
123
+ # - generator of PixInternalTransactionReport objects with updated attributes
124
+ def self.query(limit: nil, after: nil, before: nil, status: nil, ids: nil, user: nil)
125
+ after = StarkCore::Utils::Checks.check_date(after)
126
+ before = StarkCore::Utils::Checks.check_date(before)
127
+ StarkInfra::Utils::Rest.get_stream(
128
+ limit: limit,
129
+ after: after,
130
+ before: before,
131
+ status: status,
132
+ ids: ids,
133
+ user: user,
134
+ **resource
135
+ )
136
+ end
137
+
138
+ # # Retrieve paged PixInternalTransactionReports
139
+ #
140
+ # Receive a list of up to 100 PixInternalTransactionReport objects previously created in the Stark Infra API and the cursor to the next page.
141
+ # Use this function instead of query if you want to manually page your requests.
142
+ #
143
+ # ## Parameters (optional):
144
+ # - cursor [string, default nil]: cursor returned on the previous page function call
145
+ # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
146
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
147
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
148
+ # - status [list of strings, default nil]: filter for status of retrieved objects. ex: ['success'] or ['sent', 'failed']
149
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
150
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
151
+ #
152
+ # ## Return:
153
+ # - list of PixInternalTransactionReport objects with updated attributes
154
+ # - cursor to retrieve the next page of PixInternalTransactionReport objects
155
+ def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, ids: nil, user: nil)
156
+ after = StarkCore::Utils::Checks.check_date(after)
157
+ before = StarkCore::Utils::Checks.check_date(before)
158
+ StarkInfra::Utils::Rest.get_page(
159
+ cursor: cursor,
160
+ limit: limit,
161
+ after: after,
162
+ before: before,
163
+ status: status,
164
+ ids: ids,
165
+ user: user,
166
+ **resource
167
+ )
168
+ end
169
+
170
+ def self.resource
171
+ {
172
+ resource_name: 'PixInternalTransactionReport',
173
+ resource_maker: proc { |json|
174
+ PixInternalTransactionReport.new(
175
+ id: json['id'],
176
+ amount: json['amount'],
177
+ created: json['created'],
178
+ end_to_end_id: json['end_to_end_id'],
179
+ method: json['method'],
180
+ reference_type: json['reference_type'],
181
+ sender_account_number: json['sender_account_number'],
182
+ sender_branch_code: json['sender_branch_code'],
183
+ sender_account_type: json['sender_account_type'],
184
+ sender_bank_code: json['sender_bank_code'],
185
+ sender_tax_id: json['sender_tax_id'],
186
+ receiver_account_number: json['receiver_account_number'],
187
+ receiver_branch_code: json['receiver_branch_code'],
188
+ receiver_account_type: json['receiver_account_type'],
189
+ receiver_bank_code: json['receiver_bank_code'],
190
+ receiver_tax_id: json['receiver_tax_id'],
191
+ receiver_key_id: json['receiver_key_id'],
192
+ return_id: json['return_id'],
193
+ status: json['status'],
194
+ updated: json['updated']
195
+ )
196
+ }
197
+ }
198
+ end
199
+ end
200
+ end
@@ -16,7 +16,7 @@ module StarkInfra
16
16
  # ## Parameters (required):
17
17
  # - account_created [DateTime or string]: opening Date or DateTime for the linked account. ex: '2020-03-10T10:30:00.000000+00:00' or DateTime.new(2020, 3, 10, 10, 30, 0, 0).
18
18
  # - account_number [string]: number of the linked account. ex: '76543'.
19
- # - account_type [string]: type of the linked account. Options: 'checking', 'savings', 'salary' or 'payment'.
19
+ # - account_type [string]: type of the linked account. Options: 'checking', 'savings', 'salary', 'payment', 'other'.
20
20
  # - branch_code [string]: branch code of the linked account. ex: '1234'.
21
21
  # - name [string]: holder's name of the linked account. ex: 'Jamie Lannister'.
22
22
  # - tax_id [string]: holder's taxId (CPF/CNPJ) of the linked account. ex: '012.345.678-90'.
@@ -0,0 +1,129 @@
1
+ # frozen_string_literal: true
2
+
3
+ require('starkcore')
4
+ require_relative('../utils/rest')
5
+ require_relative('pix_key_holmes')
6
+
7
+ module StarkInfra
8
+ class PixKeyHolmes
9
+ # # PixKeyHolmes::Log object
10
+ #
11
+ # Every time a PixKeyHolmes entity is updated, a corresponding PixKeyHolmes::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 PixKeyHolmes.
15
+ #
16
+ # ## Attributes (return-only):
17
+ # - id [string]: unique id returned when the log is created. ex: '5656565656565656'
18
+ # - holmes [PixKeyHolmes]: PixKeyHolmes entity to which the log refers to.
19
+ # - errors [list of strings]: list of errors linked to this PixKeyHolmes event.
20
+ # - type [string]: type of the PixKeyHolmes event which triggered the log creation. ex: 'solving', 'solved'
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 PixKeyHolmes::Log
33
+ #
34
+ # Receive a single PixKeyHolmes::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
+ # - PixKeyHolmes::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 PixKeyHolmes::Logs
49
+ #
50
+ # Receive a generator of PixKeyHolmes::Log objects previously created in the Stark Infra API
51
+ #
52
+ # ## Parameters (optional):
53
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
54
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
55
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
56
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
57
+ # - types [list of strings, default nil]: filter for log event types. ex: ['solving', 'solved']
58
+ # - holmes_ids [list of strings, default nil]: list of PixKeyHolmes ids to filter logs. ex: ['5656565656565656', '4545454545454545']
59
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
60
+ #
61
+ # ## Return:
62
+ # - generator of PixKeyHolmes::Log objects with updated attributes
63
+ def self.query(ids: nil, limit: nil, after: nil, before: nil, types: nil, holmes_ids: nil, user: nil)
64
+ after = StarkCore::Utils::Checks.check_date(after)
65
+ before = StarkCore::Utils::Checks.check_date(before)
66
+ StarkInfra::Utils::Rest.get_stream(
67
+ ids: ids,
68
+ limit: limit,
69
+ after: after,
70
+ before: before,
71
+ types: types,
72
+ holmes_ids: holmes_ids,
73
+ user: user,
74
+ **resource
75
+ )
76
+ end
77
+
78
+ # # Retrieve paged PixKeyHolmes::Logs
79
+ #
80
+ # Receive a list of up to 100 PixKeyHolmes::Log objects previously created in the Stark Infra API and the cursor to the next page.
81
+ # Use this function instead of query if you want to manually page your requests.
82
+ #
83
+ # ## Parameters (optional):
84
+ # - cursor [string, default nil]: cursor returned on the previous page function call
85
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
86
+ # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
87
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
88
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
89
+ # - types [list of strings, default nil]: filter for log event types. ex: ['solving', 'solved']
90
+ # - holmes_ids [list of strings, default nil]: list of PixKeyHolmes ids to filter logs. ex: ['5656565656565656', '4545454545454545']
91
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
92
+ #
93
+ # ## Return:
94
+ # - list of PixKeyHolmes::Log objects with updated attributes
95
+ # - cursor to retrieve the next page of PixKeyHolmes::Log objects
96
+ def self.page(cursor: nil, ids: nil, limit: nil, after: nil, before: nil, types: nil, holmes_ids: nil, user: nil)
97
+ after = StarkCore::Utils::Checks.check_date(after)
98
+ before = StarkCore::Utils::Checks.check_date(before)
99
+ StarkInfra::Utils::Rest.get_page(
100
+ cursor: cursor,
101
+ ids: ids,
102
+ limit: limit,
103
+ after: after,
104
+ before: before,
105
+ types: types,
106
+ holmes_ids: holmes_ids,
107
+ user: user,
108
+ **resource
109
+ )
110
+ end
111
+
112
+ def self.resource
113
+ holmes_maker = StarkInfra::PixKeyHolmes.resource[:resource_maker]
114
+ {
115
+ resource_name: 'PixKeyHolmesLog',
116
+ resource_maker: proc { |json|
117
+ Log.new(
118
+ id: json['id'],
119
+ holmes: StarkCore::Utils::API.from_api_json(holmes_maker, json['holmes']),
120
+ errors: json['errors'],
121
+ type: json['type'],
122
+ created: json['created']
123
+ )
124
+ }
125
+ }
126
+ end
127
+ end
128
+ end
129
+ end
@@ -2,97 +2,91 @@
2
2
 
3
3
  require('starkcore')
4
4
  require_relative('../utils/rest')
5
- require_relative('../utils/parse')
6
5
 
7
6
  module StarkInfra
8
- # # IndividualDocument object
7
+ # # PixKeyHolmes object
9
8
  #
10
- # Individual documents are images containing either side of a document or a selfie
11
- # to be used in a matching validation. When created, they must be attached to an individual
12
- # identity to be used for its validation.
9
+ # A PixKeyHolmes investigates the registration status of a Pix Key in the
10
+ # Central Bank's DICT. You open one per key you want to check; the API
11
+ # resolves it asynchronously and reports back whether the key is registered.
13
12
  #
14
- # When you initialize a IndividualDocument, the entity will not be automatically
13
+ # When you initialize a PixKeyHolmes, the entity will not be automatically
15
14
  # created in the Stark Infra API. The 'create' function sends the objects
16
15
  # to the Stark Infra API and returns the list of created objects.
17
16
  #
18
17
  # ## Parameters (required):
19
- # - type [string]: type of the IndividualDocument. Options: "drivers-license-front", "drivers-license-back", "identity-front", "identity-back" or "selfie"
20
- # - content [string]: Base64 data url of the picture. ex: data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD...
21
- # - content_type [string]: content MIME type. This parameter is required as input only. ex: "image/png" or "image/jpeg"
22
- # - identity_id [string]: Unique id of IndividualIdentity. ex: "5656565656565656"
18
+ # - key_id [string]: Pix Key to be investigated. ex: "+5511989898989", "11.222.333/0001-00", "valid@sandbox.com"
23
19
  #
24
20
  # ## Parameters (optional):
25
- # - tags [list of strings, default nil]: list of strings for reference when searching for IndividualDocuments. ex: ["employees", "monthly"]
21
+ # - tags [list of strings, default nil]: list of strings for reference when searching for PixKeyHolmes. ex: ["travel", "food"]
26
22
  #
27
23
  # ## Attributes (return-only):
28
- # - id [string]: unique id returned when the IndividualDocument is created. ex: "5656565656565656"
29
- # - status [string]: current status of the IndividualDocument. Options: "created", "canceled", "processing", "failed", "success"
30
- # - created [DateTime]: creation datetime for the IndividualDocument. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
31
- class IndividualDocument < StarkCore::Utils::Resource
32
- attr_reader :type, :content, :content_type, :identity_id, :tags, :id, :status, :created
33
- def initialize(type:, content:, content_type:, identity_id:, tags: nil, id: nil, status: nil, created: nil)
24
+ # - id [string]: unique id returned when the PixKeyHolmes is created. ex: "5656565656565656"
25
+ # - result [string]: investigation result once the case is solved. ex: "registered", "unregistered"
26
+ # - status [string]: current status of the PixKeyHolmes. ex: "solving", "solved"
27
+ # - created [DateTime]: creation datetime for the PixKeyHolmes. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
28
+ # - updated [DateTime]: latest update datetime for the PixKeyHolmes. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
29
+ class PixKeyHolmes < StarkCore::Utils::Resource
30
+ attr_reader :key_id, :tags, :id, :result, :status, :updated, :created
31
+ def initialize(key_id:, tags: nil, id: nil, result: nil, status: nil, updated: nil, created: nil)
34
32
  super(id)
35
- @type = type
36
- @identity_id = identity_id
33
+ @key_id = key_id
37
34
  @tags = tags
35
+ @id = id
36
+ @result = result
38
37
  @status = status
39
38
  @created = StarkCore::Utils::Checks.check_datetime(created)
40
- @content = content
41
- @content_type = content_type
42
-
43
- if @content_type
44
- @content = "data:#{content_type};base64,#{Base64.encode64(content)}"
45
- @content_type = nil
46
- end
39
+ @updated = StarkCore::Utils::Checks.check_datetime(updated)
47
40
  end
48
41
 
49
- # # Create IndividualDocuments
42
+ # # Create PixKeyHolmes
50
43
  #
51
- # Send a list of IndividualDocument objects for creation at the Stark Infra API
44
+ # Send a list of PixKeyHolmes objects for creation at the Stark Infra API. You can create up to 100
45
+ # PixKeyHolmes in a single call.
52
46
  #
53
47
  # ## Parameters (required):
54
- # - documents [list of IndividualDocument objects]: list of IndividualDocument objects to be created in the API.
48
+ # - holmes [list of PixKeyHolmes objects]: list of PixKeyHolmes objects to be created in the API.
55
49
  #
56
50
  # ## Parameters (optional):
57
- # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
51
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
58
52
  #
59
53
  # ## Return:
60
- # - list of IndividualDocument object with updated attributes
61
- def self.create(documents, user: nil)
62
- StarkInfra::Utils::Rest.post(entities: documents, user: user, **resource)
54
+ # - list of PixKeyHolmes objects with updated attributes
55
+ def self.create(holmes, user: nil)
56
+ StarkInfra::Utils::Rest.post(entities: holmes, user: user, **resource)
63
57
  end
64
58
 
65
- # # Retrieve a specific IndividualDocument
59
+ # # Retrieve a specific PixKeyHolmes
66
60
  #
67
- # Receive a single IndividualDocument object previously created in the Stark Infra API by its id
61
+ # Receive a single PixKeyHolmes object previously created in the Stark Infra API by its id
68
62
  #
69
63
  # ## Parameters (required):
70
64
  # - id [string]: object unique id. ex: "5656565656565656"
71
65
  #
72
66
  # ## Parameters (optional):
73
- # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
67
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
74
68
  #
75
69
  # ## Return:
76
- # - IndividualDocument object with updated attributes
70
+ # - PixKeyHolmes object with updated attributes
77
71
  def self.get(id, user: nil)
78
72
  StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
79
73
  end
80
74
 
81
- # # Retrieve IndividualDocuments
75
+ # # Retrieve PixKeyHolmes
82
76
  #
83
- # Receive a generator of IndividualDocument objects previously created in the Stark Infra API
77
+ # Receive a generator of PixKeyHolmes objects previously created in the Stark Infra API
84
78
  #
85
79
  # ## Parameters (optional):
86
80
  # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
87
81
  # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
88
82
  # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
89
- # - status [list of strings, default nil]: filter for status of retrieved objects. Options: ["created", "canceled", "processing", "failed", "success"]
90
- # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
83
+ # - status [list of strings, default nil]: filter for status of retrieved objects. The live API accepts only "solved" or "solving" as filter values. ex: ["solved", "solving"]
84
+ # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ["travel", "food"]
91
85
  # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"]
92
86
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
93
87
  #
94
88
  # ## Return:
95
- # - generator of IndividualDocument objects with updated attributes
89
+ # - generator of PixKeyHolmes objects with updated attributes
96
90
  def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
97
91
  after = StarkCore::Utils::Checks.check_date(after)
98
92
  before = StarkCore::Utils::Checks.check_date(before)
@@ -108,9 +102,9 @@ module StarkInfra
108
102
  )
109
103
  end
110
104
 
111
- # # Retrieve paged IndividualDocuments
105
+ # # Retrieve PixKeyHolmes
112
106
  #
113
- # Receive a list of up to 100 IndividualDocument objects previously created in the Stark Infra API and the cursor to the next page.
107
+ # Receive a list of up to 100 PixKeyHolmes objects previously created in the Stark Infra API and the cursor to the next page.
114
108
  # Use this function instead of query if you want to manually page your requests.
115
109
  #
116
110
  # ## Parameters (optional):
@@ -118,14 +112,14 @@ module StarkInfra
118
112
  # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex 35
119
113
  # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
120
114
  # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
121
- # - status [list of strings, default nil]: filter for status of retrieved objects. Options: ["created", "canceled", "processing", "failed", "success"]
122
- # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
115
+ # - status [list of strings, default nil]: filter for status of retrieved objects. The live API accepts only "solved" or "solving" as filter values. ex: ["solved", "solving"]
116
+ # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ["travel", "food"]
123
117
  # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"]
124
118
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
125
119
  #
126
120
  # ## Return:
127
- # - list of IndividualDocument objects with updated attributes
128
- # - cursor to retrieve the next page of IndividualDocument objects
121
+ # - list of PixKeyHolmes objects with updated attributes
122
+ # - cursor to retrieve the next page of PixKeyHolmes objects
129
123
  def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
130
124
  after = StarkCore::Utils::Checks.check_date(after)
131
125
  before = StarkCore::Utils::Checks.check_date(before)
@@ -142,20 +136,18 @@ module StarkInfra
142
136
  )
143
137
  end
144
138
 
145
-
146
139
  def self.resource
147
140
  {
148
- resource_name: 'IndividualDocument',
141
+ resource_name: 'PixKeyHolmes',
149
142
  resource_maker: proc { |json|
150
- IndividualDocument.new(
151
- type: json['type'],
152
- content: json['content'],
153
- content_type: json['content_type'],
154
- identity_id: json['identity_id'],
143
+ PixKeyHolmes.new(
144
+ key_id: json['key_id'],
155
145
  tags: json['tags'],
156
146
  id: json['id'],
147
+ result: json['result'],
157
148
  status: json['status'],
158
- created: json['created']
149
+ created: json['created'],
150
+ updated: json['updated']
159
151
  )
160
152
  }
161
153
  }
@@ -0,0 +1,127 @@
1
+ # frozen_string_literal: true
2
+
3
+ require('starkcore')
4
+ require_relative('pix_pull_request')
5
+ require_relative('../utils/rest')
6
+
7
+ module StarkInfra
8
+ class PixPullRequest
9
+ # # PixPullRequest::Log object
10
+ #
11
+ # Every time a PixPullRequest entity is modified, a corresponding PixPullRequest::Log
12
+ # is generated for the entity. This log is never generated by the user.
13
+ #
14
+ # ## Attributes (return-only):
15
+ # - id [string]: unique id returned when the log is created. ex: '5656565656565656'
16
+ # - request [PixPullRequest]: PixPullRequest entity to which the log refers to.
17
+ # - type [string]: type of the PixPullRequest event which triggered the log creation. Options: 'created', 'sent', 'scheduled', 'denied', 'success', 'canceling', 'canceled', 'expired'
18
+ # - errors [list of strings]: list of errors linked to this PixPullRequest event. Empty list when the type is non-failing.
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, :request, :type, :errors, :created
22
+ def initialize(id:, request:, type:, errors:, created:)
23
+ super(id)
24
+ @request = request
25
+ @type = type
26
+ @errors = errors.nil? ? [] : errors
27
+ @created = StarkCore::Utils::Checks.check_datetime(created)
28
+ end
29
+
30
+ # # Retrieve a specific PixPullRequest::Log
31
+ #
32
+ # Receive a single PixPullRequest::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
+ # - PixPullRequest::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 PixPullRequest::Logs
47
+ #
48
+ # Receive a generator of PixPullRequest::Log objects previously created in the Stark Infra API
49
+ #
50
+ # ## Parameters (optional):
51
+ # - ids [list of strings, default nil]: Log ids to filter PixPullRequest Logs. ex: ['5656565656565656']
52
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
53
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
54
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
55
+ # - types [list of strings, default nil]: filter retrieved objects by types. Options: 'created', 'sent', 'scheduled', 'denied', 'success', 'canceling', 'canceled', 'expired'
56
+ # - request_ids [list of strings, default nil]: list of PixPullRequest ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
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 PixPullRequest::Log objects with updated attributes
61
+ def self.query(ids: nil, limit: nil, after: nil, before: nil, types: nil, request_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
+ request_ids: request_ids,
71
+ user: user,
72
+ **resource
73
+ )
74
+ end
75
+
76
+ # # Retrieve paged PixPullRequest::Logs
77
+ #
78
+ # Receive a list of up to 100 PixPullRequest::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
+ # - ids [list of strings, default nil]: Log ids to filter PixPullRequest Logs. ex: ['5656565656565656']
84
+ # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
85
+ # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
86
+ # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
87
+ # - types [list of strings, default nil]: filter retrieved objects by types. Options: 'created', 'sent', 'scheduled', 'denied', 'success', 'canceling', 'canceled', 'expired'
88
+ # - request_ids [list of strings, default nil]: list of PixPullRequest ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
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 PixPullRequest::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, request_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
+ request_ids: request_ids,
105
+ user: user,
106
+ **resource
107
+ )
108
+ end
109
+
110
+ def self.resource
111
+ request_maker = StarkInfra::PixPullRequest.resource[:resource_maker]
112
+ {
113
+ resource_name: 'PixPullRequestLog',
114
+ resource_maker: proc { |json|
115
+ Log.new(
116
+ id: json['id'],
117
+ request: StarkCore::Utils::API.from_api_json(request_maker, json['request']),
118
+ type: json['type'],
119
+ errors: json['errors'],
120
+ created: json['created']
121
+ )
122
+ }
123
+ }
124
+ end
125
+ end
126
+ end
127
+ end