starkcore 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/utils/request.rb +6 -2
- data/lib/utils/rest.rb +62 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f49e3ab77f8d3d10f3227dd30a0ee700b8635ac7ed41ebbab94af362ac6c9b61
|
4
|
+
data.tar.gz: c0ad8fbde54179ee5a33f333925c7ebe99a3cd82ce00ff682d7a6fd0f5242059
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d8adc68be29f4d4e172a7f3b310addc444328a62655ff1c3b040196698753c7b4d559fbb444679a64c4976f7ee738ee4d27261b96539cbad31ece5f0c0f8028
|
7
|
+
data.tar.gz: fbc856a03e4af5c725dd063b02ad6b9a13114e30cd4d4fb69322cfdf4719ddb9b7ff93ea1c11cfb553aab166d9a67110ef960e0b3ffa85cac540d731496f2c5c
|
data/lib/utils/request.rb
CHANGED
@@ -23,7 +23,7 @@ module StarkCore
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def self.fetch(host:, sdk_version:, user:, method:, path:, payload: nil, query: nil,
|
26
|
-
api_version: "v2", language: "en-US", timeout: 15)
|
26
|
+
api_version: "v2", language: "en-US", timeout: 15, prefix: nil, raiseException: true)
|
27
27
|
user = Checks.check_user(user)
|
28
28
|
language = Checks.check_language(language)
|
29
29
|
|
@@ -64,17 +64,21 @@ module StarkCore
|
|
64
64
|
raise(ArgumentError, 'unknown HTTP method ' + method)
|
65
65
|
end
|
66
66
|
|
67
|
+
agent = prefix ? "Joker-Ruby-#{RUBY_VERSION}-SDK-#{host}-#{sdk_version}" : "Ruby-#{RUBY_VERSION}-SDK-#{host}-#{sdk_version}"
|
68
|
+
|
67
69
|
req['Access-Id'] = user.access_id
|
68
70
|
req['Access-Time'] = access_time
|
69
71
|
req['Access-Signature'] = signature
|
70
72
|
req['Content-Type'] = 'application/json'
|
71
|
-
req['User-Agent'] =
|
73
|
+
req['User-Agent'] = agent
|
72
74
|
req['Accept-Language'] = language
|
73
75
|
|
74
76
|
request = Net::HTTP.start(uri.hostname, use_ssl: true) { |http| http.request(req) }
|
75
77
|
|
76
78
|
response = Response.new(Integer(request.code, 10), request.body)
|
77
79
|
|
80
|
+
return response if raiseException != true
|
81
|
+
|
78
82
|
raise(StarkCore::Error::InternalServerError) if response.status == 500
|
79
83
|
raise(StarkCore::Error::InputErrors, response.json['errors']) if response.status == 400
|
80
84
|
raise(StarkCore::Error::UnknownError, response.content) unless response.status == 200
|
data/lib/utils/rest.rb
CHANGED
@@ -196,20 +196,23 @@ module StarkCore
|
|
196
196
|
return StarkCore::Utils::API.from_api_json(resource_maker, entity)
|
197
197
|
end
|
198
198
|
|
199
|
-
def self.get_raw(sdk_version:, host:, api_version:, path:, user:, language:, timeout:, **query)
|
199
|
+
def self.get_raw(sdk_version:, host:, api_version:, path:, user:, language:, timeout:, prefix:, raiseException:, **query)
|
200
200
|
json = StarkCore::Utils::Request.fetch(
|
201
201
|
host: host,
|
202
202
|
sdk_version: sdk_version,
|
203
203
|
user: user,
|
204
204
|
method: 'GET',
|
205
205
|
path: path,
|
206
|
+
query: query,
|
206
207
|
api_version: api_version,
|
207
|
-
timeout: timeout
|
208
|
+
timeout: timeout,
|
209
|
+
prefix: prefix,
|
210
|
+
raiseException: raiseException
|
208
211
|
).json
|
209
212
|
return json
|
210
213
|
end
|
211
214
|
|
212
|
-
def self.post_raw(sdk_version:, host:, api_version:, user:, language:, path:, payload:, timeout:, **query)
|
215
|
+
def self.post_raw(sdk_version:, host:, api_version:, user:, language:, path:, payload:, timeout:, prefix:, raiseException:, **query)
|
213
216
|
json = StarkCore::Utils::Request.fetch(
|
214
217
|
host: host,
|
215
218
|
sdk_version: sdk_version,
|
@@ -221,9 +224,65 @@ module StarkCore
|
|
221
224
|
api_version: api_version,
|
222
225
|
language: language,
|
223
226
|
timeout: timeout,
|
227
|
+
prefix: prefix,
|
228
|
+
raiseException: raiseException
|
229
|
+
).json
|
230
|
+
return json
|
231
|
+
end
|
232
|
+
|
233
|
+
def self.patch_raw(sdk_version:, host:, api_version:, user:, language:, path:, payload:, timeout:, prefix:, raiseException:, **query)
|
234
|
+
json = StarkCore::Utils::Request.fetch(
|
235
|
+
host: host,
|
236
|
+
sdk_version: sdk_version,
|
237
|
+
user: user,
|
238
|
+
method: 'PATCH',
|
239
|
+
path: path,
|
240
|
+
query: query,
|
241
|
+
payload: payload,
|
242
|
+
api_version: api_version,
|
243
|
+
language: language,
|
244
|
+
timeout: timeout,
|
245
|
+
prefix: prefix,
|
246
|
+
raiseException: raiseException
|
224
247
|
).json
|
225
248
|
return json
|
226
249
|
end
|
250
|
+
|
251
|
+
def self.put_raw(sdk_version:, host:, api_version:, user:, language:, path:, payload:, timeout:, prefix:, raiseException:, **query)
|
252
|
+
json = StarkCore::Utils::Request.fetch(
|
253
|
+
host: host,
|
254
|
+
sdk_version: sdk_version,
|
255
|
+
user: user,
|
256
|
+
method: 'PUT',
|
257
|
+
path: path,
|
258
|
+
query: query,
|
259
|
+
payload: payload,
|
260
|
+
api_version: api_version,
|
261
|
+
language: language,
|
262
|
+
timeout: timeout,
|
263
|
+
prefix: prefix,
|
264
|
+
raiseException: raiseException
|
265
|
+
).json
|
266
|
+
return json
|
267
|
+
end
|
268
|
+
|
269
|
+
def self.delete_raw(sdk_version:, host:, api_version:, user:, language:, path:, timeout:, prefix:, raiseException:, **query)
|
270
|
+
json = StarkCore::Utils::Request.fetch(
|
271
|
+
host: host,
|
272
|
+
sdk_version: sdk_version,
|
273
|
+
user: user,
|
274
|
+
method: 'DELETE',
|
275
|
+
path: path,
|
276
|
+
query: query,
|
277
|
+
api_version: api_version,
|
278
|
+
language: language,
|
279
|
+
timeout: timeout,
|
280
|
+
prefix: prefix,
|
281
|
+
raiseException: raiseException
|
282
|
+
).json
|
283
|
+
return json
|
284
|
+
end
|
285
|
+
|
227
286
|
end
|
228
287
|
end
|
229
288
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: starkcore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.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-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: starkbank-ecdsa
|