Class: Smplkit::Audit::ForwarderHttp
- Inherits:
-
Struct
- Object
- Struct
- Smplkit::Audit::ForwarderHttp
- Defined in:
- lib/smplkit/audit/forwarders.rb
Overview
rubocop:disable Lint/StructNewOverride – “:method“ matches the API attribute and shadowing Struct#method is the expected ergonomics.
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#method ⇒ Object
Returns the value of attribute method.
-
#success_status ⇒ Object
Returns the value of attribute success_status.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(method: "POST", url: "", headers: nil, body: nil, success_status: "2xx") ⇒ ForwarderHttp
constructor
A new instance of ForwarderHttp.
Constructor Details
#initialize(method: "POST", url: "", headers: nil, body: nil, success_status: "2xx") ⇒ ForwarderHttp
Returns a new instance of ForwarderHttp.
146 147 148 |
# File 'lib/smplkit/audit/forwarders.rb', line 146 def initialize(method: "POST", url: "", headers: nil, body: nil, success_status: "2xx") super(method: method, url: url, headers: headers || [], body: body, success_status: success_status) end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body
145 146 147 |
# File 'lib/smplkit/audit/forwarders.rb', line 145 def body @body end |
#headers ⇒ Object
Returns the value of attribute headers
145 146 147 |
# File 'lib/smplkit/audit/forwarders.rb', line 145 def headers @headers end |
#method ⇒ Object
Returns the value of attribute method
145 146 147 |
# File 'lib/smplkit/audit/forwarders.rb', line 145 def method @method end |
#success_status ⇒ Object
Returns the value of attribute success_status
145 146 147 |
# File 'lib/smplkit/audit/forwarders.rb', line 145 def success_status @success_status end |
#url ⇒ Object
Returns the value of attribute url
145 146 147 |
# File 'lib/smplkit/audit/forwarders.rb', line 145 def url @url end |
Class Method Details
.from_wire(src) ⇒ Object
169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/smplkit/audit/forwarders.rb', line 169 def self.from_wire(src) return new if src.nil? new( method: src.method || "POST", url: src.url || "", headers: (src.headers || []).map { |h| HttpHeader.new(name: h.name, value: h.value) }, body: src.body, success_status: src.success_status || "2xx" ) end |
.to_wire(src) ⇒ Object
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/smplkit/audit/forwarders.rb', line 150 def self.to_wire(src) h = src.is_a?(Hash) ? new(**src) : src SmplkitGeneratedClient::Audit::ForwarderHttp.new( method: h.method, url: h.url, headers: (h.headers || []).map do |hdr| name, value = if hdr.is_a?(Hash) [hdr[:name] || hdr["name"], hdr[:value] || hdr["value"]] else [hdr.name, hdr.value] end SmplkitGeneratedClient::Audit::HttpHeader.new(name: name, value: value) end, body: h.body, success_status: h.success_status ) end |