diff --git a/README.md b/README.md index 03af940..1f31839 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,15 @@ $ttlock->lock->getKeyboardPwdVersion($lockId,$date); $ttlock->lock->updateElectricQuantity($lockId,$electricQuantity,$date); $ttlock->lock->transfer($receiverUsername,$lockIdList,$date); + +// Passcode +$ttlock->passcode->get( int $lockId, int $keyboardPwdVersion, int $keyboardPwdType, int $startDate, int $endDate, int $date ) : array +$ttlock->passcode->delete( int $lockId, int $keyboardPwdId, int $deleteType, int $date ):array +$ttlock->passcode->change( int $lockId, int $keyboardPwdId, string $newKeyboardPwd, int $startDate, int $endDate, int $changeType, int $date ) +$ttlock->passcode->add( int $lockId, string $keyboardPwd, int $startDate, int $endDate, int $addType, int $date ) + + + // 其他接口本次开发没用上 后续有需要再完善 diff --git a/src/Passcode.php b/src/Passcode.php index c12e54d..31e1cb0 100644 --- a/src/Passcode.php +++ b/src/Passcode.php @@ -68,7 +68,7 @@ public function get( int $lockId, int $keyboardPwdVersion, int $keyboardPwdType, * @throws \GuzzleHttp\Exception\GuzzleException | \Exception * @author 韩文博 */ - public function delete( int $lockId, int $keyboardPwdId, int $deleteType, int $date ) + public function delete( int $lockId, int $keyboardPwdId, int $deleteType, int $date ):array { $response = $this->client->request( 'POST', '/v3/keyboardPwd/get', [ 'form_params' => [ @@ -100,7 +100,7 @@ public function delete( int $lockId, int $keyboardPwdId, int $deleteType, int $d * @throws \GuzzleHttp\Exception\GuzzleException | \Exception * @author 韩文博 */ - public function change( int $lockId, int $keyboardPwdId, string $newKeyboardPwd, int $startDate, int $endDate, int $changeType, int $date ) + public function change( int $lockId, int $keyboardPwdId, string $newKeyboardPwd, int $startDate, int $endDate, int $changeType, int $date ) : array { $response = $this->client->request( 'POST', '/v3/keyboardPwd/get', [ 'form_params' => [ @@ -135,7 +135,7 @@ public function change( int $lockId, int $keyboardPwdId, string $newKeyboardPwd, * @throws \GuzzleHttp\Exception\GuzzleException | \Exception * @author 韩文博 */ - public function add( int $lockId, string $keyboardPwd, int $startDate, int $endDate, int $addType, int $date ) + public function add( int $lockId, string $keyboardPwd, int $startDate, int $endDate, int $addType, int $date ) : array { $response = $this->client->request( 'POST', '/v3/keyboardPwd/get', [ 'form_params' => [ diff --git a/src/TTLock.php b/src/TTLock.php index 7e79d6e..80845ad 100644 --- a/src/TTLock.php +++ b/src/TTLock.php @@ -48,10 +48,11 @@ public function __construct( string $clientId, string $clientSecret ) protected $container = []; protected $providers = [ - "user" => User::class, - "lock" => Lock::class, - "oauth2" => Oauth2::class, - "key" => Key::class, + "user" => User::class, + "lock" => Lock::class, + "oauth2" => Oauth2::class, + "key" => Key::class, + "passcode" => Passcode::class, ]; /** @@ -75,18 +76,19 @@ public function __get( $name ) return $this->container["{$name}"]; } } + /** * 根据日期时间返回毫秒时间戳 - * @param string$dateTime + * @param string $dateTime * @return int * @author 韩文博 */ - static function getDateTimeMillisecond(string $dateTime) : int + static function getDateTimeMillisecond( string $dateTime ) : int { - $dateTime = $dateTime .".0"; - list($usec, $sec) = explode(".", $dateTime); - $date = strtotime($usec); - $return_data = str_pad($date.$sec,13,"0",STR_PAD_RIGHT); //不足13位。右边补0 + $dateTime = $dateTime.".0"; + list( $usec, $sec ) = explode( ".", $dateTime ); + $date = strtotime( $usec ); + $return_data = str_pad( $date.$sec, 13, "0", STR_PAD_RIGHT ); //不足13位。右边补0 return (int)$return_data; } } \ No newline at end of file