starkinfra 0.0.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/lib/brcodepreview/brcodepreview.rb +121 -0
  3. data/lib/cardmethod/cardmethod.rb +56 -0
  4. data/lib/creditnote/creditnote.rb +58 -341
  5. data/lib/creditnote/invoice/description.rb +51 -0
  6. data/lib/creditnote/invoice/discount.rb +49 -0
  7. data/lib/creditnote/invoice/invoice.rb +123 -0
  8. data/lib/creditnote/log.rb +2 -2
  9. data/lib/creditnote/transfer.rb +90 -0
  10. data/lib/creditpreview/creditnotepreview.rb +85 -0
  11. data/lib/creditpreview/creditpreview.rb +83 -0
  12. data/lib/creditsigner/creditsigner.rb +57 -0
  13. data/lib/dynamicbrcode/dynamicbrcode.rb +350 -0
  14. data/lib/event/attempt.rb +4 -3
  15. data/lib/event/event.rb +10 -10
  16. data/lib/issuingbalance/issuingbalance.rb +4 -4
  17. data/lib/issuingcard/issuingcard.rb +40 -36
  18. data/lib/issuingcard/log.rb +3 -3
  19. data/lib/issuingholder/issuingholder.rb +14 -9
  20. data/lib/issuingholder/log.rb +3 -3
  21. data/lib/issuinginvoice/issuinginvoice.rb +24 -10
  22. data/lib/issuinginvoice/log.rb +3 -3
  23. data/lib/issuingproduct/issuingproduct.rb +86 -0
  24. data/lib/issuingpurchase/issuingpurchase.rb +100 -24
  25. data/lib/issuingpurchase/log.rb +2 -2
  26. data/lib/issuingrule/issuingrule.rb +74 -30
  27. data/lib/issuingtransaction/issuingtransaction.rb +6 -8
  28. data/lib/issuingwithdrawal/issuingwithdrawal.rb +11 -7
  29. data/lib/merchantcategory/merchantcategory.rb +63 -0
  30. data/lib/merchantcountry/merchantcountry.rb +59 -0
  31. data/lib/pixbalance/pixbalance.rb +5 -5
  32. data/lib/pixchargeback/log.rb +3 -3
  33. data/lib/pixchargeback/pixchargeback.rb +32 -20
  34. data/lib/pixclaim/log.rb +8 -11
  35. data/lib/pixclaim/pixclaim.rb +43 -32
  36. data/lib/pixdirector/pixdirector.rb +9 -11
  37. data/lib/pixdomain/certificate.rb +1 -1
  38. data/lib/pixdomain/pixdomain.rb +4 -4
  39. data/lib/pixinfraction/log.rb +2 -2
  40. data/lib/pixinfraction/pixinfraction.rb +21 -13
  41. data/lib/pixkey/log.rb +5 -5
  42. data/lib/pixkey/pixkey.rb +12 -10
  43. data/lib/pixrequest/log.rb +2 -2
  44. data/lib/pixrequest/pixrequest.rb +51 -21
  45. data/lib/pixreversal/log.rb +2 -2
  46. data/lib/pixreversal/pixreversal.rb +48 -20
  47. data/lib/pixstatement/pixstatement.rb +12 -7
  48. data/lib/starkinfra.rb +27 -15
  49. data/lib/staticbrcode/staticbrcode.rb +164 -0
  50. data/lib/user/project.rb +1 -1
  51. data/lib/utils/api.rb +1 -0
  52. data/lib/utils/parse.rb +7 -3
  53. data/lib/utils/request.rb +1 -1
  54. data/lib/utils/resource.rb +1 -1
  55. data/lib/utils/rest.rb +1 -2
  56. data/lib/utils/sub_resource.rb +21 -22
  57. data/lib/webhook/webhook.rb +3 -3
  58. metadata +16 -4
  59. data/lib/issuingauthorization/issuingauthorization.rb +0 -141
  60. data/lib/issuingbin/issuingbin.rb +0 -89
data/lib/pixclaim/log.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative('../utils/resource')
3
+ require_relative('pixclaim')
4
4
  require_relative('../utils/rest')
5
5
  require_relative('../utils/checks')
6
- require_relative('pixclaim')
6
+ require_relative('../utils/resource')
7
7
 
8
8
  module StarkInfra
9
9
  class PixClaim
@@ -18,17 +18,15 @@ module StarkInfra
18
18
  # - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
19
19
  # - type [string]: type of the PixClaim event which triggered the log creation. Options: 'created', 'failed', 'delivering', 'delivered', 'confirming', 'confirmed', 'success', 'canceling', 'canceled'.
20
20
  # - errors [list of strings]: list of errors linked to this PixClaim event.
21
- # - agent [string]: agent that modified the PixClaim resulting in the Log. Options: 'claimer', 'claimed'.
22
21
  # - reason [string]: reason why the PixClaim was modified, resulting in the Log. Options: 'fraud', 'userRequested', 'accountClosure', 'defaultOperation', 'reconciliation'
23
22
  # - claim [PixClaim]: PixClaim entity to which the log refers to.
24
23
  class Log < StarkInfra::Utils::Resource
25
- attr_reader :id, :created, :type, :errors, :agent, :reason, :claim
26
- def initialize(id:, created:, type:, errors:, agent:, reason:, claim:)
24
+ attr_reader :id, :created, :type, :errors, :reason, :claim
25
+ def initialize(id:, created:, type:, errors:, reason:, claim:)
27
26
  super(id)
28
27
  @created = StarkInfra::Utils::Checks.check_datetime(created)
29
28
  @type = type
30
29
  @errors = errors
31
- @agent = agent
32
30
  @reason = reason
33
31
  @claim = claim
34
32
  end
@@ -58,8 +56,8 @@ module StarkInfra
58
56
  # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
59
57
  # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
60
58
  # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
61
- # - types [list of strings]: filter PixClaim Logs by their types. Options: 'created', 'failed', 'delivering', 'delivered', 'confirming', 'confirmed', 'success', 'canceling', 'canceled'.
62
- # - claim_ids [list of strings, default nil]: list of PixClaim ids to filter retrieved objects. ex: %w[5656565656565656 4545454545454545]
59
+ # - types [list of strings, default nil]: filter PixClaim Logs by their types. Options: 'created', 'failed', 'delivering', 'delivered', 'confirming', 'confirmed', 'success', 'canceling', 'canceled'.
60
+ # - claim_ids [list of strings, default nil]: list of PixClaim ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
63
61
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
64
62
  #
65
63
  # ## Return:
@@ -90,8 +88,8 @@ module StarkInfra
90
88
  # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
91
89
  # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
92
90
  # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
93
- # - types [list of strings]: filter PixClaim Logs by their types. Options: 'created', 'failed', 'delivering', 'delivered', 'confirming', 'confirmed', 'success', 'canceling', 'canceled'.
94
- # - claim_ids [list of strings, default nil]: list of PixClaim ids to filter retrieved objects. ex: %w[5656565656565656 4545454545454545]
91
+ # - types [list of strings, default nil]: filter PixClaim Logs by their types. Options: 'created', 'failed', 'delivering', 'delivered', 'confirming', 'confirmed', 'success', 'canceling', 'canceled'.
92
+ # - claim_ids [list of strings, default nil]: list of PixClaim ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
95
93
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
96
94
  #
97
95
  # ## Return:
@@ -123,7 +121,6 @@ module StarkInfra
123
121
  created: json['created'],
124
122
  type: json['type'],
125
123
  errors: json['errors'],
126
- agent: json['agent'],
127
124
  reason: json['reason'],
128
125
  claim: StarkInfra::Utils::API.from_api_json(claim_maker, json['claim'])
129
126
  )
@@ -1,42 +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
- attr_reader :account_created, :account_number, :account_type, :branch_code, :name, :tax_id, :key_id, :id, :status, :type, :key_type, :agent, :bank_code, :claimed_bank_code, :created, :updated
40
+ attr_reader :account_created, :account_number, :account_type, :branch_code, :name, :tax_id, :key_id,
41
+ :tags, :id, :status, :type, :key_type, :flow, :claimer_bank_code, :claimed_bank_code, :created, :updated
36
42
  def initialize(
37
43
  account_created:, account_number:, account_type:, branch_code:, name:,
38
- tax_id:, key_id:, id: nil, status: nil, type: nil, key_type: nil, agent: nil,
39
- 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
40
46
  )
41
47
  super(id)
42
48
  @account_created = account_created
@@ -46,22 +52,24 @@ module StarkInfra
46
52
  @name = name
47
53
  @tax_id = tax_id
48
54
  @key_id = key_id
55
+ @tags = tags
49
56
  @status = status
50
57
  @type = type
51
58
  @key_type = key_type
52
- @agent = agent
53
- @bank_code = bank_code
59
+ @flow = flow
60
+ @claimer_bank_code = claimer_bank_code
54
61
  @claimed_bank_code = claimed_bank_code
55
62
  @created = StarkInfra::Utils::Checks.check_datetime(created)
56
63
  @updated = StarkInfra::Utils::Checks.check_datetime(updated)
57
64
  end
58
65
 
59
- # # Create a PixClaim
66
+ # # Create a PixClaim object
60
67
  #
61
- # Send a PixClaim object for creation in the Stark Infra API
68
+ # Create a PixClaim to request the transfer of a Pix Key from an account
69
+ # hosted at another Pix participants to an account under you bank code.
62
70
  #
63
71
  # ## Parameters (required):
64
- # - 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.
65
73
  #
66
74
  # ## Parameters (optional):
67
75
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
@@ -72,9 +80,9 @@ module StarkInfra
72
80
  StarkInfra::Utils::Rest.post_single(entity: claim, user: user, **resource)
73
81
  end
74
82
 
75
- # # Retrieve a specific PixClaim
83
+ # # Retrieve a PixClaim object
76
84
  #
77
- # 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.
78
86
  #
79
87
  # ## Parameters (required):
80
88
  # - id [string]: object unique id. ex: '5656565656565656'
@@ -83,7 +91,7 @@ module StarkInfra
83
91
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
84
92
  #
85
93
  # ## Return:
86
- # - PixClaim object with updated attributes
94
+ # - PixClaim object that corresponds to the given id.
87
95
  def self.get(id, user: nil)
88
96
  StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
89
97
  end
@@ -97,19 +105,19 @@ module StarkInfra
97
105
  # - after [Date or string, default nil]: date filter for objects created or updated only after specified date. ex: Date.new(2020, 3, 10)
98
106
  # - before [Date or string, default nil]: date filter for objects created or updated only before specified date. ex: Date.new(2020, 3, 10)
99
107
  # - status [string, default nil]: filter for status of retrieved objects. Options: 'created', 'failed', 'delivered', 'confirmed', 'success', 'canceled'
100
- # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
101
108
  # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
102
109
  # - type [string, default nil]: filter for the type of retrieved PixClaims. Options: 'ownership' or 'portability'
103
- # - agent [string, default nil]: filter for the agent of retrieved PixClaims. Options: 'claimer' or 'claimed'.
104
110
  # - key_type [string, default nil]: filter for the PixKey type of retrieved PixClaims. Options: 'cpf', 'cnpj', 'phone', 'email' and 'evp',
105
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']
106
114
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
107
115
  #
108
116
  # ## Return:
109
117
  # - generator of PixClaim objects with updated attributes
110
118
  def self.query(
111
119
  limit: nil, after: nil, before: nil, status: nil, ids: nil,
112
- 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
113
121
  )
114
122
  after = StarkInfra::Utils::Checks.check_date(after)
115
123
  before = StarkInfra::Utils::Checks.check_date(before)
@@ -120,7 +128,8 @@ module StarkInfra
120
128
  status: status,
121
129
  ids: ids,
122
130
  type: type,
123
- agent: agent,
131
+ flow: flow,
132
+ tags: tags,
124
133
  key_type: key_type,
125
134
  key_id: key_id,
126
135
  user: user,
@@ -139,12 +148,12 @@ module StarkInfra
139
148
  # - after [Date or string, default nil]: date filter for objects created or updated only after specified date. ex: Date.new(2020, 3, 10)
140
149
  # - before [Date or string, default nil]: date filter for objects created or updated only before specified date. ex: Date.new(2020, 3, 10)
141
150
  # - status [string, default nil]: filter for status of retrieved objects. Options: 'created', 'failed', 'delivered', 'confirmed', 'success', 'canceled'
142
- # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
143
151
  # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
144
152
  # - type [string, default nil]: filter for the type of retrieved PixClaims. Options: 'ownership' or 'portability'
145
- # - agent [string, default nil]: filter for the agent of retrieved PixClaims. Options: 'claimer' or 'claimed'.
146
153
  # - key_type [string, default nil]: filter for the PixKey type of retrieved PixClaims. Options: 'cpf', 'cnpj', 'phone', 'email' and 'evp',
147
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']
148
157
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
149
158
  #
150
159
  # ## Return:
@@ -152,7 +161,7 @@ module StarkInfra
152
161
  # - cursor to retrieve the next page of PixClaim objects
153
162
  def self.page(
154
163
  cursor: nil, limit: nil, after: nil, before: nil, status: nil, ids: nil,
155
- 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
156
165
  )
157
166
  after = StarkInfra::Utils::Checks.check_date(after)
158
167
  before = StarkInfra::Utils::Checks.check_date(before)
@@ -164,7 +173,8 @@ module StarkInfra
164
173
  status: status,
165
174
  ids: ids,
166
175
  type: type,
167
- agent: agent,
176
+ flow: flow,
177
+ tags: tags,
168
178
  key_type: key_type,
169
179
  key_id: key_id,
170
180
  user: user,
@@ -201,6 +211,7 @@ module StarkInfra
201
211
  resource_name: 'PixClaim',
202
212
  resource_maker: proc { |json|
203
213
  PixClaim.new(
214
+ id: json['id'],
204
215
  account_created: json['account_created'],
205
216
  account_number: json['account_number'],
206
217
  account_type: json['account_type'],
@@ -208,12 +219,12 @@ module StarkInfra
208
219
  name: json['name'],
209
220
  tax_id: json['tax_id'],
210
221
  key_id: json['key_id'],
211
- id: json['id'],
222
+ tags: json['tags'],
212
223
  status: json['status'],
213
224
  type: json['type'],
214
225
  key_type: json['key_type'],
215
- agent: json['agent'],
216
- bank_code: json['bank_code'],
226
+ flow: json['flow'],
227
+ claimer_bank_code: json['claimer_bank_code'],
217
228
  claimed_bank_code: json['claimed_bank_code'],
218
229
  created: json['created'],
219
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):
@@ -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
@@ -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,34 +19,34 @@ 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
+ @flow = flow
48
49
  @analysis = analysis
49
- @bacen_id = bacen_id
50
50
  @debited_bank_code = debited_bank_code
51
51
  @reported_by = reported_by
52
52
  @result = result
@@ -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
@@ -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'],
data/lib/pixkey/log.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative('../utils/resource')
3
+ require_relative('pixkey')
4
4
  require_relative('../utils/rest')
5
5
  require_relative('../utils/checks')
6
- require_relative('pixkey')
6
+ require_relative('../utils/resource')
7
7
 
8
8
  module StarkInfra
9
9
  class PixKey
@@ -54,7 +54,7 @@ module StarkInfra
54
54
  # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
55
55
  # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
56
56
  # - types [list of strings, default nil]: filter PixKey Logs by their types. Options: 'created', 'registered', 'updated', 'failed', 'canceling', 'canceled'.
57
- # - key_ids [list of strings, default nil]: list of PixKey ids to filter retrieved objects. ex: %w[5656565656565656 4545454545454545]
57
+ # - key_ids [list of strings, default nil]: list of PixKey ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
58
58
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
59
59
  #
60
60
  # ## Return:
@@ -85,8 +85,8 @@ module StarkInfra
85
85
  # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
86
86
  # - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
87
87
  # - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
88
- # - types [list of strings]: filter PixKey Logs by their types. Options: 'created', 'registered', 'updated', 'failed', 'canceling', 'canceled'.
89
- # - key_ids [list of strings, default nil]: list of PixKey ids to filter retrieved objects. ex: %w[5656565656565656 4545454545454545]
88
+ # - types [list of strings, default nil]: filter PixKey Logs by their types. Options: 'created', 'registered', 'updated', 'failed', 'canceling', 'canceled'.
89
+ # - key_ids [list of strings, default nil]: list of PixKey ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
90
90
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
91
91
  #
92
92
  # ## Return:
data/lib/pixkey/pixkey.rb CHANGED
@@ -1,19 +1,20 @@
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
  # # PixKey object
9
9
  # PixKeys link bank account information to key ids.
10
10
  # Key ids are a convenient way to search and pass bank account information.
11
+ #
11
12
  # When you initialize a Pix Key, the entity will not be automatically
12
13
  # created in the Stark Infra API. The 'create' function sends the objects
13
14
  # to the Stark Infra API and returns the created object.
14
15
  #
15
16
  # ## Parameters (required):
16
- # - account_created [DateTime, Date or string]: opening Date or DateTime for the linked account. ex: '2022-01-01T12:00:00:00'.
17
+ # - account_created [DateTime or string]: opening Date or DateTime for the linked account. ex: '2020-03-10T10:30:00.000000+00:00' or DateTime.new(2020, 3, 10, 10, 30, 0, 0).
17
18
  # - account_number [string]: number of the linked account. ex: '76543'.
18
19
  # - account_type [string]: type of the linked account. Options: 'checking', 'savings', 'salary' or 'payment'.
19
20
  # - branch_code [string]: branch code of the linked account. ex: '1234'.
@@ -33,7 +34,8 @@ module StarkInfra
33
34
  # - type [string]: type of the PixKey. Options: 'cpf', 'cnpj', 'phone', 'email' and 'evp',
34
35
  # - created [DateTime]: creation datetime for the PixKey. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
35
36
  class PixKey < StarkInfra::Utils::Resource
36
- attr_reader :account_created, :account_number, :account_type, :branch_code, :name, :tax_id, :id, :tags, :owned, :owner_type, :status, :bank_code, :bank_name, :type, :created
37
+ attr_reader :account_created, :account_number, :account_type, :branch_code, :name, :tax_id, :id,
38
+ :tags, :owned, :owner_type, :status, :bank_code, :bank_name, :type, :created
37
39
  def initialize(
38
40
  account_created:, account_number:, account_type:, branch_code:, name:, tax_id:, id: nil, tags: nil, owned: nil,
39
41
  owner_type: nil, status: nil, bank_code: nil, bank_name: nil, type: nil, created: nil
@@ -76,7 +78,7 @@ module StarkInfra
76
78
  # Receive a single PixKey object previously created in the Stark Infra API by passing its id
77
79
  #
78
80
  # ## Parameters (required):
79
- # - id [string]: object unique id. ex: '5656565656565656'
81
+ # - id [string]: object unique id. ex: '+5511989898989'
80
82
  # - 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'.
81
83
  #
82
84
  # ## Parameters (optional):
@@ -105,7 +107,7 @@ module StarkInfra
105
107
  # - before [Date or string, default nil]: date filter for objects created or updated only before specified date. ex: Date.new(2020, 3, 10)
106
108
  # - status [string, default nil]: filter for status of retrieved objects. ex: 'success' or 'failed'
107
109
  # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
108
- # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
110
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['+5511989898989', '+5511967676767']
109
111
  # - type [string, default nil]: filter for the type of retrieved PixKeys. Options: 'cpf', 'cnpj', 'phone', 'email' and 'evp'
110
112
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
111
113
  #
@@ -139,7 +141,7 @@ module StarkInfra
139
141
  # - before [Date or string, default nil]: date filter for objects created or updated only before specified date. ex: Date.new(2020, 3, 10)
140
142
  # - status [string, default nil]: filter for status of retrieved objects. ex: 'success' or 'failed'
141
143
  # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
142
- # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
144
+ # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['+5511989898989', '+5511967676767']
143
145
  # - type [string, default nil]: filter for the type of retrieved PixKeys. Options: 'cpf', 'cnpj', 'phone', 'email' and 'evp'
144
146
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
145
147
  #
@@ -168,11 +170,11 @@ module StarkInfra
168
170
  # Respond to a received PixKey.
169
171
  #
170
172
  # ## Parameters (required):
171
- # - id [string]: PixKey unique id. ex: '5656565656565656'
173
+ # - id [string]: PixKey unique id. ex: '+5511989898989'
172
174
  # - reason [string]: reason why the PixKey is being patched. Options: 'branchTransfer', 'reconciliation' or 'userRequested'.
173
175
  #
174
176
  # ## Parameters (optional):
175
- # - account_created [Date, DateTime or string, default nil]: opening Date or DateTime for the account to be linked. ex: '2022-01-01.
177
+ # - account_created [Date, DateTime or string, default nil]: opening Date or DateTime for the account to be linked. ex: '2022-01-01', Date.new(2020, 3, 10) or DateTime.new(2020, 3, 10, 10, 30, 0, 0)
176
178
  # - account_number [string, default nil]: number of the account to be linked. ex: '76543'.
177
179
  # - account_type [string, default nil]: type of the account to be linked. Options: 'checking', 'savings', 'salary' or 'payment'.
178
180
  # - branch_code [string, default nil]: branch code of the account to be linked. ex: 1234'.
@@ -200,7 +202,7 @@ module StarkInfra
200
202
  # Cancel a PixKey entity previously created in the Stark Infra API
201
203
  #
202
204
  # ## Parameters (required):
203
- # - id [string]: PixKey unique id. ex: '5656565656565656'
205
+ # - id [string]: PixKey unique id. ex: '+5511989898989'
204
206
  #
205
207
  # ## Parameters (optional):
206
208
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
@@ -216,13 +218,13 @@ module StarkInfra
216
218
  resource_name: 'PixKey',
217
219
  resource_maker: proc { |json|
218
220
  PixKey.new(
221
+ id: json['id'],
219
222
  account_created: json['account_created'],
220
223
  account_number: json['account_number'],
221
224
  account_type: json['account_type'],
222
225
  branch_code: json['branch_code'],
223
226
  name: json['name'],
224
227
  tax_id: json['tax_id'],
225
- id: json['id'],
226
228
  tags: json['tags'],
227
229
  owned: json['owned'],
228
230
  owner_type: json['owner_type'],
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative('../utils/resource')
3
+ require_relative('pixrequest')
4
4
  require_relative('../utils/rest')
5
5
  require_relative('../utils/checks')
6
- require_relative('pixrequest')
6
+ require_relative('../utils/resource')
7
7
 
8
8
  module StarkInfra
9
9
  class PixRequest