Module: Codelocks

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

Defined Under Namespace

Classes: CodelocksError, Lock, NetCode, Request, Response

Constant Summary collapse

VERSION =
"2.0.3"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.access_keyString

Return the access key. This is tied to the K3 Connect App. This can be nil, as for certain models of locks you will provide a 6 digit ID instead.

Returns:

  • (String)

    the access key


36
37
38
# File 'lib/codelocks.rb', line 36

def access_key
  @access_key || ENV['CODELOCKS_ACCESS_KEY']
end

.api_keyString

Return the configured API key or raise an exception

Returns:

  • (String)

    the API key


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

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

.base_uriString

The base URI used for API request

Returns:

  • (String)

    the base URI


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

def base_uri
  @base_uri || ENV['CODELOCKS_BASE_URI'] || (raise CodelocksError.new("No base URI specified"))
end

Class Method Details

.connectionFaraday

Faraday connection object

Returns:

  • (Faraday)

44
45
46
47
48
49
50
# File 'lib/codelocks.rb', line 44

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