Class: Smplkit::Jobs::HttpConfig

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

Overview

The HTTP request a job performs when it fires (the http configuration).

Extends the shared forwarder shape with the two fields a scheduled job needs beyond a forwarder: a request body and a per-run timeout.

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(url: "", method: HttpMethod::POST, headers: nil, body: nil, success_status: "2xx", timeout: 30, tls_verify: true, ca_cert: nil) ⇒ HttpConfig

Returns a new instance of HttpConfig.



111
112
113
114
115
116
117
118
119
# File 'lib/smplkit/jobs/models.rb', line 111

def initialize(
  url: "", method: HttpMethod::POST, headers: nil, body: nil,
  success_status: "2xx", timeout: 30, tls_verify: true, ca_cert: nil
)
  super(
    method: HttpMethod.coerce(method), url: url, headers: headers || [], body: body,
    success_status: success_status, timeout: timeout, tls_verify: tls_verify, ca_cert: ca_cert
  )
end

Instance Attribute Details

#bodyString?

Returns Request body sent on each run. nil (the default) sends an empty body, suitable for a connectivity ping. Sent verbatim —pair with a matching Content-Type header.

Returns:

  • (String, nil)

    Request body sent on each run. nil (the default) sends an empty body, suitable for a connectivity ping. Sent verbatim —pair with a matching Content-Type header.



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/smplkit/jobs/models.rb', line 107

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

  def self.to_wire(src)
    h = src.is_a?(Hash) ? new(**src) : src
    SmplkitGeneratedClient::Jobs::JobHttpConfiguration.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::Jobs::HttpHeader.new(name: name, value: value)
      end,
      body: h.body,
      success_status: h.success_status,
      timeout: h.timeout,
      tls_verify: h.tls_verify,
      ca_cert: h.ca_cert
    )
  end

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

    # +url+, +success_status+, and +timeout+ are required non-nil on the
    # generated jobs config, so they pass straight through. +method+,
    # +tls_verify+, +headers+, +body+, and +ca_cert+ are nullable and get
    # wrapper-side defaults when the wire omits them.
    new(
      method: src.method || HttpMethod::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,
      timeout: src.timeout,
      # rubocop:disable Style/RedundantCondition -- nil and false are
      # distinct: nil means "field absent on the wire" (default to true);
      # explicit false means "verification disabled".
      tls_verify: src.tls_verify.nil? ? true : src.tls_verify,
      # rubocop:enable Style/RedundantCondition
      ca_cert: src.ca_cert
    )
  end
end

#ca_certString?

Returns Optional PEM-encoded certificate (or bundle) trusted in addition to the system CA store. Ignored when tls_verify is false. nil (the default) means “use system CAs only”.

Returns:

  • (String, nil)

    Optional PEM-encoded certificate (or bundle) trusted in addition to the system CA store. Ignored when tls_verify is false. nil (the default) means “use system CAs only”.



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/smplkit/jobs/models.rb', line 107

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

  def self.to_wire(src)
    h = src.is_a?(Hash) ? new(**src) : src
    SmplkitGeneratedClient::Jobs::JobHttpConfiguration.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::Jobs::HttpHeader.new(name: name, value: value)
      end,
      body: h.body,
      success_status: h.success_status,
      timeout: h.timeout,
      tls_verify: h.tls_verify,
      ca_cert: h.ca_cert
    )
  end

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

    # +url+, +success_status+, and +timeout+ are required non-nil on the
    # generated jobs config, so they pass straight through. +method+,
    # +tls_verify+, +headers+, +body+, and +ca_cert+ are nullable and get
    # wrapper-side defaults when the wire omits them.
    new(
      method: src.method || HttpMethod::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,
      timeout: src.timeout,
      # rubocop:disable Style/RedundantCondition -- nil and false are
      # distinct: nil means "field absent on the wire" (default to true);
      # explicit false means "verification disabled".
      tls_verify: src.tls_verify.nil? ? true : src.tls_verify,
      # rubocop:enable Style/RedundantCondition
      ca_cert: src.ca_cert
    )
  end
end

#headersArray<HttpHeader>

Returns Headers attached to every request. Values are redacted on reads.

Returns:

  • (Array<HttpHeader>)

    Headers attached to every request. Values are redacted on reads.



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/smplkit/jobs/models.rb', line 107

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

  def self.to_wire(src)
    h = src.is_a?(Hash) ? new(**src) : src
    SmplkitGeneratedClient::Jobs::JobHttpConfiguration.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::Jobs::HttpHeader.new(name: name, value: value)
      end,
      body: h.body,
      success_status: h.success_status,
      timeout: h.timeout,
      tls_verify: h.tls_verify,
      ca_cert: h.ca_cert
    )
  end

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

    # +url+, +success_status+, and +timeout+ are required non-nil on the
    # generated jobs config, so they pass straight through. +method+,
    # +tls_verify+, +headers+, +body+, and +ca_cert+ are nullable and get
    # wrapper-side defaults when the wire omits them.
    new(
      method: src.method || HttpMethod::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,
      timeout: src.timeout,
      # rubocop:disable Style/RedundantCondition -- nil and false are
      # distinct: nil means "field absent on the wire" (default to true);
      # explicit false means "verification disabled".
      tls_verify: src.tls_verify.nil? ? true : src.tls_verify,
      # rubocop:enable Style/RedundantCondition
      ca_cert: src.ca_cert
    )
  end
end

#methodString

Returns HTTP verb used when the job fires. Defaults to Smplkit::Jobs::HttpMethod::POST.

Returns:



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/smplkit/jobs/models.rb', line 107

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

  def self.to_wire(src)
    h = src.is_a?(Hash) ? new(**src) : src
    SmplkitGeneratedClient::Jobs::JobHttpConfiguration.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::Jobs::HttpHeader.new(name: name, value: value)
      end,
      body: h.body,
      success_status: h.success_status,
      timeout: h.timeout,
      tls_verify: h.tls_verify,
      ca_cert: h.ca_cert
    )
  end

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

    # +url+, +success_status+, and +timeout+ are required non-nil on the
    # generated jobs config, so they pass straight through. +method+,
    # +tls_verify+, +headers+, +body+, and +ca_cert+ are nullable and get
    # wrapper-side defaults when the wire omits them.
    new(
      method: src.method || HttpMethod::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,
      timeout: src.timeout,
      # rubocop:disable Style/RedundantCondition -- nil and false are
      # distinct: nil means "field absent on the wire" (default to true);
      # explicit false means "verification disabled".
      tls_verify: src.tls_verify.nil? ? true : src.tls_verify,
      # rubocop:enable Style/RedundantCondition
      ca_cert: src.ca_cert
    )
  end
end

#success_statusString

Returns Status the destination must return for the run 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 the run to count as success — an exact code (+“200”+, “204”) or a class (+“2xx”+, “4xx”). Defaults to “2xx”.



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/smplkit/jobs/models.rb', line 107

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

  def self.to_wire(src)
    h = src.is_a?(Hash) ? new(**src) : src
    SmplkitGeneratedClient::Jobs::JobHttpConfiguration.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::Jobs::HttpHeader.new(name: name, value: value)
      end,
      body: h.body,
      success_status: h.success_status,
      timeout: h.timeout,
      tls_verify: h.tls_verify,
      ca_cert: h.ca_cert
    )
  end

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

    # +url+, +success_status+, and +timeout+ are required non-nil on the
    # generated jobs config, so they pass straight through. +method+,
    # +tls_verify+, +headers+, +body+, and +ca_cert+ are nullable and get
    # wrapper-side defaults when the wire omits them.
    new(
      method: src.method || HttpMethod::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,
      timeout: src.timeout,
      # rubocop:disable Style/RedundantCondition -- nil and false are
      # distinct: nil means "field absent on the wire" (default to true);
      # explicit false means "verification disabled".
      tls_verify: src.tls_verify.nil? ? true : src.tls_verify,
      # rubocop:enable Style/RedundantCondition
      ca_cert: src.ca_cert
    )
  end
end

#timeoutInteger

Returns Per-run timeout in seconds. A run that does not complete within this many seconds fails with reason TIMEOUT. Defaults to 30; bounded by your plan’s maximum timeout.

Returns:

  • (Integer)

    Per-run timeout in seconds. A run that does not complete within this many seconds fails with reason TIMEOUT. Defaults to 30; bounded by your plan’s maximum timeout.



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/smplkit/jobs/models.rb', line 107

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

  def self.to_wire(src)
    h = src.is_a?(Hash) ? new(**src) : src
    SmplkitGeneratedClient::Jobs::JobHttpConfiguration.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::Jobs::HttpHeader.new(name: name, value: value)
      end,
      body: h.body,
      success_status: h.success_status,
      timeout: h.timeout,
      tls_verify: h.tls_verify,
      ca_cert: h.ca_cert
    )
  end

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

    # +url+, +success_status+, and +timeout+ are required non-nil on the
    # generated jobs config, so they pass straight through. +method+,
    # +tls_verify+, +headers+, +body+, and +ca_cert+ are nullable and get
    # wrapper-side defaults when the wire omits them.
    new(
      method: src.method || HttpMethod::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,
      timeout: src.timeout,
      # rubocop:disable Style/RedundantCondition -- nil and false are
      # distinct: nil means "field absent on the wire" (default to true);
      # explicit false means "verification disabled".
      tls_verify: src.tls_verify.nil? ? true : src.tls_verify,
      # rubocop:enable Style/RedundantCondition
      ca_cert: src.ca_cert
    )
  end
end

#tls_verifyBoolean

Returns Whether to verify the destination’s TLS certificate chain. Defaults to true; flip to false only for short-lived testing against an untrusted certificate. Prefer pinning the CA via ca_cert.

Returns:

  • (Boolean)

    Whether to verify the destination’s TLS certificate chain. Defaults to true; flip to false only for short-lived testing against an untrusted certificate. Prefer pinning the CA via ca_cert.



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/smplkit/jobs/models.rb', line 107

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

  def self.to_wire(src)
    h = src.is_a?(Hash) ? new(**src) : src
    SmplkitGeneratedClient::Jobs::JobHttpConfiguration.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::Jobs::HttpHeader.new(name: name, value: value)
      end,
      body: h.body,
      success_status: h.success_status,
      timeout: h.timeout,
      tls_verify: h.tls_verify,
      ca_cert: h.ca_cert
    )
  end

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

    # +url+, +success_status+, and +timeout+ are required non-nil on the
    # generated jobs config, so they pass straight through. +method+,
    # +tls_verify+, +headers+, +body+, and +ca_cert+ are nullable and get
    # wrapper-side defaults when the wire omits them.
    new(
      method: src.method || HttpMethod::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,
      timeout: src.timeout,
      # rubocop:disable Style/RedundantCondition -- nil and false are
      # distinct: nil means "field absent on the wire" (default to true);
      # explicit false means "verification disabled".
      tls_verify: src.tls_verify.nil? ? true : src.tls_verify,
      # rubocop:enable Style/RedundantCondition
      ca_cert: src.ca_cert
    )
  end
end

#urlString

Returns Destination URL the job requests on each run.

Returns:

  • (String)

    Destination URL the job requests on each run.



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/smplkit/jobs/models.rb', line 107

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

  def self.to_wire(src)
    h = src.is_a?(Hash) ? new(**src) : src
    SmplkitGeneratedClient::Jobs::JobHttpConfiguration.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::Jobs::HttpHeader.new(name: name, value: value)
      end,
      body: h.body,
      success_status: h.success_status,
      timeout: h.timeout,
      tls_verify: h.tls_verify,
      ca_cert: h.ca_cert
    )
  end

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

    # +url+, +success_status+, and +timeout+ are required non-nil on the
    # generated jobs config, so they pass straight through. +method+,
    # +tls_verify+, +headers+, +body+, and +ca_cert+ are nullable and get
    # wrapper-side defaults when the wire omits them.
    new(
      method: src.method || HttpMethod::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,
      timeout: src.timeout,
      # rubocop:disable Style/RedundantCondition -- nil and false are
      # distinct: nil means "field absent on the wire" (default to true);
      # explicit false means "verification disabled".
      tls_verify: src.tls_verify.nil? ? true : src.tls_verify,
      # rubocop:enable Style/RedundantCondition
      ca_cert: src.ca_cert
    )
  end
end

Class Method Details

.from_wire(src) ⇒ Object



142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/smplkit/jobs/models.rb', line 142

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

  # +url+, +success_status+, and +timeout+ are required non-nil on the
  # generated jobs config, so they pass straight through. +method+,
  # +tls_verify+, +headers+, +body+, and +ca_cert+ are nullable and get
  # wrapper-side defaults when the wire omits them.
  new(
    method: src.method || HttpMethod::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,
    timeout: src.timeout,
    # rubocop:disable Style/RedundantCondition -- nil and false are
    # distinct: nil means "field absent on the wire" (default to true);
    # explicit false means "verification disabled".
    tls_verify: src.tls_verify.nil? ? true : src.tls_verify,
    # rubocop:enable Style/RedundantCondition
    ca_cert: src.ca_cert
  )
end

.to_wire(src) ⇒ Object



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/smplkit/jobs/models.rb', line 121

def self.to_wire(src)
  h = src.is_a?(Hash) ? new(**src) : src
  SmplkitGeneratedClient::Jobs::JobHttpConfiguration.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::Jobs::HttpHeader.new(name: name, value: value)
    end,
    body: h.body,
    success_status: h.success_status,
    timeout: h.timeout,
    tls_verify: h.tls_verify,
    ca_cert: h.ca_cert
  )
end