starkinfra 0.2.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/lib/brcodepreview/brcodepreview.rb +12 -8
  3. data/lib/cardmethod/cardmethod.rb +1 -1
  4. data/lib/creditholmes/creditholmes.rb +160 -0
  5. data/lib/creditnote/creditnote.rb +19 -18
  6. data/lib/creditnote/invoice/discount.rb +1 -1
  7. data/lib/creditnote/invoice/invoice.rb +4 -3
  8. data/lib/creditnote/log.rb +16 -17
  9. data/lib/creditpreview/creditpreview.rb +2 -8
  10. data/lib/dynamicbrcode/dynamicbrcode.rb +3 -3
  11. data/lib/event/attempt.rb +1 -1
  12. data/lib/event/event.rb +1 -1
  13. data/lib/individualdocument/individualdocument.rb +165 -0
  14. data/lib/individualdocument/log.rb +125 -0
  15. data/lib/individualidentity/individualidentity.rb +193 -0
  16. data/lib/individualidentity/log.rb +124 -0
  17. data/lib/issuingcard/issuingcard.rb +11 -12
  18. data/lib/issuingcard/log.rb +19 -19
  19. data/lib/issuingdesign/issuingdesign.rb +138 -0
  20. data/lib/issuingembossingkit/issuingembossingkit.rb +121 -0
  21. data/lib/issuingembossingrequest/issuingembossingrequest.rb +210 -0
  22. data/lib/issuingembossingrequest/log.rb +128 -0
  23. data/lib/issuingholder/issuingholder.rb +8 -7
  24. data/lib/issuingholder/log.rb +17 -17
  25. data/lib/issuinginvoice/issuinginvoice.rb +6 -5
  26. data/lib/issuinginvoice/log.rb +16 -16
  27. data/lib/issuingproduct/issuingproduct.rb +2 -2
  28. data/lib/issuingpurchase/issuingpurchase.rb +22 -15
  29. data/lib/issuingpurchase/log.rb +15 -15
  30. data/lib/issuingrestock/issuingrestock.rb +162 -0
  31. data/lib/issuingrestock/log.rb +127 -0
  32. data/lib/issuingstock/issuingstock.rb +138 -0
  33. data/lib/issuingstock/log.rb +130 -0
  34. data/lib/issuingtransaction/issuingtransaction.rb +7 -6
  35. data/lib/issuingwithdrawal/issuingwithdrawal.rb +8 -11
  36. data/lib/pixchargeback/log.rb +12 -12
  37. data/lib/pixclaim/log.rb +13 -13
  38. data/lib/pixclaim/pixclaim.rb +4 -4
  39. data/lib/pixdomain/pixdomain.rb +1 -1
  40. data/lib/pixinfraction/log.rb +18 -18
  41. data/lib/pixinfraction/pixinfraction.rb +3 -3
  42. data/lib/pixkey/log.rb +18 -18
  43. data/lib/pixkey/pixkey.rb +4 -3
  44. data/lib/pixrequest/log.rb +22 -18
  45. data/lib/pixrequest/pixrequest.rb +3 -0
  46. data/lib/pixreversal/log.rb +1 -1
  47. data/lib/pixstatement/pixstatement.rb +1 -1
  48. data/lib/starkinfra.rb +13 -0
  49. data/lib/staticbrcode/staticbrcode.rb +8 -2
  50. data/lib/utils/bacenid.rb +1 -1
  51. data/lib/utils/request.rb +1 -1
  52. data/lib/webhook/webhook.rb +9 -9
  53. metadata +15 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 407cfd041d62916d22344d376a24ff392b4ef1fcf38cf3ae1c6ab38f01916e3a
4
- data.tar.gz: 29d6b4e29af482ce49862a6e77eb72c570bad1844e66fcf1171f6148497179ec
3
+ metadata.gz: dfe030935b84e3e7e9a9a96bcb145d726a2e696f0c5a01242775fd40a4f11346
4
+ data.tar.gz: 027fb38f86fbad096b1bd57ced082c11337b593910c3668aded8d94725982a16
5
5
  SHA512:
6
- metadata.gz: d4a549b1f028df0b976c790587c5f7c3989a5290f356e93816aa6051537241f6a490617c5cd19fabf6755ec31ec9a085b1049907d2b6df35d342def6e0b065b8
7
- data.tar.gz: 22556e362fb270328d57d12875797961ecb06bf87f2e19a15fa6a37b598c4d37fe76209f0a9be93289ce68c0e6c82f63fc6156745b93eb662403bb73671f618a
6
+ metadata.gz: 0575a435a71032b94c887fe7df43a67fb284cc9c184ab9154b85de9f0a7c24f37ad444a9813a8d10d35ef4ef2e35ba53820ff2c95c6a97a531108cd6f03ace87
7
+ data.tar.gz: d23e36168a82bc5c917a30308383e830ff40cf0d8d5472953558676004e6a960e54fd34c7d95c67ebc5c268844b30ffd31766b3031f54cc75ab9ba5f5b3986e5
@@ -10,12 +10,12 @@ module StarkInfra
10
10
  #
11
11
  # A BrcodePreview is used to get information from a BR Code you received to check the information before paying it.
12
12
  #
13
- # When you initialize a BrcodePreview, 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):
13
+ # Parameters (required):
18
14
  # - id [string]: BR Code string for the Pix payment. This is also de information directly encoded in a QR Code. ex: '00020126580014br.gov.bcb.pix0136a629532e-7693-4846-852d-1bbff817b5a8520400005303986540510.005802BR5908T'Challa6009Sao Paulo62090505123456304B14A'
15
+ # - payer_id [string]: tax id (CPF/CNPJ) of the individual or business requesting the PixKey information. This id is used by the Central Bank to limit request rates. ex: "20.018.183/0001-80"
16
+ #
17
+ # Parameters (optional):
18
+ # - end_to_end_id [string]: central bank's unique transaction ID. ex: "E79457883202101262140HHX553UPqeq"
19
19
  #
20
20
  # Attributes (return-only):
21
21
  # - account_number [string]: Payment receiver account number. ex: '1234567'
@@ -39,16 +39,18 @@ module StarkInfra
39
39
  # - status [string]: Payment status. ex: 'active', 'paid', 'canceled' or 'unknown'
40
40
  # - tax_id [string]: Payment receiver tax ID. ex: '012.345.678-90'
41
41
  class BrcodePreview < StarkInfra::Utils::Resource
42
- attr_reader :id, :account_number, :account_type, :amount, :amount_type, :bank_code, :branch_code, :cash_amount,
42
+ attr_reader :id, :payer_id, :end_to_end_id, :account_number, :account_type, :amount, :amount_type, :bank_code, :branch_code, :cash_amount,
43
43
  :cashier_bank_code, :cashier_type, :discount_amount, :fine_amount, :key_id, :interest_amount, :name,
44
44
  :nominal_amount, :reconciliation_id, :reduction_amount, :scheduled, :status, :tax_id
45
45
  def initialize(
46
- id:, account_number: nil, account_type: nil, amount: nil, amount_type: nil, bank_code: nil,
46
+ id:, payer_id:, end_to_end_id: nil, account_number: nil, account_type: nil, amount: nil, amount_type: nil, bank_code: nil,
47
47
  branch_code: nil, cash_amount: nil, cashier_bank_code:nil, cashier_type:nil, discount_amount: nil,
48
48
  fine_amount: nil, key_id: nil, interest_amount: nil, name: nil, nominal_amount: nil,
49
49
  reconciliation_id: nil, reduction_amount: nil, scheduled: nil, status: nil, tax_id: nil
50
50
  )
51
51
  super(id)
52
+ @payer_id = payer_id
53
+ @end_to_end_id = end_to_end_id
52
54
  @account_number = account_number
53
55
  @account_type = account_type
54
56
  @amount = amount
@@ -60,8 +62,8 @@ module StarkInfra
60
62
  @cashier_type = cashier_type
61
63
  @discount_amount = discount_amount
62
64
  @fine_amount = fine_amount
63
- @key_id = key_id
64
65
  @interest_amount = interest_amount
66
+ @key_id = key_id
65
67
  @name = name
66
68
  @nominal_amount = nominal_amount
67
69
  @reconciliation_id = reconciliation_id
@@ -93,6 +95,8 @@ module StarkInfra
93
95
  resource_maker: proc { |json|
94
96
  BrcodePreview.new(
95
97
  id: json['id'],
98
+ payer_id: json['payer_id'],
99
+ end_to_end_id: json['end_to_end_id'],
96
100
  account_number: json['account_number'],
97
101
  account_type: json['account_type'],
98
102
  amount: json['amount'],
@@ -27,7 +27,7 @@ module StarkInfra
27
27
  # Receive a generator of CardMethod objects available in the Stark Infra API
28
28
  #
29
29
  # ## Parameters (optional):
30
- # - search [string, default nil]: keyword to search for code, name, number or short_code. ex: 'token'
30
+ # - search [string, default nil]: keyword to search for code, name, number or short_code
31
31
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
32
32
  #
33
33
  # ## Return:
@@ -0,0 +1,160 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative('../utils/rest')
4
+ require_relative('../utils/parse')
5
+ require_relative('../utils/checks')
6
+ require_relative('../utils/resource')
7
+
8
+ module StarkInfra
9
+ # # CreditHolmes object
10
+ #
11
+ # CreditHolmes are used to obtain debt information on your customers.
12
+ # Before you create a CreditHolmes, make sure you have your customer's express
13
+ # authorization to verify their information in the Central Bank's SCR.
14
+ #
15
+ # When you initialize a CreditHolmes, the entity will not be automatically
16
+ # created in the Stark Infra API. The 'create' function sends the objects
17
+ # to the Stark Infra API and returns the list of created objects.
18
+ #
19
+ # ## Parameters (required):
20
+ # - tax_id [string]: customer's tax ID (CPF or CNPJ) for whom the credit operations will be verified. ex: "20.018.183/0001-80"
21
+ #
22
+ # ## Parameters (optional):
23
+ # - competence [string, default 'two months before current date']: competence month of the operation verification, format: "YYYY-MM". ex: "2021-04"
24
+ # - tags [list of strings, default []]: list of strings for reference when searching for CreditHolmes. ex: ["credit", "operation"]
25
+ #
26
+ # ## Attributes (return-only):
27
+ # - id [string]: unique id returned when the CreditHolmes is created. ex: "5656565656565656"
28
+ # - result [dictionary]: result of the investigation after the case is solved.
29
+ # - status [string]: current status of the CreditHolmes. ex: "created", "failed", "success"
30
+ # - created [DateTime]: creation datetime for the CreditHolmes. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
31
+ # - updated [DateTime]: latest update datetime for the CreditHolmes. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
32
+ class CreditHolmes < StarkInfra::Utils::Resource
33
+ attr_reader :tax_id, :competence, :tags, :id, :result, :status, :updated, :created
34
+ def initialize(tax_id:, competence: nil, tags: nil, id: nil, result: nil, status: nil, updated: nil, created: nil)
35
+ super(id)
36
+ @tax_id = tax_id
37
+ @competence = competence
38
+ @tags = tags
39
+ @id = id
40
+ @result = result
41
+ @status = status
42
+ @created = StarkInfra::Utils::Checks.check_datetime(created)
43
+ @updated = StarkInfra::Utils::Checks.check_datetime(updated)
44
+ end
45
+
46
+ # # Create CreditHolmes
47
+ #
48
+ # Send a list of CreditHolmes objects for creation at the Stark Infra API
49
+ #
50
+ # ## Parameters (required):
51
+ # - holmes [list of CreditHolmes objects]: list of CreditHolmes objects to be created in the API.
52
+ #
53
+ # ## Parameters (optional):
54
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
55
+ #
56
+ # ## Return:
57
+ # - list of CreditHolmes object with updated attributes
58
+ def self.create(holmes, user: nil)
59
+ StarkInfra::Utils::Rest.post(entities: holmes, user: user, **resource)
60
+ end
61
+
62
+ # # Retrieve a specific CreditHolmes
63
+ #
64
+ # Receive a single CreditHolmes object previously created in the Stark Infra API by its id
65
+ #
66
+ # ## Parameters (required):
67
+ # - id [string]: object unique id. ex: "5656565656565656"
68
+ #
69
+ # ## Parameters (optional):
70
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
71
+ #
72
+ # ## Return:
73
+ # - CreditHolmes object with updated attributes
74
+ def self.get(id, user: nil)
75
+ StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
76
+ end
77
+
78
+ # # Retrieve CreditHolmes
79
+ #
80
+ # Receive a generator of CreditHolmes objects previously created in the Stark Infra API
81
+ #
82
+ # ## Parameters (optional):
83
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. 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
+ # - status [list of strings, default nil]: filter for status of retrieved objects. ex: "created", "failed", "success"
87
+ # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ["tony", "stark"]
88
+ # - ids [list of strings, default nil]: list of 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
+ # - generator of CreditHolmes objects with updated attributes
93
+ def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
94
+ after = StarkInfra::Utils::Checks.check_date(after)
95
+ before = StarkInfra::Utils::Checks.check_date(before)
96
+ StarkInfra::Utils::Rest.get_stream(
97
+ limit: limit,
98
+ after: after,
99
+ before: before,
100
+ status: status,
101
+ tags: tags,
102
+ ids: ids,
103
+ user: user,
104
+ **resource
105
+ )
106
+ end
107
+
108
+ # # Retrieve CreditHolmes
109
+ #
110
+ # Receive a list of up to 100 CreditHolmes objects previously created in the Stark Infra API and the cursor to the next page.
111
+ # Use this function instead of query if you want to manually page your requests.
112
+ #
113
+ # ## Parameters (optional):
114
+ # - cursor [string, default nil]: cursor returned on the previous page function call
115
+ # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. 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: "created", "failed", "success"
119
+ # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ["tony", "stark"]
120
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"]
121
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
122
+ #
123
+ # ## Return:
124
+ # - list of CreditHolmes objects with updated attributes
125
+ # - cursor to retrieve the next page of CreditHolmes objects
126
+ def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
127
+ after = StarkInfra::Utils::Checks.check_date(after)
128
+ before = StarkInfra::Utils::Checks.check_date(before)
129
+ StarkInfra::Utils::Rest.get_page(
130
+ cursor: cursor,
131
+ limit: limit,
132
+ after: after,
133
+ before: before,
134
+ status: status,
135
+ tags: tags,
136
+ ids: ids,
137
+ user: user,
138
+ **resource
139
+ )
140
+ end
141
+
142
+ def self.resource
143
+ {
144
+ resource_name: 'CreditHolmes',
145
+ resource_maker: proc { |json|
146
+ CreditHolmes.new(
147
+ tax_id: json['tax_id'],
148
+ competence: json['competence'],
149
+ tags: json['tags'],
150
+ id: json['id'],
151
+ result: json['result'],
152
+ status: json['status'],
153
+ created: json['created'],
154
+ updated: json['updated']
155
+ )
156
+ }
157
+ }
158
+ end
159
+ end
160
+ end
@@ -22,7 +22,6 @@ module StarkInfra
22
22
  # - template_id [string]: ID of the contract template on which the credit note will be based. ex: '0123456789101112'
23
23
  # - name [string]: credit receiver's full name. ex: 'Edward Stark'
24
24
  # - tax_id [string]: credit receiver's tax ID (CPF or CNPJ). ex: '20.018.183/0001-80'
25
- # - nominal_amount [integer]: amount in cents transferred to the credit receiver, before deductions. ex: 11234 (= R$ 112.34)
26
25
  # - scheduled [DateTime, Date or string]: date of transfer execution. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
27
26
  # - invoices [list of CreditNote::Invoice objects]: list of Invoice objects to be created and sent to the credit receiver. ex: [Invoice.new(), Invoice.new()]
28
27
  # - payment [CreditNote::Transfer object]: payment entity to be created and sent to the credit receiver. ex: Transfer.new()
@@ -37,6 +36,8 @@ module StarkInfra
37
36
  #
38
37
  # ## Parameters (conditionally required):
39
38
  # - payment_type [string]: payment type, inferred from the payment parameter if it is not a hash. ex: 'transfer'
39
+ # - nominal_amount [integer]: CreditNote value in cents. The nominal_amount parameter is required when amount is not sent. ex: 1234 (= R$ 12.34)
40
+ # - amount [integer]: amount in cents transferred to the credit receiver, before deductions. The amount parameter is required when nominal_amount is not sent. ex: 1234 (= R$ 12.34)
40
41
  #
41
42
  # ## Parameters (optional):
42
43
  # - rebate_amount [integer, default nil]: credit analysis fee deducted from lent amount. ex: 11234 (= R$ 112.34)
@@ -45,7 +46,6 @@ module StarkInfra
45
46
  #
46
47
  # ## Attributes (return-only):
47
48
  # - id [string]: unique id returned when the CreditNote is created. ex: '5656565656565656'
48
- # - amount [integer]: CreditNote value in cents. ex: 1234 (= R$ 12.34)
49
49
  # - document_id [string]: ID of the signed document to execute this CreditNote. ex: '4545454545454545'
50
50
  # - status [string]: current status of the CreditNote. ex: 'canceled', 'created', 'expired', 'failed', 'processing', 'signed', 'success'
51
51
  # - transaction_ids [list of strings]: ledger transaction ids linked to this CreditNote. ex: ['19827356981273']
@@ -56,14 +56,14 @@ module StarkInfra
56
56
  # - created [DateTime]: creation datetime for the CreditNote. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
57
57
  # - updated [DateTime]: latest update datetime for the CreditNote. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
58
58
  class CreditNote < StarkInfra::Utils::Resource
59
- attr_reader :template_id, :name, :tax_id, :nominal_amount, :scheduled, :invoices, :payment, :signers, :external_id,
60
- :street_line_1, :street_line_2, :district, :city, :state_code, :zip_code, :payment_type, :rebate_amount,
61
- :tags, :expiration, :id, :amount, :document_id, :status, :transaction_ids, :workspace_id, :tax_amount,
62
- :nominal_interest, :interest, :created, :updated
59
+ attr_reader :template_id, :name, :tax_id, :scheduled, :invoices, :payment, :signers, :external_id,
60
+ :street_line_1, :street_line_2, :district, :city, :state_code, :zip_code, :payment_type,
61
+ :nominal_amount, :amount, :rebate_amount, :tags, :expiration, :id, :document_id, :status,
62
+ :transaction_ids, :workspace_id, :tax_amount, :nominal_interest, :interest, :created, :updated
63
63
  def initialize(
64
- template_id:, name:, tax_id:, nominal_amount:, scheduled:, invoices:, payment:,
65
- signers:, external_id:, street_line_1:, street_line_2:, district:, city:, state_code:, zip_code:,
66
- payment_type: nil, rebate_amount: nil, tags: nil, expiration: nil, id: nil, amount: nil,
64
+ template_id:, name:, tax_id:, scheduled:, invoices:, payment:, signers:, external_id:,
65
+ street_line_1:, street_line_2:, district:, city:, state_code:, zip_code:, payment_type: nil,
66
+ nominal_amount: nil, amount: nil, rebate_amount: nil, tags: nil, expiration: nil, id: nil,
67
67
  document_id: nil, status: nil, transaction_ids: nil, workspace_id: nil, tax_amount: nil,
68
68
  nominal_interest: nil, interest: nil, created: nil, updated: nil
69
69
  )
@@ -71,7 +71,6 @@ module StarkInfra
71
71
  @template_id = template_id
72
72
  @name = name
73
73
  @tax_id = tax_id
74
- @nominal_amount = nominal_amount
75
74
  @scheduled = scheduled
76
75
  @invoices = Invoice.parse_invoices(invoices)
77
76
  @signers = CreditSigner.parse_signers(signers)
@@ -82,9 +81,10 @@ module StarkInfra
82
81
  @city = city
83
82
  @state_code = state_code
84
83
  @zip_code = zip_code
84
+ @nominal_amount = nominal_amount
85
+ @amount = amount
85
86
  @rebate_amount = rebate_amount
86
87
  @tags = tags
87
- @amount = amount
88
88
  @expiration = expiration
89
89
  @document_id = document_id
90
90
  @status = status
@@ -141,7 +141,7 @@ module StarkInfra
141
141
  # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
142
142
  # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
143
143
  # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
144
- # - status [string, default nil]: filter for status of retrieved objects. ex: 'success' or 'failed'
144
+ # - status [string, default nil]: filter for status of retrieved objects. ex: ["canceled", "created", "expired", "failed", "processing", "signed", "success"]
145
145
  # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
146
146
  # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
147
147
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
@@ -173,7 +173,7 @@ module StarkInfra
173
173
  # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
174
174
  # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
175
175
  # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
176
- # - status [string, default nil]: filter for status of retrieved objects. ex: 'paid' or 'registered'
176
+ # - status [string, default nil]: filter for status of retrieved objects. ex: ["canceled", "created", "expired", "failed", "processing", "signed", "success"]
177
177
  # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
178
178
  # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
179
179
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
@@ -197,9 +197,9 @@ module StarkInfra
197
197
  )
198
198
  end
199
199
 
200
- # # Cancel a specific CreditNote
200
+ # # Cancel a CreditNote entity
201
201
  #
202
- # Cancel a single CreditNote object previously created in the Stark Infra API by passing its id
202
+ # Cancel a CreditNote entity previously created in the Stark Infra API
203
203
  #
204
204
  # ## Parameters (required):
205
205
  # - id [string]: object unique id. ex: '5656565656565656'
@@ -208,7 +208,7 @@ module StarkInfra
208
208
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
209
209
  #
210
210
  # ## Return:
211
- # - canceled CreditNote object with updated attributes
211
+ # - canceled CreditNote object
212
212
  def self.cancel(id, user: nil)
213
213
  StarkInfra::Utils::Rest.delete_id(id: id, user: user, **resource)
214
214
  end
@@ -245,7 +245,6 @@ module StarkInfra
245
245
  template_id: json['template_id'],
246
246
  name: json['name'],
247
247
  tax_id: json['tax_id'],
248
- nominal_amount: json['nominal_amount'],
249
248
  scheduled: json['scheduled'],
250
249
  invoices: json['invoices'],
251
250
  payment: json['payment'],
@@ -258,15 +257,17 @@ module StarkInfra
258
257
  state_code: json['state_code'],
259
258
  zip_code: json['zip_code'],
260
259
  payment_type: json['payment_type'],
260
+ nominal_amount: json['nominal_amount'],
261
+ amount: json['amount'],
261
262
  rebate_amount: json['rebate_amount'],
262
263
  tags: json['tags'],
263
264
  expiration: json['expiration'],
264
- amount: json['amount'],
265
265
  document_id: json['document_id'],
266
266
  status: json['status'],
267
267
  transaction_ids: json['transaction_ids'],
268
268
  workspace_id: json['workspace_id'],
269
269
  tax_amount: json['tax_amount'],
270
+ nominal_interest: json['nominal_interest'],
270
271
  interest: json['interest'],
271
272
  created: json['created'],
272
273
  updated: json['updated']
@@ -11,7 +11,7 @@ module StarkInfra
11
11
  # Invoice discount information.
12
12
  #
13
13
  # ## Parameters (required):
14
- # - percentage [float]: percentage of discount applied until specified due date. ex: 2.5
14
+ # - percentage [float]: percentage of discount applied until specified due date.
15
15
  # - due [DateTime or string]: due datetime for the discount. ex: '2020-03-10T10:30:00.000000+00:00' or DateTime.new(2020, 3, 10, 10, 30, 0, 0).
16
16
  class Discount < StarkInfra::Utils::SubResource
17
17
  attr_reader :percentage, :due
@@ -7,15 +7,16 @@ require_relative('../../utils/sub_resource')
7
7
  module StarkInfra
8
8
 
9
9
  # CreditNote::Invoice object
10
- # Invoice object to be issued after contract signature and paid by the credit receiver.
10
+ #
11
+ # Invoice issued after the contract is signed, to be paid by the credit receiver.
11
12
  #
12
13
  # ## Parameters (required):
13
14
  # - amount [integer]: Invoice value in cents. Minimum = 1 (any value will be accepted). ex: 1234 (= R$ 12.34)
14
15
  #
15
16
  # ## Parameters (optional):
16
17
  # - due [DateTime, Date or string, default now + 2 days]: Invoice due date in UTC ISO format. DateTime.new(2020, 3, 10, 10, 30, 0, 0) for immediate invoices and '2020-10-28' for scheduled invoices
17
- # - expiration [integer, default 604800]: time interval in seconds between scheduled date and expiration date. ex 123456789
18
- # - tags [list of strings, default nil]: list of strings for tagging. ex: tags=['employees', 'monthly']
18
+ # - expiration [integer, default 604800]: time interval in seconds between scheduled date and expiration date. ex: 123456789
19
+ # - tags [list of strings, default nil]: list of strings for tagging. ex: ['employees', 'monthly']
19
20
  # - descriptions [list of CreditNote::Invoice::Description objects or hash, default nil]: list Description objects. ex: [Description.new()]
20
21
  #
21
22
  # ## Attributes (return-only):
@@ -13,25 +13,25 @@ module StarkInfra
13
13
  # is generated for the entity. This log is never generated by the
14
14
  # user.
15
15
  #
16
- # ## Attributes:
16
+ # ## Attributes (return-only):
17
17
  # - id [string]: unique id returned when the log is created. ex: '5656565656565656'
18
- # - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
19
- # - type [string]: type of the CreditNote event which triggered the log creation. Options: 'canceled', 'created', 'expired', 'failed', 'refunded', 'registered', 'sending', 'sent', 'signed', 'success'
20
- # - errors [list of strings]: list of errors linked to this CreditNote event.
21
18
  # - note [CreditNote]: CreditNote entity to which the log refers to.
19
+ # - errors [list of strings]: list of errors linked to this CreditNote event.
20
+ # - type [string]: type of the CreditNote event which triggered the log creation. Options: 'canceled', 'created', 'expired', 'failed', 'refunded', 'registered', 'sending', 'sent', 'signed', 'success'
21
+ # - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
22
22
  class Log < StarkInfra::Utils::Resource
23
23
  attr_reader :id, :created, :type, :errors, :note
24
24
  def initialize(id:, created:, type:, errors:, note:)
25
25
  super(id)
26
- @created = StarkInfra::Utils::Checks.check_datetime(created)
27
- @type = type
28
- @errors = errors
29
26
  @note = note
27
+ @errors = errors
28
+ @type = type
29
+ @created = StarkInfra::Utils::Checks.check_datetime(created)
30
30
  end
31
31
 
32
- # # Retrieve a specific Log
32
+ # # Retrieve a specific CreditNote::Log
33
33
  #
34
- # Receive a single Log object previously created by the Stark Infra API by passing its id
34
+ # Receive a single CreditNote::Log object previously created by the Stark Infra API by passing its id
35
35
  #
36
36
  # ## Parameters (required):
37
37
  # - id [string]: object unique id. ex: '5656565656565656'
@@ -45,12 +45,11 @@ module StarkInfra
45
45
  StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
46
46
  end
47
47
 
48
- # # Retrieve Logs
48
+ # # Retrieve CreditNote::Logs
49
49
  #
50
- # Receive a generator of Log objects previously created in the Stark Infra API
50
+ # Receive a generator of CreditNote::Log objects previously created in the Stark Infra API
51
51
  #
52
52
  # ## Parameters (optional):
53
- # - ids [list of strings, default nil]: Log ids to filter PixKey Logs. ex: ['5656565656565656']
54
53
  # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
55
54
  # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
56
55
  # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
@@ -74,9 +73,9 @@ module StarkInfra
74
73
  )
75
74
  end
76
75
 
77
- # # Retrieve paged Logs
76
+ # # Retrieve paged CreditNote::Logs
78
77
  #
79
- # Receive a list of up to 100 Log objects previously created in the Stark Infra API and the cursor to the next page.
78
+ # Receive a list of up to 100 CreditNote::Log objects previously created in the Stark Infra API and the cursor to the next page.
80
79
  # Use this function instead of query if you want to manually page your notes.
81
80
  #
82
81
  # ## Parameters (optional):
@@ -113,10 +112,10 @@ module StarkInfra
113
112
  resource_maker: proc { |json|
114
113
  Log.new(
115
114
  id: json['id'],
116
- created: json['created'],
117
- type: json['type'],
115
+ note: StarkInfra::Utils::API.from_api_json(note_maker, json['note']),
118
116
  errors: json['errors'],
119
- note: StarkInfra::Utils::API.from_api_json(note_maker, json['note'])
117
+ type: json['type'],
118
+ created: json['created']
120
119
  )
121
120
  }
122
121
  }
@@ -10,15 +10,9 @@ module StarkInfra
10
10
  # A CreditPreview is used to get information from a credit before taking it.
11
11
  # This resource can be used to preview credit notes.
12
12
  #
13
- # When you initialize a CreditPreview, 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
13
  # ## Parameters (required):
18
- # - credit [CreditNotePreview object or hash]: Information preview of the informed credit.
19
- #
20
- # ## Parameters (conditionally required):
21
- # - type [string]: Credit type, inferred from the payment parameter if it is not a dictionary. ex: 'credit-note'
14
+ # - credit [CreditNotePreview object]: Information preview of the informed credit.
15
+ # - type [string]: Credit type. ex: "credit-note"
22
16
  class CreditPreview < StarkInfra::Utils::SubResource
23
17
  attr_reader :credit, :type
24
18
  def initialize(credit:, type: nil)
@@ -61,7 +61,7 @@ module StarkInfra
61
61
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
62
62
  #
63
63
  # ## Return:
64
- # - DynamicBrcode object with updated attributes
64
+ # - list of DynamicBrcode objects with updated attributes
65
65
  def self.create(brcodes, user: nil)
66
66
  StarkInfra::Utils::Rest.post(entities: brcodes, user: user, **resource)
67
67
  end
@@ -167,9 +167,9 @@ module StarkInfra
167
167
  # - receiver_city [string]: receiver's address city name. ex: "Sao Paulo"
168
168
  # - receiver_state_code [string]: receiver's address state code. ex: "SP"
169
169
  # - receiver_zip_code [string]: receiver's address zip code. ex: "01234-567"
170
- # - expiration [integer]: time in seconds counted from the creation datetime until the DynamicBrcode expires. After expiration, the BR Code cannot be paid anymore.
171
170
  #
172
171
  # ## Parameters (optional):
172
+ # - expiration [integer]: time in seconds counted from the creation datetime until the DynamicBrcode expires. After expiration, the BR Code cannot be paid anymore.
173
173
  # - sender_tax_id [string, default nil]: sender's CPF (11 digits formatted or unformatted) or CNPJ (14 digits formatted or unformatted). ex: '01.001.001/0001-01'
174
174
  # - receiver_tax_id [string, default nil]: receiver's CPF (11 digits formatted or unformatted) or CNPJ (14 digits formatted or unformatted). ex: '012.345.678-90'
175
175
  # - fine [float, default 2.0]: Percentage charged if the sender pays after the due datetime. ex. 2.0
@@ -225,13 +225,13 @@ module StarkInfra
225
225
  # - status [string]: BR Code status. Options: 'created', 'overdue', 'paid', 'canceled' or 'expired'
226
226
  # - reconciliation_id [string]: id to be used for conciliation of the resulting Pix transaction. This id must have from to 26 to 35 alphanumeric characters' ex: "cd65c78aeb6543eaaa0170f68bd741ee"
227
227
  # - amount [integer]: positive integer that represents the amount in cents of the resulting Pix transaction. ex: 1234 (= R$ 12.34)
228
- # - expiration [integer]: time in seconds counted from the creation datetime until the DynamicBrcode expires. After expiration, the BR Code cannot be paid anymore. ex: 123456789
229
228
  #
230
229
  # ## Parameters (required):
231
230
  # - cashier_type [string, default nil]: cashier's type. Required if the cashAmount is different from 0. Options: 'merchant', 'participant' and 'other'
232
231
  # - cashier_bank_code [string, default nil]: cashier's bank code. Required if the cash_amount is different from 0. ex: '20018183'
233
232
  #
234
233
  # ## Parameters (optional):
234
+ # - expiration [integer, default nil]: time in seconds counted from the creation datetime until the DynamicBrcode expires. After expiration, the BR Code cannot be paid anymore. ex: 123456789
235
235
  # - cash_amount [integer, default nil]: amount to be withdrawn from the cashier in cents. ex: 1000 (= R$ 10.00)
236
236
  # - sender_name [string, default nil]: sender's full name. ex: 'Anthony Edward Stark'
237
237
  # - sender_tax_id [string, default nil]: sender's CPF (11 digits formatted or unformatted) or CNPJ (14 digits formatted or unformatted). ex: '01.001.001/0001-01'
data/lib/event/attempt.rb CHANGED
@@ -12,7 +12,7 @@ module StarkInfra
12
12
  # When an Event delivery fails, an event attempt will be registered.
13
13
  # It carries information meant to help you debug event reception issues.
14
14
  #
15
- # ## Attributes:
15
+ # ## Attributes (return-only):
16
16
  # - id [string]: unique id that identifies the delivery attempt. ex: '5656565656565656'
17
17
  # - code [string]: delivery error code. ex: badHttpStatus, badConnection, timeout
18
18
  # - message [string]: delivery error full description. ex: 'HTTP POST request returned status 404'
data/lib/event/event.rb CHANGED
@@ -18,7 +18,7 @@ module StarkInfra
18
18
  # Events cannot be created, but may be retrieved from the Stark Infra API to
19
19
  # list all generated updates on entities.
20
20
  #
21
- # ## Attributes:
21
+ # ## Attributes (return-only):
22
22
  # - id [string]: unique id returned when the event is created. ex: '5656565656565656'
23
23
  # - log [Log]: a Log object from one the subscription services (PixRequestLog, PixReversalLog)
24
24
  # - created [DateTime]: creation datetime for the notification event. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)