xendit-node
Advanced tools
Comparing version 1.19.8 to 1.19.9
@@ -52,2 +52,31 @@ const x = require('../xendit'); | ||
const accountV2 = await p.createV2Account({ | ||
email: `example+${Date.now().toString()}@gmail.com`, | ||
type: 'OWNED', | ||
publicProfile: { | ||
businessName: `example+${Date.now().toString()}`, | ||
}, | ||
}); | ||
// eslint-disable-next-line no-console | ||
console.log('created account details (using V2):', accountV2); | ||
const getAccount = await p.getAccountByID({ | ||
id: accountV2.id, | ||
}); | ||
// eslint-disable-next-line no-console | ||
console.log('get account details: ', getAccount); | ||
const updateAccount = await p.updateAccount({ | ||
id: accountV2.id, | ||
email: `example_updated+${Date.now().toString()}@gmail.com`, | ||
publicProfile: { | ||
businessName: `example_updated+${Date.now().toString()}`, | ||
}, | ||
}); | ||
// eslint-disable-next-line no-console | ||
console.log('update account details: ', updateAccount); | ||
process.exit(0); | ||
@@ -54,0 +83,0 @@ } catch (e) { |
@@ -61,2 +61,40 @@ const x = require('../xendit'); | ||
}) | ||
.then(() => | ||
p.createV2Account({ | ||
email: `example+${Date.now().toString()}@gmail.com`, | ||
type: 'OWNED', | ||
publicProfile: { | ||
businessName: `example+${Date.now().toString()}`, | ||
}, | ||
}), | ||
) | ||
.then(r => { | ||
// eslint-disable-next-line no-console | ||
console.log('created account details (using V2):', r); | ||
return r; | ||
}) | ||
.then(r => | ||
p.getAccountByID({ | ||
id: r.id, | ||
}), | ||
) | ||
.then(r => { | ||
// eslint-disable-next-line no-console | ||
console.log('get account details: ', r); | ||
return r; | ||
}) | ||
.then(r => | ||
p.updateAccount({ | ||
id: r.id, | ||
email: `example_updated+${Date.now().toString()}@gmail.com`, | ||
publicProfile: { | ||
businessName: `example_updated+${Date.now().toString()}`, | ||
}, | ||
}), | ||
) | ||
.then(r => { | ||
// eslint-disable-next-line no-console | ||
console.log('update account details: ', r); | ||
return r; | ||
}) | ||
.catch(e => { | ||
@@ -63,0 +101,0 @@ console.error(e); // eslint-disable-line no-console |
@@ -43,2 +43,25 @@ const x = require('./xendit.test'); | ||
) | ||
.then(() => | ||
p.createV2Account({ | ||
email: `example+${Date.now().toString()}@gmail.com`, | ||
type: 'OWNED', | ||
publicProfile: { | ||
businessName: `example+${Date.now().toString()}`, | ||
}, | ||
}), | ||
) | ||
.then(r => | ||
p.getAccountByID({ | ||
id: r.id, | ||
}), | ||
) | ||
.then(r => | ||
p.updateAccount({ | ||
id: r.id, | ||
email: `example_updated+${Date.now().toString()}@gmail.com`, | ||
publicProfile: { | ||
businessName: `example_updated+${Date.now().toString()}`, | ||
}, | ||
}), | ||
) | ||
.then(() => { | ||
@@ -45,0 +68,0 @@ // eslint-disable-next-line no-console |
{ | ||
"name": "xendit-node", | ||
"version": "1.19.8", | ||
"version": "1.19.9", | ||
"description": "NodeJS client for Xendit API", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -99,3 +99,6 @@ # Xendit API Node.js Client | ||
* [XenPlatform Service](#xenplatform-service) | ||
+ [Create sub-accounts](#create-sub-accounts) | ||
+ [Create sub-account](#create-sub-account) | ||
+ [Create sub-account using V2](#create-sub-account-using-v2) | ||
+ [Get sub-account by ID](#get-sub-account-by-id) | ||
+ [Update sub-account](#update-sub-account) | ||
+ [Set Callback URL](#set-callback-url) | ||
@@ -1295,3 +1298,3 @@ + [Create transfers](#create-transfers) | ||
#### Create sub-accounts | ||
#### Create sub-account | ||
@@ -1308,2 +1311,34 @@ ```ts | ||
#### Create sub-account using V2 | ||
```ts | ||
p.createV2Account(data: { | ||
email: string; | ||
type: string; | ||
publicProfile?: { | ||
businessName: string; | ||
}; | ||
}) | ||
``` | ||
#### Get sub-account by ID | ||
```ts | ||
p.getAccountByID(data: { | ||
id: string; | ||
}) | ||
``` | ||
#### Update sub-account | ||
```ts | ||
p.updateAccount(data: { | ||
id: string; | ||
email: string; | ||
publicProfile?: { | ||
businessName: string; | ||
}; | ||
}) | ||
``` | ||
#### Set Callback URL | ||
@@ -1310,0 +1345,0 @@ |
@@ -24,2 +24,17 @@ import { XenditOptions } from '../xendit_opts'; | ||
}): Promise<object>; | ||
createV2Account(data: { | ||
email: string; | ||
type: string; | ||
publicProfile?: { | ||
businessName: string; | ||
}; | ||
}): Promise<object>; | ||
getAccountByID(data: { id: string }): Promise<object>; | ||
updateAccount(data: { | ||
id: string; | ||
email: string; | ||
publicProfile?: { | ||
businessName: string; | ||
}; | ||
}): Promise<object>; | ||
setCallbackURL(data: { | ||
@@ -26,0 +41,0 @@ type: string; |
@@ -52,2 +52,69 @@ const { promWithJsErr, Validate, fetchWithHTTPErr, Auth } = require('../utils'); | ||
Platform.prototype.createV2Account = function(data) { | ||
return promWithJsErr((resolve, reject) => { | ||
let validationFields = ['email', 'type']; | ||
if (data.type === 'OWNED') { | ||
validationFields.push('publicProfile'); | ||
} | ||
Validate.rejectOnMissingFields(validationFields, data, reject); | ||
const body = { email: data.email, type: data.type }; | ||
if (data.publicProfile) { | ||
body.public_profile = { | ||
business_name: data.publicProfile.businessName, | ||
}; | ||
} | ||
fetchWithHTTPErr(`${this.API_ENDPOINT}/v2/accounts`, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
Authorization: Auth.basicAuthHeader(this.opts.secretKey), | ||
}, | ||
body: JSON.stringify(body), | ||
}) | ||
.then(resolve) | ||
.catch(reject); | ||
}); | ||
}; | ||
Platform.prototype.getAccountByID = function(data) { | ||
return promWithJsErr((resolve, reject) => { | ||
Validate.rejectOnMissingFields(['id'], data, reject); | ||
fetchWithHTTPErr(`${this.API_ENDPOINT}/v2/accounts/${data.id}`, { | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
Authorization: Auth.basicAuthHeader(this.opts.secretKey), | ||
}, | ||
}) | ||
.then(resolve) | ||
.catch(reject); | ||
}); | ||
}; | ||
Platform.prototype.updateAccount = function(data) { | ||
return promWithJsErr((resolve, reject) => { | ||
let validationFields = ['email', 'id']; | ||
if (data.type === 'OWNED') { | ||
validationFields.push('publicProfile'); | ||
} | ||
Validate.rejectOnMissingFields(validationFields, data, reject); | ||
const body = { email: data.email }; | ||
if (data.publicProfile) { | ||
body.public_profile = { | ||
business_name: data.publicProfile.businessName, | ||
}; | ||
} | ||
fetchWithHTTPErr(`${this.API_ENDPOINT}/v2/accounts/${data.id}`, { | ||
method: 'PATCH', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
Authorization: Auth.basicAuthHeader(this.opts.secretKey), | ||
}, | ||
body: JSON.stringify(body), | ||
}) | ||
.then(resolve) | ||
.catch(reject); | ||
}); | ||
}; | ||
Platform.prototype.setCallbackURL = function(data) { | ||
@@ -54,0 +121,0 @@ return promWithJsErr((resolve, reject) => { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
214604
5901
1396