starkinfra 0.1.0 → 0.2.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 (58) 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 +37 -342
  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 +32 -29
  18. data/lib/issuingcard/log.rb +2 -2
  19. data/lib/issuingholder/issuingholder.rb +13 -8
  20. data/lib/issuingholder/log.rb +2 -2
  21. data/lib/issuinginvoice/issuinginvoice.rb +23 -9
  22. data/lib/issuinginvoice/log.rb +2 -2
  23. data/lib/{issuingbin/issuingbin.rb → issuingproduct/issuingproduct.rb} +27 -30
  24. data/lib/issuingpurchase/issuingpurchase.rb +99 -23
  25. data/lib/issuingpurchase/log.rb +1 -1
  26. data/lib/issuingrule/issuingrule.rb +64 -18
  27. data/lib/issuingtransaction/issuingtransaction.rb +5 -7
  28. data/lib/issuingwithdrawal/issuingwithdrawal.rb +10 -6
  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 +42 -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 +10 -9
  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 -21
  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/sub_resource.rb +21 -22
  56. data/lib/webhook/webhook.rb +3 -3
  57. metadata +16 -4
  58. data/lib/issuingauthorization/issuingauthorization.rb +0 -141
@@ -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
  # # IssuingTransaction object
@@ -20,9 +20,7 @@ module StarkInfra
20
20
  class IssuingTransaction < StarkInfra::Utils::Resource
21
21
  attr_reader :id, :amount, :balance, :description, :source, :tags, :created
22
22
 
23
- def initialize(
24
- id: nil, amount: nil, balance: nil, description: nil, source: nil, tags: nil, created: nil
25
- )
23
+ def initialize(id: nil, amount: nil, balance: nil, description: nil, source: nil, tags: nil, created: nil)
26
24
  super(id)
27
25
  @amount = amount
28
26
  @balance = balance
@@ -54,11 +52,11 @@ module StarkInfra
54
52
  #
55
53
  # ## Parameters (optional):
56
54
  # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
57
- # - external_ids [list of strings, default []]: external IDs. ex: ['5656565656565656', '4545454545454545']
55
+ # - external_ids [list of strings, default nil]: external IDs. ex: ['5656565656565656', '4545454545454545']
58
56
  # - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
59
57
  # - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
60
58
  # - status [string, default nil]: filter for status of retrieved objects. ex: 'approved', 'canceled', 'denied', 'confirmed' or 'voided'
61
- # - ids [list of strings, default [], default nil]: purchase IDs
59
+ # - ids [list of strings, default nil]: purchase IDs
62
60
  # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
63
61
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
64
62
  #
@@ -87,7 +85,7 @@ module StarkInfra
87
85
  # ## Parameters (optional):
88
86
  # - cursor [string, default nil]: cursor returned on the previous page function call.
89
87
  # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
90
- # - external_ids [list of strings, default nil: external IDs. ex: ['5656565656565656', '4545454545454545']
88
+ # - external_ids [list of strings, default nil]: external IDs. ex: ['5656565656565656', '4545454545454545']
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
91
  # - status [string, default nil]: filter for status of retrieved objects. ex: 'approved', 'canceled', 'denied', 'confirmed' or 'voided'
@@ -1,21 +1,25 @@
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
  # # IssuingWithdrawal object
9
9
  #
10
10
  # The IssuingWithdrawal objects created in your Workspace return cash from your Issuing balance to your Banking balance.
11
11
  #
12
+ # When you initialize a IssuingWithdrawal, 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.
15
+ #
12
16
  # ## Parameters (required):
13
17
  # - amount [integer]: IssuingWithdrawal value in cents. Minimum = 0 (any value will be accepted). ex: 1234 (= R$ 12.34)
14
18
  # - external_id [string] IssuingWithdrawal external ID. ex: '12345'
15
19
  # - description [string]: IssuingWithdrawal description. ex: 'sending money back'
16
20
  #
17
21
  # ## Parameters (optional):
18
- # - tags [list of strings, default []]: list of strings for tagging. ex: ['tony', 'stark']
22
+ # - tags [list of strings, default nil]: list of strings for tagging. ex: ['tony', 'stark']
19
23
  #
20
24
  # ## Attributes (return-only):
21
25
  # - id [string]: unique id returned when IssuingWithdrawal is created. ex: '5656565656565656'
@@ -36,8 +40,8 @@ module StarkInfra
36
40
  @tags = tags
37
41
  @transaction_id = transaction_id
38
42
  @issuing_transaction_id = issuing_transaction_id
39
- @created = StarkInfra::Utils::Checks.check_datetime(created)
40
43
  @updated = StarkInfra::Utils::Checks.check_datetime(updated)
44
+ @created = StarkInfra::Utils::Checks.check_datetime(created)
41
45
  end
42
46
 
43
47
  # # Create an IssuingWithdrawal
@@ -78,7 +82,7 @@ module StarkInfra
78
82
  #
79
83
  # ## Parameters (optional):
80
84
  # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
81
- # - external_ids [list of strings, default []]: external IDs. ex: ['5656565656565656', '4545454545454545']
85
+ # - external_ids [list of strings, default nil]: external IDs. ex: ['5656565656565656', '4545454545454545']
82
86
  # - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
83
87
  # - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
84
88
  # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
@@ -107,7 +111,7 @@ module StarkInfra
107
111
  # ## Parameters (optional):
108
112
  # - cursor [string, default nil]: cursor returned on the previous page function call.
109
113
  # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
110
- # - external_ids [list of strings, default []]: external IDs. ex: ['5656565656565656', '4545454545454545']
114
+ # - external_ids [list of strings, default nil]: external IDs. ex: ['5656565656565656', '4545454545454545']
111
115
  # - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
112
116
  # - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
113
117
  # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
@@ -136,11 +140,11 @@ module StarkInfra
136
140
  resource_name: 'IssuingWithdrawal',
137
141
  resource_maker: proc { |json|
138
142
  IssuingWithdrawal.new(
143
+ id: json['id'],
139
144
  amount: json['amount'],
140
145
  external_id: json['external_id'],
141
146
  description: json['description'],
142
147
  tags: json['tags'],
143
- id: json['id'],
144
148
  transaction_id: json['transaction_id'],
145
149
  issuing_transaction_id: json['issuing_transaction_id'],
146
150
  updated: json['updated'],
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative('../utils/rest')
4
+ require_relative('../utils/sub_resource')
5
+
6
+ module StarkInfra
7
+ # # MerchantCategory object
8
+ #
9
+ # MerchantCategory's codes and types are used to define categories filters in IssuingRules.
10
+ #
11
+ # A MerchantCategory filter must define exactly one parameter between code and type.
12
+ # A type, such as 'food', 'services', etc., defines an entire group of merchant codes,
13
+ # whereas a code only specifies a specific MCC.
14
+ #
15
+ # ## Parameters (conditionally required):
16
+ # - code [string, default nil]: category's code. ex: 'veterinaryServices', 'fastFoodRestaurants'
17
+ # - type [string, default nil]: category's type. ex: 'pets', 'food'
18
+ #
19
+ # Attributes (return-only):
20
+ # - name [string]: category's name. ex: 'Veterinary services', 'Fast food restaurants'
21
+ # - number [string]: category's number. ex: '742', '5814'
22
+ class MerchantCategory < StarkInfra::Utils::SubResource
23
+ attr_reader :code, :type, :name, :number
24
+ def initialize(code:, type:, name: nil, number: nil)
25
+ @code = code
26
+ @type = type
27
+ @name = name
28
+ @number = number
29
+ end
30
+
31
+ # # Retrieve MerchantCategories
32
+ #
33
+ # Receive a generator of MerchantCategory objects available in the Stark Infra API
34
+ #
35
+ # ## Parameters (optional):
36
+ # - search [string, default nil]: keyword to search for code, name, number or short_code
37
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
38
+ #
39
+ # ## Return:
40
+ # - generator of MerchantCategory objects with updated attributes
41
+ def self.query(search: nil, user: nil)
42
+ StarkInfra::Utils::Rest.get_stream(
43
+ search: search,
44
+ user: user,
45
+ **resource
46
+ )
47
+ end
48
+
49
+ def self.resource
50
+ {
51
+ resource_name: 'MerchantCategory',
52
+ resource_maker: proc { |json|
53
+ MerchantCategory.new(
54
+ code: json['code'],
55
+ type: json['type'],
56
+ name: json['name'],
57
+ number: json['number']
58
+ )
59
+ }
60
+ }
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative('../utils/rest')
4
+ require_relative('../utils/sub_resource')
5
+
6
+ module StarkInfra
7
+ # # MerchantCountry object
8
+ #
9
+ # MerchantCountry's codes are used to define countries filters in IssuingRules.
10
+ #
11
+ # ## Parameters (required):
12
+ # - code [string]: country's code. ex: 'BRA'
13
+ #
14
+ # Attributes (return-only):
15
+ # - name [string]: country's name. ex: 'Brazil'
16
+ # - number [string]: country's number. ex: '076'
17
+ # - short_code [string]: country's short code. ex: 'BR'
18
+ class MerchantCountry < StarkInfra::Utils::SubResource
19
+ attr_reader :code, :short_code, :name, :number
20
+ def initialize(code:, name: nil, number: nil, short_code: nil)
21
+ @code = code
22
+ @name = name
23
+ @number = number
24
+ @short_code = short_code
25
+ end
26
+
27
+ # # Retrieve MerchantCountries
28
+ #
29
+ # Receive a generator of MerchantCountry objects available in the Stark Infra API
30
+ #
31
+ # ## Parameters (optional):
32
+ # - search [string, default nil]: keyword to search for code, name, number or short_code
33
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
34
+ #
35
+ # ## Return:
36
+ # - generator of MerchantCountry objects with updated attributes
37
+ def self.query(search: nil, user: nil)
38
+ StarkInfra::Utils::Rest.get_stream(
39
+ search: search,
40
+ user: user,
41
+ **resource
42
+ )
43
+ end
44
+
45
+ def self.resource
46
+ {
47
+ resource_name: 'MerchantCountry',
48
+ resource_maker: proc { |json|
49
+ MerchantCountry.new(
50
+ code: json['code'],
51
+ name: json['name'],
52
+ number: json['number'],
53
+ short_code: json['short_code']
54
+ )
55
+ }
56
+ }
57
+ end
58
+ end
59
+ end
@@ -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
  # # PixBalance object
@@ -18,8 +18,8 @@ module StarkInfra
18
18
  # - currency [string]: currency of the current workspace. Expect others to be added eventually. ex: 'BRL'
19
19
  # - updated [DateTime]: latest update datetime for the balance. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
20
20
  class PixBalance < StarkInfra::Utils::Resource
21
- attr_reader :amount, :currency, :updated, :id
22
- def initialize(amount: nil, currency: nil, updated: nil, id: nil)
21
+ attr_reader :id, :amount, :currency, :updated
22
+ def initialize(id: nil, amount: nil, currency: nil, updated: nil)
23
23
  super(id)
24
24
  @amount = amount
25
25
  @currency = currency
@@ -44,10 +44,10 @@ module StarkInfra
44
44
  resource_name: 'PixBalance',
45
45
  resource_maker: proc { |json|
46
46
  PixBalance.new(
47
+ id: json['id'],
47
48
  amount: json['amount'],
48
49
  currency: json['currency'],
49
- updated: json['updated'],
50
- id: json['id']
50
+ updated: json['updated']
51
51
  )
52
52
  }
53
53
  }
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative('../utils/resource')
3
+ require_relative('pixchargeback')
4
4
  require_relative('../utils/rest')
5
5
  require_relative('../utils/checks')
6
- require_relative('pixchargeback')
6
+ require_relative('../utils/resource')
7
7
 
8
8
  module StarkInfra
9
9
  class PixChargeback
@@ -44,7 +44,7 @@ module StarkInfra
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
48
  # # Retrieve Logs
49
49
  #
50
50
  # Receive a generator of Log objects previously created in the Stark Infra API
@@ -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
  # # PixChargeback object
@@ -10,8 +10,10 @@ module StarkInfra
10
10
  # A Pix chargeback can be created when fraud is detected on a transaction or a system malfunction
11
11
  # results in an erroneous transaction.
12
12
  # It notifies another participant of your request to reverse the payment they have received.
13
+ #
13
14
  # When you initialize a PixChargeback, the entity will not be automatically
14
15
  # created in the Stark Infra API. The 'create' function sends the objects
16
+ # to the Stark Infra API and returns the created object.
15
17
  #
16
18
  # ## Parameters (required):
17
19
  # - amount [integer]: amount in cents to be reversed. ex: 11234 (= R$ 112.34)
@@ -20,40 +22,41 @@ module StarkInfra
20
22
  #
21
23
  # ## Parameters (optional):
22
24
  # - description [string, default nil]: description for the PixChargeback. ex: 'Payment for service #1234'
25
+ # - tags [list of strings, default nil]: list of strings for tagging. ex: ['travel', 'food']
23
26
  #
24
27
  # ## Attributes (return-only):
25
- # - id [string]: unique id returned when PixChargeback is created. ex: '5656565656565656'
28
+ # - id [string]: unique id returned when the PixChargeback is created. ex: '5656565656565656'
26
29
  # - analysis [string]: analysis that led to the result.
27
- # - bacen_id [string]: central bank's unique UUID that identifies the PixChargeback.
28
30
  # - sender_bank_code [string]: bank_code of the Pix participant that created the PixChargeback. ex: '20018183'
29
31
  # - receiver_bank_code [string]: bank_code of the Pix participant that received the PixChargeback. ex: '20018183'
30
32
  # - rejection_reason [string]: reason for the rejection of the Pix chargeback. Options: 'noBalance', 'accountClosed', 'unableToReverse'
31
33
  # - reversal_reference_id [string]: return id of the reversal transaction. ex: 'D20018183202202030109X3OoBHG74wo'.
32
- # - id [string]: unique id returned when the PixChargeback is created. ex: '5656565656565656'
33
34
  # - result [string]: result after the analysis of the PixChargeback by the receiving party. Options: 'rejected', 'accepted', 'partiallyAccepted'
35
+ # - flow [string]: direction of the Pix Chargeback. Options: 'in' for received chargebacks, 'out' for chargebacks you requested
34
36
  # - status [string]: current PixChargeback status. Options: 'created', 'failed', 'delivered', 'closed', 'canceled'.
35
37
  # - created [DateTime]: creation datetime for the PixChargeback. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
36
38
  # - updated [DateTime]: latest update datetime for the PixChargeback. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
37
39
  class PixChargeback < StarkInfra::Utils::Resource
38
- attr_reader :amount, :reference_id, :reason, :description, :id, :analysis, :bacen_id, :sender_bank_code,
39
- :receiver_bank_code, :rejection_reason, :reversal_reference_id, :result, :status, :created, :updated
40
+ attr_reader :amount, :reference_id, :reason, :description, :tags, :id, :analysis, :sender_bank_code,
41
+ :receiver_bank_code, :rejection_reason, :reversal_reference_id, :result, :flow, :status, :created, :updated
40
42
  def initialize(
41
- amount:, reference_id:, reason:, description: nil, id: nil, analysis: nil, bacen_id: nil,
42
- sender_bank_code: nil, receiver_bank_code: nil, rejection_reason: nil, reversal_reference_id: nil,
43
- result: nil, status: nil, created: nil, updated: nil
43
+ amount:, reference_id:, reason:, description: nil, tags: nil, id: nil, analysis: nil, sender_bank_code: nil,
44
+ receiver_bank_code: nil, rejection_reason: nil, reversal_reference_id: nil, result: nil, flow: nil, status: nil,
45
+ created: nil, updated: nil
44
46
  )
45
47
  super(id)
46
48
  @amount = amount
47
49
  @reference_id = reference_id
48
50
  @reason = reason
49
51
  @description = description
52
+ @tags = tags
50
53
  @analysis = analysis
51
- @bacen_id = bacen_id
52
54
  @sender_bank_code = sender_bank_code
53
55
  @receiver_bank_code = receiver_bank_code
54
56
  @rejection_reason = rejection_reason
55
57
  @reversal_reference_id = reversal_reference_id
56
58
  @result = result
59
+ @flow = flow
57
60
  @status = status
58
61
  @created = StarkInfra::Utils::Checks.check_datetime(created)
59
62
  @updated = StarkInfra::Utils::Checks.check_datetime(updated)
@@ -61,10 +64,10 @@ module StarkInfra
61
64
 
62
65
  # # Create PixChargebacks
63
66
  #
64
- # Send a list of PixChargeback objects for creation in the Stark Infra API
67
+ # Create PixChargebacks in the Stark Infra API
65
68
  #
66
69
  # ## Parameters (required):
67
- # - chargebacks [list of PixChargeback objects]: list of PixChargeback objects to be created in the API. ex: [PixChargeback.new()]
70
+ # - chargebacks [list of PixChargeback objects]: list of PixChargeback objects to be created in the API.
68
71
  #
69
72
  # ## Parameters (optional):
70
73
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
@@ -75,9 +78,9 @@ module StarkInfra
75
78
  StarkInfra::Utils::Rest.post(entities: chargebacks, user: user, **resource)
76
79
  end
77
80
 
78
- # # Retrieve a specific PixChargeback
81
+ # # Retrieve a PixChargeback object
79
82
  #
80
- # Receive a single PixChargeback object previously created in the Stark Infra API by passing its id
83
+ # Retrieve a PixChargeback object linked to your Workspace in the Stark Infra API using its id.
81
84
  #
82
85
  # ## Parameters (required):
83
86
  # - id [string]: object unique id. ex: '5656565656565656'
@@ -101,11 +104,13 @@ module StarkInfra
101
104
  # - before [Date or string, default nil]: date filter for objects created or updated only before specified date. ex: Date.new(2020, 3, 10)
102
105
  # - status [string, default nil]: filter for status of retrieved objects. ex: 'success' or 'failed'
103
106
  # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
107
+ # - flow [string, default nil]: direction of the Pix Chargeback. Options: 'in' for received chargebacks, 'out' for chargebacks you requested
108
+ # - tags [list of strings, default nil]: filter for tags of retrieved objects. ex: ['travel', 'food']
104
109
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
105
110
  #
106
111
  # ## Return:
107
112
  # - generator of PixChargeback objects with updated attributes
108
- def self.query(limit: nil, after: nil, before: nil, status: nil, ids: nil, user: nil)
113
+ def self.query(limit: nil, after: nil, before: nil, status: nil, ids: nil, flow: nil, tags: nil, user: nil)
109
114
  after = StarkInfra::Utils::Checks.check_date(after)
110
115
  before = StarkInfra::Utils::Checks.check_date(before)
111
116
  StarkInfra::Utils::Rest.get_stream(
@@ -114,6 +119,8 @@ module StarkInfra
114
119
  before: before,
115
120
  status: status,
116
121
  ids: ids,
122
+ flow: flow,
123
+ tags: tags,
117
124
  user: user,
118
125
  **resource
119
126
  )
@@ -131,12 +138,14 @@ module StarkInfra
131
138
  # - before [Date or string, default nil]: date filter for objects created or updated only before specified date. ex: Date.new(2020, 3, 10)
132
139
  # - status [string, default nil]: filter for status of retrieved objects. ex: 'success' or 'failed'
133
140
  # - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
141
+ # - flow [string, default nil]: direction of the Pix Chargeback. Options: 'in' for received chargebacks, 'out' for chargebacks you requested
142
+ # - tags [list of strings, default nil]: filter for tags of retrieved objects. ex: ['travel', 'food']
134
143
  # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
135
144
  #
136
145
  # ## Return:
137
146
  # - list of PixChargeback objects with updated attributes
138
147
  # - cursor to retrieve the next page of PixChargeback objects
139
- def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, ids: nil, user: nil)
148
+ def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, ids: nil, flow: nil, tags: nil, user: nil)
140
149
  after = StarkInfra::Utils::Checks.check_date(after)
141
150
  before = StarkInfra::Utils::Checks.check_date(before)
142
151
  StarkInfra::Utils::Rest.get_page(
@@ -146,6 +155,8 @@ module StarkInfra
146
155
  before: before,
147
156
  status: status,
148
157
  ids: ids,
158
+ flow: flow,
159
+ tags: tags,
149
160
  user: user,
150
161
  **resource
151
162
  )
@@ -157,7 +168,7 @@ module StarkInfra
157
168
  #
158
169
  # ## Parameters (required):
159
170
  # - id [string]: PixChargeback unique id. ex: '5656565656565656'
160
- # - result [string]: result of the PixChargeback. Options: 'rejected', 'accepted', 'partiallyAccepted'.
171
+ # - result [string]: result after the analysis of the PixChargeback. Options: 'rejected', 'accepted', 'partiallyAccepted'.
161
172
  #
162
173
  # ## Parameters (conditionally required):
163
174
  # - rejection_reason [string, default nil]: if the PixChargeback is rejected a reason is required. Options: 'noBalance', 'accountClosed', 'unableToReverse',
@@ -174,8 +185,8 @@ module StarkInfra
174
185
  id: id,
175
186
  result: result,
176
187
  rejection_reason: rejection_reason,
177
- analysis: analysis,
178
188
  reversal_reference_id: reversal_reference_id,
189
+ analysis: analysis,
179
190
  user: user,
180
191
  **resource
181
192
  )
@@ -202,18 +213,19 @@ module StarkInfra
202
213
  resource_name: 'PixChargeback',
203
214
  resource_maker: proc { |json|
204
215
  PixChargeback.new(
216
+ id: json['id'],
205
217
  amount: json['amount'],
206
218
  reference_id: json['reference_id'],
207
219
  reason: json['reason'],
208
220
  description: json['description'],
209
- id: json['id'],
221
+ tags: json['tags'],
210
222
  analysis: json['analysis'],
211
- bacen_id: json['bacen_id'],
212
223
  sender_bank_code: json['sender_bank_code'],
213
224
  receiver_bank_code: json['receiver_bank_code'],
214
225
  rejection_reason: json['rejection_reason'],
215
226
  reversal_reference_id: json['reversal_reference_id'],
216
227
  result: json['result'],
228
+ flow: json['flow'],
217
229
  status: json['status'],
218
230
  created: json['created'],
219
231
  updated: json['updated']
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
  )