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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 61eb746142fdcedb5bb2668292aaee6995c898114b0abea9a545e49593a005ac
|
|
4
|
+
data.tar.gz: '04082c73ccc17fd54b98b81d3ff05672c05a9d674fc5585745167eafcbda2153'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d61b4d1ab3e1569d5dd4ab63f18c94fe7f566cdb1486f4601d64e87be2f848026b1bcf7573592cefed3e73bc786fd11da776e0a860618f86b25456e4aaac8939
|
|
7
|
+
data.tar.gz: b57a0caaeb2a8c7c26330f18bca61a8e073186ffff1f83d95888c704bcc57919d76aa1a4a6c29d02a87c462a3e5bf41151802d52a5da80ee12584d449974c4ca
|
|
@@ -34,16 +34,17 @@ module StarkInfra
|
|
|
34
34
|
# - reduction_amount [integer]: Reduction value to discount from nominal_amount. ex: 1000
|
|
35
35
|
# - scheduled [DateTime]: date of payment execution. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0).
|
|
36
36
|
# - status [string]: Payment status. ex: 'active', 'paid', 'canceled' or 'unknown'
|
|
37
|
+
# - subscription [BrcodePreview::Subscription, default nil]: snapshot of the recurring-debit subscription attached to the BR Code, when present. Nil for one-shot BR Codes.
|
|
37
38
|
# - tax_id [string]: Payment receiver tax ID. ex: '012.345.678-90'
|
|
38
39
|
class BrcodePreview < StarkCore::Utils::Resource
|
|
39
40
|
attr_reader :id, :payer_id, :end_to_end_id, :account_number, :account_type, :amount, :amount_type, :bank_code, :branch_code, :cash_amount,
|
|
40
41
|
:cashier_bank_code, :cashier_type, :discount_amount, :fine_amount, :key_id, :interest_amount, :name,
|
|
41
|
-
:nominal_amount, :reconciliation_id, :reduction_amount, :scheduled, :status, :tax_id
|
|
42
|
+
:nominal_amount, :reconciliation_id, :reduction_amount, :scheduled, :status, :subscription, :tax_id
|
|
42
43
|
def initialize(
|
|
43
44
|
id:, payer_id:, end_to_end_id: nil, account_number: nil, account_type: nil, amount: nil, amount_type: nil, bank_code: nil,
|
|
44
45
|
branch_code: nil, cash_amount: nil, cashier_bank_code:nil, cashier_type:nil, discount_amount: nil,
|
|
45
46
|
fine_amount: nil, key_id: nil, interest_amount: nil, name: nil, nominal_amount: nil,
|
|
46
|
-
reconciliation_id: nil, reduction_amount: nil, scheduled: nil, status: nil, tax_id: nil
|
|
47
|
+
reconciliation_id: nil, reduction_amount: nil, scheduled: nil, status: nil, subscription: nil, tax_id: nil
|
|
47
48
|
)
|
|
48
49
|
super(id)
|
|
49
50
|
@payer_id = payer_id
|
|
@@ -67,6 +68,7 @@ module StarkInfra
|
|
|
67
68
|
@reduction_amount = reduction_amount
|
|
68
69
|
@scheduled = scheduled
|
|
69
70
|
@status = status
|
|
71
|
+
@subscription = subscription
|
|
70
72
|
@tax_id = tax_id
|
|
71
73
|
end
|
|
72
74
|
|
|
@@ -113,6 +115,7 @@ module StarkInfra
|
|
|
113
115
|
reduction_amount: json['reduction_amount'],
|
|
114
116
|
scheduled: json['scheduled'],
|
|
115
117
|
status: json['status'],
|
|
118
|
+
subscription: BrcodePreview::Subscription.parse_subscription(json['subscription']),
|
|
116
119
|
tax_id: json['tax_id']
|
|
117
120
|
)
|
|
118
121
|
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require('starkcore')
|
|
4
|
+
require_relative('brcode_preview')
|
|
5
|
+
require_relative('../utils/rest')
|
|
6
|
+
|
|
7
|
+
module StarkInfra
|
|
8
|
+
class BrcodePreview
|
|
9
|
+
# # BrcodePreview::Subscription object
|
|
10
|
+
#
|
|
11
|
+
# A read-only snapshot of a Pix recurring-debit subscription, embedded inside a
|
|
12
|
+
# BrcodePreview response when the previewed BR Code carries subscription metadata.
|
|
13
|
+
# This sub-resource has no endpoints and is constructed only when deserializing a
|
|
14
|
+
# BrcodePreview returned by the API.
|
|
15
|
+
#
|
|
16
|
+
# ## Attributes (return-only):
|
|
17
|
+
# - amount [integer]: amount in cents charged per cycle. nil for variable-amount subscriptions. ex: 1000 (= R$ 10.00)
|
|
18
|
+
# - amount_min_limit [integer]: floor value for the maximum amount the sender can set when approving a variable-amount subscription. nil for fixed-amount subscriptions. ex: 500 (= R$ 5.00)
|
|
19
|
+
# - bacen_id [string]: Central Bank's unique recurrency id for the subscription.
|
|
20
|
+
# - created [DateTime]: creation datetime of the subscription. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
|
21
|
+
# - description [string]: additional information delivered to the sender.
|
|
22
|
+
# - installment_end [DateTime]: end datetime of settlements allowed for this subscription. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
|
23
|
+
# - installment_start [DateTime]: start datetime of settlements allowed for this subscription. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
|
24
|
+
# - interval [string]: cycle definition exposed verbatim from the server. ex: 'monthly'
|
|
25
|
+
# - pull_retry_limit [integer]: max number of retries the receiver may issue for a single failed pull cycle.
|
|
26
|
+
# - receiver_bank_code [string]: receiver's bank institution code.
|
|
27
|
+
# - receiver_name [string]: receiver's full name.
|
|
28
|
+
# - receiver_tax_id [string]: receiver's tax id (CPF or CNPJ).
|
|
29
|
+
# - reference_code [string]: commercial-relation identifier (contract number, order id, or client code).
|
|
30
|
+
# - sender_final_name [string]: final sender name when the sender differs from the originating institution.
|
|
31
|
+
# - sender_final_tax_id [string]: final sender tax id when distinct from the originating sender.
|
|
32
|
+
# - status [string]: current lifecycle state of the subscription snapshot, verbatim from the server. ex: 'created', 'pending', 'failed', 'denied', 'approved', 'active', 'expired', 'canceled'
|
|
33
|
+
# - type [string]: subscription journey type, verbatim from the server. ex: 'push', 'qrcode', 'qrcodeAndPayment', 'paymentAndOrQrcode'
|
|
34
|
+
# - updated [DateTime]: latest update datetime of the subscription. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
|
35
|
+
class Subscription < StarkCore::Utils::SubResource
|
|
36
|
+
attr_reader :amount, :amount_min_limit, :bacen_id, :created, :description, :installment_end,
|
|
37
|
+
:installment_start, :interval, :pull_retry_limit, :receiver_bank_code, :receiver_name,
|
|
38
|
+
:receiver_tax_id, :reference_code, :sender_final_name, :sender_final_tax_id, :status,
|
|
39
|
+
:type, :updated
|
|
40
|
+
def initialize(
|
|
41
|
+
amount: nil, amount_min_limit: nil, bacen_id: nil, created: nil, description: nil,
|
|
42
|
+
installment_end: nil, installment_start: nil, interval: nil, pull_retry_limit: nil,
|
|
43
|
+
receiver_bank_code: nil, receiver_name: nil, receiver_tax_id: nil, reference_code: nil,
|
|
44
|
+
sender_final_name: nil, sender_final_tax_id: nil, status: nil, type: nil, updated: nil
|
|
45
|
+
)
|
|
46
|
+
@amount = amount
|
|
47
|
+
@amount_min_limit = amount_min_limit
|
|
48
|
+
@bacen_id = bacen_id
|
|
49
|
+
@created = StarkCore::Utils::Checks.check_datetime(created)
|
|
50
|
+
@description = description
|
|
51
|
+
@installment_end = StarkCore::Utils::Checks.check_datetime(installment_end == '' ? nil : installment_end)
|
|
52
|
+
@installment_start = StarkCore::Utils::Checks.check_datetime(installment_start == '' ? nil : installment_start)
|
|
53
|
+
@interval = interval
|
|
54
|
+
@pull_retry_limit = pull_retry_limit
|
|
55
|
+
@receiver_bank_code = receiver_bank_code
|
|
56
|
+
@receiver_name = receiver_name
|
|
57
|
+
@receiver_tax_id = receiver_tax_id
|
|
58
|
+
@reference_code = reference_code
|
|
59
|
+
@sender_final_name = sender_final_name
|
|
60
|
+
@sender_final_tax_id = sender_final_tax_id
|
|
61
|
+
@status = status
|
|
62
|
+
@type = type
|
|
63
|
+
@updated = StarkCore::Utils::Checks.check_datetime(updated)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def self.parse_subscription(json)
|
|
67
|
+
return nil if json.nil? || (json.respond_to?(:empty?) && json.empty?)
|
|
68
|
+
|
|
69
|
+
subscription_maker = Subscription.resource[:resource_maker]
|
|
70
|
+
StarkCore::Utils::API.from_api_json(subscription_maker, json)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def self.resource
|
|
74
|
+
{
|
|
75
|
+
resource_name: 'Subscription',
|
|
76
|
+
resource_maker: proc { |json|
|
|
77
|
+
Subscription.new(
|
|
78
|
+
amount: json['amount'],
|
|
79
|
+
amount_min_limit: json['amount_min_limit'],
|
|
80
|
+
bacen_id: json['bacen_id'],
|
|
81
|
+
created: json['created'],
|
|
82
|
+
description: json['description'],
|
|
83
|
+
installment_end: json['installment_end'],
|
|
84
|
+
installment_start: json['installment_start'],
|
|
85
|
+
interval: json['interval'],
|
|
86
|
+
pull_retry_limit: json['pull_retry_limit'],
|
|
87
|
+
receiver_bank_code: json['receiver_bank_code'],
|
|
88
|
+
receiver_name: json['receiver_name'],
|
|
89
|
+
receiver_tax_id: json['receiver_tax_id'],
|
|
90
|
+
reference_code: json['reference_code'],
|
|
91
|
+
sender_final_name: json['sender_final_name'],
|
|
92
|
+
sender_final_tax_id: json['sender_final_tax_id'],
|
|
93
|
+
status: json['status'],
|
|
94
|
+
type: json['type'],
|
|
95
|
+
updated: json['updated']
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require('starkcore')
|
|
4
|
+
require_relative('../utils/rest')
|
|
5
|
+
require_relative('../utils/parse')
|
|
6
|
+
|
|
7
|
+
module StarkInfra
|
|
8
|
+
# # BusinessAttachment object
|
|
9
|
+
#
|
|
10
|
+
# Business attachments are files containing documents of a company that must be attached to a business
|
|
11
|
+
# identity to be used for its validation.
|
|
12
|
+
#
|
|
13
|
+
# When you initialize a BusinessAttachment, the entity will not be automatically
|
|
14
|
+
# created in the Stark Infra API. The 'create' function sends the objects
|
|
15
|
+
# to the Stark Infra API and returns the list of created objects.
|
|
16
|
+
#
|
|
17
|
+
# ## Parameters (required):
|
|
18
|
+
# - name [string]: name of the BusinessAttachment. ex: "articles-of-incorporation.pdf"
|
|
19
|
+
# - content [string]: Base64 data url of the file or its raw bytes. ex: data:application/pdf;base64,JVBERi0xLjQ...
|
|
20
|
+
# - business_identity_id [string]: Unique id of BusinessIdentity. ex: "5656565656565656"
|
|
21
|
+
#
|
|
22
|
+
# ## Parameters (optional):
|
|
23
|
+
# - content_type [string, default nil]: content MIME type. This parameter is required as input only. ex: "image/png" or "application/pdf"
|
|
24
|
+
# - tags [list of strings, default nil]: list of strings for reference when searching for BusinessAttachments. ex: ["employees", "monthly"]
|
|
25
|
+
#
|
|
26
|
+
# ## Attributes (return-only):
|
|
27
|
+
# - id [string]: unique id returned when the BusinessAttachment is created. ex: "5656565656565656"
|
|
28
|
+
# - attachment_id [string]: Unique id of the attached file. ex: "5656565656565656"
|
|
29
|
+
# - status [string]: current status of the BusinessAttachment. Options: "created", "canceled", "approved", "denied"
|
|
30
|
+
# - created [DateTime]: creation datetime for the BusinessAttachment. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
|
31
|
+
# - updated [DateTime]: latest update datetime for the BusinessAttachment. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
|
32
|
+
class BusinessAttachment < StarkCore::Utils::Resource
|
|
33
|
+
attr_reader :name, :content, :content_type, :business_identity_id, :tags, :id, :attachment_id, :status, :created, :updated
|
|
34
|
+
def initialize(name:, content:, business_identity_id:, content_type: nil, tags: nil, id: nil, attachment_id: nil,
|
|
35
|
+
status: nil, created: nil, updated: nil)
|
|
36
|
+
super(id)
|
|
37
|
+
@name = name
|
|
38
|
+
@business_identity_id = business_identity_id
|
|
39
|
+
@tags = tags
|
|
40
|
+
@attachment_id = attachment_id
|
|
41
|
+
@status = status
|
|
42
|
+
@created = StarkCore::Utils::Checks.check_datetime(created)
|
|
43
|
+
@updated = StarkCore::Utils::Checks.check_datetime(updated)
|
|
44
|
+
@content = content
|
|
45
|
+
@content_type = content_type
|
|
46
|
+
|
|
47
|
+
if @content_type
|
|
48
|
+
@content = "data:#{content_type};base64,#{Base64.encode64(content)}"
|
|
49
|
+
@content_type = nil
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# # Create BusinessAttachments
|
|
54
|
+
#
|
|
55
|
+
# Send a list of BusinessAttachment objects for creation at the Stark Infra API
|
|
56
|
+
#
|
|
57
|
+
# ## Parameters (required):
|
|
58
|
+
# - attachments [list of BusinessAttachment objects]: list of BusinessAttachment objects to be created in the API.
|
|
59
|
+
#
|
|
60
|
+
# ## Parameters (optional):
|
|
61
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
|
|
62
|
+
#
|
|
63
|
+
# ## Return:
|
|
64
|
+
# - list of BusinessAttachment objects with updated attributes
|
|
65
|
+
def self.create(attachments, user: nil)
|
|
66
|
+
StarkInfra::Utils::Rest.post(entities: attachments, user: user, **resource)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# # Retrieve a specific BusinessAttachment
|
|
70
|
+
#
|
|
71
|
+
# Receive a single BusinessAttachment object previously created in the Stark Infra API by its id
|
|
72
|
+
#
|
|
73
|
+
# ## Parameters (required):
|
|
74
|
+
# - id [string]: object unique id. ex: "5656565656565656"
|
|
75
|
+
#
|
|
76
|
+
# ## Parameters (optional):
|
|
77
|
+
# - expand [list of strings, default nil]: fields to expand information. ex: ["content"]
|
|
78
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
|
|
79
|
+
#
|
|
80
|
+
# ## Return:
|
|
81
|
+
# - BusinessAttachment object with updated attributes
|
|
82
|
+
def self.get(id, expand: nil, user: nil)
|
|
83
|
+
StarkInfra::Utils::Rest.get_id(id: id, expand: expand, user: user, **resource)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# # Retrieve BusinessAttachments
|
|
87
|
+
#
|
|
88
|
+
# Receive a generator of BusinessAttachment objects previously created in the Stark Infra API
|
|
89
|
+
#
|
|
90
|
+
# ## Parameters (optional):
|
|
91
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
|
92
|
+
# - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
|
93
|
+
# - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
|
94
|
+
# - status [list of strings, default nil]: filter for status of retrieved objects. Options: ["created", "canceled", "approved", "denied"]
|
|
95
|
+
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
|
96
|
+
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"]
|
|
97
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
98
|
+
#
|
|
99
|
+
# ## Return:
|
|
100
|
+
# - generator of BusinessAttachment objects with updated attributes
|
|
101
|
+
def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
|
|
102
|
+
after = StarkCore::Utils::Checks.check_date(after)
|
|
103
|
+
before = StarkCore::Utils::Checks.check_date(before)
|
|
104
|
+
StarkInfra::Utils::Rest.get_stream(
|
|
105
|
+
limit: limit,
|
|
106
|
+
after: after,
|
|
107
|
+
before: before,
|
|
108
|
+
status: status,
|
|
109
|
+
tags: tags,
|
|
110
|
+
ids: ids,
|
|
111
|
+
user: user,
|
|
112
|
+
**resource
|
|
113
|
+
)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# # Retrieve paged BusinessAttachments
|
|
117
|
+
#
|
|
118
|
+
# Receive a list of up to 100 BusinessAttachment objects previously created in the Stark Infra API and the cursor to the next page.
|
|
119
|
+
# Use this function instead of query if you want to manually page your requests.
|
|
120
|
+
#
|
|
121
|
+
# ## Parameters (optional):
|
|
122
|
+
# - cursor [string, default nil]: cursor returned on the previous page function call
|
|
123
|
+
# - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex 35
|
|
124
|
+
# - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
|
125
|
+
# - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
|
126
|
+
# - status [list of strings, default nil]: filter for status of retrieved objects. Options: ["created", "canceled", "approved", "denied"]
|
|
127
|
+
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
|
128
|
+
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"]
|
|
129
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
130
|
+
#
|
|
131
|
+
# ## Return:
|
|
132
|
+
# - list of BusinessAttachment objects with updated attributes
|
|
133
|
+
# - cursor to retrieve the next page of BusinessAttachment objects
|
|
134
|
+
def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
|
|
135
|
+
after = StarkCore::Utils::Checks.check_date(after)
|
|
136
|
+
before = StarkCore::Utils::Checks.check_date(before)
|
|
137
|
+
StarkInfra::Utils::Rest.get_page(
|
|
138
|
+
cursor: cursor,
|
|
139
|
+
limit: limit,
|
|
140
|
+
after: after,
|
|
141
|
+
before: before,
|
|
142
|
+
status: status,
|
|
143
|
+
tags: tags,
|
|
144
|
+
ids: ids,
|
|
145
|
+
user: user,
|
|
146
|
+
**resource
|
|
147
|
+
)
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
# # Cancel a BusinessAttachment entity
|
|
151
|
+
#
|
|
152
|
+
# Cancel a BusinessAttachment entity previously created in the Stark Infra API
|
|
153
|
+
#
|
|
154
|
+
# ## Parameters (required):
|
|
155
|
+
# - id [string]: BusinessAttachment unique id. ex: '5656565656565656'
|
|
156
|
+
#
|
|
157
|
+
# ## Parameters (optional):
|
|
158
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
|
159
|
+
#
|
|
160
|
+
# ## Return:
|
|
161
|
+
# - canceled BusinessAttachment object
|
|
162
|
+
def self.cancel(id, user: nil)
|
|
163
|
+
StarkInfra::Utils::Rest.delete_id(id: id, user: user, **resource)
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def self.resource
|
|
167
|
+
{
|
|
168
|
+
resource_name: 'BusinessAttachment',
|
|
169
|
+
resource_maker: proc { |json|
|
|
170
|
+
BusinessAttachment.new(
|
|
171
|
+
name: json['name'],
|
|
172
|
+
content: json['content'],
|
|
173
|
+
content_type: json['content_type'],
|
|
174
|
+
business_identity_id: json['business_identity_id'],
|
|
175
|
+
tags: json['tags'],
|
|
176
|
+
id: json['id'],
|
|
177
|
+
attachment_id: json['attachment_id'],
|
|
178
|
+
status: json['status'],
|
|
179
|
+
created: json['created'],
|
|
180
|
+
updated: json['updated']
|
|
181
|
+
)
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
end
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require('starkcore')
|
|
4
|
+
require_relative('../utils/rest')
|
|
5
|
+
require_relative('business_attachment')
|
|
6
|
+
|
|
7
|
+
module StarkInfra
|
|
8
|
+
class BusinessAttachment
|
|
9
|
+
# # BusinessAttachment::Log object
|
|
10
|
+
#
|
|
11
|
+
# Every time a BusinessAttachment entity is updated, a corresponding BusinessAttachment::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 BusinessAttachment.
|
|
13
|
+
#
|
|
14
|
+
# ## Attributes (return-only):
|
|
15
|
+
# - id [string]: unique id returned when the log is created. ex: '5656565656565656'
|
|
16
|
+
# - attachment [BusinessAttachment]: BusinessAttachment entity to which the log refers to.
|
|
17
|
+
# - errors [list of strings]: list of errors linked to this BusinessAttachment event
|
|
18
|
+
# - type [string]: type of the BusinessAttachment event which triggered the log creation. ex: 'created', 'canceled', 'approved', 'denied'.
|
|
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, :attachment, :errors, :type, :created
|
|
22
|
+
def initialize(id: nil, attachment: nil, errors: nil, type: nil, created: nil)
|
|
23
|
+
super(id)
|
|
24
|
+
@attachment = attachment
|
|
25
|
+
@errors = errors
|
|
26
|
+
@type = type
|
|
27
|
+
@created = StarkCore::Utils::Checks.check_datetime(created)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# # Retrieve a specific BusinessAttachment::Log
|
|
31
|
+
#
|
|
32
|
+
# Receive a single BusinessAttachment::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
|
+
# - BusinessAttachment::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 BusinessAttachment::Logs
|
|
47
|
+
#
|
|
48
|
+
# Receive a generator of BusinessAttachment::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', 'canceled', 'approved', 'denied']
|
|
55
|
+
# - attachment_ids [list of strings, default nil]: list of BusinessAttachment ids to filter logs. ex: ['5656565656565656', '4545454545454545']
|
|
56
|
+
# - ids [list of strings, default nil]: Log ids to filter BusinessAttachment 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 BusinessAttachment::Log objects with updated attributes
|
|
61
|
+
def self.query(ids: nil, limit: nil, after: nil, before: nil, types: nil, attachment_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
|
+
attachment_ids: attachment_ids,
|
|
71
|
+
user: user,
|
|
72
|
+
**resource
|
|
73
|
+
)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# # Retrieve paged BusinessAttachment::Logs
|
|
77
|
+
#
|
|
78
|
+
# Receive a list of up to 100 BusinessAttachment::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 attachments.
|
|
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', 'canceled', 'approved', 'denied']
|
|
87
|
+
# - attachment_ids [list of strings, default nil]: list of attachment ids to filter logs. ex: ['5656565656565656', '4545454545454545']
|
|
88
|
+
# - ids [list of strings, default nil]: Log ids to filter BusinessAttachment 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 BusinessAttachment::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, attachment_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
|
+
attachment_ids: attachment_ids,
|
|
105
|
+
user: user,
|
|
106
|
+
**resource
|
|
107
|
+
)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def self.resource
|
|
111
|
+
request_maker = StarkInfra::BusinessAttachment.resource[:resource_maker]
|
|
112
|
+
{
|
|
113
|
+
resource_name: 'BusinessAttachmentLog',
|
|
114
|
+
resource_maker: proc { |json|
|
|
115
|
+
Log.new(
|
|
116
|
+
id: json['id'],
|
|
117
|
+
attachment: StarkCore::Utils::API.from_api_json(request_maker, json['attachment']),
|
|
118
|
+
errors: json['errors'],
|
|
119
|
+
type: json['type'],
|
|
120
|
+
created: json['created']
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|