From 721fb02777eb02394e1fa5cb032fb67bc90f0427 Mon Sep 17 00:00:00 2001 From: Gianni Ferullo Date: Tue, 17 Oct 2023 14:35:49 -0400 Subject: [PATCH 1/4] fetch-api: add optional qsParams argument to GiphyFetch --- packages/fetch-api/public/index.tsx | 14 ++++++++++++++ packages/fetch-api/src/api.ts | 11 +++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/packages/fetch-api/public/index.tsx b/packages/fetch-api/public/index.tsx index 801df209..f8c7f270 100644 --- a/packages/fetch-api/public/index.tsx +++ b/packages/fetch-api/public/index.tsx @@ -138,6 +138,19 @@ const textTrending = async () => { console.error('textTrending', error) } } + +const extraQS = async () => { + try { + const gf = new GiphyFetch('sXpGFDGZs0Dv1mmNFvYaGUvYwKX0PWIh', { countryCode: 'us' }) + const result = await gf.trending({ + limit: 2, + type: 'text', + }) + console.log('extra qs', result) + } catch (error) { + console.error('extra qs', error) + } +} categories() search() searchChannel() @@ -154,4 +167,5 @@ text() textTrending() animate() searchVideos() +extraQS() relatedClips() diff --git a/packages/fetch-api/src/api.ts b/packages/fetch-api/src/api.ts index 6a2064e9..5f047b4c 100644 --- a/packages/fetch-api/src/api.ts +++ b/packages/fetch-api/src/api.ts @@ -21,21 +21,28 @@ const getType = (options?: TypeOption): MediaType => (options && options.type ? /** * @class GiphyFetch * @param {string} apiKey + * @param {object} qsParams */ export class GiphyFetch { - constructor(apiKey: string) { + constructor(apiKey: string, qsParams: Record = {}) { this.apiKey = apiKey + this.qsParams = qsParams } /** * @hidden */ private apiKey: string + + /** + * @hidden + */ + private qsParams: Record /** * @hidden */ private getQS = (options: any = {}) => { - return qs.stringify({ ...options, api_key: this.apiKey, pingback_id: getPingbackId() }) + return qs.stringify({ ...options, api_key: this.apiKey, pingback_id: getPingbackId(), ...this.qsParams }) } /** From 27f26d226b70161417cf4f2167d229c5b1338eee Mon Sep 17 00:00:00 2001 From: Gianni Ferullo Date: Tue, 17 Oct 2023 15:10:41 -0400 Subject: [PATCH 2/4] yarn: remove immutable cache flag --- .github/workflows/main.yml | 2 +- .github/workflows/publish.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1af372c0..bc50896e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,7 +16,7 @@ jobs: with: node-version: 16.x cache: 'yarn' - - run: yarn install --immutable --immutable-cache + - run: yarn install --immutable - name: Build run: yarn run build - name: Lint and Test diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 938dd6f9..66302fac 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -21,7 +21,7 @@ jobs: node-version: 16.x cache: 'yarn' - - run: yarn install --immutable --immutable-cache + - run: yarn install --immutable - name: Create Release Pull Request or Publish id: changesets uses: changesets/action@v1 From 7faf808830e80e76409c173c8b18ea83e8fe0e2f Mon Sep 17 00:00:00 2001 From: Gianni Ferullo Date: Tue, 17 Oct 2023 15:18:54 -0400 Subject: [PATCH 3/4] deps: update typedoc theme --- packages/fetch-api/package.json | 4 ++-- yarn.lock | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/fetch-api/package.json b/packages/fetch-api/package.json index 702239ef..c5d94d5a 100644 --- a/packages/fetch-api/package.json +++ b/packages/fetch-api/package.json @@ -43,8 +43,8 @@ "@types/qs": "^6.9.4", "jest-fetch-mock": "^3.0.3", "parcel-bundler": "latest", - "typedoc": "^0.20.36", - "typedoc-thunder-theme": "^0.0.2", + "typedoc": "^0.20.37", + "typedoc-thunder-theme": "^0.0.3", "typescript": "^5.0.4" } } diff --git a/yarn.lock b/yarn.lock index a39960cb..48414c0d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2533,8 +2533,8 @@ __metadata: jest-fetch-mock: ^3.0.3 parcel-bundler: latest qs: ^6.9.4 - typedoc: ^0.20.36 - typedoc-thunder-theme: ^0.0.2 + typedoc: ^0.20.37 + typedoc-thunder-theme: ^0.0.3 typescript: ^5.0.4 languageName: unknown linkType: soft @@ -21879,14 +21879,14 @@ __metadata: languageName: node linkType: hard -"typedoc-thunder-theme@npm:^0.0.2": - version: 0.0.2 - resolution: "typedoc-thunder-theme@npm:0.0.2" - checksum: 0d41937b831aff3cd653a436f05d0eba0757315ac712171aab497cd108f3e0fbc8ee82eaa28e3db0af41ad7eb790ea8c2dffd6e97a7aae39f3bcb4af43c112ec +"typedoc-thunder-theme@npm:^0.0.3": + version: 0.0.3 + resolution: "typedoc-thunder-theme@npm:0.0.3" + checksum: f19ce94290fe2c145170dfb7d52e90dfe16da1c8c6e7b38b6e997ccf3cb943c6e85f9bcff2efeac0dfbfbac747dedb558b59f5dbfe9594d5d9bc5cfcde938e28 languageName: node linkType: hard -"typedoc@npm:^0.20.36": +"typedoc@npm:^0.20.37": version: 0.20.37 resolution: "typedoc@npm:0.20.37" dependencies: From bb4b82c9956a74d640abb1e30b41ca5da20856fd Mon Sep 17 00:00:00 2001 From: Gianni Ferullo Date: Tue, 17 Oct 2023 16:42:36 -0400 Subject: [PATCH 4/4] changeset --- .changeset/fluffy-months-play.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changeset/fluffy-months-play.md diff --git a/.changeset/fluffy-months-play.md b/.changeset/fluffy-months-play.md new file mode 100644 index 00000000..57355c7f --- /dev/null +++ b/.changeset/fluffy-months-play.md @@ -0,0 +1,7 @@ +--- +'@giphy/js-fetch-api': minor +--- + +add optional qs params argument to GiphyFetch constructor + +Any params passed here will be apppened to all requests \ No newline at end of file