Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add date inequality support #41

Merged
merged 29 commits into from
Aug 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
53059ed
Add DateSent> and DateSent< API parameters and convert API names when…
JenniferMah Jul 18, 2019
59ec147
Added parameters for date> and date< and conversion of parameter name…
JenniferMah Jul 23, 2019
5d15a37
Modify replacement statement to replace API parameter name with CLI k…
JenniferMah Jul 23, 2019
d48c997
Ran npm audit fix to fix high severity vulnerabilities
JenniferMah Jul 23, 2019
dfaee43
Add DateSent> and DateSent< API parameters and convert API names when…
JenniferMah Jul 18, 2019
35cd03a
Added parameters for date> and date< and conversion of parameter name…
JenniferMah Jul 23, 2019
8c403cb
Modify replacement statement to replace API parameter name with CLI k…
JenniferMah Jul 23, 2019
9ea3c3a
Ran npm audit fix to fix high severity vulnerabilities
JenniferMah Jul 23, 2019
4355d3d
rebase
JenniferMah Jul 23, 2019
550faf6
rebase
JenniferMah Jul 23, 2019
f296619
Remove changes to generated file. Change the function to look for ine…
JenniferMah Jul 26, 2019
57af8fe
Add new twilio_api.json with inequality parameters generated
JenniferMah Aug 1, 2019
51f02e2
Add DateSent> and DateSent< API parameters and convert API names when…
JenniferMah Jul 18, 2019
75f1c75
Added parameters for date> and date< and conversion of parameter name…
JenniferMah Jul 23, 2019
6b34859
Modify replacement statement to replace API parameter name with CLI k…
JenniferMah Jul 23, 2019
419c326
Ran npm audit fix to fix high severity vulnerabilities
JenniferMah Jul 23, 2019
a1f4ce5
Add DateSent> and DateSent< API parameters and convert API names when…
JenniferMah Jul 18, 2019
56a3130
Added parameters for date> and date< and conversion of parameter name…
JenniferMah Jul 23, 2019
165ddd6
Modify replacement statement to replace API parameter name with CLI k…
JenniferMah Jul 23, 2019
785f47c
rebase
JenniferMah Jul 23, 2019
bc45415
Remove changes to generated file. Change the function to look for ine…
JenniferMah Jul 26, 2019
b00b122
Add new twilio_api.json with inequality parameters generated
JenniferMah Aug 1, 2019
3a1effe
Merge branch 'DateInequality' of github.com:twilio/twilio-cli-core in…
JenniferMah Aug 7, 2019
c0dd502
Add DateSent> and DateSent< API parameters and convert API names when…
JenniferMah Jul 18, 2019
a524592
Merge branch 'DateInequality' of github.com:twilio/twilio-cli-core in…
JenniferMah Aug 7, 2019
7feb5e4
Added tests for inequality conversion
JenniferMah Aug 7, 2019
ea3fb2a
run npm install to fix errors in package-lock.json
JenniferMah Aug 7, 2019
99607ed
API spec changes removed
JenniferMah Aug 8, 2019
224cbf2
Merge branch 'master' into DateInequality
Aug 8, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions package-lock.json

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

7 changes: 3 additions & 4 deletions src/services/open-api-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,14 @@ class OpenApiClient {
getParams(opts, operation) {
const params = {};
operation.parameters.forEach(parameter => {
const replaceSymbolName = parameter.name.replace('>', 'After').replace('<', 'Before');
// Build the actual request params from the spec's query parameters. This
// effectively drops all params that are not in the spec.
if (parameter.in === 'query' && doesObjectHaveProperty(opts.data, parameter.name)) {
let value = opts.data[parameter.name];

if (parameter.in === 'query' && doesObjectHaveProperty(opts.data, replaceSymbolName)) {
let value = opts.data[replaceSymbolName];
if (parameter.schema.type === 'boolean') {
value = value.toString();
}

params[parameter.name] = value;
}
});
Expand Down
40 changes: 40 additions & 0 deletions test/services/twilio-api/twilio-client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,46 @@ describe('services', () => {
expect(response).to.eql([{ sid: callSid }, { sid: callSid }]);
});

test
.nock('https://api.twilio.com', api => {
/* eslint-disable camelcase */
api.get(`/2010-04-01/Accounts/${accountSid}/Calls.json?StartTime%3E=${callStartTime}`).reply(200, {
calls: [{
sid: callSid
}]
});
/* eslint-enable camelcase */
})
.it('test greater than inequality conversion', async () => {
const response = await client.list({
domain: 'api',
path: '/2010-04-01/Accounts/{AccountSid}/Calls.json',
data: { startTimeAfter: callStartTime } // CLI is startTimeAfter
});

expect(response).to.eql([{ sid: callSid }]);
});

test
.nock('https://api.twilio.com', api => {
/* eslint-disable camelcase */
api.get(`/2010-04-01/Accounts/${accountSid}/Calls.json?StartTime%3C=${callStartTime}`).reply(200, {
calls: [{
sid: callSid
}]
});
/* eslint-enable camelcase */
})
.it('test less than inequality conversion', async () => {
const response = await client.list({
domain: 'api',
path: '/2010-04-01/Accounts/{AccountSid}/Calls.json',
data: { startTimeBefore: callStartTime } // CLI is startTimeBefore
});

expect(response).to.eql([{ sid: callSid }]);
});

test
.nock('https://studio.twilio.com', api => {
/* eslint-disable camelcase */
Expand Down