Skip to content

Commit

Permalink
fix: Card searches can use the 'cardSequentialId' as a search param, …
Browse files Browse the repository at this point in the history
…but that value can be provided in multiple formats and the Favro API doesn't always play nice. The value should be normalized to the numeric identifier.
  • Loading branch information
adam-coster committed Oct 6, 2021
1 parent b9580d1 commit c2d6db0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/lib/BravoClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
createIsMatchFilter,
stringsMatch,
generateRandomString,
stringToNumber,
} from './utility.js';
import { BravoCollection } from './entities/BravoCollection';
import { BravoUser } from '$/lib/entities/BravoUser';
Expand Down Expand Up @@ -539,6 +540,13 @@ export class BravoClient extends FavroClient {
* {@link https://favro.com/developer/#get-all-cards}
*/
async listCardInstances(options?: FavroApi.Card.SearchQuery) {
// Clean up the sequentialId, if present, since it can come in
// in multiple ways (as a URL, with a prefix, or plain)
if (typeof options?.cardSequentialId == 'string') {
options.cardSequentialId = stringToNumber(
options.cardSequentialId.replace(/^.*(\d+)$/, '$1'),
);
}
const res = (await this.requestWithReturnedEntities(
`cards`,
{
Expand Down

0 comments on commit c2d6db0

Please sign in to comment.