Skip to content

Commit

Permalink
feat: move Twilio (Sub)Account APIs to their own topic (twilio#195)
Browse files Browse the repository at this point in the history
The account create, fetch, list, and update commands were previously under the 'api:core' topic (mixed in with other topics). This change moves the to under their  own 'api:core:accounts' topic.
  • Loading branch information
childish-sambino committed Jun 23, 2020
1 parent ef04bad commit 35340f3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/services/twilio-api/get-topic-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ const getTopicName = actionDefinition => {
.replace(/\.json$/, '') // Drop the JSON extension
.replace(/\/{.+?}/g, '') // Drop every {PathParameter}
.replace(/\/+/g, TOPIC_SEPARATOR) // Separate paths with topic separator
)
).replace(/api:2010-04-01:accounts/, CORE_TOPIC_NAME); // Chop the legacy API version down
))
// Chop the legacy API version down
.replace(/api:2010-04-01:accounts(?=:)/, CORE_TOPIC_NAME) // First non-account level APIs
.replace(/api:2010-04-01/, CORE_TOPIC_NAME); // Then account APIs (i.e., modifying Twilio accounts or subaccounts)
};

module.exports = {
Expand Down
12 changes: 12 additions & 0 deletions test/services/twilio-api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ describe('services', () => {
path: '/v1/Bars/{BarId}/SubBars/{SubBarId}.json'
})).to.equal('foo:v1:bars:sub-bars');
});

test.it('handles v2010 APIs', () => {
expect(getTopicName({
domainName: 'api',
path: '/2010-04-01/Accounts/{Sid}.json'
})).to.equal('core:accounts');

expect(getTopicName({
domainName: 'api',
path: '/2010-04-01/Accounts/{AccountSid}/Addresses/{Sid}.json'
})).to.equal('core:addresses');
});
});

describe('getActionDescription', () => {
Expand Down

0 comments on commit 35340f3

Please sign in to comment.