starkinfra 0.5.0 → 0.6.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.
- checksums.yaml +4 -4
- data/lib/{brcodepreview/brcodepreview.rb → brcode_preview/brcode_preview.rb} +5 -2
- data/lib/brcode_preview/subscription.rb +102 -0
- data/lib/business_attachment/business_attachment.rb +186 -0
- data/lib/business_attachment/log.rb +127 -0
- data/lib/business_identity/business_identity.rb +225 -0
- data/lib/business_identity/log.rb +127 -0
- data/lib/{creditnote/creditnote.rb → credit_note/credit_note.rb} +11 -5
- data/lib/{creditnote → credit_note}/log.rb +1 -1
- data/lib/credit_note/rule.rb +46 -0
- data/lib/event/event.rb +10 -2
- data/lib/{individualdocument → individual_document}/log.rb +1 -1
- data/lib/{individualidentity → individual_identity}/log.rb +1 -1
- data/lib/{issuingbalance/issuingbalance.rb → issuing_balance/issuing_balance.rb} +8 -2
- data/lib/issuing_billing_invoice/issuing_billing_invoice.rb +155 -0
- data/lib/issuing_billing_transaction/issuing_billing_transaction.rb +142 -0
- data/lib/{issuingcard/issuingcard.rb → issuing_card/issuing_card.rb} +5 -2
- data/lib/{issuingcard → issuing_card}/log.rb +1 -1
- data/lib/{issuingembossingrequest → issuing_embossing_request}/log.rb +1 -1
- data/lib/{issuingholder → issuing_holder}/log.rb +1 -1
- data/lib/{issuinginvoice → issuing_invoice}/log.rb +1 -1
- data/lib/{issuingproduct/issuingproduct.rb → issuing_product/issuing_product.rb} +5 -2
- data/lib/{issuingpurchase/issuingpurchase.rb → issuing_purchase/issuing_purchase.rb} +18 -9
- data/lib/{issuingpurchase → issuing_purchase}/log.rb +1 -1
- data/lib/{issuingrestock → issuing_restock}/log.rb +1 -1
- data/lib/{issuingrule/issuingrule.rb → issuing_rule/issuing_rule.rb} +9 -3
- data/lib/{issuingstock/issuingstock.rb → issuing_stock/issuing_stock.rb} +5 -2
- data/lib/{issuingstock → issuing_stock}/log.rb +1 -1
- data/lib/issuing_stock_rule/issuing_stock_rule.rb +213 -0
- data/lib/issuing_token/issuing_token.rb +309 -0
- data/lib/issuing_token_design/issuing_token_design.rb +118 -0
- data/lib/issuing_token_request/issuing_token_request.rb +63 -0
- data/lib/{merchantcategory/merchantcategory.rb → merchant_category/merchant_category.rb} +6 -3
- data/lib/{pixchargeback → pix_chargeback}/log.rb +1 -1
- data/lib/{pixchargeback/pixchargeback.rb → pix_chargeback/pix_chargeback.rb} +26 -2
- data/lib/{pixclaim → pix_claim}/log.rb +1 -1
- data/lib/pix_dispute/log.rb +127 -0
- data/lib/pix_dispute/pix_dispute.rb +210 -0
- data/lib/pix_dispute/transaction.rb +91 -0
- data/lib/pix_fraud/log.rb +128 -0
- data/lib/pix_fraud/pix_fraud.rb +180 -0
- data/lib/{pixinfraction → pix_infraction}/log.rb +1 -1
- data/lib/{pixinfraction/pixinfraction.rb → pix_infraction/pix_infraction.rb} +18 -4
- data/lib/pix_internal_transaction_report/log.rb +129 -0
- data/lib/pix_internal_transaction_report/pix_internal_transaction_report.rb +200 -0
- data/lib/{pixkey → pix_key}/log.rb +1 -1
- data/lib/pix_key_holmes/pix_key_holmes.rb +139 -0
- data/lib/pix_pull_request/log.rb +127 -0
- data/lib/pix_pull_request/pix_pull_request.rb +265 -0
- data/lib/pix_pull_subscription/log.rb +127 -0
- data/lib/pix_pull_subscription/pix_pull_subscription.rb +281 -0
- data/lib/{pixrequest → pix_request}/log.rb +1 -1
- data/lib/{pixrequest/pixrequest.rb → pix_request/pix_request.rb} +9 -2
- data/lib/{pixreversal → pix_reversal}/log.rb +1 -1
- data/lib/starkinfra.rb +83 -59
- data/lib/utils/parse.rb +2 -2
- data/lib/utils/return_id.rb +24 -0
- data/lib/webhook/webhook.rb +2 -2
- metadata +87 -67
- /data/lib/{cardmethod/cardmethod.rb → card_method/card_method.rb} +0 -0
- /data/lib/{creditholmes/creditholmes.rb → credit_holmes/credit_holmes.rb} +0 -0
- /data/lib/{creditnote → credit_note}/invoice/description.rb +0 -0
- /data/lib/{creditnote → credit_note}/invoice/discount.rb +0 -0
- /data/lib/{creditnote → credit_note}/invoice/invoice.rb +0 -0
- /data/lib/{creditnote → credit_note}/transfer.rb +0 -0
- /data/lib/{creditpreview/creditnotepreview.rb → credit_preview/credit_note_preview.rb} +0 -0
- /data/lib/{creditpreview/creditpreview.rb → credit_preview/credit_preview.rb} +0 -0
- /data/lib/{creditsigner/creditsigner.rb → credit_signer/credit_signer.rb} +0 -0
- /data/lib/{dynamicbrcode/dynamicbrcode.rb → dynamic_brcode/dynamic_brcode.rb} +0 -0
- /data/lib/{individualdocument/individualdocument.rb → individual_document/individual_document.rb} +0 -0
- /data/lib/{individualidentity/individualidentity.rb → individual_identity/individual_identity.rb} +0 -0
- /data/lib/{issuingdesign/issuingdesign.rb → issuing_design/issuing_design.rb} +0 -0
- /data/lib/{issuingembossingkit/issuingembossingkit.rb → issuing_embossing_kit/issuing_embossing_kit.rb} +0 -0
- /data/lib/{issuingembossingrequest/issuingembossingrequest.rb → issuing_embossing_request/issuing_embossing_request.rb} +0 -0
- /data/lib/{issuingholder/issuingholder.rb → issuing_holder/issuing_holder.rb} +0 -0
- /data/lib/{issuinginvoice/issuinginvoice.rb → issuing_invoice/issuing_invoice.rb} +0 -0
- /data/lib/{issuingrestock/issuingrestock.rb → issuing_restock/issuing_restock.rb} +0 -0
- /data/lib/{issuingtransaction/issuingtransaction.rb → issuing_transaction/issuing_transaction.rb} +0 -0
- /data/lib/{issuingwithdrawal/issuingwithdrawal.rb → issuing_withdrawal/issuing_withdrawal.rb} +0 -0
- /data/lib/{merchantcountry/merchantcountry.rb → merchant_country/merchant_country.rb} +0 -0
- /data/lib/{pixbalance/pixbalance.rb → pix_balance/pix_balance.rb} +0 -0
- /data/lib/{pixclaim/pixclaim.rb → pix_claim/pix_claim.rb} +0 -0
- /data/lib/{pixdirector/pixdirector.rb → pix_director/pix_director.rb} +0 -0
- /data/lib/{pixdomain → pix_domain}/certificate.rb +0 -0
- /data/lib/{pixdomain/pixdomain.rb → pix_domain/pix_domain.rb} +0 -0
- /data/lib/{pixkey/pixkey.rb → pix_key/pix_key.rb} +0 -0
- /data/lib/{pixreversal/pixreversal.rb → pix_reversal/pix_reversal.rb} +0 -0
- /data/lib/{pixstatement/pixstatement.rb → pix_statement/pix_statement.rb} +0 -0
- /data/lib/{staticbrcode/staticbrcode.rb → static_brcode/static_brcode.rb} +0 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require('starkcore')
|
|
4
|
+
require_relative('../utils/rest')
|
|
5
|
+
require_relative('../utils/parse')
|
|
6
|
+
|
|
7
|
+
module StarkInfra
|
|
8
|
+
# # BusinessIdentity object
|
|
9
|
+
#
|
|
10
|
+
# A BusinessIdentity represents a company to be validated. It can have several business attachments
|
|
11
|
+
# attached to it, which are used to validate the identity of the company. Once a business identity is created,
|
|
12
|
+
# business attachments must be attached to it using the created method of the business attachment resource. When all
|
|
13
|
+
# the required business attachments are attached to a business identity it can be sent to validation by patching its
|
|
14
|
+
# status to processing.
|
|
15
|
+
#
|
|
16
|
+
# When you initialize a BusinessIdentity, the entity will not be automatically
|
|
17
|
+
# created in the Stark Infra API. The 'create' function sends the objects
|
|
18
|
+
# to the Stark Infra API and returns the list of created objects.
|
|
19
|
+
#
|
|
20
|
+
# ## Parameters (required):
|
|
21
|
+
# - tax_id [string]: company's tax ID (CNPJ). ex: "20.018.183/0001-80"
|
|
22
|
+
#
|
|
23
|
+
# ## Parameters (optional):
|
|
24
|
+
# - tags [list of strings, default nil]: list of strings for reference when searching for BusinessIdentities. ex: ["employees", "monthly"]
|
|
25
|
+
#
|
|
26
|
+
# ## Attributes (return-only):
|
|
27
|
+
# - id [string]: unique id returned when the BusinessIdentity is created. ex: "5656565656565656"
|
|
28
|
+
# - name [string]: company's full name. ex: "Stark Bank S.A."
|
|
29
|
+
# - tax_id_status [string]: current status of the tax ID. ex: "active"
|
|
30
|
+
# - insight_tax_id [string]: tax ID returned by the validation insight. ex: "20018183000180"
|
|
31
|
+
# - insight_document_type [string]: document type returned by the validation insight. ex: "cnpj"
|
|
32
|
+
# - num_pages [integer]: number of pages of the attached documents. ex: 3
|
|
33
|
+
# - representatives [string]: JSON string with the company's representatives.
|
|
34
|
+
# - attachments [list of strings]: list of BusinessAttachment ids attached to the BusinessIdentity. ex: ["5656565656565656", "4545454545454545"]
|
|
35
|
+
# - rules [string]: JSON string with the validation rules.
|
|
36
|
+
# - status [string]: current status of the BusinessIdentity. Options: "created", "pending", "canceled", "processing", "success", "failed"
|
|
37
|
+
# - created [DateTime]: creation datetime for the BusinessIdentity. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
|
38
|
+
# - updated [DateTime]: latest update datetime for the BusinessIdentity. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
|
39
|
+
class BusinessIdentity < StarkCore::Utils::Resource
|
|
40
|
+
attr_reader :tax_id, :tags, :id, :name, :tax_id_status, :insight_tax_id, :insight_document_type, :num_pages,
|
|
41
|
+
:representatives, :attachments, :rules, :status, :created, :updated
|
|
42
|
+
def initialize(tax_id:, tags: nil, id: nil, name: nil, tax_id_status: nil, insight_tax_id: nil,
|
|
43
|
+
insight_document_type: nil, num_pages: nil, representatives: nil, attachments: nil, rules: nil,
|
|
44
|
+
status: nil, created: nil, updated: nil)
|
|
45
|
+
super(id)
|
|
46
|
+
@tax_id = tax_id
|
|
47
|
+
@tags = tags
|
|
48
|
+
@name = name
|
|
49
|
+
@tax_id_status = tax_id_status
|
|
50
|
+
@insight_tax_id = insight_tax_id
|
|
51
|
+
@insight_document_type = insight_document_type
|
|
52
|
+
@num_pages = num_pages
|
|
53
|
+
@representatives = representatives
|
|
54
|
+
@attachments = attachments
|
|
55
|
+
@rules = rules
|
|
56
|
+
@status = status
|
|
57
|
+
@created = StarkCore::Utils::Checks.check_datetime(created)
|
|
58
|
+
@updated = StarkCore::Utils::Checks.check_datetime(updated)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# # Create BusinessIdentities
|
|
62
|
+
#
|
|
63
|
+
# Send a list of BusinessIdentity objects for creation at the Stark Infra API
|
|
64
|
+
#
|
|
65
|
+
# ## Parameters (required):
|
|
66
|
+
# - identities [list of BusinessIdentity objects]: list of BusinessIdentity objects to be created in the API.
|
|
67
|
+
#
|
|
68
|
+
# ## Parameters (optional):
|
|
69
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
|
|
70
|
+
#
|
|
71
|
+
# ## Return:
|
|
72
|
+
# - list of BusinessIdentity objects with updated attributes
|
|
73
|
+
def self.create(identities, user: nil)
|
|
74
|
+
StarkInfra::Utils::Rest.post(entities: identities, user: user, **resource)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# # Retrieve a specific BusinessIdentity
|
|
78
|
+
#
|
|
79
|
+
# Receive a single BusinessIdentity object previously created in the Stark Infra API by its id
|
|
80
|
+
#
|
|
81
|
+
# ## Parameters (required):
|
|
82
|
+
# - id [string]: object unique id. ex: "5656565656565656"
|
|
83
|
+
#
|
|
84
|
+
# ## Parameters (optional):
|
|
85
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
|
|
86
|
+
#
|
|
87
|
+
# ## Return:
|
|
88
|
+
# - BusinessIdentity object with updated attributes
|
|
89
|
+
def self.get(uuid, user: nil)
|
|
90
|
+
StarkInfra::Utils::Rest.get_id(id: uuid, user: user, **resource)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# # Retrieve BusinessIdentities
|
|
94
|
+
#
|
|
95
|
+
# Receive a generator of BusinessIdentity objects previously created in the Stark Infra API
|
|
96
|
+
#
|
|
97
|
+
# ## Parameters (optional):
|
|
98
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
|
99
|
+
# - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
|
100
|
+
# - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
|
101
|
+
# - status [list of strings, default nil]: filter for status of retrieved objects. ex: ["created", "pending", "canceled", "processing", "success", "failed"]
|
|
102
|
+
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
|
103
|
+
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"]
|
|
104
|
+
# - tax_ids [list of strings, default nil]: list of tax ids to filter retrieved objects. ex: ["20.018.183/0001-80"]
|
|
105
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
106
|
+
#
|
|
107
|
+
# ## Return:
|
|
108
|
+
# - generator of BusinessIdentity objects with updated attributes
|
|
109
|
+
def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, tax_ids: nil, user: nil)
|
|
110
|
+
after = StarkCore::Utils::Checks.check_date(after)
|
|
111
|
+
before = StarkCore::Utils::Checks.check_date(before)
|
|
112
|
+
StarkInfra::Utils::Rest.get_stream(
|
|
113
|
+
limit: limit,
|
|
114
|
+
after: after,
|
|
115
|
+
before: before,
|
|
116
|
+
status: status,
|
|
117
|
+
tags: tags,
|
|
118
|
+
ids: ids,
|
|
119
|
+
tax_ids: tax_ids,
|
|
120
|
+
user: user,
|
|
121
|
+
**resource
|
|
122
|
+
)
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# # Retrieve paged BusinessIdentities
|
|
126
|
+
#
|
|
127
|
+
# Receive a list of up to 100 BusinessIdentity objects previously created in the Stark Infra API and the cursor to the next page.
|
|
128
|
+
# Use this function instead of query if you want to manually page your requests.
|
|
129
|
+
#
|
|
130
|
+
# ## Parameters (optional):
|
|
131
|
+
# - cursor [string, default nil]: cursor returned on the previous page function call
|
|
132
|
+
# - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex 35
|
|
133
|
+
# - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
|
134
|
+
# - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
|
135
|
+
# - status [list of strings, default nil]: filter for status of retrieved objects. ex: ["created", "pending", "canceled", "processing", "success", "failed"]
|
|
136
|
+
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
|
137
|
+
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"]
|
|
138
|
+
# - tax_ids [list of strings, default nil]: list of tax ids to filter retrieved objects. ex: ["20.018.183/0001-80"]
|
|
139
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
140
|
+
#
|
|
141
|
+
# ## Return:
|
|
142
|
+
# - list of BusinessIdentity objects with updated attributes
|
|
143
|
+
# - cursor to retrieve the next page of BusinessIdentity objects
|
|
144
|
+
def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, tax_ids: nil, user: nil)
|
|
145
|
+
after = StarkCore::Utils::Checks.check_date(after)
|
|
146
|
+
before = StarkCore::Utils::Checks.check_date(before)
|
|
147
|
+
StarkInfra::Utils::Rest.get_page(
|
|
148
|
+
cursor: cursor,
|
|
149
|
+
limit: limit,
|
|
150
|
+
after: after,
|
|
151
|
+
before: before,
|
|
152
|
+
status: status,
|
|
153
|
+
tags: tags,
|
|
154
|
+
ids: ids,
|
|
155
|
+
tax_ids: tax_ids,
|
|
156
|
+
user: user,
|
|
157
|
+
**resource
|
|
158
|
+
)
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
# # Update BusinessIdentity entity
|
|
162
|
+
#
|
|
163
|
+
# Update a BusinessIdentity by passing id.
|
|
164
|
+
#
|
|
165
|
+
# ## Parameters (required):
|
|
166
|
+
# - id [string]: BusinessIdentity unique id. ex: '5656565656565656'
|
|
167
|
+
#
|
|
168
|
+
# ## Parameters (optional):
|
|
169
|
+
# - status [string, default nil]: You may send BusinessAttachments to validation by passing 'processing' in the status
|
|
170
|
+
# - tags [list of strings, default nil]: list of strings for reference when searching for BusinessIdentities. ex: ["employees", "monthly"]
|
|
171
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
|
|
172
|
+
#
|
|
173
|
+
# ## Return:
|
|
174
|
+
# - target BusinessIdentity with updated attributes
|
|
175
|
+
def self.update(id, status: nil, tags: nil, user: nil)
|
|
176
|
+
StarkInfra::Utils::Rest.patch_id(
|
|
177
|
+
id: id,
|
|
178
|
+
status: status,
|
|
179
|
+
tags: tags,
|
|
180
|
+
user: user,
|
|
181
|
+
**resource
|
|
182
|
+
)
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
# # Cancel a BusinessIdentity entity
|
|
186
|
+
#
|
|
187
|
+
# Cancel a BusinessIdentity entity previously created in the Stark Infra API
|
|
188
|
+
#
|
|
189
|
+
# ## Parameters (required):
|
|
190
|
+
# - id [string]: BusinessIdentity unique id. ex: '5656565656565656'
|
|
191
|
+
#
|
|
192
|
+
# ## Parameters (optional):
|
|
193
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
194
|
+
#
|
|
195
|
+
# ## Return:
|
|
196
|
+
# - canceled BusinessIdentity object
|
|
197
|
+
def self.cancel(id, user: nil)
|
|
198
|
+
StarkInfra::Utils::Rest.delete_id(id: id, user: user, **resource)
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
def self.resource
|
|
202
|
+
{
|
|
203
|
+
resource_name: 'BusinessIdentity',
|
|
204
|
+
resource_maker: proc { |json|
|
|
205
|
+
BusinessIdentity.new(
|
|
206
|
+
tax_id: json['tax_id'],
|
|
207
|
+
tags: json['tags'],
|
|
208
|
+
id: json['id'],
|
|
209
|
+
name: json['name'],
|
|
210
|
+
tax_id_status: json['tax_id_status'],
|
|
211
|
+
insight_tax_id: json['insight_tax_id'],
|
|
212
|
+
insight_document_type: json['insight_document_type'],
|
|
213
|
+
num_pages: json['num_pages'],
|
|
214
|
+
representatives: json['representatives'],
|
|
215
|
+
attachments: json['attachments'],
|
|
216
|
+
rules: json['rules'],
|
|
217
|
+
status: json['status'],
|
|
218
|
+
created: json['created'],
|
|
219
|
+
updated: json['updated']
|
|
220
|
+
)
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
end
|
|
224
|
+
end
|
|
225
|
+
end
|
|
@@ -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
|
|
@@ -4,7 +4,7 @@ require_relative('../utils/rest')
|
|
|
4
4
|
require_relative('invoice/invoice')
|
|
5
5
|
require_relative('invoice/discount')
|
|
6
6
|
require_relative('invoice/description')
|
|
7
|
-
require_relative('../
|
|
7
|
+
require_relative('../credit_note/transfer')
|
|
8
8
|
|
|
9
9
|
require('starkcore')
|
|
10
10
|
|
|
@@ -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 CreditNote::Rule objects for modifying transfer behavior. ex: [CreditNote::Rule(key='invoiceCreationMode', value='scheduled')]
|
|
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,
|
|
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
|
|
|
@@ -261,6 +265,7 @@ module StarkInfra
|
|
|
261
265
|
rebate_amount: json['rebate_amount'],
|
|
262
266
|
tags: json['tags'],
|
|
263
267
|
expiration: json['expiration'],
|
|
268
|
+
rules: json['rules'],
|
|
264
269
|
document_id: json['document_id'],
|
|
265
270
|
status: json['status'],
|
|
266
271
|
transaction_ids: json['transaction_ids'],
|
|
@@ -268,6 +273,7 @@ module StarkInfra
|
|
|
268
273
|
tax_amount: json['tax_amount'],
|
|
269
274
|
nominal_interest: json['nominal_interest'],
|
|
270
275
|
interest: json['interest'],
|
|
276
|
+
debtor_workspace_id: json['debtor_workspace_id'],
|
|
271
277
|
created: json['created'],
|
|
272
278
|
updated: json['updated']
|
|
273
279
|
)
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
def self.parse_rules(rules)
|
|
20
|
+
resource_maker = StarkInfra::CreditNote::Rule.resource[:resource_maker]
|
|
21
|
+
return rules if rules.nil?
|
|
22
|
+
|
|
23
|
+
parsed_rules = []
|
|
24
|
+
rules.each do |rule|
|
|
25
|
+
unless rule.is_a? Rule
|
|
26
|
+
rule = StarkCore::Utils::API.from_api_json(resource_maker, rule)
|
|
27
|
+
end
|
|
28
|
+
parsed_rules << rule
|
|
29
|
+
end
|
|
30
|
+
return parsed_rules
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def self.resource
|
|
34
|
+
{
|
|
35
|
+
resource_name: 'Rule',
|
|
36
|
+
resource_maker: proc { |json|
|
|
37
|
+
Rule.new(
|
|
38
|
+
key: json['key'],
|
|
39
|
+
value: json['value']
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
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('../
|
|
9
|
-
require_relative('../
|
|
8
|
+
require_relative('../pix_pull_request/log')
|
|
9
|
+
require_relative('../pix_pull_subscription/log')
|
|
10
|
+
require_relative('../pix_request/log')
|
|
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
|
|
@@ -13,13 +13,17 @@ module StarkInfra
|
|
|
13
13
|
# ## Attributes (return-only):
|
|
14
14
|
# - id [string]: unique id returned when IssuingBalance is created. ex: '5656565656565656'
|
|
15
15
|
# - amount [integer]: current issuing balance amount of the Workspace in cents. ex: 200 (= R$ 2.00)
|
|
16
|
+
# - limit [integer]: Spending limit of the balance
|
|
17
|
+
# - max_limit [integer]: Maximum spending limit. This field is currently always equal to limit
|
|
16
18
|
# - currency [string]: currency of the current Workspace. Expect others to be added eventually. ex: 'BRL'
|
|
17
19
|
# - updated [DateTime]: latest update datetime for the IssuingBalance. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
|
18
20
|
class IssuingBalance < StarkCore::Utils::Resource
|
|
19
|
-
attr_reader :amount, :currency, :updated, :id
|
|
20
|
-
def initialize(amount: nil, currency: nil, updated: nil, id: nil)
|
|
21
|
+
attr_reader :amount, :limit, :max_limit, :currency, :updated, :id
|
|
22
|
+
def initialize(amount: nil, limit: nil, max_limit: nil, currency: nil, updated: nil, id: nil)
|
|
21
23
|
super(id)
|
|
22
24
|
@amount = amount
|
|
25
|
+
@limit = limit
|
|
26
|
+
@max_limit = max_limit
|
|
23
27
|
@currency = currency
|
|
24
28
|
@updated = updated
|
|
25
29
|
end
|
|
@@ -44,6 +48,8 @@ module StarkInfra
|
|
|
44
48
|
IssuingBalance.new(
|
|
45
49
|
id: json['id'],
|
|
46
50
|
amount: json['amount'],
|
|
51
|
+
limit: json['limit'],
|
|
52
|
+
max_limit: json['max_limit'],
|
|
47
53
|
currency: json['currency'],
|
|
48
54
|
updated: json['updated']
|
|
49
55
|
)
|