Device token api endpoint (#1)
* Added /device/token handler with associated business logic and storage tests. * Use crypto rand for user code Signed-off-by: justin-slowik <justin.slowik@thermofisher.com>
This commit is contained in:
committed by
justin-slowik
parent
6d343e059b
commit
0d1a0e4129
@@ -641,3 +641,11 @@ func (cli *client) CreateDeviceRequest(d storage.DeviceRequest) error {
|
||||
func (cli *client) CreateDeviceToken(t storage.DeviceToken) error {
|
||||
return cli.post(resourceDeviceToken, cli.fromStorageDeviceToken(t))
|
||||
}
|
||||
|
||||
func (cli *client) GetDeviceToken(deviceCode string) (storage.DeviceToken, error) {
|
||||
var token DeviceToken
|
||||
if err := cli.get(resourceDeviceToken, deviceCode, &token); err != nil {
|
||||
return storage.DeviceToken{}, err
|
||||
}
|
||||
return toStorageDeviceToken(token), nil
|
||||
}
|
||||
|
@@ -739,3 +739,12 @@ func (cli *client) fromStorageDeviceToken(t storage.DeviceToken) DeviceToken {
|
||||
}
|
||||
return req
|
||||
}
|
||||
|
||||
func toStorageDeviceToken(t DeviceToken) storage.DeviceToken {
|
||||
return storage.DeviceToken{
|
||||
DeviceCode: t.ObjectMeta.Name,
|
||||
Status: t.Status,
|
||||
Token: t.Token,
|
||||
Expiry: t.Expiry,
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user