foobara-http-command-connector 0.0.17 → 0.0.18
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf60ac4b2586bf6a354520e1f5628d5d15553c8d1b77c5928ccf9c2dc19d3ba8
|
4
|
+
data.tar.gz: a86337c5edea3aff592f62cb756afac76e84fd7cce39b41f8b6bfc0b74a728e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ba72c2c08688e6b08aeb76f9fcf4fe0c28f4c727093d051383f907999cedd64c773e70329079698cbbd4cbfdc390d9a27c1c73db8fd20ff2a4ba18cb252fbd3
|
7
|
+
data.tar.gz: fd2142b3f17b81148a9db464d761bb0a97368fdaaf421fd3392063e84aa4b919b6dbbd2a66089abbc1a66f0de444de5f65f521db67b50d2edee9c715e78924e8
|
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,42 @@
|
|
1
|
+
module Foobara
|
2
|
+
module CommandConnectors
|
3
|
+
class Http < CommandConnector
|
4
|
+
class SetInputFromHeader < RequestMutator
|
5
|
+
class << self
|
6
|
+
attr_accessor :attribute_name, :header_name
|
7
|
+
|
8
|
+
def for(attribute_name, header_name = attribute_name)
|
9
|
+
subclass = Class.new(self)
|
10
|
+
|
11
|
+
header_name = header_name.to_s if header_name.is_a?(::Symbol)
|
12
|
+
|
13
|
+
subclass.attribute_name = attribute_name
|
14
|
+
subclass.header_name = header_name
|
15
|
+
|
16
|
+
subclass
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
attr_writer :attribute_name, :header_name
|
21
|
+
|
22
|
+
def inputs_type_from(inputs_type)
|
23
|
+
new_declaration = TypeDeclarations::Attributes.reject(inputs_type.declaration_data, attribute_name)
|
24
|
+
Domain.current.foobara_type_from_declaration(new_declaration)
|
25
|
+
end
|
26
|
+
|
27
|
+
def mutate(request)
|
28
|
+
header_value = request.headers[header_name]
|
29
|
+
request.inputs[attribute_name] = header_value
|
30
|
+
end
|
31
|
+
|
32
|
+
def attribute_name
|
33
|
+
@attribute_name ||= self.class.attribute_name
|
34
|
+
end
|
35
|
+
|
36
|
+
def header_name
|
37
|
+
@header_name ||= self.class.header_name
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/src/http/response.rb
CHANGED
@@ -19,6 +19,11 @@ module Foobara
|
|
19
19
|
def add_cookie(cookie_name, cookie_value, cookie_opts)
|
20
20
|
cookies << Cookie.new(cookie_name, cookie_value, **cookie_opts)
|
21
21
|
end
|
22
|
+
|
23
|
+
def add_header(header_name, header_value)
|
24
|
+
self.headers ||= {}
|
25
|
+
headers[header_name] = header_value
|
26
|
+
end
|
22
27
|
end
|
23
28
|
end
|
24
29
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Foobara
|
2
|
+
module CommandConnectors
|
3
|
+
class Http < CommandConnector
|
4
|
+
class MoveAttributeToHeader < ResponseMutator
|
5
|
+
class << self
|
6
|
+
attr_accessor :attribute_name, :header_name
|
7
|
+
|
8
|
+
def for(attribute_name, header_name = attribute_name)
|
9
|
+
subclass = Class.new(self)
|
10
|
+
|
11
|
+
subclass.attribute_name = attribute_name
|
12
|
+
subclass.header_name = header_name
|
13
|
+
|
14
|
+
subclass
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
attr_writer :attribute_name, :header_name
|
19
|
+
|
20
|
+
def result_type_from(result_type)
|
21
|
+
new_declaration = TypeDeclarations::Attributes.reject(result_type.declaration_data, attribute_name)
|
22
|
+
Domain.current.foobara_type_from_declaration(new_declaration)
|
23
|
+
end
|
24
|
+
|
25
|
+
def mutate(response)
|
26
|
+
if response.command.success?
|
27
|
+
header_value = response.body.delete(attribute_name)
|
28
|
+
response.add_header(header_name, header_value)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def attribute_name
|
33
|
+
@attribute_name ||= self.class.attribute_name
|
34
|
+
end
|
35
|
+
|
36
|
+
def header_name
|
37
|
+
@header_name ||= self.class.header_name
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foobara-http-command-connector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Georgi
|
@@ -66,8 +66,10 @@ files:
|
|
66
66
|
- src/http/cookie.rb
|
67
67
|
- src/http/request.rb
|
68
68
|
- src/http/request_mutators/set_input_from_cookie.rb
|
69
|
+
- src/http/request_mutators/set_input_from_header.rb
|
69
70
|
- src/http/response.rb
|
70
71
|
- src/http/response_mutators/move_attribute_to_cookie.rb
|
72
|
+
- src/http/response_mutators/move_attribute_to_header.rb
|
71
73
|
homepage: https://github.com/foobara/http-command-connector
|
72
74
|
licenses:
|
73
75
|
- Apache-2.0
|