foobara-http-api-command 0.0.4 → 0.0.5
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/CHANGELOG.md +2 -1
- data/src/foobara/concerns/url.rb +14 -1
- data/src/foobara/http_api_command.rb +13 -3
- metadata +1 -3
- data/src/foobara/http_api_get_command.rb +0 -14
- data/src/foobara/http_api_post_command.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47344f134791c7562826026ebe261a8e89152295bb9c65fd8bc7d3a3e8bad97f
|
4
|
+
data.tar.gz: 3db4128c29680b07b59c66a76e8a53daccac99fc589d418ad0e0141c28069d97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ceca930f5086d7fd0a1814de7cc6915bbace3a0d6c85ba57e19f120004901d1ee823da5d8221c11d1d67a6e3bf82702ea959cce60246aef49b86b423a3b4744
|
7
|
+
data.tar.gz: 2ceaa7be546bde7d013c72dda00829c8f06b52267999c2e98024887d7664d81385ece7536cd3f66b04442d123edb3058d68d824ea27adc78a87e91fb62ed4374
|
data/CHANGELOG.md
CHANGED
data/src/foobara/concerns/url.rb
CHANGED
@@ -9,7 +9,20 @@ module Foobara
|
|
9
9
|
end
|
10
10
|
|
11
11
|
module ClassMethods
|
12
|
-
attr_accessor :foobara_base_url_block,
|
12
|
+
attr_accessor :foobara_base_url_block,
|
13
|
+
:foobara_base_url,
|
14
|
+
:foobara_path,
|
15
|
+
:foobara_url_block,
|
16
|
+
:foobara_url,
|
17
|
+
:foobara_http_method
|
18
|
+
|
19
|
+
def http_method(method = nil)
|
20
|
+
if method
|
21
|
+
self.foobara_http_method = method
|
22
|
+
else
|
23
|
+
foobara_http_method || :get
|
24
|
+
end
|
25
|
+
end
|
13
26
|
|
14
27
|
def base_url(url = nil, &block)
|
15
28
|
if block_given?
|
@@ -27,9 +27,19 @@ module Foobara
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def issue_http_request
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
case self.class.http_method
|
31
|
+
when :get
|
32
|
+
uri = URI(api_url)
|
33
|
+
uri.query = URI.encode_www_form(request_body)
|
34
|
+
self.response = Net::HTTP.get_response(uri, request_headers)
|
35
|
+
when :post
|
36
|
+
uri = URI.parse(api_url)
|
37
|
+
self.response = Net::HTTP.post(uri, JSON.generate(request_body), request_headers)
|
38
|
+
else
|
39
|
+
# :nocov:
|
40
|
+
raise "Unknown http method #{self.class.http_method}"
|
41
|
+
# :nocov:
|
42
|
+
end
|
33
43
|
end
|
34
44
|
|
35
45
|
def build_result
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foobara-http-api-command
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Georgi
|
@@ -36,8 +36,6 @@ files:
|
|
36
36
|
- lib/foobara/http_api_command.rb
|
37
37
|
- src/foobara/concerns/url.rb
|
38
38
|
- src/foobara/http_api_command.rb
|
39
|
-
- src/foobara/http_api_get_command.rb
|
40
|
-
- src/foobara/http_api_post_command.rb
|
41
39
|
homepage: https://github.com/foobara/http-api-command
|
42
40
|
licenses:
|
43
41
|
- MPL-2.0
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require_relative "http_api_command"
|
2
|
-
|
3
|
-
module Foobara
|
4
|
-
module HttpApiGetCommand
|
5
|
-
include Concern
|
6
|
-
include HttpApiCommand
|
7
|
-
|
8
|
-
def issue_http_request
|
9
|
-
uri = URI(api_url)
|
10
|
-
uri.query = URI.encode_www_form(request_body)
|
11
|
-
self.response = Net::HTTP.get_response(uri, request_headers)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
require_relative "http_api_command"
|
2
|
-
|
3
|
-
module Foobara
|
4
|
-
module HttpApiPostCommand
|
5
|
-
include Concern
|
6
|
-
include HttpApiCommand
|
7
|
-
|
8
|
-
def issue_http_request
|
9
|
-
uri = URI.parse(api_url)
|
10
|
-
self.response = Net::HTTP.post(uri, JSON.generate(request_body), request_headers)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|