Class: Transistor::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/transistor/client.rb

Instance Method Summary collapse

Instance Method Details

#connection_optionsObject



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/transistor/client.rb', line 8

def connection_options
  @collection_options ||= {
    builder: middleware,
    headers: {
      accept: 'application/json',
      user_agent: Transistor.config.user_agent
    },
    request: {
      open_timeout: 5,
      timeout: 10
    }
  }
end

#delete(path, params = {}) ⇒ Object



30
31
32
# File 'lib/transistor/client.rb', line 30

def delete(path, params = {})
  request(:delete, path, params)
end

#get(path, params = {}) ⇒ Object



34
35
36
# File 'lib/transistor/client.rb', line 34

def get(path, params = {})
  request(:get, path, params)
end

#middlewareObject



22
23
24
25
26
27
28
# File 'lib/transistor/client.rb', line 22

def middleware
  @middleware = Faraday::Builder.new do |builder|
    builder.use Faraday::Request::UrlEncoded
    builder.use Transistor::Middleware::Authentication
    builder.adapter Faraday.default_adapter
  end
end

#post(path, params = {}) ⇒ Object



38
39
40
# File 'lib/transistor/client.rb', line 38

def post(path, params = {})
  request(:post, path, params)
end

#put(path, params = {}) ⇒ Object



42
43
44
# File 'lib/transistor/client.rb', line 42

def put(path, params = {})
  request(:put, path, params)
end