starkinfra 0.3.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/brcodepreview/brcodepreview.rb +2 -5
- data/lib/cardmethod/cardmethod.rb +2 -2
- data/lib/creditholmes/creditholmes.rb +8 -11
- data/lib/creditnote/creditnote.rb +10 -11
- data/lib/creditnote/invoice/description.rb +3 -5
- data/lib/creditnote/invoice/discount.rb +3 -4
- data/lib/creditnote/invoice/invoice.rb +5 -6
- data/lib/creditnote/log.rb +8 -9
- data/lib/creditnote/transfer.rb +4 -5
- data/lib/creditpreview/creditnotepreview.rb +2 -3
- data/lib/creditpreview/creditpreview.rb +3 -4
- data/lib/creditsigner/creditsigner.rb +3 -6
- data/lib/dynamicbrcode/dynamicbrcode.rb +17 -19
- data/lib/error.rb +7 -40
- data/lib/event/attempt.rb +7 -8
- data/lib/event/event.rb +8 -11
- data/lib/individualdocument/individualdocument.rb +7 -8
- data/lib/individualdocument/log.rb +8 -9
- data/lib/individualidentity/individualidentity.rb +7 -8
- data/lib/individualidentity/log.rb +8 -9
- data/lib/issuingbalance/issuingbalance.rb +2 -3
- data/lib/issuingcard/issuingcard.rb +9 -10
- data/lib/issuingcard/log.rb +8 -9
- data/lib/issuingdesign/issuingdesign.rb +5 -6
- data/lib/issuingembossingkit/issuingembossingkit.rb +4 -5
- data/lib/issuingembossingrequest/issuingembossingrequest.rb +8 -9
- data/lib/issuingembossingrequest/log.rb +8 -9
- data/lib/issuingholder/issuingholder.rb +9 -10
- data/lib/issuingholder/log.rb +8 -9
- data/lib/issuinginvoice/issuinginvoice.rb +8 -9
- data/lib/issuinginvoice/log.rb +8 -9
- data/lib/issuingproduct/issuingproduct.rb +3 -4
- data/lib/issuingpurchase/issuingpurchase.rb +33 -22
- data/lib/issuingpurchase/log.rb +8 -9
- data/lib/issuingrestock/issuingrestock.rb +8 -9
- data/lib/issuingrestock/log.rb +8 -9
- data/lib/issuingrule/issuingrule.rb +6 -7
- data/lib/issuingstock/issuingstock.rb +8 -9
- data/lib/issuingstock/log.rb +8 -9
- data/lib/issuingtransaction/issuingtransaction.rb +7 -8
- data/lib/issuingwithdrawal/issuingwithdrawal.rb +8 -9
- data/lib/merchantcategory/merchantcategory.rb +2 -2
- data/lib/merchantcountry/merchantcountry.rb +2 -2
- data/lib/pixbalance/pixbalance.rb +2 -3
- data/lib/pixchargeback/log.rb +8 -9
- data/lib/pixchargeback/pixchargeback.rb +8 -9
- data/lib/pixclaim/log.rb +8 -9
- data/lib/pixclaim/pixclaim.rb +8 -9
- data/lib/pixdirector/pixdirector.rb +2 -2
- data/lib/pixdomain/certificate.rb +2 -2
- data/lib/pixdomain/pixdomain.rb +3 -3
- data/lib/pixinfraction/log.rb +8 -9
- data/lib/pixinfraction/pixinfraction.rb +8 -9
- data/lib/pixkey/log.rb +8 -9
- data/lib/pixkey/pixkey.rb +8 -9
- data/lib/pixrequest/log.rb +8 -9
- data/lib/pixrequest/pixrequest.rb +9 -10
- data/lib/pixreversal/log.rb +7 -9
- data/lib/pixreversal/pixreversal.rb +9 -10
- data/lib/pixstatement/pixstatement.rb +6 -7
- data/lib/request/request.rb +152 -0
- data/lib/starkinfra.rb +14 -6
- data/lib/staticbrcode/staticbrcode.rb +8 -9
- data/lib/utils/parse.rb +23 -42
- data/lib/utils/rest.rb +211 -110
- data/lib/webhook/webhook.rb +2 -3
- metadata +6 -21
- data/lib/key.rb +0 -33
- data/lib/user/organization.rb +0 -54
- data/lib/user/project.rb +0 -37
- data/lib/user/user.rb +0 -20
- data/lib/utils/api.rb +0 -89
- data/lib/utils/bacenid.rb +0 -19
- data/lib/utils/cache.rb +0 -10
- data/lib/utils/case.rb +0 -21
- data/lib/utils/checks.rb +0 -100
- data/lib/utils/endtoendid.rb +0 -11
- data/lib/utils/environment.rb +0 -14
- data/lib/utils/request.rb +0 -79
- data/lib/utils/resource.rb +0 -13
- data/lib/utils/returnid.rb +0 -11
- data/lib/utils/sub_resource.rb +0 -27
- data/lib/utils/url.rb +0 -28
data/lib/utils/parse.rb
CHANGED
@@ -1,53 +1,34 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require('json')
|
4
|
-
require('starkbank-ecdsa')
|
5
|
-
require_relative('api')
|
6
|
-
require_relative('cache')
|
7
|
-
require_relative('request')
|
8
|
-
require_relative('../error')
|
1
|
+
require('starkcore')
|
9
2
|
|
10
3
|
module StarkInfra
|
11
4
|
module Utils
|
12
5
|
module Parse
|
13
6
|
def self.parse_and_verify(content:, signature:, user: nil, resource:, key: nil)
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
7
|
+
return StarkCore::Utils::Parse.parse_and_verify(
|
8
|
+
content: content,
|
9
|
+
signature: signature,
|
10
|
+
sdk_version: StarkInfra::SDK_VERSION,
|
11
|
+
api_version: StarkInfra::API_VERSION,
|
12
|
+
host: StarkInfra::HOST,
|
13
|
+
resource: resource,
|
14
|
+
user: user ? user : StarkInfra.user,
|
15
|
+
language: StarkInfra.language,
|
16
|
+
timeout: StarkInfra.language,
|
17
|
+
key: key
|
18
|
+
)
|
19
19
|
end
|
20
20
|
|
21
21
|
def self.verify(content:, signature:, user: nil)
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
if verify_signature(content: content, signature: signature, user: user, refresh: true)
|
33
|
-
return content
|
34
|
-
end
|
35
|
-
|
36
|
-
raise(StarkInfra::Error::InvalidSignatureError, 'The provided signature and content do not match the Stark Infra public key')
|
37
|
-
end
|
38
|
-
|
39
|
-
def self.verify_signature(content:, signature:, user:, refresh: false)
|
40
|
-
public_key = StarkInfra::Utils::Cache.starkinfra_public_key
|
41
|
-
if public_key.nil? || refresh
|
42
|
-
pem = get_public_key_pem(user)
|
43
|
-
public_key = EllipticCurve::PublicKey.fromPem(pem)
|
44
|
-
StarkInfra::Utils::Cache.starkinfra_public_key = public_key
|
45
|
-
end
|
46
|
-
EllipticCurve::Ecdsa.verify(content, signature, public_key)
|
47
|
-
end
|
48
|
-
|
49
|
-
def self.get_public_key_pem(user)
|
50
|
-
StarkInfra::Utils::Request.fetch(method: 'GET', path: 'public-key', query: { limit: 1 }, user: user).json['publicKeys'][0]['content']
|
22
|
+
return StarkCore::Utils::Parse.verify(
|
23
|
+
content: content,
|
24
|
+
signature: signature,
|
25
|
+
sdk_version: StarkInfra::SDK_VERSION,
|
26
|
+
api_version: StarkInfra::API_VERSION,
|
27
|
+
host: StarkInfra::HOST,
|
28
|
+
user: user ? user : StarkInfra.user,
|
29
|
+
language: StarkInfra.language,
|
30
|
+
timeout: StarkInfra.language
|
31
|
+
)
|
51
32
|
end
|
52
33
|
end
|
53
34
|
end
|
data/lib/utils/rest.rb
CHANGED
@@ -1,136 +1,237 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
require_relative('api')
|
3
|
+
require('starkcore')
|
5
4
|
|
6
5
|
module StarkInfra
|
7
6
|
module Utils
|
8
7
|
module Rest
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
8
|
+
|
9
|
+
def self.get_page(resource_name:, resource_maker:, user:, **query)
|
10
|
+
return StarkCore::Utils::Rest.get_page(
|
11
|
+
resource_name: resource_name,
|
12
|
+
resource_maker: resource_maker,
|
13
|
+
sdk_version: StarkInfra::SDK_VERSION,
|
14
|
+
host: StarkInfra::HOST,
|
15
|
+
api_version: StarkInfra::API_VERSION,
|
16
|
+
user: user ? user : StarkInfra.user,
|
17
|
+
language: StarkInfra.language,
|
18
|
+
timeout: StarkInfra.timeout,
|
19
|
+
**query
|
20
|
+
)
|
21
21
|
end
|
22
22
|
|
23
|
-
def self.get_stream(resource_name:, resource_maker:, user
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
entities = json[StarkInfra::Utils::API.last_name_plural(resource_name)]
|
36
|
-
|
37
|
-
entities.each do |entity|
|
38
|
-
enum << StarkInfra::Utils::API.from_api_json(resource_maker, entity)
|
39
|
-
end
|
40
|
-
|
41
|
-
unless limit.nil?
|
42
|
-
limit -= 100
|
43
|
-
query[:limit] = [limit, 100].min
|
44
|
-
end
|
45
|
-
|
46
|
-
cursor = json['cursor']
|
47
|
-
query['cursor'] = cursor
|
48
|
-
break if cursor.nil? || cursor.empty? || (!limit.nil? && limit <= 0)
|
49
|
-
end
|
50
|
-
end
|
23
|
+
def self.get_stream(resource_name:, resource_maker:, user:, **query)
|
24
|
+
return StarkCore::Utils::Rest.get_stream(
|
25
|
+
resource_name: resource_name,
|
26
|
+
resource_maker: resource_maker,
|
27
|
+
sdk_version: StarkInfra::SDK_VERSION,
|
28
|
+
host: StarkInfra::HOST,
|
29
|
+
api_version: StarkInfra::API_VERSION,
|
30
|
+
user: user ? user : StarkInfra.user,
|
31
|
+
language: StarkInfra.language,
|
32
|
+
timeout: StarkInfra.timeout,
|
33
|
+
**query
|
34
|
+
)
|
51
35
|
end
|
52
36
|
|
53
|
-
def self.get_id(resource_name:, resource_maker:, id:,
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
37
|
+
def self.get_id(resource_name:, resource_maker:, user:, id:, **query)
|
38
|
+
return StarkCore::Utils::Rest.get_id(
|
39
|
+
resource_name: resource_name,
|
40
|
+
resource_maker: resource_maker,
|
41
|
+
sdk_version: StarkInfra::SDK_VERSION,
|
42
|
+
host: StarkInfra::HOST,
|
43
|
+
api_version: StarkInfra::API_VERSION,
|
44
|
+
user: user ? user : StarkInfra.user,
|
45
|
+
language: StarkInfra.language,
|
46
|
+
timeout: StarkInfra.timeout,
|
47
|
+
id: id,
|
48
|
+
**query
|
49
|
+
)
|
62
50
|
end
|
63
51
|
|
64
|
-
def self.get_content(resource_name:, sub_resource_name:, id:,
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
52
|
+
def self.get_content(resource_name:, resource_maker:, user:, sub_resource_name:, id:, **query)
|
53
|
+
return StarkCore::Utils::Rest.get_content(
|
54
|
+
resource_name: resource_name,
|
55
|
+
resource_maker: resource_maker,
|
56
|
+
sdk_version: StarkInfra::SDK_VERSION,
|
57
|
+
host: StarkInfra::HOST,
|
58
|
+
api_version: StarkInfra::API_VERSION,
|
59
|
+
user: user ? user : StarkInfra.user,
|
60
|
+
language: StarkInfra.language,
|
61
|
+
timeout: StarkInfra.timeout,
|
62
|
+
sub_resource_name: sub_resource_name,
|
63
|
+
id: id,
|
64
|
+
**query
|
65
|
+
)
|
70
66
|
end
|
71
67
|
|
72
|
-
def self.
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
68
|
+
def self.get_sub_resource(resource_name:, sub_resource_maker:, sub_resource_name:, user:, id:, **query)
|
69
|
+
return StarkCore::Utils::Rest.get_sub_resource(
|
70
|
+
resource_name: resource_name,
|
71
|
+
sub_resource_maker: sub_resource_maker,
|
72
|
+
sub_resource_name: sub_resource_name,
|
73
|
+
sdk_version: StarkInfra::SDK_VERSION,
|
74
|
+
host: StarkInfra::HOST,
|
75
|
+
api_version: StarkInfra::API_VERSION,
|
76
|
+
user: user ? user : StarkInfra.user,
|
77
|
+
language: StarkInfra.language,
|
78
|
+
timeout: StarkInfra.timeout,
|
79
|
+
id: id,
|
80
|
+
**query
|
81
|
+
)
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.get_sub_resources(resource_name:, sub_resource_maker:, sub_resource_name:, user:, id:, **query)
|
85
|
+
return StarkCore::Utils::Rest.get_sub_resource(
|
86
|
+
resource_name: resource_name,
|
87
|
+
sub_resource_maker: sub_resource_maker,
|
88
|
+
sub_resource_name: sub_resource_name,
|
89
|
+
sdk_version: StarkInfra::SDK_VERSION,
|
90
|
+
host: StarkInfra::HOST,
|
91
|
+
api_version: StarkInfra::API_VERSION,
|
92
|
+
user: user ? user : StarkInfra.user,
|
93
|
+
language: StarkInfra.language,
|
94
|
+
timeout: StarkInfra.timeout,
|
95
|
+
id: id,
|
96
|
+
**query
|
97
|
+
)
|
91
98
|
end
|
92
99
|
|
93
|
-
def self.
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
100
|
+
def self.post(resource_name:, resource_maker:, user:, entities:, **query)
|
101
|
+
return StarkCore::Utils::Rest.post(
|
102
|
+
resource_name: resource_name,
|
103
|
+
resource_maker: resource_maker,
|
104
|
+
sdk_version: StarkInfra::SDK_VERSION,
|
105
|
+
host: StarkInfra::HOST,
|
106
|
+
api_version: StarkInfra::API_VERSION,
|
107
|
+
user: user ? user : StarkInfra.user,
|
108
|
+
language: StarkInfra.language,
|
109
|
+
timeout: StarkInfra.timeout,
|
110
|
+
entities: entities,
|
111
|
+
**query
|
112
|
+
)
|
102
113
|
end
|
103
114
|
|
104
|
-
def self.
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
115
|
+
def self.post_single(resource_name:, resource_maker:, user:, entity:)
|
116
|
+
return StarkCore::Utils::Rest.post_single(
|
117
|
+
resource_name: resource_name,
|
118
|
+
resource_maker: resource_maker,
|
119
|
+
sdk_version: StarkInfra::SDK_VERSION,
|
120
|
+
host: StarkInfra::HOST,
|
121
|
+
api_version: StarkInfra::API_VERSION,
|
122
|
+
user: user ? user : StarkInfra.user,
|
123
|
+
language: StarkInfra.language,
|
124
|
+
timeout: StarkInfra.timeout,
|
125
|
+
entity: entity
|
126
|
+
)
|
112
127
|
end
|
113
128
|
|
114
|
-
def self.
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
129
|
+
def self.delete_id(resource_name:, resource_maker:, user:, id:)
|
130
|
+
return StarkCore::Utils::Rest.delete_id(
|
131
|
+
resource_name: resource_name,
|
132
|
+
resource_maker: resource_maker,
|
133
|
+
sdk_version: StarkInfra::SDK_VERSION,
|
134
|
+
host: StarkInfra::HOST,
|
135
|
+
api_version: StarkInfra::API_VERSION,
|
136
|
+
user: user ? user : StarkInfra.user,
|
137
|
+
language: StarkInfra.language,
|
138
|
+
timeout: StarkInfra.timeout,
|
139
|
+
id: id
|
140
|
+
)
|
123
141
|
end
|
124
142
|
|
125
|
-
def self.
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
143
|
+
def self.patch_id(resource_name:, resource_maker:, user:, id:, **payload)
|
144
|
+
return StarkCore::Utils::Rest.patch_id(
|
145
|
+
resource_name: resource_name,
|
146
|
+
resource_maker: resource_maker,
|
147
|
+
sdk_version: StarkInfra::SDK_VERSION,
|
148
|
+
host: StarkInfra::HOST,
|
149
|
+
api_version: StarkInfra::API_VERSION,
|
150
|
+
user: user ? user : StarkInfra.user,
|
151
|
+
language: StarkInfra.language,
|
152
|
+
timeout: StarkInfra.timeout,
|
153
|
+
id: id,
|
154
|
+
**payload
|
155
|
+
)
|
156
|
+
end
|
157
|
+
|
158
|
+
def self.get_raw(path:, prefix: nil, raiseException: nil, user: nil, query: nil)
|
159
|
+
return StarkCore::Utils::Rest.get_raw(
|
160
|
+
host: StarkInfra::HOST,
|
161
|
+
sdk_version: StarkInfra::SDK_VERSION,
|
162
|
+
user: user ? user : StarkInfra.user,
|
163
|
+
path: path,
|
164
|
+
api_version: StarkInfra::API_VERSION,
|
165
|
+
language: StarkInfra.language,
|
166
|
+
timeout: StarkInfra.timeout,
|
167
|
+
prefix: prefix,
|
168
|
+
raiseException: raiseException,
|
130
169
|
query: query
|
131
|
-
)
|
132
|
-
|
133
|
-
|
170
|
+
)
|
171
|
+
end
|
172
|
+
|
173
|
+
def self.post_raw(path:, payload:, query: nil, prefix: nil, raiseException: nil, user:)
|
174
|
+
|
175
|
+
return StarkCore::Utils::Rest.post_raw(
|
176
|
+
host: StarkInfra::HOST,
|
177
|
+
sdk_version: StarkInfra::SDK_VERSION,
|
178
|
+
user: user ? user : StarkInfra.user,
|
179
|
+
path: path,
|
180
|
+
payload: payload,
|
181
|
+
api_version: StarkInfra::API_VERSION,
|
182
|
+
language: StarkInfra.language,
|
183
|
+
timeout: StarkInfra.timeout,
|
184
|
+
query: query,
|
185
|
+
prefix: prefix,
|
186
|
+
raiseException: raiseException
|
187
|
+
)
|
188
|
+
end
|
189
|
+
|
190
|
+
def self.patch_raw(path:, payload:, query: nil, prefix: nil, raiseException: nil, user: nil)
|
191
|
+
return StarkCore::Utils::Rest.patch_raw(
|
192
|
+
host: StarkInfra::HOST,
|
193
|
+
sdk_version: StarkInfra::SDK_VERSION,
|
194
|
+
user: user ? user : StarkInfra.user,
|
195
|
+
path: path,
|
196
|
+
payload: payload,
|
197
|
+
api_version: StarkInfra::API_VERSION,
|
198
|
+
language: StarkInfra.language,
|
199
|
+
timeout: StarkInfra.timeout,
|
200
|
+
query: query,
|
201
|
+
prefix: prefix,
|
202
|
+
raiseException: raiseException
|
203
|
+
)
|
204
|
+
end
|
205
|
+
|
206
|
+
def self.put_raw(path:, payload:, query: nil, prefix: nil, raiseException: nil, user: nil)
|
207
|
+
return StarkCore::Utils::Rest.put_raw(
|
208
|
+
host: StarkInfra::HOST,
|
209
|
+
sdk_version: StarkInfra::SDK_VERSION,
|
210
|
+
user: user ? user : StarkInfra.user,
|
211
|
+
path: path,
|
212
|
+
payload: payload,
|
213
|
+
api_version: StarkInfra::API_VERSION,
|
214
|
+
language: StarkInfra.language,
|
215
|
+
timeout: StarkInfra.timeout,
|
216
|
+
query: query,
|
217
|
+
prefix: prefix,
|
218
|
+
raiseException: raiseException
|
219
|
+
)
|
220
|
+
end
|
221
|
+
|
222
|
+
def self.delete_raw(path:, query: nil, prefix: nil, raiseException: nil, user: nil)
|
223
|
+
return StarkCore::Utils::Rest.delete_raw(
|
224
|
+
host: StarkInfra::HOST,
|
225
|
+
sdk_version: StarkInfra::SDK_VERSION,
|
226
|
+
user: user ? user : StarkInfra.user,
|
227
|
+
path: path,
|
228
|
+
api_version: StarkInfra::API_VERSION,
|
229
|
+
language: StarkInfra.language,
|
230
|
+
timeout: StarkInfra.timeout,
|
231
|
+
query: query,
|
232
|
+
prefix: prefix,
|
233
|
+
raiseException: raiseException
|
234
|
+
)
|
134
235
|
end
|
135
236
|
end
|
136
237
|
end
|
data/lib/webhook/webhook.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require('starkcore')
|
3
4
|
require_relative('../utils/rest')
|
4
|
-
require_relative('../utils/checks')
|
5
|
-
require_relative('../utils/resource')
|
6
5
|
|
7
6
|
module StarkInfra
|
8
7
|
# # Webhook object
|
@@ -16,7 +15,7 @@ module StarkInfra
|
|
16
15
|
#
|
17
16
|
# ## Attributes (return-only):
|
18
17
|
# - id [string]: unique id returned when the webhook is created. ex: '5656565656565656'
|
19
|
-
class Webhook <
|
18
|
+
class Webhook < StarkCore::Utils::Resource
|
20
19
|
attr_reader :url, :subscriptions, :id
|
21
20
|
def initialize(url:, subscriptions:, id: nil)
|
22
21
|
super(id)
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: starkinfra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- starkinfra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: starkcore
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.2.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.2.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: minitest
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -113,7 +113,6 @@ files:
|
|
113
113
|
- lib/issuingstock/log.rb
|
114
114
|
- lib/issuingtransaction/issuingtransaction.rb
|
115
115
|
- lib/issuingwithdrawal/issuingwithdrawal.rb
|
116
|
-
- lib/key.rb
|
117
116
|
- lib/merchantcategory/merchantcategory.rb
|
118
117
|
- lib/merchantcountry/merchantcountry.rb
|
119
118
|
- lib/pixbalance/pixbalance.rb
|
@@ -133,25 +132,11 @@ files:
|
|
133
132
|
- lib/pixreversal/log.rb
|
134
133
|
- lib/pixreversal/pixreversal.rb
|
135
134
|
- lib/pixstatement/pixstatement.rb
|
135
|
+
- lib/request/request.rb
|
136
136
|
- lib/starkinfra.rb
|
137
137
|
- lib/staticbrcode/staticbrcode.rb
|
138
|
-
- lib/user/organization.rb
|
139
|
-
- lib/user/project.rb
|
140
|
-
- lib/user/user.rb
|
141
|
-
- lib/utils/api.rb
|
142
|
-
- lib/utils/bacenid.rb
|
143
|
-
- lib/utils/cache.rb
|
144
|
-
- lib/utils/case.rb
|
145
|
-
- lib/utils/checks.rb
|
146
|
-
- lib/utils/endtoendid.rb
|
147
|
-
- lib/utils/environment.rb
|
148
138
|
- lib/utils/parse.rb
|
149
|
-
- lib/utils/request.rb
|
150
|
-
- lib/utils/resource.rb
|
151
139
|
- lib/utils/rest.rb
|
152
|
-
- lib/utils/returnid.rb
|
153
|
-
- lib/utils/sub_resource.rb
|
154
|
-
- lib/utils/url.rb
|
155
140
|
- lib/webhook/webhook.rb
|
156
141
|
homepage: https://github.com/starkinfra/sdk-ruby
|
157
142
|
licenses:
|
data/lib/key.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require('fileutils')
|
4
|
-
require('starkbank-ecdsa')
|
5
|
-
|
6
|
-
module StarkInfra
|
7
|
-
module Key
|
8
|
-
# # Generate a new key pair
|
9
|
-
# Generates a secp256k1 ECDSA private/public key pair to be used in the API
|
10
|
-
# authentications
|
11
|
-
#
|
12
|
-
# ## Parameters (optional):
|
13
|
-
# - path [string]: path to save the keys .pem files. No files will be saved if this parameter isn't provided
|
14
|
-
#
|
15
|
-
# ## Return:
|
16
|
-
# - private and public key pems
|
17
|
-
def self.create(path = nil)
|
18
|
-
private_key = EllipticCurve::PrivateKey.new
|
19
|
-
public_key = private_key.publicKey
|
20
|
-
|
21
|
-
private_key_pem = private_key.toPem
|
22
|
-
public_key_pem = public_key.toPem
|
23
|
-
|
24
|
-
unless path.nil?
|
25
|
-
FileUtils.mkdir_p(path)
|
26
|
-
File.write(File.join(path, 'private.pem'), private_key_pem)
|
27
|
-
File.write(File.join(path, 'public.pem'), public_key_pem)
|
28
|
-
end
|
29
|
-
|
30
|
-
[private_key_pem, public_key_pem]
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
data/lib/user/organization.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative('user')
|
4
|
-
|
5
|
-
module StarkInfra
|
6
|
-
# # Organization object
|
7
|
-
# The Organization object is an authentication entity for the SDK that
|
8
|
-
# represents your entire Organization, being able to access any Workspace
|
9
|
-
# underneath it and even create new Workspaces. Only a legal representative
|
10
|
-
# of your organization can register or change the Organization credentials.
|
11
|
-
# All requests to the Stark Infra API must be authenticated via an SDK user,
|
12
|
-
# which must have been previously created at the Stark Infra website
|
13
|
-
# [https://web.sandbox.starkinfra.com] or [https://web.starkinfra.com]
|
14
|
-
# before you can use it in this SDK. Organizations may be passed as the user parameter on
|
15
|
-
# each request or may be defined as the default user at the start (See README).
|
16
|
-
# If you are accessing a specific Workspace using Organization credentials, you should
|
17
|
-
# specify the workspace ID when building the Organization object or by request, using
|
18
|
-
# the Organization.replace(organization, workspace_id) method, which creates a copy of the organization
|
19
|
-
# object with the altered workspace ID. If you are listing or creating new Workspaces, the
|
20
|
-
# workspace_id should be nil.
|
21
|
-
#
|
22
|
-
# ## Parameters (required):
|
23
|
-
# - environment [string]: environment where the organization is being used. ex: 'sandbox' or 'production'
|
24
|
-
# - id [string]: unique id required to identify organization. ex: '5656565656565656'
|
25
|
-
# - private_key [string]: PEM string of the private key linked to the organization. ex: '-----BEGIN PUBLIC KEY-----\nMFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEyTIHK6jYuik6ktM9FIF3yCEYzpLjO5X/\ntqDioGM+R2RyW0QEo+1DG8BrUf4UXHSvCjtQ0yLppygz23z0yPZYfw==\n-----END PUBLIC KEY-----'
|
26
|
-
# - workspace_id [string]: unique id of the accessed Workspace, if any. ex: nil or '4848484848484848'
|
27
|
-
#
|
28
|
-
# ## Attributes (return-only):
|
29
|
-
# - pem [string]: private key in pem format. ex: '-----BEGIN PUBLIC KEY-----\nMFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEyTIHK6jYuik6ktM9FIF3yCEYzpLjO5X/\ntqDioGM+R2RyW0QEo+1DG8BrUf4UXHSvCjtQ0yLppygz23z0yPZYfw==\n-----END PUBLIC KEY-----'
|
30
|
-
class Organization < StarkInfra::User
|
31
|
-
attr_reader :workspace_id
|
32
|
-
def initialize(id:, environment:, private_key:, workspace_id: nil)
|
33
|
-
super(environment, id, private_key)
|
34
|
-
@workspace_id = workspace_id
|
35
|
-
end
|
36
|
-
|
37
|
-
def access_id
|
38
|
-
if @workspace_id
|
39
|
-
"organization/#{@id}/workspace/#{@workspace_id}"
|
40
|
-
else
|
41
|
-
"organization/#{@id}"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def self.replace(organization, workspace_id)
|
46
|
-
Organization.new(
|
47
|
-
environment: organization.environment,
|
48
|
-
id: organization.id,
|
49
|
-
private_key: organization.pem,
|
50
|
-
workspace_id: workspace_id
|
51
|
-
)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
data/lib/user/project.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative('user')
|
4
|
-
|
5
|
-
module StarkInfra
|
6
|
-
# # Project object
|
7
|
-
#
|
8
|
-
# The Project object is an authentication entity for the SDK that is permanently
|
9
|
-
# linked to a specific Workspace.
|
10
|
-
# All requests to the Stark Infra API must be authenticated via an SDK user,
|
11
|
-
# which must have been previously created at the Stark Infra website
|
12
|
-
# [https://web.sandbox.starkinfra.com] or [https://web.starkinfra.com]
|
13
|
-
# before you can use it in this SDK. Projects may be passed as the user parameter on
|
14
|
-
# each request or may be defined as the default user at the start (See README).
|
15
|
-
#
|
16
|
-
# ## Parameters (required):
|
17
|
-
# - id [string]: unique id required to identify project. ex: '5656565656565656'
|
18
|
-
# - private_key [string]: PEM string of the private key linked to the project. ex: '-----BEGIN PUBLIC KEY-----\nMFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEyTIHK6jYuik6ktM9FIF3yCEYzpLjO5X/\ntqDioGM+R2RyW0QEo+1DG8BrUf4UXHSvCjtQ0yLppygz23z0yPZYfw==\n-----END PUBLIC KEY-----'
|
19
|
-
# - environment [string]: environment where the project is being used. ex: 'sandbox' or 'production'
|
20
|
-
#
|
21
|
-
# ## Attributes (return-only):
|
22
|
-
# - name [string, default nil]: project name. ex: 'MyProject'
|
23
|
-
# - allowed_ips [list of strings]: list containing the strings of the ips allowed to make requests on behalf of this project. ex: ['190.190.0.50']
|
24
|
-
# - pem [string]: private key in pem format. ex: '-----BEGIN PUBLIC KEY-----\nMFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEyTIHK6jYuik6ktM9FIF3yCEYzpLjO5X/\ntqDioGM+R2RyW0QEo+1DG8BrUf4UXHSvCjtQ0yLppygz23z0yPZYfw==\n-----END PUBLIC KEY-----'
|
25
|
-
class Project < StarkInfra::User
|
26
|
-
attr_reader :name, :allowed_ips
|
27
|
-
def initialize(environment:, id:, private_key:, name: '', allowed_ips: nil)
|
28
|
-
super(environment, id, private_key)
|
29
|
-
@name = name
|
30
|
-
@allowed_ips = allowed_ips
|
31
|
-
end
|
32
|
-
|
33
|
-
def access_id
|
34
|
-
"project/#{@id}"
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
data/lib/user/user.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require('starkbank-ecdsa')
|
4
|
-
require_relative('../utils/resource')
|
5
|
-
|
6
|
-
module StarkInfra
|
7
|
-
class User < StarkInfra::Utils::Resource
|
8
|
-
attr_reader :pem, :environment
|
9
|
-
def initialize(environment, id, private_key)
|
10
|
-
require_relative('../utils/checks')
|
11
|
-
super(id)
|
12
|
-
@pem = StarkInfra::Utils::Checks.check_private_key(private_key)
|
13
|
-
@environment = StarkInfra::Utils::Checks.check_environment(environment)
|
14
|
-
end
|
15
|
-
|
16
|
-
def private_key
|
17
|
-
EllipticCurve::PrivateKey.fromPem(@pem)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|