Class: Smplkit::Audit::HttpConfiguration

Inherits:
Struct
  • Object
show all
Defined in:
lib/smplkit/audit/models.rb

Overview

Forwarder destination HTTP request shape.

rubocop:disable Lint/StructNewOverride – “:method“ matches the API attribute and shadowing Struct#method is the expected ergonomics.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method: HttpMethod::POST, url: "", headers: nil, success_status: "2xx") ⇒ HttpConfiguration

Returns a new instance of HttpConfiguration.



269
270
271
# File 'lib/smplkit/audit/models.rb', line 269

def initialize(method: HttpMethod::POST, url: "", headers: nil, success_status: "2xx")
  super(method: HttpMethod.coerce(method), url: url, headers: headers || [], success_status: success_status)
end

Instance Attribute Details

#headersArray<HttpHeader>

Headers attached to every outbound request. Values carry credentials and are encrypted at rest server-side; reads return them redacted.

Returns:

  • (Array<HttpHeader>)

    Headers attached to every outbound request. Values carry credentials and are encrypted at rest server-side; reads return them redacted.



268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
# File 'lib/smplkit/audit/models.rb', line 268

HttpConfiguration = Struct.new(:method, :url, :headers, :success_status, keyword_init: true) do
  def initialize(method: HttpMethod::POST, url: "", headers: nil, success_status: "2xx")
    super(method: HttpMethod.coerce(method), url: url, headers: headers || [], success_status: success_status)
  end

  def self.to_wire(src)
    h = src.is_a?(Hash) ? new(**src) : src
    SmplkitGeneratedClient::Audit::HttpConfiguration.new(
      method: HttpMethod.coerce(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,
      success_status: h.success_status
    )
  end

  def self.from_wire(src)
    return new if src.nil?

    new(
      method: src.method || HttpMethod::POST,
      url: src.url || "",
      headers: (src.headers || []).map { |h| HttpHeader.new(name: h.name, value: h.value) },
      success_status: src.success_status || "2xx"
    )
  end
end

#methodString

Returns HTTP verb used for delivery. Defaults to Smplkit::Audit::HttpMethod::POST.

Returns:



268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
# File 'lib/smplkit/audit/models.rb', line 268

HttpConfiguration = Struct.new(:method, :url, :headers, :success_status, keyword_init: true) do
  def initialize(method: HttpMethod::POST, url: "", headers: nil, success_status: "2xx")
    super(method: HttpMethod.coerce(method), url: url, headers: headers || [], success_status: success_status)
  end

  def self.to_wire(src)
    h = src.is_a?(Hash) ? new(**src) : src
    SmplkitGeneratedClient::Audit::HttpConfiguration.new(
      method: HttpMethod.coerce(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,
      success_status: h.success_status
    )
  end

  def self.from_wire(src)
    return new if src.nil?

    new(
      method: src.method || HttpMethod::POST,
      url: src.url || "",
      headers: (src.headers || []).map { |h| HttpHeader.new(name: h.name, value: h.value) },
      success_status: src.success_status || "2xx"
    )
  end
end

#success_statusString

Returns Status the destination must return for delivery to count as success — an exact code (+“200”+, “204”) or a class (+“2xx”+, “4xx”). Defaults to “2xx”.

Returns:

  • (String)

    Status the destination must return for delivery to count as success — an exact code (+“200”+, “204”) or a class (+“2xx”+, “4xx”). Defaults to “2xx”.



268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
# File 'lib/smplkit/audit/models.rb', line 268

HttpConfiguration = Struct.new(:method, :url, :headers, :success_status, keyword_init: true) do
  def initialize(method: HttpMethod::POST, url: "", headers: nil, success_status: "2xx")
    super(method: HttpMethod.coerce(method), url: url, headers: headers || [], success_status: success_status)
  end

  def self.to_wire(src)
    h = src.is_a?(Hash) ? new(**src) : src
    SmplkitGeneratedClient::Audit::HttpConfiguration.new(
      method: HttpMethod.coerce(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,
      success_status: h.success_status
    )
  end

  def self.from_wire(src)
    return new if src.nil?

    new(
      method: src.method || HttpMethod::POST,
      url: src.url || "",
      headers: (src.headers || []).map { |h| HttpHeader.new(name: h.name, value: h.value) },
      success_status: src.success_status || "2xx"
    )
  end
end

#urlString

Returns Destination URL the audit service sends each event to.

Returns:

  • (String)

    Destination URL the audit service sends each event to.



268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
# File 'lib/smplkit/audit/models.rb', line 268

HttpConfiguration = Struct.new(:method, :url, :headers, :success_status, keyword_init: true) do
  def initialize(method: HttpMethod::POST, url: "", headers: nil, success_status: "2xx")
    super(method: HttpMethod.coerce(method), url: url, headers: headers || [], success_status: success_status)
  end

  def self.to_wire(src)
    h = src.is_a?(Hash) ? new(**src) : src
    SmplkitGeneratedClient::Audit::HttpConfiguration.new(
      method: HttpMethod.coerce(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,
      success_status: h.success_status
    )
  end

  def self.from_wire(src)
    return new if src.nil?

    new(
      method: src.method || HttpMethod::POST,
      url: src.url || "",
      headers: (src.headers || []).map { |h| HttpHeader.new(name: h.name, value: h.value) },
      success_status: src.success_status || "2xx"
    )
  end
end

Class Method Details

.from_wire(src) ⇒ Object



291
292
293
294
295
296
297
298
299
300
# File 'lib/smplkit/audit/models.rb', line 291

def self.from_wire(src)
  return new if src.nil?

  new(
    method: src.method || HttpMethod::POST,
    url: src.url || "",
    headers: (src.headers || []).map { |h| HttpHeader.new(name: h.name, value: h.value) },
    success_status: src.success_status || "2xx"
  )
end

.to_wire(src) ⇒ Object



273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
# File 'lib/smplkit/audit/models.rb', line 273

def self.to_wire(src)
  h = src.is_a?(Hash) ? new(**src) : src
  SmplkitGeneratedClient::Audit::HttpConfiguration.new(
    method: HttpMethod.coerce(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,
    success_status: h.success_status
  )
end