Class: Sydecar::BaseConnection

Inherits:
Object
  • Object
show all
Defined in:
lib/sydecar/base_connection.rb

Direct Known Subclasses

Connection, FileConnection

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.base_urlObject

Returns the value of attribute base_url.



4
5
6
# File 'lib/sydecar/base_connection.rb', line 4

def base_url
  @base_url
end

.envObject

Returns the value of attribute env.



4
5
6
# File 'lib/sydecar/base_connection.rb', line 4

def env
  @env
end

.tokenObject

Returns the value of attribute token.



4
5
6
# File 'lib/sydecar/base_connection.rb', line 4

def token
  @token
end

Class Method Details

.common_headersObject



6
7
8
9
10
11
12
13
# File 'lib/sydecar/base_connection.rb', line 6

def common_headers
  {
    'Authorization' => "Bearer #{token}",
    'User-Agent' => 'Faraday',
    'Connection' => 'keep-alive',
    'Accept' => 'application/json',
  }
end

.instanceObject



15
16
17
18
19
20
21
22
23
# File 'lib/sydecar/base_connection.rb', line 15

def instance
  unless token
    raise TokenNotSetError
  end

  unless base_url
    raise BaseUrlNotSetError
  end
end