Class: NukiApi::Client
Overview
Main client class that implements communication with the API global_params:
-
include_related_objects: int 0-1 0
-
page: int positive 1
-
per_page: int positive 20
Constant Summary
Constants inherited from API
API::API_ENDPOINT, API::API_STALE_VALIDITY, API::API_TIMEOUT, API::API_TOKEN, API::HTTP_STATUS_MAPPING
Constants included from HttpStatusCodes
HttpStatusCodes::HTTP_ACCOUNT_UPGRADE_REQUIRED, HttpStatusCodes::HTTP_BAD_REQUEST_CODE, HttpStatusCodes::HTTP_FORBIDDEN_CODE, HttpStatusCodes::HTTP_LOCKED, HttpStatusCodes::HTTP_NOT_FOUND_CODE, HttpStatusCodes::HTTP_NOT_PAID_CODE, HttpStatusCodes::HTTP_NO_CONTENT, HttpStatusCodes::HTTP_OK_CODE, HttpStatusCodes::HTTP_PARAMETER_CONFLICT_CODE, HttpStatusCodes::HTTP_UNAUTHORIZED_CODE, HttpStatusCodes::HTTP_UNPROCESSABLE_ENTITY_CODE
Constants included from Constants
NukiApi::Constants::ACCEPT, NukiApi::Constants::ACCEPTED_OAUTH_SCOPES, NukiApi::Constants::ACCEPT_CHARSET, NukiApi::Constants::CACHE_CONTROL, NukiApi::Constants::CONTENT_LENGTH, NukiApi::Constants::CONTENT_TYPE, NukiApi::Constants::DATE, NukiApi::Constants::ETAG, NukiApi::Constants::HEADER_LAST, NukiApi::Constants::HEADER_LINK, NukiApi::Constants::HEADER_NEXT, NukiApi::Constants::LOCATION, NukiApi::Constants::META_FIRST, NukiApi::Constants::META_LAST, NukiApi::Constants::META_NEXT, NukiApi::Constants::META_PREV, NukiApi::Constants::META_REL, NukiApi::Constants::OAUTH_SCOPES, NukiApi::Constants::PARAM_INCLUDE_RELATED, NukiApi::Constants::PARAM_PAGE, NukiApi::Constants::PARAM_PER_PAGE, NukiApi::Constants::PARAM_START_PAGE, NukiApi::Constants::RATELIMIT_LIMIT, NukiApi::Constants::RATELIMIT_REMAINING, NukiApi::Constants::RATELIMIT_RESET, NukiApi::Constants::SERVER, NukiApi::Constants::USER_AGENT
Constants included from ApiExceptions
ApiExceptions::APIExceptionError, ApiExceptions::ApiError, ApiExceptions::ApiRequestsQuotaReachedError, ApiExceptions::BadRequestError, ApiExceptions::ForbiddenError, ApiExceptions::NotFoundError, ApiExceptions::UnauthorizedError, ApiExceptions::UnprocessableEntityError
Instance Method Summary collapse
- #account ⇒ Object
-
#search(query, type = nil, global_params = {}) ⇒ Object
NukiApi::Client.new.search(query).
- #smartlock(smartlock_id, global_params = {}) ⇒ Object
- #smartlock_auth(smartlock_id, global_params = {}) ⇒ Object
-
#smartlock_auth_create(params = {}) ⇒ Object
SmartlockAuthCreate{ name* string The name of the authorization (max 32 chars).
- #smartlock_log(smartlock_id, global_params = {}) ⇒ Object
- #smartlocks ⇒ Object
- #smartlocks_auth ⇒ Object
- #smartlocks_log ⇒ Object
Methods inherited from API
Constructor Details
This class inherits a constructor from NukiApi::API
Instance Method Details
#account ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/nuki_api/client.rb', line 14 def account response = request( http_method: :get, endpoint: 'account' ) process_response(response) end |
#search(query, type = nil, global_params = {}) ⇒ Object
NukiApi::Client.new.search(query)
121 122 123 124 125 126 127 128 129 |
# File 'lib/nuki_api/client.rb', line 121 def search(query, type = nil, global_params = {}) response = request( http_method: :get, endpoint: 'search', params: { q: query, type: type }.merge!(global_params), cache_ttl: 3600 * 24 ) process_response(response) end |
#smartlock(smartlock_id, global_params = {}) ⇒ Object
93 94 95 96 97 98 99 100 |
# File 'lib/nuki_api/client.rb', line 93 def smartlock(smartlock_id, global_params = {}) response = request( http_method: :get, endpoint: "smartlock/#{smartlock_id}", params: global_params ) process_response(response) end |
#smartlock_auth(smartlock_id, global_params = {}) ⇒ Object
111 112 113 114 115 116 117 118 |
# File 'lib/nuki_api/client.rb', line 111 def smartlock_auth(smartlock_id, global_params = {}) response = request( http_method: :get, endpoint: "smartlock/#{smartlock_id}/auth", params: global_params ) process_response(response) end |
#smartlock_auth_create(params = {}) ⇒ Object
SmartlockAuthCreate{ name* string The name of the authorization (max 32 chars)
allowedFromDate string($date-time) The allowed from date
allowedUntilDate string($date-time) The allowed until date
allowedWeekDays integer($int32) minimum: 0 maximum: 127 The allowed weekdays bitmask: 64 .. monday, 32 .. tuesday, 16 .. wednesday, 8 .. thursday, 4 .. friday, 2 .. saturday, 1 .. sunday
allowedFromTime integer($int32) The allowed from time (in minutes from midnight)
allowedUntilTime integer($int32) The allowed until time (in minutes from midnight)
accountUserId integer($int32) The id of the linked account user (required if type is NOT 13 .. keypad)
remoteAllowed* boolean True if the auth has remote access
smartActionsEnabled boolean The smart actions enabled flag
type integer($int32) The optional type of the auth 0 .. app (default), 2 .. fob, 13 .. keypad
code integer($int32) The code of the keypad authorization (only for keypad)
}
83 84 85 86 87 88 89 90 91 |
# File 'lib/nuki_api/client.rb', line 83 def smartlock_auth_create(params = {}) response = request( http_method: :put, endpoint: 'smartlock/auth', params: params, cache_ttl: 5 # Prevent "double click" for 5 seconds ) process_response(response) end |
#smartlock_log(smartlock_id, global_params = {}) ⇒ Object
102 103 104 105 106 107 108 109 |
# File 'lib/nuki_api/client.rb', line 102 def smartlock_log(smartlock_id, global_params = {}) response = request( http_method: :get, endpoint: "smartlock/#{smartlock_id}/log", params: global_params ) process_response(response) end |
#smartlocks ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/nuki_api/client.rb', line 22 def smartlocks response = request( http_method: :get, endpoint: 'smartlock' ) process_response(response) end |
#smartlocks_auth ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/nuki_api/client.rb', line 38 def smartlocks_auth response = request( http_method: :get, endpoint: 'smartlock/auth' ) process_response(response) end |
#smartlocks_log ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/nuki_api/client.rb', line 30 def smartlocks_log response = request( http_method: :get, endpoint: 'smartlock/log' ) process_response(response) end |