Class: Fal::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/fal/connection.rb

Overview

HTTP connection wrapper using http.rb gem. Dependency-injected for testability.

Instance Method Summary collapse

Constructor Details

#initialize(config:, http: HTTP) ⇒ Connection

Returns a new instance of Connection.



9
10
11
12
13
# File 'lib/fal/connection.rb', line 9

def initialize(config:, http: HTTP)
  @config = config
  @http = http
  @request = Request.new(config: config)
end

Instance Method Details

#get(endpoint) ⇒ Object



20
21
22
23
# File 'lib/fal/connection.rb', line 20

def get(endpoint)
  response = perform_get(endpoint)
  handle_response(response)
end

#post(endpoint, body: nil) ⇒ Object



15
16
17
18
# File 'lib/fal/connection.rb', line 15

def post(endpoint, body: nil)
  response = perform_post(endpoint, body)
  handle_response(response)
end