Card Management

Last Updated on : 2024-06-18 06:56:30download

Get the list of enrolled cards

API description

- (void)getCardListWithSiteId:(long long)siteId
                     deviceId:(NSString *)deviceId
                       pageNo:(NSInteger)pageNumber
                     pageSize:(NSInteger)pageSize
                      success:(ThingLockCardSuccessList)success
                      failure:(ThingFailureError)failure;

Parameters

Parameter Description
siteId The site ID.
deviceId The device ID of the lock.
pageNo The page number.
pageSize The number of items returned per page.
success The success callback.
failure The failure callback.

Example

[ThingLockCardManager.shared getCardListWithSiteId:siteId
                                          deviceId:self.devId
                                            pageNo:self.pageNo
                                          pageSize:20
                                           success:^(NSArray<ThingLockCardModel *> * _Nullable list, NSInteger totalPage) {

} failure:^(NSError *error) {

}];

Get card details

API description

- (void)getCardDetailWithSiteId:(long long)siteId
                       deviceId:(NSString *)deviceId
                         cardId:(NSString *)cardId
                        success:(ThingLockCardSuccess)success
                        failure:(ThingFailureError)failure;

Parameters

Parameter Description
siteId The site ID.
deviceId The device ID of the lock.
cardId The card ID.
success The success callback.
failure The failure callback.

Example

[ThingLockCardManager.shared getCardDetailWithSiteId:siteId
                                deviceId:self.devId
                                  cardId:self.cardId
                               success:^(ThingLockCardModel * _Nullable model) {


} failure:^(NSError *error) {

}];

Add a time-limited card

API description

- (void)createLimitCardWithSiteId:(long long)siteId
                         deviceId:(NSString *)deviceId
                         cardName:(NSString *)cardName
            effectiveTimeInterval:(NSTimeInterval)effectiveTimeInterval
              invalidTimeInterval:(NSTimeInterval)invalidTimeInterval
                          success:(ThingSuccessHandler)success
                          failure:(ThingFailureError)failure;

Parameters

Parameter Description
siteId The site ID.
lockDevId The device ID of the lock.
cardName The name of the card.
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

[ThingLockCardManager.shared createLimitCardWithSiteId:SiteManager.shared.siteId
                                         deviceId:self.devId
                                         cardName:self.nameLabel.text
                            effectiveTimeInterval:effectiveTime
                              invalidTimeInterval:invalidTime
                                          success:^{

} failure:^(NSError *error) {

}];

Add a permanent card

API description

- (void)createPermanentCardWithSiteId:(long long)siteId
                             deviceId:(NSString *)deviceId
                             cardName:(NSString *)cardName
                              success:(ThingSuccessHandler)success
                              failure:(ThingFailureError)failure;

Parameters

Parameter Description
siteId The site ID.
deviceId The device ID of the lock.
cardName The name of the card.
success The success callback.
failure The failure callback.

Example

[ThingLockCardManager.shared createPermanentCardWithSiteId:SiteManager.shared.siteId
                                         deviceId:self.devId
                                         cardName:self.nameLabel.text
                                          success:^{

} failure:^(NSError *error) {

}];

Rename a card

API description

- (void)updateNameWithSiteId:(long long)siteId
                    deviceId:(NSString *)deviceId
                      cardId:(NSString *)cardId
                    cardName:(NSString *)cardName
                     success:(ThingSuccessHandler)success
                     failure:(ThingFailureError)failure;

Parameters

Parameter Description
siteId The site ID.
deviceId The device ID of the lock.
cardId The card ID.
cardName The name of the card.
success The success callback.
failure The failure callback.

Example

[ThingLockCardManager.shared updateNameWithSiteId:siteId
                                             deviceId:self.devId
                                               cardId:self.cardId
                                             cardName:name
                                              success:^{

} failure:^(NSError *error) {

}];

Delete a card

API description

- (void)removeCardWithSiteId:(long long)siteId
                    deviceId:(NSString *)deviceId
                      cardId:(NSString *)cardId
                      lockId:(NSString *)lockId
                     success:(ThingSuccessHandler)success
                     failure:(ThingFailureError)failure;

Parameters

Parameter Description
siteId The site ID.
deviceId The device ID of the lock.
cardId The card ID.
lockId The lockId of the card, corresponding to the lockId field in the card details.
success The success callback.
failure The failure callback.

Example

[ThingLockCardManager.shared removeCardWithSiteId:siteId
                                         deviceId:self.devId
                                           cardId:self.cardId
                                           lockId:self.cardModel.lockId
                                          success:^{

} failure:^(NSError *error) {

}];

Empty cards

API description

- (void)clearAllCardWithSiteId:(long long)siteId
                       deviceId:(NSString *)deviceId
                        success:(ThingSuccessHandler)success
                        failure:(ThingFailureError)failure;

Parameters

Parameter Description
siteId The site ID.
deviceId The device ID of the lock.
success The success callback.
failure The failure callback.

Example

[ThingLockCardManager.shared clearAllCardWithSiteId:siteId
                                           deviceId:self.devId
                                            success:^{

} failure:^(NSError *error) {
}];

Emptying cards will delete all enrolled cards.