TTlockClient.Types (TTlockClient v2.1.0)
Type definitions and records for TTLock client library.
Summary
Functions
Creates authentication credentials with MD5 hashed password.
Creates a new client configuration record.
Creates lock detail request parameters.
Creates lock list request parameters.
Creates passcode add request parameters.
Creates passcode change request parameters.
Creates passcode delete request parameters.
Creates passcode list request parameters.
Creates a new token info record from OAuth response.
Checks if a token is expired or will expire within the given buffer seconds.
Checks if a token info record has valid token data.
Types
@type auth_result() :: {:ok, oauth_response()} | {:error, oauth_error() | atom()}
@type lock_api_result() :: {:ok, lock_list_response() | lock_detail_response()} | {:error, oauth_error() | atom()}
@type lock_detail_params() :: {:lock_detail_params, lock_id :: integer()}
@type lock_detail_response() :: %{ lockId: integer(), lockName: String.t(), lockAlias: String.t(), lockMac: String.t(), noKeyPwd: String.t(), electricQuantity: integer(), featureValue: String.t(), timezoneRawOffset: integer(), modelNum: String.t(), hardwareRevision: String.t(), firmwareRevision: String.t(), autoLockTime: integer(), lockSound: integer(), privacyLock: integer(), tamperAlert: integer(), resetButton: integer(), openDirection: integer(), passageMode: integer(), passageModeAutoUnlock: integer(), date: integer() }
@type lock_list_response() :: %{ list: [lock_record()], pageNo: integer(), pageSize: integer(), pages: integer(), total: integer() }
@type passcode_add_response() :: %{keyboardPwdId: integer()}
@type passcode_api_result() :: {:ok, passcode_add_response() | passcode_list_response() | passcode_delete_response() | passcode_change_response()} | {:error, oauth_error() | atom()}
@type passcode_list_response() :: %{ list: [passcode_record()], pageNo: integer(), pageSize: integer(), pages: integer(), total: integer() }
@type token_info() :: {:token_info, access_token :: String.t() | nil, refresh_token :: String.t() | nil, expires_at :: DateTime.t() | nil, uid :: integer() | nil}
Functions
@spec new_auth_credentials(String.t(), String.t()) :: auth_credentials()
Creates authentication credentials with MD5 hashed password.
@spec new_client_config(String.t(), String.t(), String.t()) :: client_config()
Creates a new client configuration record.
@spec new_lock_detail_params(integer()) :: lock_detail_params()
Creates lock detail request parameters.
@spec new_lock_list_params(integer(), integer(), String.t() | nil, integer() | nil) :: lock_list_params()
Creates lock list request parameters.
new_passcode_add_params(lock_id, keyboard_pwd, keyboard_pwd_name \\ nil, keyboard_pwd_type \\ 3, start_date \\ nil, end_date \\ nil, add_type \\ 1)
@spec new_passcode_add_params( integer(), integer(), String.t() | nil, integer(), integer() | nil, integer() | nil, integer() ) :: passcode_add_params()
Creates passcode add request parameters.
Parameters
lock_id- The lock ID to add the passcode tokeyboard_pwd- The passcode (4-9 digits)keyboard_pwd_name- Optional name/alias for the passcodekeyboard_pwd_type- Passcode type: 2 = permanent, 3 = period (default 3)start_date- Start time in milliseconds (required if type = 3)end_date- End time in milliseconds (required if type = 3)add_type- Add method: 1 = Bluetooth, 2 = Gateway/WiFi (default 1)
new_passcode_change_params(lock_id, keyboard_pwd_id, keyboard_pwd_name \\ nil, new_keyboard_pwd \\ nil, start_date \\ nil, end_date \\ nil, change_type \\ 2)
@spec new_passcode_change_params( integer(), integer(), String.t() | nil, integer() | nil, integer() | nil, integer() | nil, integer() ) :: passcode_change_params()
Creates passcode change request parameters.
Parameters
lock_id- The lock ID containing the passcodekeyboard_pwd_id- The passcode ID to changekeyboard_pwd_name- Optional new name for the passcodenew_keyboard_pwd- Optional new passcode value (4-9 digits)start_date- Optional new start time in millisecondsend_date- Optional new end time in millisecondschange_type- Change method: 2 = Gateway/WiFi (default 2)
@spec new_passcode_delete_params(integer(), integer()) :: passcode_delete_params()
Creates passcode delete request parameters.
Parameters
lock_id- The lock ID containing the passcodekeyboard_pwd_id- The passcode ID to delete
@spec new_passcode_list_params( integer(), String.t() | nil, integer(), integer(), integer() ) :: passcode_list_params()
Creates passcode list request parameters.
Parameters
lock_id- The lock ID to get passcodes forsearch_str- Optional search keyword (fuzzy search by name or exact match by passcode)page_no- Page number (default 1)page_size- Items per page (default 20, max 200)order_by- Sorting: 0 = by name, 1 = reverse by time, 2 = reverse by name (default 1)
@spec new_token_info(oauth_response()) :: token_info()
Creates a new token info record from OAuth response.
@spec token_expired?(token_info(), integer()) :: boolean()
Checks if a token is expired or will expire within the given buffer seconds.
@spec valid_token_info?(token_info()) :: boolean()
Checks if a token info record has valid token data.