Module: Stability::HTTP

Included in:
Client
Defined in:
lib/stability/http.rb

Instance Method Summary collapse

Instance Method Details

#delete(path:) ⇒ Object



33
34
35
36
37
# File 'lib/stability/http.rb', line 33

def delete(path:)
  conn.delete(uri(path:)) do |req|
    req.headers = headers
  end&.body
end

#get(path:) ⇒ Object



8
9
10
11
12
# File 'lib/stability/http.rb', line 8

def get(path:)
  conn.get(uri(path:)) do |req|
    req.headers = headers
  end&.body
end

#multipart_post(path:, headers: {}, parameters: nil) ⇒ Object



26
27
28
29
30
31
# File 'lib/stability/http.rb', line 26

def multipart_post(path:, headers: {}, parameters: nil)
  conn(multipart: true).post(uri(path:)) do |req|
    req.headers = default_headers.merge(headers).merge({ "Content-Type" => "multipart/form-data" })
    req.body = multipart_parameters(parameters)
  end&.body
end

#post(path:, parameters:) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/stability/http.rb', line 14

def post(path:, parameters:)
  conn.post(uri(path:)) do |req|
    if parameters[:stream].respond_to?(:call)
      req.options.on_data = to_json_stream(user_proc: parameters[:stream])
      parameters[:stream] = true
    end

    req.headers = headers
    req.body = parameters.to_json
  end&.body
end