Module: Codelocks

Defined in:
lib/codelocks.rb,
lib/codelocks/version.rb,
lib/codelocks/net_code.rb,
lib/codelocks/net_code/request.rb,
lib/codelocks/net_code/response.rb

Defined Under Namespace

Modules: NetCode Classes: CodelocksError

Constant Summary collapse

VERSION =
"0.1.0"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.api_keyString

Return the configured API key or raise an exception

Returns:

  • (String)

    the API key


26
27
28
# File 'lib/codelocks.rb', line 26

def api_key
  @api_key || ENV['CODELOCKS_API_KEY'] || (raise CodelocksError.new("No API key specified"))
end

.pairing_idString

Return the configured pairing ID or raise an exception

Returns:

  • (String)

    the pairing ID


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

def pairing_id
  @pairing_id || ENV['CODELOCKS_PAIRING_ID'] || (raise CodelocksError.new("No pairing ID specified"))
end

Class Method Details

.base_uriString

The base URI used for API request

Returns:

  • (String)

    the base URI


18
19
20
# File 'lib/codelocks.rb', line 18

def base_uri
  "https://api-2445581366752.apicast.io/api/v3"
end

.connectionFaraday

Faraday connection object

Returns:

  • (Faraday)

42
43
44
45
46
47
48
# File 'lib/codelocks.rb', line 42

def connection
  @connection ||= Faraday.new(url: base_uri) do |faraday|
    faraday.request  :url_encoded
    faraday.response :logger
    faraday.adapter  Faraday.default_adapter
  end
end