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.
182 183 184 |
# File 'lib/smplkit/audit/forwarders.rb', line 182 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
181 182 183 |
# File 'lib/smplkit/audit/forwarders.rb', line 181 def body @body end |
#headers ⇒ Object
Returns the value of attribute headers
181 182 183 |
# File 'lib/smplkit/audit/forwarders.rb', line 181 def headers @headers end |
#method ⇒ Object
Returns the value of attribute method
181 182 183 |
# File 'lib/smplkit/audit/forwarders.rb', line 181 def method @method end |
#success_status ⇒ Object
Returns the value of attribute success_status
181 182 183 |
# File 'lib/smplkit/audit/forwarders.rb', line 181 def success_status @success_status end |
#url ⇒ Object
Returns the value of attribute url
181 182 183 |
# File 'lib/smplkit/audit/forwarders.rb', line 181 def url @url end |
Class Method Details
.from_wire(src) ⇒ Object
205 206 207 208 209 210 211 212 213 214 215 |
# File 'lib/smplkit/audit/forwarders.rb', line 205 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
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
# File 'lib/smplkit/audit/forwarders.rb', line 186 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 |