Skip to content

Commit

Permalink
Merge 7ffdb19 into 56567cc
Browse files Browse the repository at this point in the history
  • Loading branch information
jkurra-hw committed Sep 24, 2020
2 parents 56567cc + 7ffdb19 commit 8bb294e
Show file tree
Hide file tree
Showing 2 changed files with 570 additions and 0 deletions.
170 changes: 170 additions & 0 deletions src/Hyperwallet.js
Expand Up @@ -1455,4 +1455,174 @@ export default class Hyperwallet {
callback(err, data, res);
};
}

//--------------------------------------
// Venmo Accounts
//--------------------------------------

/**
* Create a Venmo account
*
* @param {string} userToken - The user token
* @param {Object} data - The Venmo account data
* @param {api-callback} callback - The callback for this call
*
* @throws Will throw an error if userToken is not provided
*/
createVenmoAccount(userToken, data, callback) {
if (!userToken) {
throw new Error("userToken is required");
}
if (!data.transferMethodCountry) {
throw new Error("transferMethodCountry is required");
}
if (!data.transferMethodCurrency) {
throw new Error("transferMethodCurrency is required");
}
if (!data.accountId) {
throw new Error("Account is required");
}
this.client.doPost(`users/${encodeURIComponent(userToken)}/venmo-accounts`, data, {}, callback);
}
/**
* Get a Venmo account
*
* @param {string} userToken - The user token
* @param {string} venmoAccountToken - The venmo account token
* @param {api-callback} callback - The callback for this call
*
* @throws Will throw an error if userToken or venmoAccountToken is not provided
*/
getVenmoAccount(userToken, venmoAccountToken, callback) {
if (!userToken) {
throw new Error("userToken is required");
}
if (!venmoAccountToken) {
throw new Error("venmoAccountToken is required");
}
this.client.doGet(`users/${encodeURIComponent(userToken)}/venmo-accounts/${encodeURIComponent(venmoAccountToken)}`, {}, callback);
}

/**
* List all Venmo accounts
*
* @param {string} userToken - The user token
* @param {Object} options - The query parameters to send
* @param {api-callback} callback - The callback for this call
* @throws Will throw an error if userToken is not provided
*/
listVenmoAccounts(userToken, options, callback) {
if (!userToken) {
throw new Error("userToken is required");
}
this.client.doGet(`users/${encodeURIComponent(userToken)}/venmo-accounts`, options, Hyperwallet.handle204Response(callback));
}

/**
* Update a venmo account
*
* @param {string} userToken - The user token
* @param {string} venmoAccountToken - The bank account token
* @param {Object} data - The venmo account data to update
* @param {api-callback} callback - The callback for this call
*
* @throws Will throw an error if userToken or venmoAccountToken is not provided
*/
updateVenmoAccount(userToken, venmoAccountToken, data, callback) {
if (!userToken) {
throw new Error("userToken is required");
}
if (!venmoAccountToken) {
throw new Error("venmoAccountToken is required");
}
this.client.doPut(`users/${encodeURIComponent(userToken)}/venmo-accounts/${encodeURIComponent(venmoAccountToken)}`, data, {}, callback);
}

/**
* Deactivate a venmo account
*
* @param {string} userToken - user token
* @param {string} venmoAccountToken - Venmo account token
* @param {api-callback} callback - callback for this call
*
* @throws Will throw an error if userToken or venmoAccountToken is not provided
*/

deactivateVenmoAccount(userToken, venmoAccountToken, callback) {
if (!userToken) {
throw new Error("userToken is required");
}
if (!venmoAccountToken) {
throw new Error("venmoAccountToken is required");
}

const transition = {
transition: "DE-ACTIVATED",
};
this.client.doPost(`users/${encodeURIComponent(userToken)}/venmo-accounts/${encodeURIComponent(venmoAccountToken)}/status-transitions`, transition, {}, callback);
}

/**
* Create Venmo account status transition
*
* @param {string} userToken - The user token
* @param {string} venmoAccountToken - venmo account token
* @param {Object} data - Venmo account status transition data
* @param {api-callback} callback - The callback for this call
* @throws Will throw an error if userToken or venmoAccountToken is not provided
*/
createVenmoAccountStatusTransition(userToken, venmoAccountToken, data, callback) {
if (!userToken) {
throw new Error("userToken is required");
}
if (!venmoAccountToken) {
throw new Error("venmoAccountToken is required");
}

this.client.doPost(`users/${encodeURIComponent(userToken)}/venmo-accounts/${encodeURIComponent(venmoAccountToken)}/status-transitions`, data, {}, callback);
}
/**
* Get Venmo account status transition
*
* @param {string} userToken -user token
* @param {string} venmoAccountToken - The venmo account token
* @param {string} statusTransitionToken - The venmo account status transition token
* @param {api-callback} callback - The callback for this call
*
* @throws Will throw an error if userToken or venmoAccountToken is not provided
*/
getVenmoAccountStatusTransition(userToken, venmoAccountToken, statusTransitionToken, callback) {
if (!userToken) {
throw new Error("userToken is required");
}
if (!venmoAccountToken) {
throw new Error("venmoAccountToken is required");
}
if (!statusTransitionToken) {
throw new Error("statusTransitionToken is required");
}
this.client.doGet(`users/${encodeURIComponent(userToken)}/venmo-accounts/${encodeURIComponent(venmoAccountToken)}/status-transitions/${encodeURIComponent(statusTransitionToken)}`,
{},
callback);
}

/**
* List all venmo account status transitions
*
* @param {string} userToken - user token
* @param {string} venmoAccountToken - venmo account token
* @param {Object} options - query parameters to send
* @param {api-callback} callback - callback for this call
*
* @throws Will throw an error if userToken or venmoAccountToken is not provided
*/
listVenmoAccountStatusTransitions(userToken, venmoAccountToken, options, callback) {
if (!userToken) {
throw new Error("userToken is required");
}
if (!venmoAccountToken) {
throw new Error("venmoAccountToken is required");
}
this.client.doGet(`users/${encodeURIComponent(userToken)}/venmo-accounts/${encodeURIComponent(venmoAccountToken)}/status-transitions`, options, Hyperwallet.handle204Response(callback));
}
}

0 comments on commit 8bb294e

Please sign in to comment.