starkinfra 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/lib/brcodepreview/brcodepreview.rb +125 -0
  3. data/lib/cardmethod/cardmethod.rb +56 -0
  4. data/lib/creditholmes/creditholmes.rb +160 -0
  5. data/lib/creditnote/creditnote.rb +51 -355
  6. data/lib/creditnote/invoice/description.rb +51 -0
  7. data/lib/creditnote/invoice/discount.rb +49 -0
  8. data/lib/creditnote/invoice/invoice.rb +124 -0
  9. data/lib/creditnote/log.rb +18 -19
  10. data/lib/creditnote/transfer.rb +90 -0
  11. data/lib/creditpreview/creditnotepreview.rb +85 -0
  12. data/lib/creditpreview/creditpreview.rb +77 -0
  13. data/lib/creditsigner/creditsigner.rb +57 -0
  14. data/lib/dynamicbrcode/dynamicbrcode.rb +350 -0
  15. data/lib/event/attempt.rb +5 -4
  16. data/lib/event/event.rb +11 -11
  17. data/lib/individualdocument/individualdocument.rb +165 -0
  18. data/lib/individualdocument/log.rb +125 -0
  19. data/lib/individualidentity/individualidentity.rb +193 -0
  20. data/lib/individualidentity/log.rb +124 -0
  21. data/lib/issuingbalance/issuingbalance.rb +4 -4
  22. data/lib/issuingcard/issuingcard.rb +35 -33
  23. data/lib/issuingcard/log.rb +21 -21
  24. data/lib/issuingdesign/issuingdesign.rb +138 -0
  25. data/lib/issuingembossingkit/issuingembossingkit.rb +121 -0
  26. data/lib/issuingembossingrequest/issuingembossingrequest.rb +210 -0
  27. data/lib/issuingembossingrequest/log.rb +128 -0
  28. data/lib/issuingholder/issuingholder.rb +21 -15
  29. data/lib/issuingholder/log.rb +19 -19
  30. data/lib/issuinginvoice/issuinginvoice.rb +29 -14
  31. data/lib/issuinginvoice/log.rb +18 -18
  32. data/lib/{issuingbin/issuingbin.rb → issuingproduct/issuingproduct.rb} +27 -30
  33. data/lib/issuingpurchase/issuingpurchase.rb +111 -31
  34. data/lib/issuingpurchase/log.rb +16 -16
  35. data/lib/issuingrestock/issuingrestock.rb +162 -0
  36. data/lib/issuingrestock/log.rb +127 -0
  37. data/lib/issuingrule/issuingrule.rb +64 -18
  38. data/lib/issuingstock/issuingstock.rb +138 -0
  39. data/lib/issuingstock/log.rb +130 -0
  40. data/lib/issuingtransaction/issuingtransaction.rb +12 -13
  41. data/lib/issuingwithdrawal/issuingwithdrawal.rb +12 -11
  42. data/lib/merchantcategory/merchantcategory.rb +63 -0
  43. data/lib/merchantcountry/merchantcountry.rb +59 -0
  44. data/lib/pixbalance/pixbalance.rb +5 -5
  45. data/lib/pixchargeback/log.rb +15 -15
  46. data/lib/pixchargeback/pixchargeback.rb +32 -20
  47. data/lib/pixclaim/log.rb +21 -24
  48. data/lib/pixclaim/pixclaim.rb +44 -34
  49. data/lib/pixdirector/pixdirector.rb +9 -11
  50. data/lib/pixdomain/certificate.rb +1 -1
  51. data/lib/pixdomain/pixdomain.rb +5 -5
  52. data/lib/pixinfraction/log.rb +20 -20
  53. data/lib/pixinfraction/pixinfraction.rb +23 -15
  54. data/lib/pixkey/log.rb +23 -23
  55. data/lib/pixkey/pixkey.rb +14 -12
  56. data/lib/pixrequest/log.rb +24 -20
  57. data/lib/pixrequest/pixrequest.rb +54 -21
  58. data/lib/pixreversal/log.rb +3 -3
  59. data/lib/pixreversal/pixreversal.rb +48 -21
  60. data/lib/pixstatement/pixstatement.rb +13 -8
  61. data/lib/starkinfra.rb +40 -15
  62. data/lib/staticbrcode/staticbrcode.rb +170 -0
  63. data/lib/user/project.rb +1 -1
  64. data/lib/utils/api.rb +1 -0
  65. data/lib/utils/bacenid.rb +1 -1
  66. data/lib/utils/parse.rb +7 -3
  67. data/lib/utils/request.rb +1 -1
  68. data/lib/utils/resource.rb +1 -1
  69. data/lib/utils/sub_resource.rb +21 -22
  70. data/lib/webhook/webhook.rb +11 -11
  71. metadata +29 -4
  72. data/lib/issuingauthorization/issuingauthorization.rb +0 -141
@@ -1,43 +1,48 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative('../utils/resource')
4
3
  require_relative('../utils/rest')
5
4
  require_relative('../utils/checks')
5
+ require_relative('../utils/resource')
6
6
 
7
7
  module StarkInfra
8
8
  # # PixClaim object
9
9
  #
10
- # PixClaims intend to transfer a PixClaim from one account to another.
10
+ # A Pix Claim is a request to transfer a Pix Key from an account hosted at another
11
+ # Pix participant to an account under your bank code. Pix Claims must always be requested by the claimer.
12
+ #
11
13
  # When you initialize a PixClaim, the entity will not be automatically
12
14
  # created in the Stark Infra API. The 'create' function sends the objects
13
15
  # to the Stark Infra API and returns the created object.
14
16
  #
15
17
  # ## Parameters (required):
16
- # - account_created [Date, DateTime or string]: opening Date or DateTime for the account claiming the PixClaim. ex: '2022-01-01'.
17
- # - account_number [string]: number of the account claiming the PixClaim. ex: '76543'.
18
- # - account_type [string]: type of the account claiming the PixClaim. Options: 'checking', 'savings', 'salary' or 'payment'.
19
- # - branch_code [string]: branch code of the account claiming the PixClaim. ex: 1234'.
20
- # - name [string]: holder's name of the account claiming the PixClaim. ex: 'Jamie Lannister'.
21
- # - tax_id [string]: holder's taxId of the account claiming the PixClaim (CPF/CNPJ). ex: '012.345.678-90'.
18
+ # - account_created [Date, DateTime or string]: opening Date or DateTime for the account claiming the PixKey. ex: '2022-01-01', Date.new(2020, 3, 10) or DateTime.new(2020, 3, 10, 10, 30, 0, 0)
19
+ # - account_number [string]: number of the account claiming the PixKey. ex: '76543'.
20
+ # - account_type [string]: type of the account claiming the PixKey. Options: 'checking', 'savings', 'salary' or 'payment'.
21
+ # - branch_code [string]: branch code of the account claiming the PixKey. ex: 1234'.
22
+ # - name [string]: holder's name of the account claiming the PixKey. ex: 'Jamie Lannister'.
23
+ # - tax_id [string]: holder's taxId of the account claiming the PixKey (CPF/CNPJ). ex: '012.345.678-90'.
22
24
  # - key_id [string]: id of the registered Pix Key to be claimed. Allowed keyTypes are CPF, CNPJ, phone number or email. ex: '+5511989898989'.
23
25
  #
26
+ # ## Parameters (optional):
27
+ # - tags [list of strings, default nil]: list of strings for tagging. ex: ['travel', 'food']
28
+ #
24
29
  # ## Attributes (return-only):
25
30
  # - id [string]: unique id returned when the PixClaim is created. ex: '5656565656565656'
26
31
  # - status [string]: current PixClaim status. Options: 'created', 'failed', 'delivered', 'confirmed', 'success', 'canceled'
27
32
  # - type [string]: type of Pix Claim. Options: 'ownership', 'portability'.
28
33
  # - key_type [string]: keyType of the claimed Pix Key. Options: 'CPF', 'CNPJ', 'phone' or 'email'
29
- # - agent [string]: Options: 'claimer' if you requested the PixClaim or 'claimed' if you received a PixClaim request.
30
- # - bank_code [string]: bank_code of the account linked to the PixClaim being claimed. ex: '20018183'.
34
+ # - flow [string]: direction of the Pix Claim. Options: 'in' if you received the PixClaim or 'out' if you created the PixClaim.
35
+ # - claimer_bank_code [string]: bank_code of the Pix participant that created the PixClaim. ex: '20018183'.
31
36
  # - claimed_bank_code [string]: bank_code of the account donating the PixClaim. ex: '20018183'.
32
37
  # - created [DateTime]: creation datetime for the PixClaim. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
33
38
  # - updated [DateTime]: update datetime for the PixClaim. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
34
39
  class PixClaim < StarkInfra::Utils::Resource
35
40
  attr_reader :account_created, :account_number, :account_type, :branch_code, :name, :tax_id, :key_id,
36
- :id, :status, :type, :key_type, :agent, :bank_code, :claimed_bank_code, :created, :updated
41
+ :tags, :id, :status, :type, :key_type, :flow, :claimer_bank_code, :claimed_bank_code, :created, :updated
37
42
  def initialize(
38
43
  account_created:, account_number:, account_type:, branch_code:, name:,
39
- tax_id:, key_id:, id: nil, status: nil, type: nil, key_type: nil, agent: nil,
40
- bank_code: nil, claimed_bank_code: nil, created: nil, updated: nil
44
+ tax_id:, key_id:, tags: nil, id: nil, status: nil, type: nil, key_type: nil, flow: nil,
45
+ claimer_bank_code: nil, claimed_bank_code: nil, created: nil, updated: nil
41
46
  )
42
47
  super(id)
43
48
  @account_created = account_created
@@ -47,22 +52,24 @@ module StarkInfra
47
52
  @name = name
48
53
  @tax_id = tax_id
49
54
  @key_id = key_id
55
+ @tags = tags
50
56
  @status = status
51
57
  @type = type
52
58
  @key_type = key_type
53
- @agent = agent
54
- @bank_code = bank_code
59
+ @flow = flow
60
+ @claimer_bank_code = claimer_bank_code
55
61
  @claimed_bank_code = claimed_bank_code
56
62
  @created = StarkInfra::Utils::Checks.check_datetime(created)
57
63
  @updated = StarkInfra::Utils::Checks.check_datetime(updated)
58
64
  end
59
65
 
60
- # # Create a PixClaim
66
+ # # Create a PixClaim object
61
67
  #
62
- # Send a PixClaim object for creation in the Stark Infra API
68
+ # Create a PixClaim to request the transfer of a PixKey to an account
69
+ # hosted at other Pix participants in the Stark Infra API.
63
70
  #
64
71
  # ## Parameters (required):
65
- # - claim [PixClaim object]: PixClaim object to be created in the API. ex: PixClaim.new()
72
+ # - claim [PixClaim object]: PixClaim object to be created in the API.
66
73
  #
67
74
  # ## Parameters (optional):
68
75
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
@@ -73,9 +80,9 @@ module StarkInfra
73
80
  StarkInfra::Utils::Rest.post_single(entity: claim, user: user, **resource)
74
81
  end
75
82
 
76
- # # Retrieve a specific PixClaim
83
+ # # Retrieve a PixClaim object
77
84
  #
78
- # Receive a single PixClaim object previously created in the Stark Infra API by passing its id
85
+ # Retrieve a PixClaim object linked to your Workspace in the Stark Infra API by its id.
79
86
  #
80
87
  # ## Parameters (required):
81
88
  # - id [string]: object unique id. ex: '5656565656565656'
@@ -84,7 +91,7 @@ module StarkInfra
84
91
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
85
92
  #
86
93
  # ## Return:
87
- # - PixClaim object with updated attributes
94
+ # - PixClaim object that corresponds to the given id.
88
95
  def self.get(id, user: nil)
89
96
  StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
90
97
  end
@@ -98,19 +105,19 @@ module StarkInfra
98
105
  # - after [Date or string, default nil]: date filter for objects created or updated only after specified date. ex: Date.new(2020, 3, 10)
99
106
  # - before [Date or string, default nil]: date filter for objects created or updated only before specified date. ex: Date.new(2020, 3, 10)
100
107
  # - status [string, default nil]: filter for status of retrieved objects. Options: 'created', 'failed', 'delivered', 'confirmed', 'success', 'canceled'
101
- # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
102
108
  # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
103
109
  # - type [string, default nil]: filter for the type of retrieved PixClaims. Options: 'ownership' or 'portability'
104
- # - agent [string, default nil]: filter for the agent of retrieved PixClaims. Options: 'claimer' or 'claimed'.
105
110
  # - key_type [string, default nil]: filter for the PixKey type of retrieved PixClaims. Options: 'cpf', 'cnpj', 'phone', 'email' and 'evp',
106
111
  # - key_id [string, default nil]: filter PixClaims linked to a specific PixKey id. Example: '+5511989898989'.
112
+ # - flow [string, default nil]: direction of the Pix Claim. Options: 'in' if you received the PixClaim or 'out' if you created the PixClaim.
113
+ # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
107
114
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
108
115
  #
109
116
  # ## Return:
110
117
  # - generator of PixClaim objects with updated attributes
111
118
  def self.query(
112
119
  limit: nil, after: nil, before: nil, status: nil, ids: nil,
113
- type: nil, agent: nil, key_type: nil, key_id: nil, user: nil
120
+ type: nil, flow: nil, tags: nil, key_type: nil, key_id: nil, user: nil
114
121
  )
115
122
  after = StarkInfra::Utils::Checks.check_date(after)
116
123
  before = StarkInfra::Utils::Checks.check_date(before)
@@ -121,7 +128,8 @@ module StarkInfra
121
128
  status: status,
122
129
  ids: ids,
123
130
  type: type,
124
- agent: agent,
131
+ flow: flow,
132
+ tags: tags,
125
133
  key_type: key_type,
126
134
  key_id: key_id,
127
135
  user: user,
@@ -140,12 +148,12 @@ module StarkInfra
140
148
  # - after [Date or string, default nil]: date filter for objects created or updated only after specified date. ex: Date.new(2020, 3, 10)
141
149
  # - before [Date or string, default nil]: date filter for objects created or updated only before specified date. ex: Date.new(2020, 3, 10)
142
150
  # - status [string, default nil]: filter for status of retrieved objects. Options: 'created', 'failed', 'delivered', 'confirmed', 'success', 'canceled'
143
- # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
144
151
  # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
145
152
  # - type [string, default nil]: filter for the type of retrieved PixClaims. Options: 'ownership' or 'portability'
146
- # - agent [string, default nil]: filter for the agent of retrieved PixClaims. Options: 'claimer' or 'claimed'.
147
153
  # - key_type [string, default nil]: filter for the PixKey type of retrieved PixClaims. Options: 'cpf', 'cnpj', 'phone', 'email' and 'evp',
148
154
  # - key_id [string, default nil]: filter PixClaims linked to a specific PixKey id. Example: '+5511989898989'.
155
+ # - flow [string, default nil]: direction of the Pix Claim. Options: 'in' if you received the PixClaim or 'out' if you created the PixClaim.
156
+ # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
149
157
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
150
158
  #
151
159
  # ## Return:
@@ -153,7 +161,7 @@ module StarkInfra
153
161
  # - cursor to retrieve the next page of PixClaim objects
154
162
  def self.page(
155
163
  cursor: nil, limit: nil, after: nil, before: nil, status: nil, ids: nil,
156
- type: nil, agent: nil, key_type: nil, key_id: nil, user: nil
164
+ type: nil, flow: nil, tags: nil, key_type: nil, key_id: nil, user: nil
157
165
  )
158
166
  after = StarkInfra::Utils::Checks.check_date(after)
159
167
  before = StarkInfra::Utils::Checks.check_date(before)
@@ -165,7 +173,8 @@ module StarkInfra
165
173
  status: status,
166
174
  ids: ids,
167
175
  type: type,
168
- agent: agent,
176
+ flow: flow,
177
+ tags: tags,
169
178
  key_type: key_type,
170
179
  key_id: key_id,
171
180
  user: user,
@@ -175,7 +184,7 @@ module StarkInfra
175
184
 
176
185
  # # Update a PixClaim entity
177
186
  #
178
- # Respond to a received PixClaim.
187
+ # Update a PixClaim parameters by passing id.
179
188
  #
180
189
  # ## Parameters (required):
181
190
  # - id [string]: PixClaim unique id. ex: '5656565656565656'
@@ -186,7 +195,7 @@ module StarkInfra
186
195
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
187
196
  #
188
197
  # ## Return:
189
- # - updated PixClaim object
198
+ # - updated PixClaim object with updated attributes
190
199
  def self.update(id, status:, reason: nil, user: nil)
191
200
  StarkInfra::Utils::Rest.patch_id(
192
201
  id: id,
@@ -202,6 +211,7 @@ module StarkInfra
202
211
  resource_name: 'PixClaim',
203
212
  resource_maker: proc { |json|
204
213
  PixClaim.new(
214
+ id: json['id'],
205
215
  account_created: json['account_created'],
206
216
  account_number: json['account_number'],
207
217
  account_type: json['account_type'],
@@ -209,12 +219,12 @@ module StarkInfra
209
219
  name: json['name'],
210
220
  tax_id: json['tax_id'],
211
221
  key_id: json['key_id'],
212
- id: json['id'],
222
+ tags: json['tags'],
213
223
  status: json['status'],
214
224
  type: json['type'],
215
225
  key_type: json['key_type'],
216
- agent: json['agent'],
217
- bank_code: json['bank_code'],
226
+ flow: json['flow'],
227
+ claimer_bank_code: json['claimer_bank_code'],
218
228
  claimed_bank_code: json['claimed_bank_code'],
219
229
  created: json['created'],
220
230
  updated: json['updated']
@@ -1,16 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative('../utils/resource')
4
3
  require_relative('../utils/rest')
4
+ require_relative('../utils/resource')
5
5
 
6
6
  module StarkInfra
7
7
  # # PixDirector object
8
8
  #
9
9
  # Mandatory data that must be registered within the Central Bank for
10
- # emergency contact purposes. When you initialize a PixDirector,
11
- # the entity will not be automatically created in the Stark Infra API.
12
- # The 'create' function sends the objects to the Stark Infra API and
13
- # returns the list of created objects.
10
+ # emergency contact purposes.
11
+ #
12
+ # When you initialize a PixDirector, the entity will not be automatically
13
+ # created in the Stark Infra API. The 'create' function sends the objects
14
+ # to the Stark Infra API and returns the created object.
14
15
  #
15
16
  # ## Parameters (required):
16
17
  # - name [string]: name of the PixDirector. ex: 'Edward Stark'.
@@ -22,12 +23,10 @@ module StarkInfra
22
23
  # - team_phones [list of strings]: list of phones of the team. ex: ['+5511988889999', '+5511988889998']
23
24
  #
24
25
  # ## Attributes (return-only):
25
- # - id [string]: unique id returned when the PixDirector is created. ex: '5656565656565656'
26
26
  # - status [string]: current PixDirector status. ex: 'success'
27
- class PixDirector < StarkInfra::Utils::Resource
28
- attr_reader :name, :tax_id, :phone, :email, :password, :team_email, :team_phones, :id, :status
29
- def initialize(name:, tax_id:, phone:, email:, password:, team_email:, team_phones:, id: nil, status: nil)
30
- super(id)
27
+ class PixDirector < StarkInfra::Utils::SubResource
28
+ attr_reader :name, :tax_id, :phone, :email, :password, :team_email, :team_phones, :status
29
+ def initialize(name:, tax_id:, phone:, email:, password:, team_email:, team_phones:, status: nil)
31
30
  @name = name
32
31
  @tax_id = tax_id
33
32
  @phone = phone
@@ -59,7 +58,6 @@ module StarkInfra
59
58
  resource_name: 'PixDirector',
60
59
  resource_maker: proc { |json|
61
60
  PixDirector.new(
62
- id: json['id'],
63
61
  name: json['name'],
64
62
  tax_id: json['tax_id'],
65
63
  phone: json['phone'],
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative('../utils/resource')
4
3
  require_relative('../utils/rest')
4
+ require_relative('../utils/resource')
5
5
 
6
6
  module StarkInfra
7
7
  # # PixDomain::Certificate object
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative('../utils/resource')
4
- require_relative('../utils/rest')
5
3
  require_relative('certificate')
4
+ require_relative('../utils/rest')
5
+ require_relative('../utils/resource')
6
6
 
7
7
  module StarkInfra
8
8
  # # PixDomain object
9
9
  #
10
- # The PixDomain object displays the domain name and the QR Code
11
- # domain certificate of Pix participants.
10
+ # The PixDomain object displays the domain name and the QR Code domain
11
+ # certificate of Pix participants.
12
12
  # All certificates must be registered with the Central Bank.
13
13
  #
14
14
  # ## Attributes (return-only):
@@ -23,7 +23,7 @@ module StarkInfra
23
23
 
24
24
  # # Retrieve PixDomains
25
25
  #
26
- # Receive a generator of PixDomain objects registered at the Central Bank.
26
+ # Receive a generator of PixDomain objects.
27
27
  #
28
28
  # ## Parameters (optional):
29
29
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative('../utils/resource')
3
+ require_relative('pixinfraction')
4
4
  require_relative('../utils/rest')
5
5
  require_relative('../utils/checks')
6
- require_relative('pixinfraction')
6
+ require_relative('../utils/resource')
7
7
 
8
8
  module StarkInfra
9
9
  class PixInfraction
@@ -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)
18
+ # - infraction [PixInfraction]: PixInfraction entity to which the log refers to.
19
19
  # - type [string]: type of the PixInfraction event which triggered the log creation. Options: 'created', 'failed', 'delivering', 'delivered', 'closed', 'canceled'
20
20
  # - errors [list of strings]: list of errors linked to this PixInfraction event.
21
- # - infraction [PixInfraction]: PixInfraction entity to which the log refers to.
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, :infraction
24
24
  def initialize(id:, created:, type:, errors:, infraction:)
25
25
  super(id)
26
- @created = StarkInfra::Utils::Checks.check_datetime(created)
26
+ @infraction = infraction
27
27
  @type = type
28
28
  @errors = errors
29
- @infraction = infraction
29
+ @created = StarkInfra::Utils::Checks.check_datetime(created)
30
30
  end
31
31
 
32
- # # Retrieve a specific Log
32
+ # # Retrieve a specific PixInfraction::Log
33
33
  #
34
- # Receive a single Log object previously created by the Stark Infra API by passing its id
34
+ # Receive a single PixInfraction::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'
@@ -40,26 +40,26 @@ module StarkInfra
40
40
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
41
41
  #
42
42
  # ## Return:
43
- # - Log object with updated attributes
43
+ # - PixInfraction::Log object with updated attributes
44
44
  def self.get(id, user: nil)
45
45
  StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
46
46
  end
47
47
 
48
- # # Retrieve Logs
48
+ # # Retrieve PixInfraction::Logs
49
49
  #
50
- # Receive a generator of Log objects previously created in the Stark Infra API
50
+ # Receive a generator of PixInfraction::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 PixInfraction 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)
57
56
  # - types [list of strings, default nil]: filter retrieved objects by their types. Options: 'created', 'failed', 'delivering', 'delivered', 'closed', 'canceled'
58
57
  # - infraction_ids [list of strings, default nil]: list of PixInfraction ids to filter retrieved objects. ex: %w[5656565656565656 4545454545454545]
58
+ # - ids [list of strings, default nil]: Log ids to filter PixInfraction Logs. ex: ['5656565656565656']
59
59
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
60
60
  #
61
61
  # ## Return:
62
- # - list of Log objects with updated attributes
62
+ # - list of PixInfraction::Log objects with updated attributes
63
63
  def self.query(ids: nil, limit: nil, after: nil, before: nil, types: nil, infraction_ids: nil, user: nil)
64
64
  after = StarkInfra::Utils::Checks.check_date(after)
65
65
  before = StarkInfra::Utils::Checks.check_date(before)
@@ -75,23 +75,23 @@ module StarkInfra
75
75
  )
76
76
  end
77
77
 
78
- # # Retrieve paged Logs
78
+ # # Retrieve paged PixInfraction::Logs
79
79
  #
80
- # Receive a list of up to 100 Log objects previously created in the Stark Infra API and the cursor to the next page.
80
+ # Receive a list of up to 100 PixInfraction::Log objects previously created in the Stark Infra API and the cursor to the next page.
81
81
  # Use this function instead of query if you want to manually page your infractions.
82
82
  #
83
83
  # ## Parameters (optional):
84
84
  # - cursor [string, default nil]: cursor returned on the previous page function call
85
- # - ids [list of strings, default nil]: Log ids to filter PixInfraction Logs. ex: ['5656565656565656']
86
85
  # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
87
86
  # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
88
87
  # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
89
88
  # - types [list of strings, default nil]: filter retrieved objects by their types. Options: 'created', 'failed', 'delivering', 'delivered', 'closed', 'canceled'
90
89
  # - infraction_ids [list of strings, default nil]: list of PixInfraction ids to filter retrieved objects. ex: %w[5656565656565656 4545454545454545]
90
+ # - ids [list of strings, default nil]: Log ids to filter PixInfraction Logs. ex: ['5656565656565656']
91
91
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
92
92
  #
93
93
  # ## Return:
94
- # - list of Log objects with updated attributes
94
+ # - list of PixInfraction::Log objects with updated attributes
95
95
  # - Cursor to retrieve the next page of Log objects
96
96
  def self.page(cursor: nil, ids: nil, limit: nil, after: nil, before: nil, types: nil, infraction_ids: nil, user: nil)
97
97
  after = StarkInfra::Utils::Checks.check_date(after)
@@ -116,10 +116,10 @@ module StarkInfra
116
116
  resource_maker: proc { |json|
117
117
  Log.new(
118
118
  id: json['id'],
119
- created: json['created'],
119
+ infraction: StarkInfra::Utils::API.from_api_json(infraction_maker, json['infraction']),
120
120
  type: json['type'],
121
121
  errors: json['errors'],
122
- infraction: StarkInfra::Utils::API.from_api_json(infraction_maker, json['infraction'])
122
+ created: json['created'],
123
123
  )
124
124
  }
125
125
  }
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative('../utils/resource')
4
3
  require_relative('../utils/rest')
5
4
  require_relative('../utils/checks')
5
+ require_relative('../utils/resource')
6
6
 
7
7
  module StarkInfra
8
8
  # # PixInfraction object
@@ -19,35 +19,35 @@ module StarkInfra
19
19
  #
20
20
  # ## Parameters (optional):
21
21
  # - description [string, default nil]: description for any details that can help with the infraction investigation.
22
+ # - tags [list of strings, default nil]: list of strings for tagging. ex: ['travel', 'food']
22
23
  #
23
24
  # ## Attributes (return-only):
24
25
  # - id [string]: unique id returned when the PixInfraction is created. ex: '5656565656565656'
25
26
  # - credited_bank_code [string]: bank_code of the credited Pix participant in the reported transaction. ex: '20018183'
26
27
  # - debited_bank_code [string]: bank_code of the debited Pix participant in the reported transaction. ex: '20018183'
27
- # - agent [string]: Options: 'reporter' if you created the PixInfraction, 'reported' if you received the PixInfraction.
28
+ # - flow [string]: direction of the PixInfraction flow. Options: 'out' if you created the PixInfraction, 'in' if you received the PixInfraction.
28
29
  # - analysis [string]: analysis that led to the result.
29
- # - bacen_id [string]: central bank's unique UUID that identifies the infraction report.
30
30
  # - reported_by [string]: agent that reported the PixInfraction. Options: 'debited', 'credited'.
31
31
  # - result [string]: result after the analysis of the PixInfraction by the receiving party. Options: 'agreed', 'disagreed'
32
32
  # - status [string]: current PixInfraction status. Options: 'created', 'failed', 'delivered', 'closed', 'canceled'.
33
33
  # - created [DateTime]: creation datetime for the PixInfraction. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
34
34
  # - updated [DateTime]: latest update datetime for the PixInfraction. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
35
35
  class PixInfraction < StarkInfra::Utils::Resource
36
- attr_reader :reference_id, :type, :description, :id, :credited_bank_code, :agent, :analysis, :bacen_id,
36
+ attr_reader :reference_id, :type, :description, :tags, :id, :credited_bank_code, :flow, :analysis,
37
37
  :debited_bank_code, :reported_by, :result, :status, :created, :updated
38
38
  def initialize(
39
- reference_id:, type:, description:, id: nil, credited_bank_code: nil, agent: nil, analysis: nil, bacen_id: nil,
40
- debited_bank_code: nil, reported_by: nil, result: nil, status: nil, created: nil, updated: nil
39
+ reference_id:, type:, description: nil, id: nil, tags: nil, credited_bank_code: nil, debited_bank_code: nil,
40
+ flow: nil, analysis: nil, reported_by: nil, result: nil, status: nil, created: nil, updated: nil
41
41
  )
42
42
  super(id)
43
43
  @reference_id = reference_id
44
44
  @type = type
45
45
  @description = description
46
+ @tags = tags
46
47
  @credited_bank_code = credited_bank_code
47
- @agent = agent
48
- @analysis = analysis
49
- @bacen_id = bacen_id
50
48
  @debited_bank_code = debited_bank_code
49
+ @flow = flow
50
+ @analysis = analysis
51
51
  @reported_by = reported_by
52
52
  @result = result
53
53
  @status = status
@@ -98,11 +98,13 @@ module StarkInfra
98
98
  # - status [string, default nil]: filter for status of retrieved objects. ex: 'success' or 'failed'
99
99
  # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
100
100
  # - type [string]: filter for the type of retrieved PixInfractions. Options: 'fraud', 'reversal', 'reversalChargeback'
101
+ # - flow [string, default nil]: direction of the PixInfraction flow. Options: 'out' if you created the PixInfraction, 'in' if you received the PixInfraction.
102
+ # - tags [list of strings, default nil]: list of strings for tagging. ex: ['travel', 'food']
101
103
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
102
104
  #
103
105
  # ## Return:
104
106
  # - generator of PixInfraction objects with updated attributes
105
- def self.query(limit: nil, after: nil, before: nil, status: nil, ids: nil, type: nil, user: nil)
107
+ def self.query(limit: nil, after: nil, before: nil, status: nil, ids: nil, type: nil, flow: nil, tags: nil, user: nil)
106
108
  after = StarkInfra::Utils::Checks.check_date(after)
107
109
  before = StarkInfra::Utils::Checks.check_date(before)
108
110
  StarkInfra::Utils::Rest.get_stream(
@@ -112,6 +114,8 @@ module StarkInfra
112
114
  status: status,
113
115
  ids: ids,
114
116
  type: type,
117
+ flow: flow,
118
+ tags: tags,
115
119
  user: user,
116
120
  **resource
117
121
  )
@@ -130,12 +134,14 @@ module StarkInfra
130
134
  # - status [string, default nil]: filter for status of retrieved objects. ex: 'success' or 'failed'
131
135
  # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
132
136
  # - type [string, default nil]: filter for the type of retrieved PixInfractions. Options: 'fraud', 'reversal', 'reversalChargeback'
137
+ # - flow [string, default nil]: direction of the PixInfraction flow. Options: 'out' if you created the PixInfraction, 'in' if you received the PixInfraction.
138
+ # - tags [list of strings, default nil]: list of strings for tagging. ex: ['travel', 'food']
133
139
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
134
140
  #
135
141
  # ## Return:
136
142
  # - list of PixInfraction objects with updated attributes
137
143
  # - cursor to retrieve the next page of PixInfraction objects
138
- def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, ids: nil, type: nil, user: nil)
144
+ def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, ids: nil, flow: nil, tags: nil, type: nil, user: nil)
139
145
  after = StarkInfra::Utils::Checks.check_date(after)
140
146
  before = StarkInfra::Utils::Checks.check_date(before)
141
147
  StarkInfra::Utils::Rest.get_page(
@@ -145,6 +151,8 @@ module StarkInfra
145
151
  before: before,
146
152
  status: status,
147
153
  ids: ids,
154
+ flow: flow,
155
+ tags: tags,
148
156
  type: type,
149
157
  user: user,
150
158
  **resource
@@ -164,7 +172,7 @@ module StarkInfra
164
172
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
165
173
  #
166
174
  # ## Return:
167
- # - updated PixInfraction object
175
+ # - PixInfraction object with updated attributes
168
176
  def self.update(id, result:, analysis: nil, user: nil)
169
177
  StarkInfra::Utils::Rest.patch_id(id: id, result: result, analysis: analysis, user: user, **resource)
170
178
  end
@@ -194,11 +202,11 @@ module StarkInfra
194
202
  reference_id: json['reference_id'],
195
203
  type: json['type'],
196
204
  description: json['description'],
205
+ tags: json['tags'],
197
206
  credited_bank_code: json['credited_bank_code'],
198
- agent: json['agent'],
199
- analysis: json['analysis'],
200
- bacen_id: json['bacen_id'],
201
207
  debited_bank_code: json['debited_bank_code'],
208
+ flow: json['flow'],
209
+ analysis: json['analysis'],
202
210
  reported_by: json['reported_by'],
203
211
  result: json['result'],
204
212
  status: json['status'],