Account
Contains all Requests regarding user/account and authentication
Table of Contents
-
Methods
- authenticate(data)
- changePassword(datatoken)
- deleteAccount(data)
- exportData(data)
- getAccount()
- getRegisterFields(merchantUuid)
- getSocialLoginUrls(state)
- getToken()
- isAuthenticated()
- loadMerchantRestrictionSettings(merchantUuid)
- refreshToken(clientId)
- requestNewPassword(data)
- sendPinCode(brandingId)
- setNewPassword(datatoken)
- setToken(tokenrefreshTokenexpiresAt)
- signOut()
- signUp(data)
- updateAccount(data)
- validatePinCode(pinCode)
Methods
authenticate
-
data
Signs in the user
Parameters:
-
data
Object- Contains { email: string, password: string, clientId: string, clientSecret: string, referrer: string, refreshToken: string, }
Returns:
Example:
InPlayer.Account.authenticate({
email: 'test@test.com',
password: 'test123',
clientId: '123-123-hf1hd1-12dhd1',
referrer: 'http://localhost:3000/',
refreshToken: '528b1b80-ddd1hj-4abc-gha3j-111111'
})
.then(data => console.log(data));
changePassword
-
data
-
token
Changes password for a given user
Parameters:
-
data
Object- Contains { oldPassword: string password: string passwordConfirmation: string brandingId?: number }
-
token
String- The reset token
Returns:
Example:
InPlayer.Account
.changePassword({
oldPassword: 'old123',
password: 'test123',
passwordConfirmation: 'test123'
brandingId: 1234
},'123124-1r-1r13ur1h1')
.then(data => console.log(data));
deleteAccount
-
data
Deletes an account
Parameters:
-
data
Object- Contains { password: string, brandingId?: number, }
Returns:
Example:
InPlayer.Account.deleteAccount({
password: "password",
brandingId: 1234,
})
.then(data => console.log(data));
exportData
-
data
Exports account data to the users' email
Parameters:
-
data
Object- Contains { password: string, brandingId?: number, }
Returns:
Example:
InPlayer.Account.exportData({
password: "password",
brandingId: 1234,
})
.then(data => console.log(data));
getAccount
()
Object
Gets the account information for a given auth token
Returns:
Example:
InPlayer.Account
.getAccount()
.then(data => console.log(data));
getRegisterFields
-
merchantUuid
Gets register fields
Parameters:
-
merchantUuid
String- The merchant UUID
Returns:
Example:
InPlayer.Account
.getRegisterFields('123124-1r-1r13ur1h1')
.then(data => console.log(data));
getSocialLoginUrls
-
state
Gets the social login urls for fb/twitter/google
Parameters:
-
state
String- Social login state. The state needs to be json and base64 encoded to be sent as a query parameter. Example: btoa(JSON.stringify({uuid: 'foo', redirect: 'http://example.com'}))
Returns:
Example:
InPlayer.Account
.getSocialLoginUrls('123124-1r-1r13ur1h1')
.then(data => console.log(data));
getToken
()
Credentials
Returns:
Example:
InPlayer.Account.getToken()
isAuthenticated
()
Boolean
Checks if the user is authenticated
Returns:
Example:
InPlayer.Account.isAuthenticated()
loadMerchantRestrictionSettings
-
merchantUuid
Return restriction settings per Merchant
Parameters:
-
merchantUuid
String- The merchant UUID
Returns:
Contains the data - { "age_verification_type": "pin_code", "age_verification_enabled": true, "merchant_uuid": "3b39b5ab-b5fc-4ba3-b770-73155d20e61f", "created_at": 1532425425, "updated_at": 1532425425 }
Example:
InPlayer.Account
.loadMerchantRestrictionSettings("528b1b80-5868-4abc-a9b6-4d3455d719c8")
.then(data => console.log(data));
refreshToken
-
clientId
Refreshes the token
Parameters:
-
clientId
Object- The merchant's clientId
Returns:
Example:
InPlayer.Account.refreshToken('123123121-d1-t1-1ff').then(data => console.log(data))
requestNewPassword
-
data
Requests new password for a given user
Parameters:
-
data
Object- Contains { email: string, merchantUuid: string brandingId?: number }
Returns:
Example:
InPlayer.Account
.requestNewPassword({
email: "test32@test.com",
merchantUuid: "528b1b80-5868-4abc-a9b6-4d3455d719c8",
brandingId: 12345,
})
.then(data => console.log(data));
sendPinCode
-
brandingId
Creates pin code and sends it to the users' email
Parameters:
-
brandingId
Number- Optional parametar
Returns:
Example:
InPlayer.Account.sendPinCode(1234)
.then(data => console.log(data));
setNewPassword
-
data
-
token
Sets new password for the user
Parameters:
-
data
Object- Contains { password: string passwordConfirmation: string brandingId?: number }
-
token
String- The reset token
Returns:
Example:
InPlayer.Account
.setNewPassword({
password: "password",
passwordConfirmation: "password",
brandingId: "12345",
}, 'afhqi83rji74hjf7e43df')
.then(data => console.log(data));
setToken
-
token
-
refreshToken
-
expiresAt
Parameters:
-
token
String -
refreshToken
String -
expiresAt
Number
Example:
InPlayer.Account.setToken('344244-242242', '123123121-d1-t1-1ff',1558529593297)
signOut
()
Object
Signs out the user and destroys cookies
Returns:
Example:
InPlayer.Account.signOut()
.then(data => console.log(data));
signUp
-
data
Signs up/Registers user
Parameters:
-
data
Object- Contains { fullName: string, email: string password: string, passwordConfirmation: string, clientId: string, type: string, referrer: string, brandingId?: number, metadata?: { [key: string]: string } }
Returns:
Example:
InPlayer.Account.signUp({
fullName: "test",
email: "test32@test.com",
password: "12345678",
passwordConfirmation: "12345678",
clientId: "528b1b80-5868-4abc-a9b6-4d3455d719c8",
type: "consumer",
referrer: "http://localhost:3000/",
brandingId?: 12345,
metadata : { country: "Macedonia" },
})
.then(data => console.log(data));
updateAccount
-
data
Updates the account info. Metadata fields must be from the Inplayer.getRegisterFields()
Parameters:
-
data
Object- The new data for the account
Returns:
Example:
InPlayer.Account
.updateAccount({fullName: 'test test', metadata: {country: 'Germany'}, dateOfBirth: '1999-03-05'})
.then(data => console.log(data));
validatePinCode
-
pinCode
Checks validity of pin code
Parameters:
-
pinCode
String- Code from received email message
Returns:
Example:
InPlayer.Account.validatePinCode('5566')
.then(data => console.log(data));