api_pattern 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/api-pattern/client.rb +10 -6
- data/lib/api-pattern/version.rb +1 -1
- 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: 065631a08feef6506ad617d9447b14d27e95ddeaad4ab5511864803e342b320f
|
4
|
+
data.tar.gz: 437e2ec95ef8380bee706801ef5e7e2386b911a55957d72f75821c1324236294
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d579d3e5e13944bc497a368618a20c336fbe8d32ad7c99be8578d264d6ab38b60fdb1ca464559bd21e843c0ef5012de22dd6318dc11f4df8f16815399e9dcc3a
|
7
|
+
data.tar.gz: 0c9565fb594578065156c408839ebc9c349d7886a9c1a84504cbb35279229e6715278db70c01d7ac165f601c3bdaf58bfe01dd5fce04b7459632a5ed6235895c
|
data/README.md
CHANGED
data/lib/api-pattern/client.rb
CHANGED
@@ -34,12 +34,12 @@ module ApiPattern
|
|
34
34
|
|
35
35
|
private
|
36
36
|
|
37
|
-
def unauthorised_and_send(http_method:, path:, payload: {}, params: {}, format: :json)
|
37
|
+
def unauthorised_and_send(http_method:, path:, custom_url: nil, payload: {}, params: {}, format: :json)
|
38
38
|
start_time = get_micro_second_time
|
39
39
|
|
40
40
|
response = ::HTTParty.send(
|
41
41
|
http_method.to_sym,
|
42
|
-
construct_base_path(path, params),
|
42
|
+
construct_base_path(path, params, custom_url: custom_url),
|
43
43
|
body: process_payload(payload),
|
44
44
|
headers: {
|
45
45
|
"Content-Type": @content_type,
|
@@ -52,7 +52,7 @@ module ApiPattern
|
|
52
52
|
construct_response_object(response, path, start_time, end_time)
|
53
53
|
end
|
54
54
|
|
55
|
-
def authorise_and_send(http_method:, path:, payload: {}, params: {}, format: :json)
|
55
|
+
def authorise_and_send(http_method:, path:, custom_url: nil, payload: {}, params: {}, format: :json)
|
56
56
|
start_time = get_micro_second_time
|
57
57
|
|
58
58
|
send_params = {
|
@@ -66,7 +66,7 @@ module ApiPattern
|
|
66
66
|
|
67
67
|
response = ::HTTParty.send(
|
68
68
|
http_method.to_sym,
|
69
|
-
construct_base_path(path, params),
|
69
|
+
construct_base_path(path, params, custom_url: custom_url),
|
70
70
|
**configure_auth(send_params)
|
71
71
|
)
|
72
72
|
|
@@ -116,8 +116,12 @@ module ApiPattern
|
|
116
116
|
(Time.now.to_f * 1_000_000).to_i
|
117
117
|
end
|
118
118
|
|
119
|
-
def construct_base_path(path, params)
|
120
|
-
|
119
|
+
def construct_base_path(path, params, custom_url: nil)
|
120
|
+
if custom_url
|
121
|
+
constructed_path = "#{custom_url}/#{path}"
|
122
|
+
else
|
123
|
+
constructed_path = "#{base_path}/#{path}"
|
124
|
+
end
|
121
125
|
|
122
126
|
if params == {}
|
123
127
|
constructed_path
|
data/lib/api-pattern/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: api_pattern
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- trex22
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|