Skip to content

Commit

Permalink
docs(accounts): added doc blocks for accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
manchuck committed Oct 26, 2023
1 parent c8394c8 commit 6fefd29
Show file tree
Hide file tree
Showing 38 changed files with 3,867 additions and 160 deletions.
33 changes: 22 additions & 11 deletions packages/accounts/__tests__/accounts.test.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import nock from 'nock';
import { Accounts } from '../lib/index'
import { Accounts } from '../lib/index';
import { Auth } from '@vonage/auth';

describe('accounts', () => {
let client;

beforeEach(() => {
client = new Accounts(new Auth({ apiKey: 'abcd', apiSecret: '1234' }));
client = new Accounts(new Auth({ apiKey: 'abcd', apiSecret: '1234' }));
});

afterEach(() => {
client = null;
client = null;
});

test("get balance", async () => {
const expectedResponse = {
"value": 10.28,
"autoReload": false
"autoReload": false,
};

nock("https://rest.nexmo.com")
Expand All @@ -33,7 +33,7 @@ describe('accounts', () => {
test("top up balance", async () => {
const expectedResponse = {
"error-code": "200",
"error-code-label": "success"
"error-code-label": "success",
};

nock("https://rest.nexmo.com")
Expand All @@ -42,9 +42,13 @@ describe('accounts', () => {
.query({ api_key: 'abcd', api_secret: '1234' })
.reply(200, expectedResponse);

const lookup = await client.topUpBalance('8ef2447e69604f642ae59363aa5f781b');
const lookup = await client.topUpBalance(
'8ef2447e69604f642ae59363aa5f781b',
);
expect(lookup['error-code']).toEqual(expectedResponse['error-code']);
expect(lookup['error-code-label']).toEqual(expectedResponse['error-code-label']);
expect(
lookup['error-code-label'],
).toEqual(expectedResponse['error-code-label']);
});

test("update callbacks", async () => {
Expand All @@ -53,10 +57,13 @@ describe('accounts', () => {
"dr-callback-url": "https://example.com/webhooks/delivery-receipt",
"max-outbound-request": 30,
"max-inbound-request": 30,
"max-calls-per-second": 30
"max-calls-per-second": 30,
};

const callbacks = {moCallBackUrl: "https://example.com/webhooks/inbound-sms", drCallBackUrl: "https://example.com/webhooks/delivery-receipt"};
const callbacks = {
moCallBackUrl: "https://example.com/webhooks/inbound-sms",
drCallBackUrl: "https://example.com/webhooks/delivery-receipt",
};
const queryString = new URLSearchParams(callbacks);
const re = new RegExp(queryString.toString(), "g");

Expand All @@ -67,7 +74,11 @@ describe('accounts', () => {
.reply(200, expectedResponse);

const lookup = await client.updateAccountCallbacks(callbacks);
expect(lookup['mo-callback-url']).toEqual(expectedResponse['mo-callback-url']);
expect(lookup['dr-callback-url']).toEqual(expectedResponse['dr-callback-url']);
expect(
lookup['mo-callback-url'],
).toEqual(expectedResponse['mo-callback-url']);
expect(
lookup['dr-callback-url'],
).toEqual(expectedResponse['dr-callback-url']);
});
});
52 changes: 28 additions & 24 deletions packages/accounts/__tests__/secrets.test.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
import nock from 'nock';
import { Secrets } from '../lib/index'
import { Secrets } from '../lib/index';
import { Auth } from '@vonage/auth';

describe('secrets', () => {
let client;

beforeEach(() => {
client = new Secrets(new Auth({ apiKey: 'abcd', apiSecret: '1234' }));
client = new Secrets(new Auth({ apiKey: 'abcd', apiSecret: '1234' }));
});

afterEach(() => {
client = null;
client = null;
});

test("list secrets", async () => {
const expectedResponse = {
"_links": {
"self": {
"href": "abc123"
}
"href": "abc123",
},
},
"_embedded": {
"secrets": [
{
"_links": {
"self": {
"href": "abc123"
}
"href": "abc123",
},
},
"id": "ad6dc56f-07b5-46e1-a527-85530e625800",
"created_at": "2017-03-02T16:34:49Z"
}
]
}
"created_at": "2017-03-02T16:34:49Z",
},
],
},
};

nock("https://api.nexmo.com", {reqheaders: {'Authorization': 'Basic YWJjZDoxMjM0'} })
nock("https://api.nexmo.com", { reqheaders: { 'Authorization': 'Basic YWJjZDoxMjM0' } })
.persist()
.get('/accounts/abcd/secrets')
.reply(200, expectedResponse);
Expand All @@ -49,16 +49,16 @@ describe('secrets', () => {
const expectedResponse = {
"_links": {
"self": {
"href": "abc123"
}
"href": "abc123",
},
},
"id": "ad6dc56f-07b5-46e1-a527-85530e625800",
"created_at": "2017-03-02T16:34:49Z"
"created_at": "2017-03-02T16:34:49Z",
};

nock("https://api.nexmo.com", {reqheaders: {'Authorization': 'Basic YWJjZDoxMjM0'} })
nock("https://api.nexmo.com", { reqheaders: { 'Authorization': 'Basic YWJjZDoxMjM0' } })
.persist()
.post('/accounts/abcd/secrets', {secret: 'te5ts3cret!'})
.post('/accounts/abcd/secrets', { secret: 'te5ts3cret!' })
.reply(200, expectedResponse);

const lookup = await client.createSecret('abcd', 'te5ts3cret!');
Expand All @@ -71,30 +71,34 @@ describe('secrets', () => {
const expectedResponse = {
"_links": {
"self": {
"href": "abc123"
}
"href": "abc123",
},
},
"id": "ad6dc56f-07b5-46e1-a527-85530e625800",
"created_at": "2017-03-02T16:34:49Z"
"created_at": "2017-03-02T16:34:49Z",
};

nock("https://api.nexmo.com", {reqheaders: {'Authorization': 'Basic YWJjZDoxMjM0'} })
nock("https://api.nexmo.com", { reqheaders: { 'Authorization': 'Basic YWJjZDoxMjM0' } })
.persist()
.get('/accounts/abcd/secrets/ad6dc56f-07b5-46e1-a527-85530e625800')
.reply(200, expectedResponse);

const lookup = await client.getSecret('abcd', 'ad6dc56f-07b5-46e1-a527-85530e625800');
const lookup = await client.getSecret(
'abcd',
'ad6dc56f-07b5-46e1-a527-85530e625800',
);
expect(lookup._links).toEqual(expectedResponse._links);
expect(lookup.id).toEqual(expectedResponse.id);
expect(lookup.created_at).toEqual(expectedResponse.created_at);
});

test("get a secret", async () => {
nock("https://api.nexmo.com", {reqheaders: {'Authorization': 'Basic YWJjZDoxMjM0'} })
test("delete a secret", async () => {
nock("https://api.nexmo.com", { reqheaders: { 'Authorization': 'Basic YWJjZDoxMjM0' } })
.persist()
.delete('/accounts/abcd/secrets/ad6dc56f-07b5-46e1-a527-85530e625800')
.reply(204);

await client.deleteSecret('abcd', 'ad6dc56f-07b5-46e1-a527-85530e625800');
expect(nock.isDone()).toBeTruthy();
});
});
1 change: 1 addition & 0 deletions packages/accounts/docs/.nojekyll
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false.
99 changes: 99 additions & 0 deletions packages/accounts/docs/assets/highlight.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
:root {
--light-hl-0: #795E26;
--dark-hl-0: #DCDCAA;
--light-hl-1: #000000;
--dark-hl-1: #D4D4D4;
--light-hl-2: #A31515;
--dark-hl-2: #CE9178;
--light-hl-3: #0000FF;
--dark-hl-3: #569CD6;
--light-hl-4: #0070C1;
--dark-hl-4: #4FC1FF;
--light-hl-5: #001080;
--dark-hl-5: #9CDCFE;
--light-hl-6: #AF00DB;
--dark-hl-6: #C586C0;
--light-hl-7: #267F99;
--dark-hl-7: #4EC9B0;
--light-hl-8: #000000;
--dark-hl-8: #C8C8C8;
--light-hl-9: #008000;
--dark-hl-9: #6A9955;
--light-hl-10: #098658;
--dark-hl-10: #B5CEA8;
--light-code-background: #FFFFFF;
--dark-code-background: #1E1E1E;
}

@media (prefers-color-scheme: light) { :root {
--hl-0: var(--light-hl-0);
--hl-1: var(--light-hl-1);
--hl-2: var(--light-hl-2);
--hl-3: var(--light-hl-3);
--hl-4: var(--light-hl-4);
--hl-5: var(--light-hl-5);
--hl-6: var(--light-hl-6);
--hl-7: var(--light-hl-7);
--hl-8: var(--light-hl-8);
--hl-9: var(--light-hl-9);
--hl-10: var(--light-hl-10);
--code-background: var(--light-code-background);
} }

@media (prefers-color-scheme: dark) { :root {
--hl-0: var(--dark-hl-0);
--hl-1: var(--dark-hl-1);
--hl-2: var(--dark-hl-2);
--hl-3: var(--dark-hl-3);
--hl-4: var(--dark-hl-4);
--hl-5: var(--dark-hl-5);
--hl-6: var(--dark-hl-6);
--hl-7: var(--dark-hl-7);
--hl-8: var(--dark-hl-8);
--hl-9: var(--dark-hl-9);
--hl-10: var(--dark-hl-10);
--code-background: var(--dark-code-background);
} }

:root[data-theme='light'] {
--hl-0: var(--light-hl-0);
--hl-1: var(--light-hl-1);
--hl-2: var(--light-hl-2);
--hl-3: var(--light-hl-3);
--hl-4: var(--light-hl-4);
--hl-5: var(--light-hl-5);
--hl-6: var(--light-hl-6);
--hl-7: var(--light-hl-7);
--hl-8: var(--light-hl-8);
--hl-9: var(--light-hl-9);
--hl-10: var(--light-hl-10);
--code-background: var(--light-code-background);
}

:root[data-theme='dark'] {
--hl-0: var(--dark-hl-0);
--hl-1: var(--dark-hl-1);
--hl-2: var(--dark-hl-2);
--hl-3: var(--dark-hl-3);
--hl-4: var(--dark-hl-4);
--hl-5: var(--dark-hl-5);
--hl-6: var(--dark-hl-6);
--hl-7: var(--dark-hl-7);
--hl-8: var(--dark-hl-8);
--hl-9: var(--dark-hl-9);
--hl-10: var(--dark-hl-10);
--code-background: var(--dark-code-background);
}

.hl-0 { color: var(--hl-0); }
.hl-1 { color: var(--hl-1); }
.hl-2 { color: var(--hl-2); }
.hl-3 { color: var(--hl-3); }
.hl-4 { color: var(--hl-4); }
.hl-5 { color: var(--hl-5); }
.hl-6 { color: var(--hl-6); }
.hl-7 { color: var(--hl-7); }
.hl-8 { color: var(--hl-8); }
.hl-9 { color: var(--hl-9); }
.hl-10 { color: var(--hl-10); }
pre, code { background: var(--code-background); }
59 changes: 59 additions & 0 deletions packages/accounts/docs/assets/main.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/accounts/docs/assets/navigation.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/accounts/docs/assets/search.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6fefd29

Please sign in to comment.