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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5d181593590629e548b61b096cf47322584fd943002972d002d6104348628af7
4
- data.tar.gz: 01a9168981928f32c6a64a0315dce7227c2153a4b75bfb1e9192a69f1bc80785
3
+ metadata.gz: 6e9f87a8414f328789843aa8a4cc91736c2453908cae60041e4bc780e43fda62
4
+ data.tar.gz: ccb71fac620b9beae7a308ae1f575da6ba7850578480b358c26e6191cafe5dfe
5
5
  SHA512:
6
- metadata.gz: b7eec7746486022b3f92e01a96a49057299cb2a4f6afd9b763ba4214bd6c61d79f0c2d6e4e2447a302a7751939628881dca83b274cbf4efc5a8f70b582d2ecc4
7
- data.tar.gz: 2b4729698266b975556d13b717fd6ea5224f2da79379e2f1225058b1bc03e2a20d20be7228ff4d7c181e0275529577f46cf183dcddd271efb08a95f8490ea9b8
6
+ metadata.gz: 1139fd2bcf58929790aa3923b4f3fae69f63e4bc23c9e3e59bd785e56997434c287942fb563b7c6f2c7f6689076e00ac07a550a1b198868e2137d46ae33c24de
7
+ data.tar.gz: c77f20fc74bada0c03764d945506d8ebcf51fb4a0db96ebf2221d0b4d14191a762f08a76ac046f1450f80b5b6f51f19757d074e733e737294870e779f4ba479e
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'client-api-builder'
5
- s.version = '0.2.1'
5
+ s.version = '0.2.2'
6
6
  s.licenses = ['MIT']
7
7
  s.summary = 'Develop Client API libraries faster'
8
8
  s.description = 'Utility for constructing API clients'
@@ -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.1
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-05 00:00:00.000000000 Z
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