starkinfra 0.0.2 → 0.0.3
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.
- checksums.yaml +4 -4
- data/lib/creditnote/creditnote.rb +561 -0
- data/lib/creditnote/log.rb +126 -0
- data/lib/event/attempt.rb +126 -0
- data/lib/event/event.rb +125 -7
- data/lib/issuingauthorization/issuingauthorization.rb +141 -0
- data/lib/issuingbalance/issuingbalance.rb +55 -0
- data/lib/issuingbin/issuingbin.rb +89 -0
- data/lib/issuingcard/issuingcard.rb +260 -0
- data/lib/issuingcard/log.rb +123 -0
- data/lib/issuingholder/issuingholder.rb +206 -0
- data/lib/issuingholder/log.rb +123 -0
- data/lib/issuinginvoice/issuinginvoice.rb +152 -0
- data/lib/issuinginvoice/log.rb +120 -0
- data/lib/issuingpurchase/issuingpurchase.rb +209 -0
- data/lib/issuingpurchase/log.rb +131 -0
- data/lib/issuingrule/issuingrule.rb +81 -0
- data/lib/issuingtransaction/issuingtransaction.rb +136 -0
- data/lib/issuingwithdrawal/issuingwithdrawal.rb +153 -0
- data/lib/pixbalance/pixbalance.rb +13 -13
- data/lib/pixchargeback/log.rb +129 -0
- data/lib/pixchargeback/pixchargeback.rb +225 -0
- data/lib/pixclaim/log.rb +135 -0
- data/lib/pixclaim/pixclaim.rb +225 -0
- data/lib/pixdirector/pixdirector.rb +76 -0
- data/lib/pixdomain/certificate.rb +30 -0
- data/lib/pixdomain/pixdomain.rb +58 -0
- data/lib/pixinfraction/log.rb +129 -0
- data/lib/pixinfraction/pixinfraction.rb +212 -0
- data/lib/pixkey/log.rb +128 -0
- data/lib/pixkey/pixkey.rb +239 -0
- data/lib/pixrequest/log.rb +16 -16
- data/lib/pixrequest/pixrequest.rb +66 -67
- data/lib/pixreversal/log.rb +13 -12
- data/lib/pixreversal/pixreversal.rb +72 -71
- data/lib/pixstatement/pixstatement.rb +22 -23
- data/lib/starkinfra.rb +32 -2
- data/lib/user/organization.rb +54 -0
- data/lib/user/project.rb +37 -0
- data/lib/user/user.rb +20 -0
- data/lib/utils/api.rb +10 -2
- data/lib/utils/bacenid.rb +19 -0
- data/lib/utils/checks.rb +2 -3
- data/lib/utils/endtoendid.rb +11 -0
- data/lib/utils/parse.rb +13 -13
- data/lib/utils/request.rb +1 -1
- data/lib/utils/rest.rb +7 -5
- data/lib/utils/returnid.rb +11 -0
- data/lib/webhook/webhook.rb +124 -0
- 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 nil]: 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,81 @@
|
|
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
|
+
# - interval [string]: interval after which the rule amount counter will be reset to 0. ex: 'instant', 'day', 'week', 'month', 'year' or 'lifetime'
|
16
|
+
# ## Parameters (optional):
|
17
|
+
# - currency_code [string, default 'BRL']: code of the currency that the rule amount refers to. ex: 'BRL' or 'USD'
|
18
|
+
# - categories [list of strings, default []]: merchant categories accepted by the rule. ex: ['eatingPlacesRestaurants', 'travelAgenciesTourOperators']
|
19
|
+
# - countries [list of strings, default []]: countries accepted by the rule. ex: ['BRA', 'USA']
|
20
|
+
# - methods [list of strings, default []]: card purchase methods accepted by the rule. ex: ['chip', 'token', 'server', 'manual', 'magstripe', 'contactless']
|
21
|
+
# ## Attributes (expanded return-only):
|
22
|
+
# - counter_amount [integer]: current rule spent amount. ex: 1000
|
23
|
+
# - currency_symbol [string]: currency symbol. ex: 'R$'
|
24
|
+
# - currency_name [string]: currency name. ex: 'Brazilian Real'
|
25
|
+
# ## Attributes (return-only):
|
26
|
+
# - id [string]: unique id returned when Rule is created. ex: '5656565656565656'
|
27
|
+
class IssuingRule < StarkInfra::Utils::Resource
|
28
|
+
attr_reader :name, :interval, :amount, :currency_code, :counter_amount, :currency_name, :currency_symbol, :categories, :countries, :methods
|
29
|
+
def initialize(name:, interval:, amount:, currency_code: nil, counter_amount: nil, currency_name: nil,
|
30
|
+
currency_symbol: nil, categories: nil, countries: nil, methods: nil
|
31
|
+
)
|
32
|
+
super(id)
|
33
|
+
@name = name
|
34
|
+
@interval = interval
|
35
|
+
@amount = amount
|
36
|
+
@currency_code = currency_code
|
37
|
+
@counter_amount = counter_amount
|
38
|
+
@currency_name = currency_name
|
39
|
+
@currency_symbol = currency_symbol
|
40
|
+
@categories = categories
|
41
|
+
@countries = countries
|
42
|
+
@methods = methods
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.parse_rules(rules)
|
46
|
+
parsed_rules = []
|
47
|
+
rule_maker = StarkInfra::IssuingRule.resource[:resource_maker]
|
48
|
+
return rules if rules.nil?
|
49
|
+
|
50
|
+
rules.each do |rule|
|
51
|
+
if rule.is_a? IssuingRule
|
52
|
+
parsed_rules.append(rule)
|
53
|
+
next
|
54
|
+
end
|
55
|
+
parsed_rules.append(StarkInfra::Utils::API.from_api_json(rule_maker, rule))
|
56
|
+
end
|
57
|
+
parsed_rules
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.resource
|
61
|
+
{
|
62
|
+
resource_name: 'IssuingRule',
|
63
|
+
resource_maker: proc { |json|
|
64
|
+
IssuingRule.new(
|
65
|
+
name: json[:name],
|
66
|
+
interval: json[:interval],
|
67
|
+
amount: json[:amount],
|
68
|
+
currency_code: json[:currency_code],
|
69
|
+
counter_amount: json[:counter_amount],
|
70
|
+
currency_name: json[:currency_name],
|
71
|
+
currency_symbol: json[:currency_symbol],
|
72
|
+
categories: json[:categories],
|
73
|
+
countries: json[:countries],
|
74
|
+
methods: json[:methods]
|
75
|
+
)
|
76
|
+
}
|
77
|
+
}
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
@@ -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 nil]: 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 nil]: 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
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
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,7 +31,7 @@ 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
|
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
|
@@ -0,0 +1,129 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative('../utils/resource')
|
4
|
+
require_relative('../utils/rest')
|
5
|
+
require_relative('../utils/checks')
|
6
|
+
require_relative('pixchargeback')
|
7
|
+
|
8
|
+
module StarkInfra
|
9
|
+
class PixChargeback
|
10
|
+
# # PixChargeback::Log object
|
11
|
+
#
|
12
|
+
# Every time a PixChargeback entity is modified, a corresponding PixChargeback::Log
|
13
|
+
# is generated for the entity. This log is never generated by the
|
14
|
+
# user.
|
15
|
+
#
|
16
|
+
# ## Attributes:
|
17
|
+
# - id [string]: unique id returned when the log is created. ex: '5656565656565656'
|
18
|
+
# - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
19
|
+
# - type [string]: type of the PixChargeback event which triggered the log creation. Options: 'created', 'failed', 'delivering', 'delivered', 'closed', 'canceled'
|
20
|
+
# - errors [list of strings]: list of errors linked to this PixChargeback event.
|
21
|
+
# - chargeback [PixChargeback]: PixChargeback entity to which the log refers to.
|
22
|
+
class Log < StarkInfra::Utils::Resource
|
23
|
+
attr_reader :id, :created, :type, :errors, :chargeback
|
24
|
+
def initialize(id:, created:, type:, errors:, chargeback:)
|
25
|
+
super(id)
|
26
|
+
@created = StarkInfra::Utils::Checks.check_datetime(created)
|
27
|
+
@type = type
|
28
|
+
@errors = errors
|
29
|
+
@chargeback = chargeback
|
30
|
+
end
|
31
|
+
|
32
|
+
# # Retrieve a specific Log
|
33
|
+
#
|
34
|
+
# Receive a single Log object previously created by the Stark Infra API by passing its id
|
35
|
+
#
|
36
|
+
# ## Parameters (required):
|
37
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
38
|
+
#
|
39
|
+
# ## Parameters (optional):
|
40
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
41
|
+
#
|
42
|
+
# ## Return:
|
43
|
+
# - Log object with updated attributes
|
44
|
+
def self.get(id, user: nil)
|
45
|
+
StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
|
46
|
+
end
|
47
|
+
|
48
|
+
# # Retrieve Logs
|
49
|
+
#
|
50
|
+
# Receive a generator of Log objects previously created in the Stark Infra API
|
51
|
+
#
|
52
|
+
# ## Parameters (optional):
|
53
|
+
# - ids [list of strings, default nil]: Log ids to filter PixChargeback Logs. ex: ['5656565656565656']
|
54
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
55
|
+
# - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
56
|
+
# - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
57
|
+
# - types [list of strings, default nil]: filter retrieved objects by types. Options: 'created', 'failed', 'delivering', 'delivered', 'closed', 'canceled'
|
58
|
+
# - chargeback_ids [list of strings, default nil]: list of PixChargeback ids to filter retrieved objects. ex: %w[5656565656565656 4545454545454545]
|
59
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
60
|
+
#
|
61
|
+
# ## Return:
|
62
|
+
# - generator of Log objects with updated attributes
|
63
|
+
def self.query(ids: nil, limit: nil, after: nil, before: nil, types: nil, chargeback_ids: nil, user: nil)
|
64
|
+
after = StarkInfra::Utils::Checks.check_date(after)
|
65
|
+
before = StarkInfra::Utils::Checks.check_date(before)
|
66
|
+
StarkInfra::Utils::Rest.get_stream(
|
67
|
+
ids: ids,
|
68
|
+
limit: limit,
|
69
|
+
after: after,
|
70
|
+
before: before,
|
71
|
+
types: types,
|
72
|
+
chargeback_ids: chargeback_ids,
|
73
|
+
user: user,
|
74
|
+
**resource
|
75
|
+
)
|
76
|
+
end
|
77
|
+
|
78
|
+
# # Retrieve paged Logs
|
79
|
+
#
|
80
|
+
# Receive a list of up to 100 Log objects previously created in the Stark Infra API and the cursor to the next page.
|
81
|
+
# Use this function instead of query if you want to manually page your chargebacks.
|
82
|
+
#
|
83
|
+
# ## Parameters (optional):
|
84
|
+
# - cursor [string, default nil]: cursor returned on the previous page function call
|
85
|
+
# - ids [list of strings, default nil]: Log ids to filter PixChargeback Logs. ex: ['5656565656565656']
|
86
|
+
# - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
|
87
|
+
# - after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
88
|
+
# - before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
89
|
+
# - types [list of strings, default nil]: filter retrieved objects by types. Options: 'created', 'failed', 'delivering', 'delivered', 'closed', 'canceled'
|
90
|
+
# - chargeback_ids [list of strings, default nil]: list of PixChargeback ids to filter retrieved objects. ex: %w[5656565656565656 4545454545454545]
|
91
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
92
|
+
#
|
93
|
+
# ## Return:
|
94
|
+
# - list of Log objects with updated attributes
|
95
|
+
# - cursor to retrieve the next page of Log objects
|
96
|
+
def self.page(cursor: nil, ids: nil, limit: nil, after: nil, before: nil, types: nil, chargeback_ids: nil, user: nil)
|
97
|
+
after = StarkInfra::Utils::Checks.check_date(after)
|
98
|
+
before = StarkInfra::Utils::Checks.check_date(before)
|
99
|
+
StarkInfra::Utils::Rest.get_page(
|
100
|
+
cursor: cursor,
|
101
|
+
ids: ids,
|
102
|
+
limit: limit,
|
103
|
+
after: after,
|
104
|
+
before: before,
|
105
|
+
types: types,
|
106
|
+
chargeback_ids: chargeback_ids,
|
107
|
+
user: user,
|
108
|
+
**resource
|
109
|
+
)
|
110
|
+
end
|
111
|
+
|
112
|
+
def self.resource
|
113
|
+
chargeback_maker = StarkInfra::PixChargeback.resource[:resource_maker]
|
114
|
+
{
|
115
|
+
resource_name: 'PixChargebackLog',
|
116
|
+
resource_maker: proc { |json|
|
117
|
+
Log.new(
|
118
|
+
id: json['id'],
|
119
|
+
created: json['created'],
|
120
|
+
type: json['type'],
|
121
|
+
errors: json['errors'],
|
122
|
+
chargeback: StarkInfra::Utils::API.from_api_json(chargeback_maker, json['chargeback'])
|
123
|
+
)
|
124
|
+
}
|
125
|
+
}
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|