registerAVSDevice method
Registers an Alexa-enabled device built by an Original Equipment Manufacturer (OEM) using Alexa Voice Service (AVS).
May throw LimitExceededException. May throw ConcurrentModificationException. May throw NotFoundException. May throw InvalidDeviceException.
Parameter amazonId
:
The device type ID for your AVS device generated by Amazon when the OEM
creates a new product on Amazon's Developer Console.
Parameter clientId
:
The client ID of the OEM used for code-based linking authorization on an
AVS device.
Parameter productId
:
The product ID used to identify your AVS device during authorization.
Parameter userCode
:
The code that is obtained after your AVS device has made a POST request to
LWA as a part of the Device Authorization Request component of the OAuth
code-based linking specification.
Parameter deviceSerialNumber
:
The key generated by the OEM that uniquely identifies a specified instance
of your AVS device.
Parameter roomArn
:
The ARN of the room with which to associate your AVS device.
Implementation
Future<RegisterAVSDeviceResponse> registerAVSDevice({
required String amazonId,
required String clientId,
required String productId,
required String userCode,
String? deviceSerialNumber,
String? roomArn,
}) async {
ArgumentError.checkNotNull(amazonId, 'amazonId');
ArgumentError.checkNotNull(clientId, 'clientId');
ArgumentError.checkNotNull(productId, 'productId');
ArgumentError.checkNotNull(userCode, 'userCode');
_s.validateStringLength(
'userCode',
userCode,
1,
128,
isRequired: true,
);
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'AlexaForBusiness.RegisterAVSDevice'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'AmazonId': amazonId,
'ClientId': clientId,
'ProductId': productId,
'UserCode': userCode,
if (deviceSerialNumber != null)
'DeviceSerialNumber': deviceSerialNumber,
if (roomArn != null) 'RoomArn': roomArn,
},
);
return RegisterAVSDeviceResponse.fromJson(jsonResponse.body);
}