asbeane / mlb-stats-api

Node.js Library for making requests to the MLB Stats API
MIT License
35 stars 15 forks source link

getGame not working, needed to add getGameFeedLive to call /feed/live #16

Closed albertoronu closed 1 year ago

albertoronu commented 1 year ago

Hi! πŸ‘‹

Firstly, thanks for your work on this project! πŸ™‚

Today I used patch-package to patch mlb-stats-api@1.6.0 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/mlb-stats-api/src/resources/game.js b/node_modules/mlb-stats-api/src/resources/game.js
index 888d9ab..8c48e8e 100644
--- a/node_modules/mlb-stats-api/src/resources/game.js
+++ b/node_modules/mlb-stats-api/src/resources/game.js
@@ -7,6 +7,12 @@ class Game {
         return this.request.get(`${this.apiHost}game/${gamePk}`, { params: params });
     }

+    getGameFeedLive(args = { pathParams: '' }) {
+        // if empty object but no pathParams return error, or handle it
+        const { params, pathParams: { gamePk = '', timecode = '' } } = args;
+        return this.request.get(`${this.apiHost}game/${gamePk}/feed/live?timecode=${timecode}`, { params: params });
+    }
+    
     getGameDiffPatch(args = { pathParams: '' }) {
         const { params, pathParams: { gamePk = ''}} = args;
         return this.request.get(`${this.apiHost}game/${gamePk}/feed/live/diffPatch`, { params: params });

This issue body was partially generated by patch-package.