E-Key Management

Last Updated on : 2024-03-21 04:25:25download

This topic describes how to manage an e-key. For more information, see Commercial Lock App SDK Overview.

Get the list of e-keys

API description

+ (void)getEKeyListWithSiteId:(long long)siteId
                     deviceId:(NSString *)deviceId
                       pageNo:(NSInteger)pageNo
                     pageSize:(NSInteger)pageSize
                      success:(ThingLockEKeySuccessList)success
                      failure:(ThingFailureError)failure;

Parameter description

Parameter Description
siteId The site ID.
deviceId The device ID.
pageNo The page number, starting with 1.
pageSize The number of items returned per page.
success The success callback.
failure The failure callback.

Example

    [ThingLockDevice getEKeyListWithSiteId:siteId
                                  deviceId:self.devId
                                    pageNo:1
                                  pageSize:20
                                   success:^(NSArray<ThingEKeyModel *> * _Nullable list, NSInteger totalPage) {

    } failure:^(NSError *error) {

    }];

Create a permanent e-key

API description

+ (void)createPermanentEKeyWithSiteId:(long long)siteId
                             deviceId:(NSString *)deviceId
                              account:(NSString *)account
                             eKeyName:(NSString *)ekeyName
                              success:(ThingSuccessID)success
                              failure:(ThingFailureError)failure;

Parameter description

Parameter Description
siteId The site ID.
deviceId The device ID.
account The authorized e-key account.
ekeyName The name of the e-key.
success The success callback.
failure The failure callback.

Example

    [ThingLockDevice createPermanentEKeyWithSiteId:SiteManager.shared.siteId
                                      deviceId:self.devId
                                       account:self.accountLabel.text
                                      eKeyName:self.eKeyNameLabel.text
                                       success:^(id result) {

    } failure:^(NSError *error) {

    }];

Create a time-limited e-key

API description

+ (void)createLimitEKeyWithSiteId:(long long)siteId
                         deviceId:(NSString *)deviceId
                          account:(NSString *)account
                         eKeyName:(NSString *)ekeyName
            effectiveTimeInterval:(NSTimeInterval)effectiveTimeInterval
              invalidTimeInterval:(NSTimeInterval)invalidTimeInterval
                       workingDay:(NSString *)workingDay
                        startTime:(NSString *)startTime
                          endTime:(NSString *)endTime
                          success:(ThingSuccessID)success
                          failure:(ThingFailureError)failure;

Parameter description

Parameter Description
siteId The site ID.
deviceId The device ID.
account The authorized e-key account.
ekeyName The name of the e-key.
effectiveTimeInterval The time when the e-key becomes active, in seconds. It is timestamped at the top of the hour. For example, for 15:32, pass 15:00.
invalidTimeInterval The time when the e-key expires, in seconds. It is timestamped at the top of the hour. For example, for 18:24, pass 18:00.
workingDay The schedule, for example, 1011111. From Sunday to Saturday, 0 indicates the schedule is off, while 1 indicates it is on.
startTime The start time, for example, 07:00.
endTime The end time, for example, 19:00.
success The success callback.
failure The failure callback.

Example

    [ThingLockDevice createLimitEKeyWithSiteId:SiteManager.shared.siteId
                                      deviceId:self.devId
                                       account:self.accountLabel.text
                                      eKeyName:self.eKeyNameLabel.text
                         effectiveTimeInterval:effectiveTime
                           invalidTimeInterval:invalidTime
                                    workingDay:@"1000101"
                                     startTime:@"7:00"
                                       endTime:@"19:00"
                                       success:^(id result) {

    } failure:^(NSError *error) {

    }];

Create a one-time e-key

API description

+ (void)createOnceEKeyWithSiteId:(long long)siteId
                        deviceId:(NSString *)deviceId
                         account:(NSString *)account
                        eKeyName:(NSString *)ekeyName
           effectiveTimeInterval:(NSTimeInterval)effectiveTimeInterval
             invalidTimeInterval:(NSTimeInterval)invalidTimeInterval
                         success:(ThingSuccessID)success
                         failure:(ThingFailureError)failure;

Parameter description

Parameter Description
siteId The site ID.
deviceId The device ID.
account The authorized e-key account.
ekeyName The name of the e-key.
effectiveTimeInterval The time when the e-key becomes active, in seconds. It is timestamped at the top of the hour. For example, for 15:32, pass 15:00.
invalidTimeInterval The time when the e-key expires, in seconds. It is timestamped at the top of the hour. For example, for 18:24, pass 18:00.
success The success callback.
failure The failure callback.

Example

    [ThingLockDevice createOnceEKeyWithSiteId:SiteManager.shared.siteId
                                      deviceId:self.devId
                                       account:self.accountLabel.text
                                      eKeyName:self.eKeyNameLabel.text
                         effectiveTimeInterval:effectiveTime
                           invalidTimeInterval:invalidTime
                                       success:^(id result) {

    } failure:^(NSError *error) {

    }];

Get e-key details

API description

+ (void)getEKeyDetailWithSiteId:(long long)siteId
                       deviceId:(NSString *)deviceId
                         eKeyId:(NSString *)eKeyId
                        success:(ThingLockEKeySuccess)success
                        failure:(ThingFailureError)failure;

Parameter description

Parameter Description
siteId The site ID.
deviceId The device ID.
eKeyId The ID of the e-key.
success The success callback.
failure The failure callback.

Example

    [ThingLockDevice getEKeyDetailWithSiteId:siteId
                                    deviceId:self.devId
                                      eKeyId:self.eKeyId
                                     success:^(ThingEKeyModel * _Nullable eKeyModel) {

    } failure:^(NSError *error) {

    }];

Modify a time-limited e-key

API description

+ (void)updateLimitEKeyWithSiteId:(long long)siteId
                         deviceId:(NSString *)deviceId
                           eKeyId:(NSString *)eKeyId
                         eKeyName:(NSString *)ekeyName
            effectiveTimeInterval:(NSTimeInterval)effectiveTimeInterval
              invalidTimeInterval:(NSTimeInterval)invalidTimeInterval
                       workingDay:(NSString *)workingDay
                        startTime:(NSString *)startTime
                          endTime:(NSString *)endTime
                          success:(ThingSuccessID)success
                          failure:(ThingFailureError)failure;

Parameter description

Parameter Description
siteId The site ID.
deviceId The device ID.
eKeyId The ID of the e-key.
eKeyName The name of the e-key.
effectiveTimeInterval The time when the e-key becomes active, in seconds. It is timestamped at the top of the hour. For example, for 15:32, pass 15:00.
invalidTimeInterval The time when the e-key expires, in seconds. It is timestamped at the top of the hour. For example, for 18:24, pass 18:00.
workingDay The schedule, for example, 1011111. From Sunday to Saturday, 0 indicates the schedule is off, while 1 indicates it is on.
startTime The start time, for example, 07:00.
endTime The end time, for example, 19:00.
success The success callback.
failure The failure callback.

Example

    [ThingLockDevice updateLimitEKeyWithSiteId:siteId
                                      deviceId:self.devId
                                        eKeyId:self.eKeyModel.eKeyId
                                      eKeyName:self.nameLabel.text
                         effectiveTimeInterval:effectiveTime
                           invalidTimeInterval:invalidTime
                                    workingDay:workingDay
                                     startTime:startMinute
                                       endTime:endMinute
                                       success:^(id _Nullable result) {

    } failure:^(NSError *error) {

    }];

Modify a permanent e-key

API description

+ (void)updatePermanentEKeyWithSiteId:(long long)siteId
                             deviceId:(NSString *)deviceId
                               eKeyId:(NSString *)eKeyId
                             eKeyName:(NSString *)ekeyName
                              success:(ThingSuccessID)success
                              failure:(ThingFailureError)failure;

Parameter description

Parameter Description
siteId The site ID.
deviceId The device ID.
eKeyId The ID of the e-key.
eKeyName The name of the e-key.
success The success callback.
failure The failure callback.

Example

    [ThingLockDevice updatePermanentEKeyWithSiteId:siteId
                                          deviceId:self.devId
                                            eKeyId:self.eKeyModel.eKeyId
                                          eKeyName:self.nameLabel.text
                                           success:^(id _Nullable result) {

    } failure:^(NSError *error) {

    }];

Modify a one-time e-key

API description

+ (void)updateOnceEKeyWithSiteId:(long long)siteId
                        deviceId:(NSString *)deviceId
                          eKeyId:(NSString *)eKeyId
                        eKeyName:(NSString *)ekeyName
           effectiveTimeInterval:(NSTimeInterval)effectiveTimeInterval
             invalidTimeInterval:(NSTimeInterval)invalidTimeInterval
                         success:(ThingSuccessID)success
                         failure:(ThingFailureError)failure;

Parameter description

Parameter Description
siteId The site ID.
deviceId The device ID.
eKeyId The ID of the e-key.
eKeyName The name of the e-key.
effectiveTimeInterval The time when the e-key becomes active, in seconds. It is timestamped at the top of the hour. For example, for 15:32, pass 15:00.
invalidTimeInterval The time when the e-key expires, in seconds. It is timestamped at the top of the hour. For example, for 18:24, pass 18:00.
success The success callback.
failure The failure callback.

Example

    [ThingLockDevice updateOnceEKeyWithSiteId:siteId
                                     deviceId:self.devId
                                       eKeyId:self.eKeyModel.eKeyId
                                     eKeyName:self.nameLabel.text
                        effectiveTimeInterval:effectiveTime
                          invalidTimeInterval:invalidTime
                                      success:^(id _Nullable result) {

    } failure:^(NSError *error) {

    }];

Delete an e-key

API description

+ (void)removeEKeyWithSiteId:(long long)siteId
                    deviceId:(NSString *)deviceId
                      eKeyId:(NSString *)eKeyId
                     success:(ThingSuccessID)success
                     failure:(ThingFailureError)failure;

Parameter description

Parameter Description
siteId The site ID.
deviceId The device ID.
eKeyId The e-key.
success The success callback.
failure The failure callback.

Example

    [ThingLockDevice removeEKeyWithSiteId:siteId
                                 deviceId:self.devId
                                   eKeyId:self.eKeyId
                                  success:^(id _Nullable result) {

    } failure:^(NSError *error) {

    }];