starkinfra 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/creditnote/creditnote.rb +583 -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 +261 -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 +79 -0
- data/lib/issuingtransaction/issuingtransaction.rb +136 -0
- data/lib/issuingwithdrawal/issuingwithdrawal.rb +153 -0
- data/lib/pixbalance/pixbalance.rb +15 -15
- 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 +226 -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 +240 -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 +74 -72
- data/lib/pixstatement/pixstatement.rb +24 -25
- data/lib/starkinfra.rb +32 -3
- 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 +2 -2
- data/lib/utils/rest.rb +6 -5
- data/lib/utils/returnid.rb +11 -0
- data/lib/webhook/webhook.rb +124 -0
- metadata +45 -24
@@ -0,0 +1,89 @@
|
|
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
|
+
# # IssuingBin object
|
9
|
+
#
|
10
|
+
# The IssuingBin object displays information of BINs registered to your Workspace.
|
11
|
+
# They represent a group of cards that begin with the same numbers (BIN) and offer the same product to end customers.
|
12
|
+
#
|
13
|
+
# ## Attributes (return-only):
|
14
|
+
# - id [string]: unique BIN number registered within the card network. ex: '53810200'
|
15
|
+
# - network [string]: card network flag. ex: 'mastercard'
|
16
|
+
# - settlement [string]: settlement type. ex: 'credit'
|
17
|
+
# - category [string]: purchase category. ex: 'prepaid'
|
18
|
+
# - client [string]: client type. ex: 'business'
|
19
|
+
# - created [DateTime]: creation datetime for the IssuingBin. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
20
|
+
# - updated [DateTime]: latest update datetime for the IssuingBin. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
21
|
+
class IssuingBin < StarkInfra::Utils::Resource
|
22
|
+
attr_reader :id, :network, :settlement, :category, :client, :updated, :created
|
23
|
+
def initialize(id: nil, network: nil, settlement: nil, category: nil, client: nil, updated: nil, created: nil)
|
24
|
+
super(id)
|
25
|
+
@network = network
|
26
|
+
@settlement = settlement
|
27
|
+
@category = category
|
28
|
+
@client = client
|
29
|
+
@updated = StarkInfra::Utils::Checks.check_datetime(updated)
|
30
|
+
@created = StarkInfra::Utils::Checks.check_datetime(created)
|
31
|
+
end
|
32
|
+
|
33
|
+
# # Retrieve the IssuingBin object
|
34
|
+
#
|
35
|
+
# Receive a generator of IssuingBin objects previously registered in the Stark Infra API
|
36
|
+
#
|
37
|
+
# ## Parameters (optional):
|
38
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
39
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
40
|
+
#
|
41
|
+
# ## Return:
|
42
|
+
# - generator of IssuingBin objects with updated attributes
|
43
|
+
def self.query(limit: nil, user: nil)
|
44
|
+
StarkInfra::Utils::Rest.get_stream(
|
45
|
+
limit: limit,
|
46
|
+
user: user,
|
47
|
+
**resource
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
51
|
+
# # Retrieve paged IssuingBins
|
52
|
+
#
|
53
|
+
# Receive a list of up to 100 IssuingBin objects previously registered in the Stark Infra API and the cursor to the next page.
|
54
|
+
#
|
55
|
+
# ## Parameters (optional):
|
56
|
+
# - cursor [string, default nil]: cursor returned on the previous page function call.
|
57
|
+
# - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
|
58
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
59
|
+
#
|
60
|
+
# ## Return:
|
61
|
+
# - list of IssuingBin objects with updated attributes
|
62
|
+
# - cursor to retrieve the next page of IssuingBin objects
|
63
|
+
def self.page(cursor: nil, limit: nil, user: nil)
|
64
|
+
StarkInfra::Utils::Rest.get_page(
|
65
|
+
cursor: cursor,
|
66
|
+
limit: limit,
|
67
|
+
user: user,
|
68
|
+
**resource
|
69
|
+
)
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.resource
|
73
|
+
{
|
74
|
+
resource_name: 'IssuingBin',
|
75
|
+
resource_maker: proc { |json|
|
76
|
+
IssuingBin.new(
|
77
|
+
id: json['id'],
|
78
|
+
network: json['network'],
|
79
|
+
settlement: json['settlement'],
|
80
|
+
category: json['category'],
|
81
|
+
client: json['client'],
|
82
|
+
updated: json['updated'],
|
83
|
+
created: json['created']
|
84
|
+
)
|
85
|
+
}
|
86
|
+
}
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,261 @@
|
|
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
|
+
# # IssuingCard object
|
9
|
+
#
|
10
|
+
# The IssuingCard object displays the information of the cards created in your Workspace.
|
11
|
+
# Sensitive information will only be returned when the 'expand' parameter is used, to avoid security concerns.
|
12
|
+
#
|
13
|
+
# ## Parameters (required):
|
14
|
+
# - holder_name [string]: card holder name. ex: 'Tony Stark'
|
15
|
+
# - holder_tax_id [string]: card holder tax ID. ex: '012.345.678-90'
|
16
|
+
# - holder_external_id [string] card holder unique id, generated by the user to avoid duplicated holders. ex: 'my-entity/123'
|
17
|
+
#
|
18
|
+
# ## Parameters (optional):
|
19
|
+
# - display_name [string, default nil]: card displayed name. ex: 'ANTHONY STARK'
|
20
|
+
# - rules [list of IssuingRule objects, default []]: [EXPANDABLE] list of card spending rules.
|
21
|
+
# - bin_id [string, default nil]: BIN ID to which the card is bound. ex: '53810200'
|
22
|
+
# - tags [list of strings, default []]: list of strings for tagging. ex: ['travel', 'food']
|
23
|
+
# - street_line_1 [string, default sub-issuer street line 1]: card holder main address. ex: 'Av. Paulista, 200'
|
24
|
+
# - street_line_2 [string, default sub-issuer street line 2]: card holder address complement. ex: 'Apto. 123'
|
25
|
+
# - district [string, default sub-issuer district]: card holder address district / neighbourhood. ex: 'Bela Vista'
|
26
|
+
# - city [string, default sub-issuer city]: card holder address city. ex: 'Rio de Janeiro'
|
27
|
+
# - state_code [string, default sub-issuer state code]: card holder address state. ex: 'GO'
|
28
|
+
# - zip_code [string, default sub-issuer zip code]: card holder address zip code. ex: '01311-200'
|
29
|
+
#
|
30
|
+
# ## Attributes (return-only):
|
31
|
+
# - id [string]: unique id returned when IssuingCard is created. ex: '5656565656565656'
|
32
|
+
# - holder_id [string]: card holder unique id. ex: '5656565656565656'
|
33
|
+
# - type [string]: card type. ex: 'virtual'
|
34
|
+
# - status [string]: current IssuingCard status. ex: 'active', 'blocked', 'canceled', 'expired'.
|
35
|
+
# - number [string]: [EXPANDABLE] masked card number. Expand to unmask the value. ex: '123'.
|
36
|
+
# - security_code [string]: [EXPANDABLE] masked card verification value (cvv). Expand to unmask the value. ex: '123'.
|
37
|
+
# - expiration [DateTime]: [EXPANDABLE] masked card expiration datetime. Expand to unmask the value. ex: DateTime.new(2032, 3, 10, 10, 30, 0, 0)
|
38
|
+
# - created [DateTime]: creation datetime for the IssuingCard. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
39
|
+
# - updated [DateTime]: latest update datetime for the IssuingCard. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
40
|
+
class IssuingCard < StarkInfra::Utils::Resource
|
41
|
+
attr_reader :id, :holder_id, :holder_name, :holder_tax_id, :holder_external_id, :type, :display_name, :status,
|
42
|
+
:rules, :bin_id, :street_line_1, :street_line_2, :district, :city, :state_code, :zip_code, :tags, :number,
|
43
|
+
:security_code, :expiration, :created, :updated
|
44
|
+
def initialize(
|
45
|
+
holder_name:, holder_tax_id:, holder_external_id:, id: nil, holder_id: nil, type: nil,
|
46
|
+
display_name: nil, status: nil, rules: nil, bin_id: nil, street_line_1: nil, street_line_2: nil, district: nil,
|
47
|
+
city: nil, state_code: nil, zip_code: nil, tags: nil, number: nil, security_code: nil, expiration: nil,
|
48
|
+
created: nil, updated: nil
|
49
|
+
)
|
50
|
+
super(id)
|
51
|
+
@holder_name = holder_name
|
52
|
+
@holder_tax_id = holder_tax_id
|
53
|
+
@holder_external_id = holder_external_id
|
54
|
+
@holder_id = holder_id
|
55
|
+
@type = type
|
56
|
+
@display_name = display_name
|
57
|
+
@status = status
|
58
|
+
@rules = StarkInfra::IssuingRule.parse_rules(rules)
|
59
|
+
@bin_id = bin_id
|
60
|
+
@street_line_1 = street_line_1
|
61
|
+
@street_line_2 = street_line_2
|
62
|
+
@district = district
|
63
|
+
@city = city
|
64
|
+
@state_code = state_code
|
65
|
+
@zip_code = zip_code
|
66
|
+
@tags = tags
|
67
|
+
@number = number
|
68
|
+
@security_code = security_code
|
69
|
+
expiration = nil if !expiration.nil? && expiration.include?('*')
|
70
|
+
@expiration = StarkInfra::Utils::Checks.check_datetime(expiration)
|
71
|
+
@created = StarkInfra::Utils::Checks.check_datetime(created)
|
72
|
+
@updated = StarkInfra::Utils::Checks.check_datetime(updated)
|
73
|
+
end
|
74
|
+
|
75
|
+
# # Create IssuingCards
|
76
|
+
#
|
77
|
+
# Send a list of IssuingCard objects for creation in the Stark Infra API
|
78
|
+
#
|
79
|
+
# ## Parameters (required):
|
80
|
+
# - cards [list of IssuingCard objects]: list of IssuingCard objects to be created in the API
|
81
|
+
#
|
82
|
+
# ## Parameters (optional):
|
83
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
84
|
+
#
|
85
|
+
# ## Return:
|
86
|
+
# - list of IssuingCard objects with updated attributes
|
87
|
+
def self.create(cards:, expand: nil, user: nil)
|
88
|
+
StarkInfra::Utils::Rest.post(entities: cards, expand: expand, user: user, **resource)
|
89
|
+
end
|
90
|
+
|
91
|
+
# # Retrieve a specific IssuingCard
|
92
|
+
#
|
93
|
+
# Receive a single IssuingCard object previously created in the Stark Infra API by its id
|
94
|
+
#
|
95
|
+
# ## Parameters (required):
|
96
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
97
|
+
#
|
98
|
+
# ## Parameters (optional):
|
99
|
+
# - expand [list of strings, default nil]: fields to expand information. ex: ['rules', 'securityCode', 'number', 'expiration']
|
100
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
101
|
+
#
|
102
|
+
# ## Return:
|
103
|
+
# - IssuingCard object with updated attributes
|
104
|
+
def self.get(id, expand: nil, user: nil)
|
105
|
+
StarkInfra::Utils::Rest.get_id(id: id, expand: expand, user: user, **resource)
|
106
|
+
end
|
107
|
+
|
108
|
+
# # Retrieve IssuingCards
|
109
|
+
#
|
110
|
+
# Receive a generator of IssuingCards objects previously created in the Stark Infra API
|
111
|
+
#
|
112
|
+
# ## Parameters (optional):
|
113
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
114
|
+
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
115
|
+
# - after [DateTime or string, default nil] date filter for objects created only after specified date. ex: DateTime.new(2020, 3, 10)
|
116
|
+
# - before [DateTime or string, default nil] date filter for objects created only before specified date. ex: DateTime.new(2020, 3, 10)
|
117
|
+
# - status [list of strings, default nil]: filter for status of retrieved objects. ex: ['active', 'blocked', 'canceled', 'expired']
|
118
|
+
# - types [list of strings, default nil]: card type. ex: ['virtual']
|
119
|
+
# - holder_ids [list of strings]: card holder IDs. ex: ['5656565656565656', '4545454545454545']
|
120
|
+
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
121
|
+
# - expand [list of strings, default []]: fields to expand information. ex: ['rules', 'security_code', 'number', 'expiration']
|
122
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
123
|
+
#
|
124
|
+
# ## Return:
|
125
|
+
# - generator of IssuingCards objects with updated attributes
|
126
|
+
def self.query(limit: nil, ids: nil, after: nil, before: nil, status: nil, types: nil, holder_ids: nil, tags: nil,
|
127
|
+
expand: nil, user: nil)
|
128
|
+
after = StarkInfra::Utils::Checks.check_date(after)
|
129
|
+
before = StarkInfra::Utils::Checks.check_date(before)
|
130
|
+
StarkInfra::Utils::Rest.get_stream(
|
131
|
+
limit: limit,
|
132
|
+
ids: ids,
|
133
|
+
after: after,
|
134
|
+
before: before,
|
135
|
+
status: status,
|
136
|
+
types: types,
|
137
|
+
holder_ids: holder_ids,
|
138
|
+
tags: tags,
|
139
|
+
expand: expand,
|
140
|
+
user: user,
|
141
|
+
**resource
|
142
|
+
)
|
143
|
+
end
|
144
|
+
|
145
|
+
# # Retrieve paged IssuingCards
|
146
|
+
#
|
147
|
+
# Receive a list of IssuingCards objects previously created in the Stark Infra API and the cursor to the next page.
|
148
|
+
#
|
149
|
+
# ## Parameters (optional):
|
150
|
+
# - cursor [string, default nil]: cursor returned on the previous page function call.
|
151
|
+
# - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
|
152
|
+
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
153
|
+
# - after [DateTime or string, default nil] date filter for objects created only after specified date. ex: DateTime.new(2020, 3, 10)
|
154
|
+
# - before [DateTime or string, default nil] date filter for objects created only before specified date. ex: DateTime.new(2020, 3, 10)
|
155
|
+
# - status [list of strings, default nil]: filter for status of retrieved objects. ex: ['active', 'blocked', 'canceled', 'expired']
|
156
|
+
# - types [list of strings, default nil]: card type. ex: ['virtual']
|
157
|
+
# - holder_ids [list of strings]: card holder IDs. ex: ['5656565656565656', '4545454545454545']
|
158
|
+
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
159
|
+
# - expand [list of strings, default []]: fields to expand information. ex: ['rules', 'security_code', 'number', 'expiration']
|
160
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
161
|
+
#
|
162
|
+
# ## Return:
|
163
|
+
# - list of IssuingCards objects with updated attributes
|
164
|
+
# - cursor to retrieve the next page of IssuingCards objects
|
165
|
+
def self.page(cursor: nil, limit: nil, ids: nil, after: nil, before: nil, status: nil, types: nil, holder_ids: nil,
|
166
|
+
tags: nil, expand: nil, user: nil)
|
167
|
+
after = StarkInfra::Utils::Checks.check_date(after)
|
168
|
+
before = StarkInfra::Utils::Checks.check_date(before)
|
169
|
+
StarkInfra::Utils::Rest.get_page(
|
170
|
+
cursor: cursor,
|
171
|
+
limit: limit,
|
172
|
+
ids: ids,
|
173
|
+
after: after,
|
174
|
+
before: before,
|
175
|
+
status: status,
|
176
|
+
types: types,
|
177
|
+
holder_ids: holder_ids,
|
178
|
+
tags: tags,
|
179
|
+
expand: expand,
|
180
|
+
user: user,
|
181
|
+
**resource
|
182
|
+
)
|
183
|
+
end
|
184
|
+
|
185
|
+
# # Update IssuingCard entity
|
186
|
+
#
|
187
|
+
# Update an IssuingCard by passing id.
|
188
|
+
#
|
189
|
+
# ## Parameters (required):
|
190
|
+
# - id [string]: IssuingCard unique id. ex: '5656565656565656'
|
191
|
+
#
|
192
|
+
# ## Parameters (optional):
|
193
|
+
# - status [string, default nil]: You may block the IssuingCard by passing 'blocked' or activate by passing 'active' in the status
|
194
|
+
# - display_name [string, default nil]: card displayed name
|
195
|
+
# - rules [list of IssuingRule objects, default nil]: [EXPANDABLE] list of card spending rules.
|
196
|
+
# - tags [list of strings, default nil]: list of strings for tagging
|
197
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
|
198
|
+
#
|
199
|
+
# ## Return:
|
200
|
+
# - target IssuingCard with updated attributes
|
201
|
+
def self.update(id, status: nil, display_name: nil, rules: nil, tags: nil, user: nil)
|
202
|
+
StarkInfra::Utils::Rest.patch_id(
|
203
|
+
id: id,
|
204
|
+
status: status,
|
205
|
+
display_name: display_name,
|
206
|
+
rules: rules,
|
207
|
+
tags: tags,
|
208
|
+
user: user,
|
209
|
+
**resource
|
210
|
+
)
|
211
|
+
end
|
212
|
+
|
213
|
+
# # Cancel an IssuingCard entity
|
214
|
+
#
|
215
|
+
# Cancel an IssuingCard entity previously created in the Stark Infra API
|
216
|
+
#
|
217
|
+
# ## Parameters (required):
|
218
|
+
# - id [string]: IssuingCard unique id. ex: '5656565656565656'
|
219
|
+
#
|
220
|
+
# ## Parameters (optional):
|
221
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
222
|
+
#
|
223
|
+
# ## Return:
|
224
|
+
# - canceled IssuingCard object
|
225
|
+
def self.cancel(id, user: nil)
|
226
|
+
StarkInfra::Utils::Rest.delete_id(id: id, user: user, **resource)
|
227
|
+
end
|
228
|
+
|
229
|
+
def self.resource
|
230
|
+
{
|
231
|
+
resource_name: 'IssuingCard',
|
232
|
+
resource_maker: proc { |json|
|
233
|
+
IssuingCard.new(
|
234
|
+
id: json['id'],
|
235
|
+
holder_id: json['holder_id'],
|
236
|
+
holder_name: json['holder_name'],
|
237
|
+
holder_tax_id: json['holder_tax_id'],
|
238
|
+
holder_external_id: json['holder_external_id'],
|
239
|
+
type: json['type'],
|
240
|
+
display_name: json['display_name'],
|
241
|
+
status: json['status'],
|
242
|
+
rules: json['rules'],
|
243
|
+
bin_id: json['bin_id'],
|
244
|
+
street_line_1: json['street_line_1'],
|
245
|
+
street_line_2: json['street_line_2'],
|
246
|
+
district: json['district'],
|
247
|
+
city: json['city'],
|
248
|
+
state_code: json['state_code'],
|
249
|
+
zip_code: json['zip_code'],
|
250
|
+
tags: json['tags'],
|
251
|
+
number: json['number'],
|
252
|
+
security_code: json['security_code'],
|
253
|
+
expiration: json['expiration'],
|
254
|
+
created: json['created'],
|
255
|
+
updated: json['updated']
|
256
|
+
)
|
257
|
+
}
|
258
|
+
}
|
259
|
+
end
|
260
|
+
end
|
261
|
+
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative('../utils/resource')
|
4
|
+
require_relative('../utils/rest')
|
5
|
+
require_relative('../utils/checks')
|
6
|
+
require_relative('issuingcard')
|
7
|
+
|
8
|
+
module StarkInfra
|
9
|
+
class IssuingCard
|
10
|
+
# # IssuingCard::Log object
|
11
|
+
#
|
12
|
+
# Every time an IssuingCard entity is updated, a corresponding issuing card.Log is generated for the entity. This log
|
13
|
+
# is never generated by the user, but it can be retrieved to check additional information on the IssuingCard.
|
14
|
+
#
|
15
|
+
# ## Attributes:
|
16
|
+
# - id [string]: unique id returned when the log is created. ex: '5656565656565656'
|
17
|
+
# - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
18
|
+
# - type [string]: type of the IssuingCard event which triggered the log creation. ex: 'processing' or 'success'
|
19
|
+
# - card [IssuingCard]: IssuingCard entity to which the log refers to.
|
20
|
+
class Log < StarkInfra::Utils::Resource
|
21
|
+
attr_reader :id, :created, :type, :card
|
22
|
+
def initialize(id:, created:, type:, card:)
|
23
|
+
super(id)
|
24
|
+
@type = type
|
25
|
+
@card = card
|
26
|
+
@created = StarkInfra::Utils::Checks.check_datetime(created)
|
27
|
+
end
|
28
|
+
|
29
|
+
# # Retrieve a specific Log
|
30
|
+
#
|
31
|
+
# Receive a single Log object previously created by the Stark Infra API by passing its id
|
32
|
+
#
|
33
|
+
# ## Parameters (required):
|
34
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
35
|
+
#
|
36
|
+
# ## Parameters (optional):
|
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
|
+
# - Log object with updated attributes
|
41
|
+
def self.get(id, user: nil)
|
42
|
+
StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource)
|
43
|
+
end
|
44
|
+
|
45
|
+
# # Retrieve Logs
|
46
|
+
#
|
47
|
+
# Receive a generator of Log objects previously created in the Stark Infra API
|
48
|
+
#
|
49
|
+
# ## Parameters (optional):
|
50
|
+
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
51
|
+
# - limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
|
52
|
+
# - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
53
|
+
# - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
54
|
+
# - types [list of strings, default nil]: filter for log event types. ex: ['blocked', 'canceled', 'created', 'expired', 'unblocked', 'updated']
|
55
|
+
# - card_ids [list of strings, default nil]: list of IssuingCard ids to filter logs. ex: ['5656565656565656', '4545454545454545']
|
56
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
|
57
|
+
#
|
58
|
+
# ## Return:
|
59
|
+
# - generator of Log objects with updated attributes
|
60
|
+
def self.query(limit: nil, after: nil, before: nil, types: nil, card_ids: nil, user: nil)
|
61
|
+
after = StarkInfra::Utils::Checks.check_date(after)
|
62
|
+
before = StarkInfra::Utils::Checks.check_date(before)
|
63
|
+
StarkInfra::Utils::Rest.get_stream(
|
64
|
+
limit: limit,
|
65
|
+
after: after,
|
66
|
+
before: before,
|
67
|
+
types: types,
|
68
|
+
card_ids: card_ids,
|
69
|
+
user: user,
|
70
|
+
**resource
|
71
|
+
)
|
72
|
+
end
|
73
|
+
|
74
|
+
# # Retrieve paged Logs
|
75
|
+
#
|
76
|
+
# Receive a list of up to 100 Log objects previously created in the Stark Infra API and the cursor to the next page.
|
77
|
+
# Use this function instead of query if you want to manually page your logs.
|
78
|
+
#
|
79
|
+
# ## Parameters (optional):
|
80
|
+
# - cursor [string, default nil]: cursor returned on the previous page function call
|
81
|
+
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
82
|
+
# - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
|
83
|
+
# - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
84
|
+
# - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
85
|
+
# - types [list of strings, default nil]: filter for log event types. ex: ['blocked', 'canceled', 'created', 'expired', 'unblocked', 'updated']
|
86
|
+
# - card_ids [list of strings, default nil]: list of IssuingCard ids to filter logs. ex: ['5656565656565656', '4545454545454545']
|
87
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
|
88
|
+
#
|
89
|
+
# ## Return:
|
90
|
+
# - list of Log objects with updated attributes
|
91
|
+
# - Cursor to retrieve the next page of Log objects
|
92
|
+
def self.page(cursor: nil, limit: nil, after: nil, before: nil, types: nil, card_ids: nil, user: nil)
|
93
|
+
after = StarkInfra::Utils::Checks.check_date(after)
|
94
|
+
before = StarkInfra::Utils::Checks.check_date(before)
|
95
|
+
StarkInfra::Utils::Rest.get_page(
|
96
|
+
cursor: cursor,
|
97
|
+
limit: limit,
|
98
|
+
after: after,
|
99
|
+
before: before,
|
100
|
+
types: types,
|
101
|
+
card_ids: card_ids,
|
102
|
+
user: user,
|
103
|
+
**resource
|
104
|
+
)
|
105
|
+
end
|
106
|
+
|
107
|
+
def self.resource
|
108
|
+
request_maker = StarkInfra::IssuingCard.resource[:resource_maker]
|
109
|
+
{
|
110
|
+
resource_name: 'IssuingCardLog',
|
111
|
+
resource_maker: proc { |json|
|
112
|
+
Log.new(
|
113
|
+
id: json['id'],
|
114
|
+
created: json['created'],
|
115
|
+
type: json['type'],
|
116
|
+
card: StarkInfra::Utils::API.from_api_json(request_maker, json['card'])
|
117
|
+
)
|
118
|
+
}
|
119
|
+
}
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -0,0 +1,206 @@
|
|
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
|
+
# # IssuingHolder object
|
9
|
+
#
|
10
|
+
# The IssuingHolder describes a card holder that may group several cards.
|
11
|
+
#
|
12
|
+
# ## Parameters (required):
|
13
|
+
# - name [string]: card holder name.
|
14
|
+
# - tax_id [string]: card holder tax ID
|
15
|
+
# - external_id [string] card holder external ID
|
16
|
+
#
|
17
|
+
# ## Parameters (optional):
|
18
|
+
# - rules [list of IssuingRule objects, default nil]: [EXPANDABLE] list of holder spending rules.
|
19
|
+
# - tags [list of strings, default []]: list of strings for tagging. ex: ['travel', 'food']
|
20
|
+
#
|
21
|
+
# ## Attributes (return-only):
|
22
|
+
# - id [string]: unique id returned when IssuingHolder is created. ex: '5656565656565656'
|
23
|
+
# - status [string]: current IssuingHolder status. ex: 'active', 'blocked', 'canceled'
|
24
|
+
# - updated [DateTime]: latest update datetime for the IssuingHolder. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
25
|
+
# - created [DateTime]: creation datetime for the log. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
|
26
|
+
class IssuingHolder < StarkInfra::Utils::Resource
|
27
|
+
attr_reader :id, :name, :tax_id, :external_id, :status, :rules, :tags, :updated, :created
|
28
|
+
def initialize(
|
29
|
+
name:, tax_id:, external_id:, id: nil, status: nil, rules: nil, tags: nil, updated: nil, created: nil
|
30
|
+
)
|
31
|
+
super(id)
|
32
|
+
@name = name
|
33
|
+
@tax_id = tax_id
|
34
|
+
@external_id = external_id
|
35
|
+
@status = status
|
36
|
+
@rules = StarkInfra::IssuingRule.parse_rules(rules)
|
37
|
+
@tags = tags
|
38
|
+
@created = StarkInfra::Utils::Checks.check_datetime(created)
|
39
|
+
@updated = StarkInfra::Utils::Checks.check_datetime(updated)
|
40
|
+
end
|
41
|
+
|
42
|
+
# # Create IssuingHolders
|
43
|
+
#
|
44
|
+
# Send a list of IssuingHolder objects for creation in the Stark Infra API
|
45
|
+
#
|
46
|
+
# ## Parameters (required):
|
47
|
+
# - holders [list of IssuingHolder objects]: list of IssuingHolder objects to be created in the API
|
48
|
+
#
|
49
|
+
# ## Parameters (optional):
|
50
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
51
|
+
#
|
52
|
+
# ## Return:
|
53
|
+
# - list of IssuingHolder objects with updated attributes
|
54
|
+
def self.create(holders:, user: nil)
|
55
|
+
StarkInfra::Utils::Rest.post(entities: holders, user: user, **resource)
|
56
|
+
end
|
57
|
+
|
58
|
+
# # Retrieve a specific IssuingHolder
|
59
|
+
#
|
60
|
+
# Receive a single IssuingHolder object previously created in the Stark Infra API by its id
|
61
|
+
#
|
62
|
+
# ## Parameters (required):
|
63
|
+
# - id [string]: object unique id. ex: '5656565656565656'
|
64
|
+
#
|
65
|
+
# ## Parameters (optional):
|
66
|
+
# - expand [list of strings, default nil]: fields to expand information. ex: ['rules']
|
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
|
+
# - IssuingHolder object with updated attributes
|
71
|
+
def self.get(id, expand: nil, user: nil)
|
72
|
+
StarkInfra::Utils::Rest.get_id(id: id, expand: expand, user: user, **resource)
|
73
|
+
end
|
74
|
+
|
75
|
+
# # Retrieve IssuingHolders
|
76
|
+
#
|
77
|
+
# Receive a generator of IssuingHolder 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
|
+
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. 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
|
+
# - status [list of strings, default nil]: filter for status of retrieved objects. ex: ['active', 'blocked', 'canceled']
|
85
|
+
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
86
|
+
# - expand [string, default nil]: fields to expand information. ex: ['rules']
|
87
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
|
88
|
+
#
|
89
|
+
# ## Return:
|
90
|
+
# - generator of IssuingHolders objects with updated attributes
|
91
|
+
def self.query(limit: nil, ids: nil, after: nil, before: nil, status: nil, tags: nil, expand: nil, user: nil)
|
92
|
+
after = StarkInfra::Utils::Checks.check_date(after)
|
93
|
+
before = StarkInfra::Utils::Checks.check_date(before)
|
94
|
+
StarkInfra::Utils::Rest.get_stream(
|
95
|
+
limit: limit,
|
96
|
+
ids: ids,
|
97
|
+
after: after,
|
98
|
+
before: before,
|
99
|
+
status: status,
|
100
|
+
tags: tags,
|
101
|
+
expand: expand,
|
102
|
+
user: user,
|
103
|
+
**resource
|
104
|
+
)
|
105
|
+
end
|
106
|
+
|
107
|
+
# # Retrieve paged IssuingHolders
|
108
|
+
#
|
109
|
+
# Receive a list of IssuingHolder objects previously created in the Stark Infra API and the cursor to the next page.
|
110
|
+
#
|
111
|
+
# ## Parameters (optional):
|
112
|
+
# - cursor [string, default nil]: cursor returned on the previous page function call.
|
113
|
+
# - limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
|
114
|
+
# - ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
|
115
|
+
# - after [Date or string, default nil] date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
|
116
|
+
# - before [Date or string, default nil] date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
|
117
|
+
# - status [list of strings, default nil]: filter for status of retrieved objects. ex: ['active', 'blocked', 'canceled']
|
118
|
+
# - tags [list of strings, default nil]: tags to filter retrieved objects. ex: ['tony', 'stark']
|
119
|
+
# - expand [string, default nil]: fields to expand information. ex: ['rules']
|
120
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
|
121
|
+
#
|
122
|
+
# ## Return:
|
123
|
+
# - list of IssuingHolders objects with updated attributes
|
124
|
+
# - cursor to retrieve the next page of IssuingHolders objects
|
125
|
+
def self.page(cursor: nil, limit: nil, ids: nil, after: nil, before: nil, status: nil, tags: nil, expand: nil,
|
126
|
+
user: nil)
|
127
|
+
after = StarkInfra::Utils::Checks.check_date(after)
|
128
|
+
before = StarkInfra::Utils::Checks.check_date(before)
|
129
|
+
StarkInfra::Utils::Rest.get_page(
|
130
|
+
cursor: cursor,
|
131
|
+
limit: limit,
|
132
|
+
ids: ids,
|
133
|
+
after: after,
|
134
|
+
before: before,
|
135
|
+
status: status,
|
136
|
+
tags: tags,
|
137
|
+
expand: expand,
|
138
|
+
user: user,
|
139
|
+
**resource
|
140
|
+
)
|
141
|
+
end
|
142
|
+
|
143
|
+
# # Update IssuingHolder entity
|
144
|
+
#
|
145
|
+
# Update an IssuingHolder by passing id, if it hasn't been paid yet.
|
146
|
+
#
|
147
|
+
# ## Parameters (required):
|
148
|
+
# - id [string]: IssuingHolder id. ex: '5656565656565656'
|
149
|
+
#
|
150
|
+
# ## Parameters (optional):
|
151
|
+
# - status [string, default nil]: You may block the IssuingHolder by passing 'blocked' in the status
|
152
|
+
# - name [string, default nil]: card holder name.
|
153
|
+
# - tags [list of strings, default nil]: list of strings for tagging
|
154
|
+
# - rules [list of IssuingRule objects, default nil]: list of objects that represent the holder's spending rules.
|
155
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call
|
156
|
+
#
|
157
|
+
# ## Return:
|
158
|
+
# - target IssuingHolder with updated attributes
|
159
|
+
def self.update(id, status: nil, name: nil, tags: nil, rules: nil, user: nil)
|
160
|
+
StarkInfra::Utils::Rest.patch_id(
|
161
|
+
id: id,
|
162
|
+
status: status,
|
163
|
+
name: name,
|
164
|
+
tags: tags,
|
165
|
+
rules: rules,
|
166
|
+
user: user,
|
167
|
+
**resource
|
168
|
+
)
|
169
|
+
end
|
170
|
+
|
171
|
+
# # Cancel an IssuingHolder entity
|
172
|
+
#
|
173
|
+
# Cancel an IssuingHolder entity previously created in the Stark Infra API
|
174
|
+
#
|
175
|
+
# ## Parameters (required):
|
176
|
+
# - id [string]: IssuingHolder unique id. ex: '5656565656565656'
|
177
|
+
#
|
178
|
+
# ## Parameters (optional):
|
179
|
+
# - user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
|
180
|
+
#
|
181
|
+
# ## Return:
|
182
|
+
# - canceled IssuingHolder object
|
183
|
+
def self.cancel(id, user: nil)
|
184
|
+
StarkInfra::Utils::Rest.delete_id(id: id, user: user, **resource)
|
185
|
+
end
|
186
|
+
|
187
|
+
def self.resource
|
188
|
+
{
|
189
|
+
resource_name: 'IssuingHolder',
|
190
|
+
resource_maker: proc { |json|
|
191
|
+
IssuingHolder.new(
|
192
|
+
id: json['id'],
|
193
|
+
name: json['name'],
|
194
|
+
tax_id: json['tax_id'],
|
195
|
+
external_id: json['external_id'],
|
196
|
+
status: json['status'],
|
197
|
+
rules: json['rules'],
|
198
|
+
tags: json['tags'],
|
199
|
+
updated: json['updated'],
|
200
|
+
created: json['created']
|
201
|
+
)
|
202
|
+
}
|
203
|
+
}
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|