starkinfra 0.0.1 → 0.1.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 (50) hide show
  1. checksums.yaml +4 -4
  2. data/lib/creditnote/creditnote.rb +583 -0
  3. data/lib/creditnote/log.rb +126 -0
  4. data/lib/event/attempt.rb +126 -0
  5. data/lib/event/event.rb +125 -7
  6. data/lib/issuingauthorization/issuingauthorization.rb +141 -0
  7. data/lib/issuingbalance/issuingbalance.rb +55 -0
  8. data/lib/issuingbin/issuingbin.rb +89 -0
  9. data/lib/issuingcard/issuingcard.rb +261 -0
  10. data/lib/issuingcard/log.rb +123 -0
  11. data/lib/issuingholder/issuingholder.rb +206 -0
  12. data/lib/issuingholder/log.rb +123 -0
  13. data/lib/issuinginvoice/issuinginvoice.rb +152 -0
  14. data/lib/issuinginvoice/log.rb +120 -0
  15. data/lib/issuingpurchase/issuingpurchase.rb +209 -0
  16. data/lib/issuingpurchase/log.rb +131 -0
  17. data/lib/issuingrule/issuingrule.rb +79 -0
  18. data/lib/issuingtransaction/issuingtransaction.rb +136 -0
  19. data/lib/issuingwithdrawal/issuingwithdrawal.rb +153 -0
  20. data/lib/pixbalance/pixbalance.rb +15 -15
  21. data/lib/pixchargeback/log.rb +129 -0
  22. data/lib/pixchargeback/pixchargeback.rb +225 -0
  23. data/lib/pixclaim/log.rb +135 -0
  24. data/lib/pixclaim/pixclaim.rb +226 -0
  25. data/lib/pixdirector/pixdirector.rb +76 -0
  26. data/lib/pixdomain/certificate.rb +30 -0
  27. data/lib/pixdomain/pixdomain.rb +58 -0
  28. data/lib/pixinfraction/log.rb +129 -0
  29. data/lib/pixinfraction/pixinfraction.rb +212 -0
  30. data/lib/pixkey/log.rb +128 -0
  31. data/lib/pixkey/pixkey.rb +240 -0
  32. data/lib/pixrequest/log.rb +16 -16
  33. data/lib/pixrequest/pixrequest.rb +66 -67
  34. data/lib/pixreversal/log.rb +13 -12
  35. data/lib/pixreversal/pixreversal.rb +74 -72
  36. data/lib/pixstatement/pixstatement.rb +24 -25
  37. data/lib/starkinfra.rb +32 -3
  38. data/lib/user/organization.rb +54 -0
  39. data/lib/user/project.rb +37 -0
  40. data/lib/user/user.rb +20 -0
  41. data/lib/utils/api.rb +10 -2
  42. data/lib/utils/bacenid.rb +19 -0
  43. data/lib/utils/checks.rb +2 -3
  44. data/lib/utils/endtoendid.rb +11 -0
  45. data/lib/utils/parse.rb +13 -13
  46. data/lib/utils/request.rb +2 -2
  47. data/lib/utils/rest.rb +6 -5
  48. data/lib/utils/returnid.rb +11 -0
  49. data/lib/webhook/webhook.rb +124 -0
  50. metadata +45 -24
@@ -0,0 +1,131 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative('../utils/resource')
4
+ require_relative('../utils/rest')
5
+ require_relative('../utils/checks')
6
+ require_relative('issuingpurchase')
7
+
8
+ module StarkInfra
9
+ class IssuingPurchase
10
+ # # IssuingPurchase::Log object
11
+ #
12
+ # Every time an IssuingPurchase entity is updated, a corresponding IssuingInvoice::Log is generated for the entity.
13
+ # This Log is never generated by the user, but it can be retrieved to check additional information on the IssuingPurchase.
14
+ #
15
+ # ## Attributes:
16
+ # - id [string]: unique id returned when the log is created. ex: '5656565656565656'
17
+ # - purchase [IssuingPurchase]: IssuingPurchase entity to which the log refers to.
18
+ # - issuing_transaction_id [string]: transaction ID related to the IssuingCard.
19
+ # - errors [list of strings]: list of errors linked to this IssuingPurchase event
20
+ # - type [string]: type of the IssuingPurchase event which triggered the log creation. ex: 'approved', 'canceled', 'confirmed', 'denied', 'reversed', 'voided'.
21
+ # - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
22
+ class Log < StarkInfra::Utils::Resource
23
+ attr_reader :id, :purchase, :issuing_transaction_id, :errors, :type, :created
24
+ def initialize(id: nil, purchase: nil, issuing_transaction_id: nil, errors: nil, type: nil, created: nil)
25
+ super(id)
26
+ @purchase = purchase
27
+ @issuing_transaction_id = issuing_transaction_id
28
+ @errors = errors
29
+ @type = type
30
+ @created = StarkInfra::Utils::Checks.check_datetime(created)
31
+ end
32
+
33
+ # # Retrieve a specific Log
34
+ #
35
+ # Receive a single Log object previously created by the Stark Infra API by passing its id
36
+ #
37
+ # ## Parameters (required):
38
+ # - id [string]: object unique id. ex: '5656565656565656'
39
+ #
40
+ # ## Parameters (optional):
41
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
42
+ #
43
+ # ## Return:
44
+ # - Log object with updated attributes
45
+ def self.get(id, user: nil)
46
+ StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
47
+ end
48
+
49
+ # # Retrieve Logs
50
+ #
51
+ # Receive a generator of Log objects previously created in the Stark Infra API
52
+ #
53
+ # ## Parameters (optional):
54
+ # - ids [list of strings, default nil]: list of IssuingPurchase ids to filter logs. ex: ['5656565656565656', '4545454545454545']
55
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
56
+ # - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
57
+ # - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
58
+ # - types [list of strings, default nil]: filter for log event types. ex: ['approved', 'canceled', 'confirmed', 'denied', 'reversed', 'voided']
59
+ # - purchase_ids [list of strings, default nil]: list of Purchase ids to filter logs. ex: ['5656565656565656', '4545454545454545']
60
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
61
+ #
62
+ # ## Return:
63
+ # - generator of Log objects with updated attributes
64
+ def self.query(ids: nil, limit: nil, after: nil, before: nil, types: nil, purchase_ids: nil, user: nil)
65
+ after = StarkInfra::Utils::Checks.check_date(after)
66
+ before = StarkInfra::Utils::Checks.check_date(before)
67
+ StarkInfra::Utils::Rest.get_stream(
68
+ ids: ids,
69
+ limit: limit,
70
+ after: after,
71
+ before: before,
72
+ types: types,
73
+ purchase_ids: purchase_ids,
74
+ user: user,
75
+ **resource
76
+ )
77
+ end
78
+
79
+ # # Retrieve paged Logs
80
+ #
81
+ # Receive a list of up to 100 Log objects previously created in the Stark Infra API and the cursor to the next page.
82
+ # Use this function instead of query if you want to manually page your purchases.
83
+ #
84
+ # ## Parameters (optional):
85
+ # - cursor [string, default nil]: cursor returned on the previous page function call
86
+ # - ids [list of strings, default nil]: list of IssuingPurchase ids to filter logs. ex: ['5656565656565656', '4545454545454545']
87
+ # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
88
+ # - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
89
+ # - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
90
+ # - types [list of strings, default nil]: filter for log event types. ex: ['approved', 'canceled', 'confirmed', 'denied', 'reversed', 'voided']
91
+ # - purchase_ids [list of strings, default nil]: list of Purchase ids to filter logs. ex: ['5656565656565656', '4545454545454545']
92
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
93
+ #
94
+ # ## Return:
95
+ # - list of Log objects with updated attributes
96
+ # - cursor to retrieve the next page of Log objects
97
+ def self.page(cursor: nil, ids: nil, limit: nil, after: nil, before: nil, types: nil, purchase_ids: nil, user: nil)
98
+ after = StarkInfra::Utils::Checks.check_date(after)
99
+ before = StarkInfra::Utils::Checks.check_date(before)
100
+ StarkInfra::Utils::Rest.get_page(
101
+ cursor: cursor,
102
+ ids: ids,
103
+ limit: limit,
104
+ after: after,
105
+ before: before,
106
+ types: types,
107
+ purchase_ids: purchase_ids,
108
+ user: user,
109
+ **resource
110
+ )
111
+ end
112
+
113
+ def self.resource
114
+ request_maker = StarkInfra::IssuingPurchase.resource[:resource_maker]
115
+ {
116
+ resource_name: 'IssuingPurchaseLog',
117
+ resource_maker: proc { |json|
118
+ Log.new(
119
+ id: json['id'],
120
+ purchase: StarkInfra::Utils::API.from_api_json(request_maker, json['purchase']),
121
+ issuing_transaction_id: json['issuing_transaction_id'],
122
+ errors: json['errors'],
123
+ type: json['type'],
124
+ created: json['created']
125
+ )
126
+ }
127
+ }
128
+ end
129
+ end
130
+ end
131
+ end
@@ -0,0 +1,79 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative('../utils/resource')
4
+ require_relative('../utils/rest')
5
+ require_relative('../utils/checks')
6
+
7
+ module StarkInfra
8
+ # # IssuingRule object
9
+ #
10
+ # The IssuingRule object displays the spending rules of IssuingCards and IssuingHolders created in your Workspace.
11
+ #
12
+ # ## Parameters (required):
13
+ # - name [string]: rule name. ex: 'Travel' or 'Food'
14
+ # - amount [integer]: maximum amount that can be spent in the informed interval. ex: 200000 (= R$ 2000.00)
15
+ # ## Parameters (optional):
16
+ # - id [string, default nil]: unique id returned when Rule is created. ex: '5656565656565656'
17
+ # - interval [string, default 'lifetime']: interval after which the rule amount counter will be reset to 0. ex: 'instant', 'day', 'week', 'month', 'year' or 'lifetime'
18
+ # - currency_code [string, default 'BRL']: code of the currency that the rule amount refers to. ex: 'BRL' or 'USD'
19
+ # - categories [list of strings, default []]: merchant categories accepted by the rule. ex: ['eatingPlacesRestaurants', 'travelAgenciesTourOperators']
20
+ # - countries [list of strings, default []]: countries accepted by the rule. ex: ['BRA', 'USA']
21
+ # - methods [list of strings, default []]: card purchase methods accepted by the rule. ex: ['chip', 'token', 'server', 'manual', 'magstripe', 'contactless']
22
+ # ## Attributes (expanded return-only):
23
+ # - counter_amount [integer]: current rule spent amount. ex: 1000
24
+ # - currency_symbol [string]: currency symbol. ex: 'R$'
25
+ # - currency_name [string]: currency name. ex: 'Brazilian Real'
26
+ class IssuingRule < StarkInfra::Utils::Resource
27
+ attr_reader :name, :interval, :amount, :currency_code, :counter_amount, :currency_name, :currency_symbol, :categories, :countries, :methods
28
+ def initialize(name:, amount:, id: nil, interval: nil, currency_code: nil, counter_amount: nil, currency_name: nil,
29
+ currency_symbol: nil, categories: nil, countries: nil, methods: nil
30
+ )
31
+ super(id)
32
+ @name = name
33
+ @interval = interval
34
+ @amount = amount
35
+ @currency_code = currency_code
36
+ @counter_amount = counter_amount
37
+ @currency_name = currency_name
38
+ @currency_symbol = currency_symbol
39
+ @categories = categories
40
+ @countries = countries
41
+ @methods = methods
42
+ end
43
+
44
+ def self.parse_rules(rules)
45
+ rule_maker = StarkInfra::IssuingRule.resource[:resource_maker]
46
+ return rules if rules.nil?
47
+
48
+ parsed_rules = []
49
+ rules.each do |rule|
50
+ unless rule.is_a? IssuingRule
51
+ rule = StarkInfra::Utils::API.from_api_json(rule_maker, rule)
52
+ end
53
+ parsed_rules << rule
54
+ end
55
+ parsed_rules
56
+ end
57
+
58
+ def self.resource
59
+ {
60
+ resource_name: 'IssuingRule',
61
+ resource_maker: proc { |json|
62
+ IssuingRule.new(
63
+ name: json['name'],
64
+ interval: json['interval'],
65
+ amount: json['amount'],
66
+ currency_code: json['currency_code'],
67
+ counter_amount: json['counter_amount'],
68
+ currency_name: json['currency_name'],
69
+ currency_symbol: json['currency_symbol'],
70
+ categories: json['categories'],
71
+ countries: json['countries'],
72
+ methods: json['methods']
73
+ )
74
+ }
75
+ }
76
+ end
77
+ end
78
+ end
79
+
@@ -0,0 +1,136 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative('../utils/resource')
4
+ require_relative('../utils/rest')
5
+ require_relative('../utils/checks')
6
+
7
+ module StarkInfra
8
+ # # IssuingTransaction object
9
+ #
10
+ # The IssuingTransaction objects created in your Workspace to represent each balance shift.
11
+ #
12
+ # ## Attributes (return-only):
13
+ # - id [string]: unique id returned when IssuingTransaction is created. ex: '5656565656565656'
14
+ # - amount [integer]: IssuingTransaction value in cents. ex: 1234 (= R$ 12.34)
15
+ # - balance [integer]: balance amount of the Workspace at the instant of the Transaction in cents. ex: 200 (= R$ 2.00)
16
+ # - description [string]: IssuingTransaction description. ex: 'Buying food'
17
+ # - source [string]: source of the transaction. ex: 'issuing-purchase/5656565656565656'
18
+ # - tags [string]: list of strings inherited from the source resource. ex: ['tony', 'stark']
19
+ # - created [DateTime]: creation datetime for the IssuingTransaction. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
20
+ class IssuingTransaction < StarkInfra::Utils::Resource
21
+ attr_reader :id, :amount, :balance, :description, :source, :tags, :created
22
+
23
+ def initialize(
24
+ id: nil, amount: nil, balance: nil, description: nil, source: nil, tags: nil, created: nil
25
+ )
26
+ super(id)
27
+ @amount = amount
28
+ @balance = balance
29
+ @description = description
30
+ @source = source
31
+ @tags = tags
32
+ @created = StarkInfra::Utils::Checks.check_datetime(created)
33
+ end
34
+
35
+ # # Retrieve a specific IssuingTransaction
36
+ #
37
+ # Receive a single IssuingTransaction object previously created in the Stark Infra API by its id
38
+ #
39
+ # ## Parameters (required):
40
+ # - id [string]: object unique id. ex: '5656565656565656'
41
+ #
42
+ # ## Parameters (optional):
43
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
44
+ #
45
+ # ## Return:
46
+ # - IssuingTransaction object with updated attributes
47
+ def self.get(id, user: nil)
48
+ StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
49
+ end
50
+
51
+ # # Retrieve IssuingTransactions
52
+ #
53
+ # Receive a generator of IssuingTransaction objects previously created in the Stark Infra API
54
+ #
55
+ # ## Parameters (optional):
56
+ # - 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']
58
+ # - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
59
+ # - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
60
+ # - 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
62
+ # - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
63
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
64
+ #
65
+ # ## Return:
66
+ # - generator of IssuingTransaction objects with updated attributes
67
+ def self.query(tags: nil, external_ids: nil, after: nil, before: nil, status: nil, ids: nil, limit: nil, user: nil)
68
+ after = StarkInfra::Utils::Checks.check_date(after)
69
+ before = StarkInfra::Utils::Checks.check_date(before)
70
+ StarkInfra::Utils::Rest.get_stream(
71
+ tags: tags,
72
+ external_ids: external_ids,
73
+ after: after,
74
+ before: before,
75
+ status: status,
76
+ ids: ids,
77
+ limit: limit,
78
+ user: user,
79
+ **resource
80
+ )
81
+ end
82
+
83
+ # # Retrieve paged IssuingTransactions
84
+ #
85
+ # Receive a list of IssuingTransaction objects previously created in the Stark Infra API and the cursor to the next page.
86
+ #
87
+ # ## Parameters (optional):
88
+ # - cursor [string, default nil]: cursor returned on the previous page function call.
89
+ # - 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']
91
+ # - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
92
+ # - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
93
+ # - status [string, default nil]: filter for status of retrieved objects. ex: 'approved', 'canceled', 'denied', 'confirmed' or 'voided'
94
+ # - ids [list of strings, default nil]: purchase IDs
95
+ # - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
96
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
97
+ #
98
+ # ## Return:
99
+ # - list of IssuingTransactions objects with updated attributes
100
+ # - cursor to retrieve the next page of IssuingTransactions objects
101
+ def self.page(cursor: nil, tags: nil, external_ids: nil, after: nil, before: nil, status: nil, ids: nil, limit: nil,
102
+ user: nil)
103
+ after = StarkInfra::Utils::Checks.check_date(after)
104
+ before = StarkInfra::Utils::Checks.check_date(before)
105
+ StarkInfra::Utils::Rest.get_page(
106
+ cursor: cursor,
107
+ tags: tags,
108
+ external_ids: external_ids,
109
+ after: after,
110
+ before: before,
111
+ status: status,
112
+ ids: ids,
113
+ limit: limit,
114
+ user: user,
115
+ **resource
116
+ )
117
+ end
118
+
119
+ def self.resource
120
+ {
121
+ resource_name: 'IssuingTransaction',
122
+ resource_maker: proc { |json|
123
+ IssuingTransaction.new(
124
+ id: json['id'],
125
+ amount: json['amount'],
126
+ balance: json['balance'],
127
+ description: json['description'],
128
+ source: json['source'],
129
+ tags: json['tags'],
130
+ created: json['created']
131
+ )
132
+ }
133
+ }
134
+ end
135
+ end
136
+ end
@@ -0,0 +1,153 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative('../utils/resource')
4
+ require_relative('../utils/rest')
5
+ require_relative('../utils/checks')
6
+
7
+ module StarkInfra
8
+ # # IssuingWithdrawal object
9
+ #
10
+ # The IssuingWithdrawal objects created in your Workspace return cash from your Issuing balance to your Banking balance.
11
+ #
12
+ # ## Parameters (required):
13
+ # - amount [integer]: IssuingWithdrawal value in cents. Minimum = 0 (any value will be accepted). ex: 1234 (= R$ 12.34)
14
+ # - external_id [string] IssuingWithdrawal external ID. ex: '12345'
15
+ # - description [string]: IssuingWithdrawal description. ex: 'sending money back'
16
+ #
17
+ # ## Parameters (optional):
18
+ # - tags [list of strings, default []]: list of strings for tagging. ex: ['tony', 'stark']
19
+ #
20
+ # ## Attributes (return-only):
21
+ # - id [string]: unique id returned when IssuingWithdrawal is created. ex: '5656565656565656'
22
+ # - transaction_id [string]: Stark Bank ledger transaction ids linked to this IssuingWithdrawal
23
+ # - issuing_transaction_id [string]: issuing ledger transaction ids linked to this IssuingWithdrawal
24
+ # - updated [DateTime]: latest update datetime for the IssuingWithdrawal. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
25
+ # - created [DateTime]: creation datetime for the IssuingWithdrawal. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
26
+ class IssuingWithdrawal < StarkInfra::Utils::Resource
27
+ attr_reader :amount, :external_id, :description, :tags, :id, :transaction_id, :issuing_transaction_id, :updated, :created
28
+ def initialize(
29
+ amount:, external_id:, description:, tags: nil, id: nil, transaction_id: nil, issuing_transaction_id: nil,
30
+ updated: nil, created: nil
31
+ )
32
+ super(id)
33
+ @amount = amount
34
+ @external_id = external_id
35
+ @description = description
36
+ @tags = tags
37
+ @transaction_id = transaction_id
38
+ @issuing_transaction_id = issuing_transaction_id
39
+ @created = StarkInfra::Utils::Checks.check_datetime(created)
40
+ @updated = StarkInfra::Utils::Checks.check_datetime(updated)
41
+ end
42
+
43
+ # # Create an IssuingWithdrawal
44
+ #
45
+ # Send a single IssuingWithdrawal object for creation in the Stark Infra API
46
+ #
47
+ # ## Parameters (required):
48
+ # - withdrawal [IssuingWithdrawal object]: IssuingWithdrawal object to be created in the API.
49
+ #
50
+ # ## Parameters (optional):
51
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
52
+ #
53
+ # ## Return:
54
+ # - IssuingWithdrawal object with updated attributes
55
+ def self.create(withdrawal, user: nil)
56
+ StarkInfra::Utils::Rest.post_single(entity: withdrawal, user: user, **resource)
57
+ end
58
+
59
+ # # Retrieve a specific IssuingWithdrawal
60
+ #
61
+ # Receive a single IssuingWithdrawal object previously created in the Stark Infra API by its id
62
+ #
63
+ # ## Parameters (required):
64
+ # - id [string]: object unique id. ex: '5656565656565656'
65
+ #
66
+ # ## Parameters (optional):
67
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
68
+ #
69
+ # ## Return:
70
+ # - IssuingWithdrawal object with updated attributes
71
+ def self.get(id, user: nil)
72
+ StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
73
+ end
74
+
75
+ # # Retrieve IssuingWithdrawals
76
+ #
77
+ # Receive a generator of IssuingWithdrawal objects previously created in the Stark Infra API
78
+ #
79
+ # ## Parameters (optional):
80
+ # - 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']
82
+ # - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
83
+ # - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
84
+ # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
85
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
86
+ #
87
+ # ## Return:
88
+ # - generator of IssuingWithdrawal objects with updated attributes
89
+ def self.query(limit: nil, external_ids: nil, after: nil, before: nil, tags: nil, user: nil)
90
+ after = StarkInfra::Utils::Checks.check_date(after)
91
+ before = StarkInfra::Utils::Checks.check_date(before)
92
+ StarkInfra::Utils::Rest.get_stream(
93
+ limit: limit,
94
+ external_ids: external_ids,
95
+ after: after,
96
+ before: before,
97
+ tags: tags,
98
+ user: user,
99
+ **resource
100
+ )
101
+ end
102
+
103
+ # # Retrieve paged IssuingWithdrawals
104
+ #
105
+ # Receive a list of IssuingWithdrawals objects previously created in the Stark Infra API and the cursor to the next page.
106
+ #
107
+ # ## Parameters (optional):
108
+ # - cursor [string, default nil]: cursor returned on the previous page function call.
109
+ # - 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']
111
+ # - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
112
+ # - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
113
+ # - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
114
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
115
+ #
116
+ # ## Return:
117
+ # - list of IssuingWithdrawal objects with updated attributes
118
+ # - cursor to retrieve the next page of IssuingWithdrawal objects
119
+ def self.page(cursor: nil, limit: nil, external_ids: nil, after: nil, before: nil, tags: nil, user: nil)
120
+ after = StarkInfra::Utils::Checks.check_date(after)
121
+ before = StarkInfra::Utils::Checks.check_date(before)
122
+ StarkInfra::Utils::Rest.get_page(
123
+ cursor: cursor,
124
+ limit: limit,
125
+ external_ids: external_ids,
126
+ after: after,
127
+ before: before,
128
+ tags: tags,
129
+ user: user,
130
+ **resource
131
+ )
132
+ end
133
+
134
+ def self.resource
135
+ {
136
+ resource_name: 'IssuingWithdrawal',
137
+ resource_maker: proc { |json|
138
+ IssuingWithdrawal.new(
139
+ amount: json['amount'],
140
+ external_id: json['external_id'],
141
+ description: json['description'],
142
+ tags: json['tags'],
143
+ id: json['id'],
144
+ transaction_id: json['transaction_id'],
145
+ issuing_transaction_id: json['issuing_transaction_id'],
146
+ updated: json['updated'],
147
+ created: json['created']
148
+ )
149
+ }
150
+ }
151
+ end
152
+ end
153
+ end
@@ -5,18 +5,18 @@ require_relative('../utils/rest')
5
5
  require_relative('../utils/checks')
6
6
 
7
7
  module StarkInfra
8
- # # PixBalance object
9
- #
10
- # The PixBalance object displays the current balance of the workspace,
11
- # which is the result of the sum of all transactions within this
12
- # workspace. The balance is never generated by the user, but it
13
- # can be retrieved to see the available information.
14
- # ## Attributes (return-only):
15
- # - id [string]: unique id returned when Balance is created. ex: "5656565656565656"
16
- # - amount [integer]: current balance amount of the workspace in cents. ex: 200 (= R$ 2.00)
17
- # - currency [string]: currency of the current workspace. Expect others to be added eventually. ex: "BRL"
18
- # - updated [Datetime]: latest update datetime for the balance. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
19
-
8
+ # # PixBalance object
9
+ #
10
+ # The PixBalance object displays the current balance of the workspace,
11
+ # which is the result of the sum of all transactions within this
12
+ # workspace. The balance is never generated by the user, but it
13
+ # can be retrieved to see the available information.
14
+ #
15
+ # ## Attributes (return-only):
16
+ # - id [string]: unique id returned when Balance is created. ex: '5656565656565656'
17
+ # - amount [integer]: current balance amount of the workspace in cents. ex: 200 (= R$ 2.00)
18
+ # - currency [string]: currency of the current workspace. Expect others to be added eventually. ex: 'BRL'
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
21
  attr_reader :amount, :currency, :updated, :id
22
22
  def initialize(amount: nil, currency: nil, updated: nil, id: nil)
@@ -31,12 +31,12 @@ module StarkInfra
31
31
  # Receive the PixBalance object linked to your workspace in the Stark Infra API
32
32
  #
33
33
  # ## Parameters (optional):
34
- # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
34
+ # - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
35
35
  #
36
36
  # ## Return:
37
37
  # - PixBalance object with updated attributes
38
38
  def self.get(user: nil)
39
- StarkInfra::Utils::Rest.get_stream(user: user, **resource)
39
+ StarkInfra::Utils::Rest.get_stream(user: user, **resource).next
40
40
  end
41
41
 
42
42
  def self.resource
@@ -47,7 +47,7 @@ module StarkInfra
47
47
  amount: json['amount'],
48
48
  currency: json['currency'],
49
49
  updated: json['updated'],
50
- id: json['id'],
50
+ id: json['id']
51
51
  )
52
52
  }
53
53
  }