### Install Pods Source: https://igloocompany.stoplight.io/docs/igloohome-api/97395de6841dd-sdk-documentation Run this command in your terminal after updating your Podfile to install the project dependencies. ```bash pod install ``` -------------------------------- ### Example cURL Request Source: https://igloocompany.stoplight.io/docs/igloohome-api/1w1cuv56ge5xq-overview Example cURL command demonstrating how to make a POST request with the required authorization and content type headers. ```curl curl -X POST -H "Authorization: Bearer {access_token}" -H "Content-Type: application/json" ``` -------------------------------- ### Signed Data Construction Example Source: https://igloocompany.stoplight.io/docs/igloohome-api/cd0c12b955d30-webhook-security This example shows how to construct the signed data string by concatenating request components with the '|' delimiter. The order of concatenation is crucial for correct signature validation. ```text 'POST|example-host.com|/example/path|application/json|Sat, 20 Jun 2015 12:34:56 GMT|{"payload":"example"}' ``` -------------------------------- ### Example Webhook Request Source: https://igloocompany.stoplight.io/docs/igloohome-api/cd0c12b955d30-webhook-security This is an example of an incoming HTTPS POST request for a webhook. Ensure your server is configured to accept POST requests. ```http POST /example/path HTTP/1.1 Host: example-host.com Date: Sat, 20 Jun 2015 12:34:56 GMT Accept: application/json Content-Type: application/json Content-Length: 29 x-igloocompany-sha256: "QA...==" { "payload": "example payload" } ``` -------------------------------- ### Install IglooAccessSDK with CocoaPods Source: https://igloocompany.stoplight.io/docs/igloohome-api/97395de6841dd-sdk-documentation Add the IglooAccessSDK to your Podfile and specify the Git repository and tag for installation. ```ruby pod 'IglooAccessSDK', :git => 'https://:@gitlab.com/igloohome/iglooaccess-ios-sdk.git', :tag => '' ``` -------------------------------- ### Lock Command Usage Source: https://igloocompany.stoplight.io/docs/igloohome-api/97395de6841dd-sdk-documentation Examples demonstrating how to use the lock command in both Android and iOS. ```APIDOC ## Lock Command Usage ### Description This section provides examples for using the `lock` command with the Igloohome SDK. ### Android Example ```kotlin lifecycleScope.launch { try { if (!isPermissionGranted()) { requestPermission() return@launch } iglooPlugin.lock("BLUETOOTH_DEVICE_NAME", "KEY") } catch(e: Throwable) { // Handle Error } } ``` ### iOS Example ```swift do { try await iglooPlugin.lock("BLUETOOTH_DEVICE_NAME", "KEY") } catch { // Handler Error } ``` ``` -------------------------------- ### Initiate IglooPlugin on Android Source: https://igloocompany.stoplight.io/docs/igloohome-api/97395de6841dd-sdk-documentation Example of how to initialize the IglooPlugin within an Android application. Ensure you pass the application context during initialization. ```kotlin class MyApplication : Application() { /** * Instance of the IglooPlugin. */ private lateinit var iglooPlugin: IglooPlugin override fun onCreate() { super.onCreate() // Initializes the `iglooPlugin` with the application context. iglooPlugin = IglooPlugin(this.applicationContext) } } ``` -------------------------------- ### Job Status Response Example Source: https://igloocompany.stoplight.io/docs/igloohome-api/74fd6741cfc20-get-job-status This is an example of a successful JSON response when querying the job status. It includes details like job ID, expiry date, completion status, job type, and the specific job response. ```json { "jobId": "6345191a82bcfc12a921bdb6", "expiryDate": "2025-01-01T00:02:00.000Z", "completed": true, "jobType": "UNLOCK", "jobResponse": { "jobStatus": 0, "opResult": { "result": 0 } } } ``` -------------------------------- ### Sync Device Operation Source: https://igloocompany.stoplight.io/docs/igloohome-api/97395de6841dd-sdk-documentation Detailed explanation and examples for syncing a device using the Igloohome SDK. ```APIDOC ## Sync Device Operation ### Description Sync the device associated with the given Bluetooth device name. This operation updates the lock time, pulls battery level, and synchronizes activity logs. **Notes:** * Sync will perform setTime command to update the lock time * Sync will pull the batteryLevel of the lock, and store the battery level to the server * Sync will repeatedly pull the activity logs from the locks, store ig into local storage and store the activity logs to the server **Prerequisite** : * Require internet access to send activity logs to server * This function require runtime bluetooth permission. refer to Request Permission section * Access token for requesting Igloohome API. Generated token should only be valid for 1 scope ### Parameters * **bluetoothDeviceName** : The name of the Bluetooth device to lock. * **key** : The bluetooth key for this bluetooth device * **getDevicesToken** : Access token for getting device information from Igloohome Server. Required scope: `igloohomeapi/get-devices` scope. See Generate Access Token for generating access token. * **storeLogsToken** : Access token for storing lock activity logs to Igloohome Server. Required scope: `igloohomeapi/store-device-activity`. See Generate Access Token for generating access token. * **updateDeviceToken** : Access token for update device to Igloohome Server. Required scope: `igloohomeapi/update-device`. See [Generate Access Token] * **timeInSeconds** : Optional integer of time in seconds. will be use to set the lock time. if not provided time will automatically be pulled from server. * **operationId** : Optional operation ID for tracking the request. ### Throws * `IglooAccessException.BluetoothException(703)`: Bluetooth Operation Timeout * `IglooAccessException.BluetoothException(708)`: Bluetooth service disabled * `IglooAccessException.ApiException(401)`: User unauthenticated * `IglooAccessException.ApiException(403)`: Forbidden, check token validity and scopes * `IglooAccessException.ApiException(serverStatusCode)`: Error during requesting API * `IglooAccessException.GenericException`: Unhandled Error ### Android Example ```kotlin lifecycleScope.launch { try { if (!isPermissionGranted()) { requestPermission() return@launch } val syncResult = iglooPlugin.sync( "BLUETOOTH_DEVICE_NAME", "KEY", getDeviceToken = "GET DEVICE ACCESS TOKEN", storeLogsToken = "STORE LOGS ACCESS TOKEN", updateDeviceToken = "UPDATE DEVICE ACCESS TOKEN", ) } catch(e: Throwable) { // Handle Error } } ``` ### iOS Example ```swift do { let syncResult = try await iglooPlugin.sync( "BLUEOOTH_DEVICE_NAME", "KEY", getDeviceToken: "GET DEVICE ACCESS TOKEN", storeLogsToken: "STORE LOGS ACCESS TOKEN") } catch { // Handle Error } ``` ``` -------------------------------- ### Request Access Token (All Permissions) Source: https://igloocompany.stoplight.io/docs/igloohome-api/67fb491f16f99-getting-started Make a POST request to the token endpoint to obtain an access token. This example requests all available permissions by omitting the scope parameter. ```bash curl --request POST \ --url https://auth.igloohome.co/oauth2/token \ --header 'Authorization: Basic {your_encoded_credentials}' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data grant_type=client_credentials ``` ```javascript fetch('https://auth.igloohome.co/oauth2/token', { method: 'POST', headers: { 'Authorization': 'Basic {your_encoded_credentials}', 'Content-Type': 'application/x-www-form-urlencoded' }, body: 'grant_type=client_credentials' }).then(response => response.json()) .then(data => console.log(data)); ``` ```go package main import ( "fmt" "net/http" "strings" ) func main() { client := &http.Client{} request, err := http.NewRequest("POST", "https://auth.igloohome.co/oauth2/token", strings.NewReader("grant_type=client_credentials")) if err != nil { fmt.Println(err) return } request.Header.Set("Authorization", "Basic {your_encoded_credentials}") request.Header.Set("Content-Type", "application/x-www-form-urlencoded") response, err := client.Do(request) if err != nil { fmt.Println(err) return } defer response.Body.Close() fmt.Println(response.Status) } ``` ```python import requests url = "https://auth.igloohome.co/oauth2/token" headers = { "Authorization": "Basic {your_encoded_credentials}", "Content-Type": "application/x-www-form-urlencoded" } data = { "grant_type": "client_credentials" } response = requests.post(url, headers=headers, data=data) print(response.json()) ``` -------------------------------- ### Get Devices Source: https://igloocompany.stoplight.io/docs/igloohome-api/67fb491f16f99-getting-started Retrieve a list of all connected devices. Requires a valid access token. ```APIDOC ## GET /igloohome/devices ### Description Retrieves a list of all connected devices associated with your account. ### Method GET ### Endpoint https://api.igloodeveloper.co/igloohome/devices ### Parameters #### Headers - **Authorization** (string) - Required - Bearer token for authentication. Example: `Bearer {your_access_token}` ``` -------------------------------- ### Initiate IglooPlugin on iOS Source: https://igloocompany.stoplight.io/docs/igloohome-api/97395de6841dd-sdk-documentation Example of how to initialize the IglooPlugin within an iOS application using Swift. The plugin is typically instantiated as a property of your ViewModel or relevant class. ```swift import IglooPluginSDK class MyViewModel: ObservableObject { let iglooPlugin = IglooPlugin() } ``` -------------------------------- ### Create One-Time PIN Code Job Source: https://igloocompany.stoplight.io/docs/igloohome-api/ck0pcqffefdc5-bridge-proxied-jobs Example of creating a one-time PIN code (jobType 4, pinType 1) which is valid for 24 hours from the start date. ```json { "jobType": 4, "jobData": { "accessName": "OTP PIN", "pin": "123456", "pinType": 1, "startDate": "2024-01-01T00:00:00+00:00" } } ``` -------------------------------- ### Lock Device - Android Source: https://igloocompany.stoplight.io/docs/igloohome-api/97395de6841dd-sdk-documentation Example of using the lock command on Android. Ensure Bluetooth permissions are granted before execution. ```kotlin lifecycleScope.launch { try { if (!isPermissionGranted()) { requestPermission() return@launch } iglooPlugin.lock("BLUETOOTH_DEVICE_NAME", "KEY") } catch(e: Throwable) { // Handle Error } } ``` -------------------------------- ### Lock Device - iOS Source: https://igloocompany.stoplight.io/docs/igloohome-api/97395de6841dd-sdk-documentation Example of using the lock command on iOS. Error handling is included for potential exceptions. ```swift do { try await iglooPlugin.lock("BLUETOOTH_DEVICE_NAME", "KEY") } catch { // Handler Error } ``` -------------------------------- ### Sync Device - iOS Source: https://igloocompany.stoplight.io/docs/igloohome-api/97395de6841dd-sdk-documentation Example of syncing a device on iOS. Requires internet access and specific access tokens for device information and log storage. Error handling is included. ```swift do { let syncResult = try await iglooPlugin.sync( "BLUEOOTH_DEVICE_NAME", "KEY", getDeviceToken: "GET DEVICE ACCESS TOKEN", storeLogsToken: "STORE LOGS ACCESS TOKEN") } catch { // Handle Error } ``` -------------------------------- ### Your GET endpoint Source: https://igloocompany.stoplight.io/docs/igloohome-api/ll14dkkm8dhkw-your-get-endpoint This endpoint retrieves device information using the Bluetooth ID. ```APIDOC ## POST https://api.igloodeveloper.co/igloohome/devices/{bluetoothId} ### Description Retrieves device information using the provided Bluetooth ID. ### Method POST ### Endpoint https://api.igloodeveloper.co/igloohome/devices/{bluetoothId} ### Parameters #### Path Parameters - **bluetoothId** (string) - Required - The unique Bluetooth ID of the device. ### Request Example ``` curl --request POST \ --url https://api.igloodeveloper.co/igloohome/devices/{bluetoothId} \ --header 'Authorization: Bearer 123' \ --header 'Content-Type: application/json' ``` ``` -------------------------------- ### Sync Device - Android Source: https://igloocompany.stoplight.io/docs/igloohome-api/97395de6841dd-sdk-documentation Example of syncing a device on Android. Requires internet access and specific access tokens for device information, log storage, and device updates. Bluetooth permissions must be granted. ```kotlin lifecycleScope.launch { try { if (!isPermissionGranted()) { requestPermission() return@launch } val syncResult = iglooPlugin.sync( "BLUETOOTH_DEVICE_NAME", "KEY", getDeviceToken = "GET DEVICE ACCESS TOKEN", storeLogsToken = "STORE LOGS ACCESS TOKEN", updateDeviceToken = "UPDATE DEVICE ACCESS TOKEN", ) } catch(e: Throwable) { // Handle Error } } ``` -------------------------------- ### Error Response Source: https://igloocompany.stoplight.io/docs/igloohome-api/67fb491f16f99-getting-started Example of an error response received when authentication fails. ```APIDOC ## Error Response ### Description This is an example of a generic error response structure when authentication or other API operations fail. ### Response Example ```json { "error": "error_type" } ``` ``` -------------------------------- ### Get Activity Logs Source: https://igloocompany.stoplight.io/docs/igloohome-api/ck0pcqffefdc5-bridge-proxied-jobs Downloads activity logs from the lock. Optionally synchronizes the lock's clock. ```APIDOC ## Get Activity Logs Command ### Description Downloads activity logs from the lock. Optionally synchronizes the lock's clock. ### Parameters #### Request Body - **jobType** (number) - Required - Must be 15. - **jobData** (object) - Optional. - **lockTime** (ISO_DATE) - Optional - Synchronize the lock's clock. ### Request Example ```json { "jobType": 15, "jobData": { "lockTime": "2024-01-01T12:00:00+00:00" } } ``` ``` -------------------------------- ### Get Job Status Request Source: https://igloocompany.stoplight.io/docs/igloohome-api/74fd6741cfc20-get-job-status Use this cURL command to make a GET request to retrieve the status of a specific job. Ensure you replace `{jobId}` with the actual job ID and provide a valid OAuth 2.0 Bearer token. ```curl curl --request GET \ --url https://api.igloodeveloper.co/igloohome/jobs/{jobId} \ --header 'Accept: application/json' \ --header 'Authorization: Bearer 123' ``` -------------------------------- ### Get Device Status Source: https://igloocompany.stoplight.io/docs/igloohome-api/ck0pcqffefdc5-bridge-proxied-jobs Queries the lock's current operational status. ```APIDOC ## Get Device Status Command ### Description Queries the lock's current operational status. ### Parameters #### Request Body - **jobType** (number) - Required - Must be 10. ### Request Example ```json { "jobType": 10 } ``` ``` -------------------------------- ### Initiate OAuth 2.0 Authentication Source: https://igloocompany.stoplight.io/docs/igloohome-api/c0431bbef586d-getting-started-with-iglooconnect Redirect users to the igloohome login page to start the OAuth 2.0 authorization code flow. Ensure you replace placeholders like {CLIENT_ID}, {REDIRECT_URI}, {SCOPES}, and {STATE} with your specific values. ```URL https://auth.igloohome.co/login?response_type=code&client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&scope={SCOPES}&state={STATE} ``` -------------------------------- ### Create Custom PIN Code Request Body Example Source: https://igloocompany.stoplight.io/docs/igloohome-api/ae3e61e390eab-create-a-bridge-proxied-job This JSON object demonstrates the structure for creating a custom PIN code with a specified duration. Ensure all required fields like `accessName`, `pin`, `pinType`, `startDate`, and `endDate` are correctly populated. ```json { "jobType": 4, "jobData": { "accessName": "Maintenance guy", "pin": "123456", "pinType": 4, "startDate": "2022-10-10T12:00:00+08:00", "endDate": "2022-10-10T16:00:00+08:00" } } ``` -------------------------------- ### Get Battery Level Source: https://igloocompany.stoplight.io/docs/igloohome-api/ck0pcqffefdc5-bridge-proxied-jobs Retrieves the lock's current battery level as a percentage. ```APIDOC ## Get Battery Level Command ### Description Retrieves the lock's current battery level as a percentage. ### Parameters #### Request Body - **jobType** (number) - Required - Must be 9. ### Request Example ```json { "jobType": 9 } ``` ``` -------------------------------- ### Get Device Status Webhook Source: https://igloocompany.stoplight.io/docs/igloohome-api/ax5zas6u26yn9-job-specific-webhook-data This webhook payload includes the job status and the device state, such as lock and door status. ```APIDOC ## Get Device Status Webhook ### Description This job retrieves the current status of the device, including whether the lock and door are open. The webhook payload includes the job status and the device state. ### Expected Payload ```json { "event": { "id": "string", "type": 3, "data": { "jobId": "string", "jobStatus": 0, "lockOpen": false, "doorOpen": true }, "date": "ISO_DATE", "proxyTransportMethod": 2, "accessoryId": "string" }, "product": { "id": "string", "type": 1 } } ``` ``` -------------------------------- ### Get Activity Logs Job Source: https://igloocompany.stoplight.io/docs/igloohome-api/ck0pcqffefdc5-bridge-proxied-jobs Use jobType 15 to download activity logs from the lock. Optionally synchronize the lock's clock with lockTime. ```json { "jobType": 15, "jobData": { "lockTime": "2024-01-01T12:00:00+00:00" } } ``` -------------------------------- ### Job Creation Response Example Source: https://igloocompany.stoplight.io/docs/igloohome-api/ae3e61e390eab-create-a-bridge-proxied-job Upon successful creation of a bridge proxied job, the API returns a JSON object containing the unique `jobId`. This ID can be used to track the status of the job. ```json { "jobId": "6345191a82bcfc12a921bdb6" } ``` -------------------------------- ### Generate a One-Time algoPIN Source: https://igloocompany.stoplight.io/docs/igloohome-api/cbc75e9e68e0e-what-is-algo-pin Use this endpoint to generate a unique one-time algoPIN. Specify the variance to get different PINs for the same duration. Ensure the device is algoPIN-supported and paired. ```curl curl --request POST \ --url https://api.igloodeveloper.co/igloohome/devices/IGP101abc123/algopin/onetime \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer abcdef' \ --data '{ "variance": 1, "startDate": "2022-01-01T00:00:00+08:00", "accessName": "Maintenance guy" }' ``` -------------------------------- ### Get Device Status Webhook Payload Source: https://igloocompany.stoplight.io/docs/igloohome-api/ax5zas6u26yn9-job-specific-webhook-data This payload provides the current status of the device, including lock and door states, along with the job status. ```json { "event": { "id": "string", "type": 3, "data": { "jobId": "string", "jobStatus": 0, "lockOpen": false, "doorOpen": true }, "date": "ISO_DATE", "proxyTransportMethod": 2, "accessoryId": "string" }, "product": { "id": "string", "type": 1 } } ``` -------------------------------- ### Configure build settings for IglooAccessSDK Source: https://igloocompany.stoplight.io/docs/igloohome-api/97395de6841dd-sdk-documentation Add this configuration to the `post_install` section of your Podfile to ensure proper build settings for the SDK. ```ruby config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES' config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = "arm64" config.build_settings['ENABLE_USER_SCRIPT_SANDBOXING'] = 'NO' ``` -------------------------------- ### Add IglooPlugin Repository (Kotlin DSL) Source: https://igloocompany.stoplight.io/docs/igloohome-api/97395de6841dd-sdk-documentation Configure your Android project's settings.gradle.kts file to include the IglooPlugin repository and credentials for accessing the SDK. ```kotlin repositories { google() mavenCentral() maven { url = uri("https://gitlab.com/api/v4/projects/64441730/packages/maven") name = "GitLab" authentication { create("basic") } credentials { username = "Private-Token" password = "Generated Personal Access Token" } } } ``` -------------------------------- ### Add IglooPlugin Repository (Groovy DSL) Source: https://igloocompany.stoplight.io/docs/igloohome-api/97395de6841dd-sdk-documentation Configure your Android project's settings.gradle file to include the IglooPlugin repository and credentials for accessing the SDK. ```groovy repositories { google() mavenCentral() maven { url "https://gitlab.com/api/v4/projects/64441730/packages/maven" name "GitLab" credentials(PasswordCredentials) { username = "Private-Token" password = "Generated Personal Access Token" } } } ``` -------------------------------- ### Get Battery Level Webhook Source: https://igloocompany.stoplight.io/docs/igloohome-api/ax5zas6u26yn9-job-specific-webhook-data This webhook payload includes the job status and the battery level as a percentage. ```APIDOC ## Get Battery Level Webhook ### Description This job retrieves the current battery level of the device. The webhook payload includes both the job status and the battery level as a percentage. ### Expected Payload ```json { "event": { "id": "string", "type": 3, "data": { "jobId": "string", "jobStatus": 0, "batteryLevel": 75 }, "date": "ISO_DATE", "proxyTransportMethod": 2, "accessoryId": "string" }, "product": { "id": "string", "type": 1 } } ``` ### Job Data Device Battery Level Range| Description ---|--- 0 - 100| Represents battery level as a percentage ``` -------------------------------- ### Sync Device with Status (Android) Source: https://igloocompany.stoplight.io/docs/igloohome-api/97395de6841dd-sdk-documentation Use this method to sync a device, ensuring all sub-processes are attempted and providing a detailed status report. It handles individual process failures gracefully and continues execution. ```kotlin try { iglooPlugin.syncWithStatus( "BLUETOOTH_DEVICE_NAME", "BLUETOOTH_KEY", timeInSeconds = , getDeviceToken = "GET_DEVICE_TOKEN", storeLogsToken = "STORE_LOGS_TOKEN", updateDeviceToken = "UPDATE_DEVICE_TOKEN", ) .onCompletion { // Do something when process completed } .catch { error -> // Do something when error } .collect { status -> if (status.isSuccess) { // Do something when the sub process success } else { // Do something when the sub process error } } } catch (e: Throwable) { // Handle error } ``` -------------------------------- ### Get Device Status Job Source: https://igloocompany.stoplight.io/docs/igloohome-api/ck0pcqffefdc5-bridge-proxied-jobs Use jobType 10 to query the current operational status of the lock. ```json { "jobType": 10 } ``` -------------------------------- ### Get Battery Level Job Source: https://igloocompany.stoplight.io/docs/igloohome-api/ck0pcqffefdc5-bridge-proxied-jobs Use jobType 9 to retrieve the current battery level of the lock. ```json { "jobType": 9 } ``` -------------------------------- ### Get Device Status Job Source: https://igloocompany.stoplight.io/docs/igloohome-api/b0amiokly9501-bridge-targeted-jobs A specific job type to retrieve the status of a device connected to the Bridge. ```APIDOC ## Get Device Status ### Description This job type is used to retrieve the current status of a device connected to the Bridge. ### Command Details #### Payload Format ```json { "jobType": 10 } ``` ``` -------------------------------- ### Job Creation Source: https://igloocompany.stoplight.io/docs/igloohome-api/ck0pcqffefdc5-bridge-proxied-jobs Create a job by making a POST request to the specified endpoint. This initiates a command to be sent to a smart lock through a Bridge. ```APIDOC ## POST /devices/{deviceId}/jobs/bridges/{bridgeId} ### Description Creates a job to send a command to a smart lock via a Bridge. ### Method POST ### Endpoint /devices/{deviceId}/jobs/bridges/{bridgeId} ### Parameters #### Request Body - **jobType** (number) - Required - Command type identifier (see Job Types). - **jobData** (object) - Required - Command-specific parameters. ### Response #### Success Response (200) - **jobId** (string) - The unique identifier for the created job. ### Request Example ```json { "jobType": 1, "jobData": {} } ``` ### Response Example ```json { "jobId": "string" } ``` ``` -------------------------------- ### Initiate OAuth 2.0 Authorization Request Source: https://igloocompany.stoplight.io/docs/igloohome-api/c0431bbef586d-getting-started-with-iglooconnect Use this cURL command to initiate the OAuth 2.0 authorization flow. Ensure all parameters are correctly set, including your client ID, redirect URI, and desired scopes. ```bash curl "https://auth.igloohome.co/login?client_id=your_client_id&response_type=code&redirect_uri=https%3A%2F%2Fyourapp.com%2Fcallback&scope=igloohomeapi%2Fget-devices+openid+profile&state=xyz987" ``` -------------------------------- ### Clone Repository with Gitlab Private Token Source: https://igloocompany.stoplight.io/docs/igloohome-api/97395de6841dd-sdk-documentation Clone the Android or iOS SDK repository using your Gitlab private token. Ensure you replace '' with your actual token. ```bash git clone https://gitlab:@gitlab.com/igloohome/iglooaccess-android-sdk.git ``` ```bash git clone https://gitlab:@gitlab.com/igloohome/iglooaccess-ios-sdk.git ``` -------------------------------- ### Get Job Status Source: https://igloocompany.stoplight.io/docs/igloohome-api/74fd6741cfc20-get-job-status Retrieves the status of a specific job by its ID. This endpoint is useful for monitoring the progress and outcome of asynchronous operations. ```APIDOC ## GET /igloohome/jobs/{jobId} ### Description Retrieves the status of a specific job using its unique identifier. This endpoint provides details on whether the job has completed, its expiry date, and the specific response from the job. ### Method GET ### Endpoint https://api.igloodeveloper.co/igloohome/jobs/{jobId} ### Parameters #### Path Parameters - **jobId** (string) - Required - The unique identifier for the job. #### Request Body This endpoint does not accept a request body. ### Response #### Success Response (200) - **jobId** (string) - The ID of the job. - **expiryDate** (string) - The date and time when the job will expire. - **completed** (boolean) - Indicates if the job has been completed. - **jobType** (string) - The type of job that was performed. - **jobResponse** (object) - An object containing the job's response details. - **jobStatus** (any) - The status of the job. Allowed values: 0 (completed), 1 (pending), 2 (expired). - **opResult** (object) - An object containing the operational result. - **result** (any) - The result code of the operation. #### Error Response - **404** - Not Found ### Request Example ```curl curl --request GET \ --url https://api.igloodeveloper.co/igloohome/jobs/{jobId} \ --header 'Accept: application/json' \ --header 'Authorization: Bearer 123' ``` ### Response Example ```json { "jobId": "6345191a82bcfc12a921bdb6", "expiryDate": "2025-01-01T00:02:00.000Z", "completed": true, "jobType": "UNLOCK", "jobResponse": { "jobStatus": 0, "opResult": { "result": 0 } } } ``` ``` -------------------------------- ### Sync with Status Source: https://igloocompany.stoplight.io/docs/igloohome-api/97395de6841dd-sdk-documentation Synchronizes a device by name, ensuring all sub-processes are attempted and providing a detailed status report. This method is non-terminating on individual command failures and offers granular output on the success or failure of each internal process. ```APIDOC ## Sync with Status ### Description Synchronizes the device associated with the given Bluetooth device name. Unlike the standard Sync, this method ensures all sub-processes are attempted regardless of individual failures and provides a detailed status report for each. ### Parameters * **bluetoothDeviceName** (string) - The name of the Bluetooth device to lock. * **key** (string) - The bluetooth key for this bluetooth device. * **getDevicesToken** (string) - Access token for getting device information from Igloohome Server. Required scope: `igloohomeapi/get-devices`. * **storeLogsToken** (string) - Access token for storing lock activity logs to Igloohome Server. Required scope: `igloohomeapi/store-device-activity`. * **updateDeviceToken** (string) - Access token for updating device to Igloohome Server. Required scope: `igloohomeapi/update-device`. * **timeInSeconds** (integer, optional) - Time in seconds to set the lock time. If not provided, time will be pulled from the server. * **operationId** (string, optional) - Operation ID for tracking the request. ### Throws * `IglooAccessException.BluetoothException(708)`: Bluetooth service disabled * `IglooAccessException.GenericException`: Unhandled Error ### Example Android ```kotlin try { iglooPlugin.syncWithStatus( "BLUETOOTH_DEVICE_NAME", "BLUETOOTH_KEY", timeInSeconds = , getDeviceToken = "GET_DEVICE_TOKEN", storeLogsToken = "STORE_LOGS_TOKEN", updateDeviceToken = "UPDATE_DEVICE_TOKEN" ) .onCompletion { /* Do something when process completed */ } .catch { error -> /* Do something when error */ } .collect { status -> if (status.isSuccess) { // Do something when the sub process success } else { // Do something when the sub process error } } } catch (e: Throwable) { // Handle error } ``` ``` -------------------------------- ### Initiate Authentication Source: https://igloocompany.stoplight.io/docs/igloohome-api/c0431bbef586d-getting-started-with-iglooconnect Initiates the OAuth 2.0 authorization code flow by redirecting the user to the IglooConnect login page. Users authenticate and grant permissions, after which they are redirected back to your application's callback URL. ```APIDOC ## GET /login ### Description Initiates the OAuth 2.0 authorization code flow. ### Method GET ### Endpoint https://auth.igloohome.co/login ### Parameters #### Query Parameters - **response_type** (string) - Required - Must be `code`. - **client_id** (string) - Required - Your client ID from igloohome. - **redirect_uri** (string) - Required - Your callback URL (URL encoded). - **scope** (string) - Required - Space-separated scope list. - **state** (string) - Optional - Recommended. Used for security and state preservation. ### Request Example ``` curl "https://auth.igloohome.co/login?client_id=your_client_id&response_type=code&redirect_uri=https%3A%2F%2Fyourapp.com%2Fcallback&scope=igloohomeapi%2Fget-devices+openid+profile&state=xyz987" ``` ### Response On successful authentication, the user is redirected to the `redirect_uri` with an authorization code and the `state` parameter if provided. #### Success Response (302 Redirect) - **Location** (string) - The callback URL with `code` and `state` parameters. ### Example Redirect URL `https://{REDIRECT_URI}?code={AUTH_CODE}&state={STATE}` ``` -------------------------------- ### Get Battery Level Webhook Payload Source: https://igloocompany.stoplight.io/docs/igloohome-api/ax5zas6u26yn9-job-specific-webhook-data This payload returns the device's battery level and job status. The battery level is represented as a percentage. ```json { "event": { "id": "string", "type": 3, "data": { "jobId": "string", "jobStatus": 0, "batteryLevel": 75 }, "date": "ISO_DATE", "proxyTransportMethod": 2, "accessoryId": "string" }, "product": { "id": "string", "type": 1 } } ``` -------------------------------- ### POST Request Sample - cURL Source: https://igloocompany.stoplight.io/docs/igloohome-api/ll14dkkm8dhkw-your-get-endpoint Use this cURL command to send a POST request to the devices endpoint. Ensure you replace `{bluetoothId}` with the actual device ID and provide a valid OAuth 2.0 Bearer token. ```Shell curl --request POST \ --url https://api.igloodeveloper.co/igloohome/devices/{bluetoothId} \ --header 'Authorization: Bearer 123' \ --header 'Content-Type: application/json' ``` -------------------------------- ### Request Access Token (Device Management Scope) Source: https://igloocompany.stoplight.io/docs/igloohome-api/67fb491f16f99-getting-started Obtain an access token for applications that require full device control and monitoring capabilities. ```APIDOC ## POST /oauth2/token ### Description Requests an OAuth 2.0 access token using the client credentials grant type. This example requests a token with scopes for comprehensive device management, including getting devices and performing lock/unlock operations via the bridge. ### Method POST ### Endpoint https://auth.igloohome.co/oauth2/token ### Parameters #### Headers - **Authorization** (string) - Required - Basic authentication credentials. Example: `Basic {credentials}` - **Content-Type** (string) - Required - `application/x-www-form-urlencoded` #### Request Body - **grant_type** (string) - Required - Must be `client_credentials`. - **scope** (string) - Required - Defines the permissions granted by the token. Example scopes: `igloohomeapi/get-devices igloohomeapi/lock-bridge-proxied-job igloohomeapi/unlock-bridge-proxied-job igloohomeapi/get-device-status-bridge-proxied-job`. ``` -------------------------------- ### Get Device Status Job Payload Source: https://igloocompany.stoplight.io/docs/igloohome-api/b0amiokly9501-bridge-targeted-jobs Specific payload format for requesting the status of a device via a Bridge targeted job. Uses jobType 10. ```json { "jobType": 10 } ``` -------------------------------- ### Generate Access Token (cURL) Source: https://igloocompany.stoplight.io/docs/igloohome-api/97395de6841dd-sdk-documentation Use this cURL command to generate an access token by making a POST request to the Igloohome authentication server. Ensure the Authorization header is correctly formatted with your base64 encoded client ID and secret. ```curl curl --location --request POST 'https://auth.igloohome.co/oauth2/token?grant_type=client_credentials&scope=igloohomeapi%2Fstore-device-activity' \ --header 'Authorization: Basic VGhpcyBpcyBiYXNlNjQgZW5jb2RlZCBjbGllbnQgSUQgYW5kIGNsaWVudCBzZWNyZXQgZm9ybWF0dGVkIGFzIGBjbGllbnRJZDpjbGllbnRTZWNyZXRgIChqb2luZWQgYnkgOiBzeW1ib2wp' \ --header 'Content-Type: application/x-www-form-urlencoded' ``` -------------------------------- ### Request Access Token (Specific Permissions) Source: https://igloocompany.stoplight.io/docs/igloohome-api/67fb491f16f99-getting-started Request an access token with specific permissions by providing a space-separated list of scopes in the request body. This limits the token's capabilities to only the specified scopes. ```bash curl --request POST \ --url https://auth.igloohome.co/oauth2/token \ --header 'Authorization: Basic {your_encoded_credentials}' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data grant_type=client_credentials \ --data 'scope=igloohomeapi/algopin-onetime igloohomeapi/get-devices' ``` ```javascript fetch('https://auth.igloohome.co/oauth2/token', { method: 'POST', headers: { 'Authorization': 'Basic {your_encoded_credentials}', 'Content-Type': 'application/x-www-form-urlencoded' }, body: 'grant_type=client_credentials&scope=igloohomeapi/algopin-onetime igloohomeapi/get-devices' }).then(response => response.json()) .then(data => console.log(data)); ``` ```go package main import ( "fmt" "net/http" "strings" ) func main() { client := &http.Client{} request, err := http.NewRequest("POST", "https://auth.igloohome.co/oauth2/token", strings.NewReader("grant_type=client_credentials&scope=igloohomeapi/algopin-onetime igloohomeapi/get-devices")) if err != nil { fmt.Println(err) return } request.Header.Set("Authorization", "Basic {your_encoded_credentials}") request.Header.Set("Content-Type", "application/x-www-form-urlencoded") response, err := client.Do(request) if err != nil { fmt.Println(err) return } defer response.Body.Close() fmt.Println(response.Status) } ``` ```python import requests url = "https://auth.igloohome.co/oauth2/token" headers = { "Authorization": "Basic {your_encoded_credentials}", "Content-Type": "application/x-www-form-urlencoded" } data = { "grant_type": "client_credentials", "scope": "igloohomeapi/algopin-onetime igloohomeapi/get-devices" } response = requests.post(url, headers=headers, data=data) print(response.json()) ``` -------------------------------- ### Request Access Token (Property Management Scope) Source: https://igloocompany.stoplight.io/docs/igloohome-api/67fb491f16f99-getting-started Obtain an access token for comprehensive property management, including all PIN types and device control. ```APIDOC ## POST /oauth2/token ### Description Requests an OAuth 2.0 access token using the client credentials grant type. This example requests a token with scopes for extensive property management, covering all PIN types and device control functionalities. ### Method POST ### Endpoint https://auth.igloohome.co/oauth2/token ### Parameters #### Headers - **Authorization** (string) - Required - Basic authentication credentials. Example: `Basic {credentials}` - **Content-Type** (string) - Required - `application/x-www-form-urlencoded` #### Request Body - **grant_type** (string) - Required - Must be `client_credentials`. - **scope** (string) - Required - Defines the permissions granted by the token. Example scopes: `igloohomeapi/algopin-permanent igloohomeapi/algopin-onetime igloohomeapi/algopin-daily igloohomeapi/get-devices igloohomeapi/lock-bridge-proxied-job igloohomeapi/unlock-bridge-proxied-job`. ``` -------------------------------- ### Create Custom PIN Webhook Source: https://igloocompany.stoplight.io/docs/igloohome-api/ax5zas6u26yn9-job-specific-webhook-data This webhook payload provides feedback on the custom PIN creation attempt. ```APIDOC ## Create Custom PIN Webhook ### Description This job creates a custom PIN on the device. The webhook payload provides feedback on the creation attempt. ### Expected Payload ```json { "event": { "id": "string", "type": 3, "data": { "jobId": "string", "jobStatus": 0 }, "date": "ISO_DATE", "proxyTransportMethod": 2, "accessoryId": "string" }, "product": { "id": "string", "type": 1 } } ``` ### Status Codes Job Status| Number Mapping ---|--- Invalid Custom PIN length| `5` Duplicate PIN| `9` Insufficient PIN Storage| `12` ``` -------------------------------- ### Create a Bridge Proxied Job Source: https://igloocompany.stoplight.io/docs/igloohome-api/ae3e61e390eab-create-a-bridge-proxied-job This endpoint creates a job for a lock via a Bridge device. It supports various job types including locking, unlocking, PIN management, and device status retrieval. ```APIDOC ## POST https://api.igloodeveloper.co/igloohome/devices/{deviceId}/jobs/bridges/{bridgeId} ### Description Creates a job for a lock via a Bridge device. ### Method POST ### Endpoint https://api.igloodeveloper.co/igloohome/devices/{deviceId}/jobs/bridges/{bridgeId} ### Parameters #### Path Parameters - **bridgeId** (string) - Required - Bluetooth ID of the Bridge - **deviceId** (string) - Required - Bluetooth ID of the Bridge-connected device #### Request Body - **jobType** (integer) - Required - **jobData** (object) - Required - **accessName** (string) - Optional - **pinType** (integer) - Required - **pin** (string) - Required - **startDate** (string) - Required - **endDate** (string) - Required ### Request Example ```json { "jobType": 4, "jobData": { "accessName": "Maintenance guy", "pin": "123456", "pinType": 4, "startDate": "2022-10-10T12:00:00+08:00", "endDate": "2022-10-10T16:00:00+08:00" } } ``` ### Response #### Success Response (200) - **jobId** (string) - Description not provided #### Response Example ```json { "jobId": "6345191a82bcfc12a921bdb6" } ``` ``` -------------------------------- ### Create Custom PIN Code Job Source: https://igloocompany.stoplight.io/docs/igloohome-api/ck0pcqffefdc5-bridge-proxied-jobs Use jobType 4 to create a custom PIN code. Requires an accessName, PIN, PIN type, and start date. An end date can be provided for duration-based PINs. ```json { "jobType": 4, "jobData": { "accessName": "Guest PIN", "pin": "123456", "pinType": 4, "startDate": "2024-01-01T12:00:00+00:00", "endDate": "2024-01-01T16:00:00+00:00" } } ``` -------------------------------- ### Add SDK Dependency (Kotlin DSL) Source: https://igloocompany.stoplight.io/docs/igloohome-api/97395de6841dd-sdk-documentation Add the Igloo SDK dependency to your app's build.gradle.kts file. ```kotlin implementation("co.igloo.access:sdk:") ``` -------------------------------- ### Create Bridge Proxied Job using cURL Source: https://igloocompany.stoplight.io/docs/igloohome-api/ae3e61e390eab-create-a-bridge-proxied-job This cURL command shows how to send a POST request to create a bridge proxied job, specifically for creating a custom PIN code. Replace `{deviceId}` and `{bridgeId}` with actual IDs and ensure your Authorization token is valid. ```curl curl --request POST \ --url https://api.igloodeveloper.co/igloohome/devices/{deviceId}/jobs/bridges/{bridgeId} \ --header 'Accept: application/json' \ --header 'Authorization: Bearer 123' \ --header 'Content-Type: application/json' \ --data '{ \ "jobType": 4, \ "jobData": { \ "accessName": "Maintenance guy", \ "pin": "123456", \ "pinType": 4, \ "startDate": "2022-10-10T12:00:00+08:00", \ "endDate": "2022-10-10T16:00:00+08:00" \ } \ }' ``` -------------------------------- ### Add SDK Dependency (Groovy DSL) Source: https://igloocompany.stoplight.io/docs/igloohome-api/97395de6841dd-sdk-documentation Add the Igloo SDK dependency to your app's build.gradle file. ```groovy implementation 'co.igloo.access:sdk:' ``` -------------------------------- ### Create Custom PIN code Source: https://igloocompany.stoplight.io/docs/igloohome-api/ck0pcqffefdc5-bridge-proxied-jobs Creates a PIN code with specific access permissions and time restrictions. ```APIDOC ## Create Custom PIN Code Command ### Description Creates a PIN code with specific access permissions and time restrictions. ### Parameters #### Request Body - **jobType** (number) - Required - Must be 4. - **jobData** (object) - Required. - **accessName** (string) - Required - Display name for the PIN code. - **pin** (string) - Required - 4-6 digit PIN code. - **pinType** (number) - Required - PIN type (1: One-Time, 2: Permanent, 4: Duration). - **startDate** (string) - Required - When PIN becomes active (ISO_DATE format). - **endDate** (string) - Optional - When PIN expires (ISO_DATE format). ### Request Example ```json { "jobType": 4, "jobData": { "accessName": "Guest PIN", "pin": "123456", "pinType": 4, "startDate": "2024-01-01T12:00:00+00:00", "endDate": "2024-01-01T16:00:00+00:00" } } ``` ### Usage Examples #### One-Time PIN (24-hour validity) ```json { "jobType": 4, "jobData": { "accessName": "OTP PIN", "pin": "123456", "pinType": 1, "startDate": "2024-01-01T00:00:00+00:00" } } ``` ```