Skip to content

Commit

Permalink
fix: number paramters casing (#848)
Browse files Browse the repository at this point in the history
  • Loading branch information
manchuck authored Aug 7, 2023
1 parent f10f344 commit 73b4a68
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
25 changes: 23 additions & 2 deletions packages/numbers/__tests__/__dataSets__/getOwnedNumbers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,36 @@ export default [
{
label: 'get owned numbers',
clientMethod: CLIENT_METHOD,
request: {
url: BASE_URL,
intercept: [`/account/numbers?api_key=12345&api_secret=ABCDE`, 'GET'],
reply: [200, validResponse],
},
parameters: [{}],
expected: validResponse,
},
{
label: 'get owned numbers with all parameters',
clientMethod: CLIENT_METHOD,
request: {
url: BASE_URL,
intercept: [
`/account/numbers?api_key=12345&api_secret=ABCDE`,
`/account/numbers?application_id=foo-bar&has_application=false&search_pattern=searchPattern&country=US&pattern=pattern&size=42&index=1&api_key=12345&api_secret=ABCDE`,
'GET',
],
reply: [200, validResponse],
},
parameters: [{}],
parameters: [
{
hasApplication: false,
applicationId: 'foo-bar',
country: 'US',
pattern: 'pattern',
searchPattern: 'searchPattern',
size: 42,
index: 1,
},
],
expected: validResponse,
},
];
13 changes: 3 additions & 10 deletions packages/numbers/lib/numbers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ const buildSearch = ({
pattern,
country,
}: NumbersSearchFilter & NumbersSearchSimple):
| NumbersQuerySearchFilter
| Record<string, never> => {
| NumbersQuerySearchFilter
| Record<string, never> => {
searchPattern = searchPattern ?? SearchPattern.CONTAINS;

if (pattern) {
Expand Down Expand Up @@ -168,16 +168,9 @@ export class Numbers extends Client {
if (!filter) {
filter = {};
}

const mapping = {
application_id: 'applicationId',
has_application: 'hasApplication',
search_pattern: 'searchPattern',
};
const data = remapObjects(mapping, {}, filter);
const resp = await this.sendGetRequest<NumbersOwnedList>(
`${this.config.restHost}/account/numbers`,
data,
Client.transformers.snakeCaseObjectKeys(filter),
);
return resp.data;
}
Expand Down

0 comments on commit 73b4a68

Please sign in to comment.