client-api-builder 0.2.1 → 0.2.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 +4 -4
- data/client-api-builder.gemspec +1 -1
- data/examples/basic_auth_example_client.rb +23 -0
- data/lib/client_api_builder/router.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e9f87a8414f328789843aa8a4cc91736c2453908cae60041e4bc780e43fda62
|
4
|
+
data.tar.gz: ccb71fac620b9beae7a308ae1f575da6ba7850578480b358c26e6191cafe5dfe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1139fd2bcf58929790aa3923b4f3fae69f63e4bc23c9e3e59bd785e56997434c287942fb563b7c6f2c7f6689076e00ac07a550a1b198868e2137d46ae33c24de
|
7
|
+
data.tar.gz: c77f20fc74bada0c03764d945506d8ebcf51fb4a0db96ebf2221d0b4d14191a762f08a76ac046f1450f80b5b6f51f19757d074e733e737294870e779f4ba479e
|
data/client-api-builder.gemspec
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'base64'
|
2
|
+
|
3
|
+
class BasicAuthExampleClient < Struct.new(
|
4
|
+
:username,
|
5
|
+
:password
|
6
|
+
)
|
7
|
+
|
8
|
+
include ClientApiBuilder::Router
|
9
|
+
|
10
|
+
base_url 'https://www.example.com'
|
11
|
+
|
12
|
+
header 'Authorization', :basic_authorization
|
13
|
+
query_param('cache_buster') { (Time.now.to_f * 1000).to_i }
|
14
|
+
|
15
|
+
route :get_apps, '/apps'
|
16
|
+
route :get_app, '/apps/:app_id'
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def basic_authorization
|
21
|
+
'basic ' + Base64.strict_encode64(username + ':' + password)
|
22
|
+
end
|
23
|
+
end
|
@@ -51,7 +51,7 @@ module ClientApiBuilder
|
|
51
51
|
add_value_to_class_method(:default_options, connection_options: connection_options)
|
52
52
|
end
|
53
53
|
|
54
|
-
def query_param(name, value)
|
54
|
+
def query_param(name, value = nil, &block)
|
55
55
|
query_params = default_options[:query_params].dup
|
56
56
|
query_params[name] = value || block
|
57
57
|
add_value_to_class_method(:default_options, query_params: query_params)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: client-api-builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Doug Youch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-07-
|
11
|
+
date: 2021-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Utility for constructing API clients
|
14
14
|
email: dougyouch@gmail.com
|
@@ -24,6 +24,7 @@ files:
|
|
24
24
|
- LICENSE
|
25
25
|
- README.md
|
26
26
|
- client-api-builder.gemspec
|
27
|
+
- examples/basic_auth_example_client.rb
|
27
28
|
- lib/client-api-builder.rb
|
28
29
|
- lib/client_api_builder/net_http_request.rb
|
29
30
|
- lib/client_api_builder/query_params.rb
|