0.2.6 • Published 8 years ago

onewallet-client-node v0.2.6

Weekly downloads
2
License
ISC
Repository
github
Last release
8 years ago

One Wallet Client (NodeJS)

The One Wallet Client will be used for making requests into the One Wallet Service API.

Getting Started

/* Example usage */
import OneWalletServiceAPI from 'onewallet-client-node';

/* Use the constructor to setup */
let client = new OneWalletServiceAPI( {
    accessId: 'SAMPLE_PROVIDER',
    secretKey: 'X6VYZBFRS8qrqhwg28eQbyEcZmTSrE9G'
} );

The accessId and the secretKey will be provided by the operator.

One Wallet Client API

constructor ( )

The OneWalletServiceAPI constructor accepts an object with the following properties:

FieldRequiredTypeDescriptionDefault
baseUrlfalseStringOne wallet service base urlhttps://api.as2bet.com
accessIdtrueStringService access id
secretKeytrueStringService secret key
backoffInitialDelayfalseNumberDelay for request retry50
timeoutfalseNumberrequest timeout3000

Input (Options)

{
    baseUrl: 'https://api.as2bet.com',
    accessId: 'SAMPLE_PROVIDER',
    secretKey: 'X6VYZBFRS8qrqhwg28eQbyEcZmTSrE9G',
    backoffInitialDelay: 50,
    timeout: 3000
}

authenticateUser ( )

This method will check the user's credentials and returns the user's information.

Input

{
    username: 'test_user1',
    password: 'pass'
}
FieldRequiredTypeDescriptionDefault
usernametrueStringUser's username
passwordtrueStringUser's password

Return Value

{
    userId: '56',
    balance: 250000.0000,
    nickname: 'zenoan',
    birthday: '1991-01-21',
    currency: 'USD',
    firstName: 'Elon',
    lastName: 'Musk',
    email: 'elonmusk@spacex.com'
}

createGameSession ( )

This method creates a player game session. This method accepts a userId as input and returns a sessionId.

Input

{
    userId: '56'
}
FieldRequiredTypeDescriptionDefault
userIdtrueStringUser's id

Return Value

{
    sessionId: '0ee89b10-e987-11e5-8b12-e5f8552670cc'
}

getUserInfo ( )

This API retrieves the player's information give it's id and the fields you want to retrieve.

Input

{
    userId: '56',
    fields: [ 'balance', 'currency', 'username', 'nickname', 'firstName', 'lastName', 'birthday', 'email' ]
}
FieldRequiredTypeDescriptionDefault
userIdtrueStringUser's id
fieldstrueArrayFields to be retrieved 'balance', 'currency', 'username', 'nickname', 'firstName', 'lastName', 'birthday', 'email'

Return Value

{
    balance: 250000.0000,
    nickname: 'zenoan',
    birthday: '1991-01-21',
    currency: 'USD',
    firstName: 'Elon',
    lastName: 'Musk',
    email: 'elonmusk@spacex.com'
}

Transfer Transactions

debit ( )

This method creates a DEBIT transaction for a specified game type.

Input

{
    userId: '56',
    sessionId: '0ee89b10-e987-11e5-8b12-e5f8552670cc',
    roundId: '43524335',
    amount: 58,
    gameType: 'Six Card Chinese',
    ...
}
FieldRequiredTypeDescriptionDefault
userIdtrueStringUser's id
sessionIdtrueStringGame session ID. Generate using the createGameSession ( ) API
roundIdtrueStringRound Id
amounttrueNumberDebit transaction amount
gameTypetrueStringGame type
...falseProvider specific key-value inputs (you can add it here).

Return Value

{
    balance: 249942.0000
    currency: 'USD'
}

credit ( )

This method creates a CREDIT transaction for a specified game type.

Input

{
    userId: '56',
    sessionId: '0ee89b10-e987-11e5-8b12-e5f8552670cc',
    roundId: '43524335',
    amount: 58,
    gameType: 'Six Card Chinese',
    ...
}
FieldRequiredTypeDescriptionDefault
userIdtrueStringUser's id
sessionIdtrueStringGame session ID. Generate using the createGameSession ( ) API
roundIdtrueStringRound Id
amounttrueNumberDebit transaction amount
gameTypetrueStringGame type
...falseProvider specific key-value inputs (you can add it here).

Return Value

{
    balance: 249942
    currency: 'USD'
}

cancelDebit ( )

This method will cancel a DEBIT transaction with the specified transactionId.

Input

{
    userId: '56',
    sessionId: '0ee89b10-e987-11e5-8b12-e5f8552670cc',
    debitTransactionId: 'c5c6ae90-e986-11e5-8b12-e5f8552670cc',
    gameType: 'Six Card Chinese',
    ...
}
FieldRequiredTypeDescriptionDefault
userIdtrueStringUser's id
sessionIdtrueStringGame session ID. Generate using the createGameSession ( ) API
debitTransactionIdtrueStringDebit transaction ID UUID.
gameTypetrueStringGame type
...falseProvider specific key-value inputs (you can add it here).

Result Value

{
    balance: 249942
    currency: 'USD'
}