api_pattern 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b824d5027294a5fbec1ae0b376da2e1031527c930aec4d70ba6924efbc1b3750
4
- data.tar.gz: 8ec7712914d9d528de5fea6ff78bc618d0e6245da5ef0fb71475334510d168e8
3
+ metadata.gz: 065631a08feef6506ad617d9447b14d27e95ddeaad4ab5511864803e342b320f
4
+ data.tar.gz: 437e2ec95ef8380bee706801ef5e7e2386b911a55957d72f75821c1324236294
5
5
  SHA512:
6
- metadata.gz: 06ede13830d1bd225cc84484c3a1aa5c6d7f723c6e32c010e27bc0c1cdefe09f1b892bdedd22d7e18fb507ac411afad7346a50103b6aeb607b426bd82f74e710
7
- data.tar.gz: 9a414a4e91c7413d430fe3e059b9eb7ff5ccb407197c4b2a358a379b81151c181a364f1613b46e28b2fcc83f5148a4ba98372fd30f4304dcff66544a4748f703
6
+ metadata.gz: d579d3e5e13944bc497a368618a20c336fbe8d32ad7c99be8578d264d6ab38b60fdb1ca464559bd21e843c0ef5012de22dd6318dc11f4df8f16815399e9dcc3a
7
+ data.tar.gz: 0c9565fb594578065156c408839ebc9c349d7886a9c1a84504cbb35279229e6715278db70c01d7ac165f601c3bdaf58bfe01dd5fce04b7459632a5ed6235895c
data/README.md CHANGED
@@ -6,7 +6,7 @@ A base set of ops for all my API clients to make maintenance easier
6
6
  Add this line to your application's Gemfile:
7
7
 
8
8
  ```ruby
9
- gem 'api-pattern'
9
+ gem 'api_pattern'
10
10
  ```
11
11
 
12
12
  And then execute:
@@ -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
- constructed_path = "#{base_path}/#{path}"
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
@@ -1,3 +1,3 @@
1
1
  module ApiPattern
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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.1
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-04-24 00:00:00.000000000 Z
11
+ date: 2023-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty