Skip to content

Instantly share code, notes, and snippets.

@iremlopsum
Created August 20, 2019 14:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iremlopsum/49d2dc758b9db49ee2be2316028c3bd3 to your computer and use it in GitHub Desktop.
Save iremlopsum/49d2dc758b9db49ee2be2316028c3bd3 to your computer and use it in GitHub Desktop.
interface SetupCallback {
/**
* @param { "0" | "1" | "2" } statusCode - Decides if registration through the native module was successful
* `"0"` - Registration was successful
* `"1"` - User canceled
* `"2"` - Registration failed
*
* @param { JSON } response - Response from the Amazon call that happens in the native module. Should include the following info:
* `authorizationCode`,
* `clientId`,
* `redirectURI`
*
* @param { string } verificationCode - code verifier that is generated by the LWA. Is used as a private key in the back end to access Amazon API
*/
(statusCode: "0" | "1" | "2", response: JSON, verificationCode: string): void
}
class DRS {
/**
* @description Uses native LWA module to open either Amazon app or website
* Through which DRS registration happens. DRS registration values are returned through
* the `callback`
*
* @param { SetupCallback } callback - Used to return data from the native module
* @callback callback
*/
startDRSSetup = async (callback: SetupCallback): Promise<void> => {
const deviceInfo = await comLayer.getDeviceConfiguration()
NativeModules.LWASharedModule.loginWithDeviceModel(
'Penguin',
deviceInfo.device_identifier,
true,
true,
callback,
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment