Skip to content

Commit

Permalink
Merge pull request #149 from Yoctol/export-messenger-version
Browse files Browse the repository at this point in the history
export getter on messenger version
  • Loading branch information
tw0517tw authored Sep 20, 2017
2 parents 601f8df + 74f93f5 commit b5f5918
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/messaging-api-messenger/src/MessengerClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,22 @@ export default class MessengerClient {
): MessengerClient => new MessengerClient(accessToken, version);

_accessToken: string;
_version: string;
_http: Axios;

constructor(accessToken: string, version?: string = 'v2.10') {
this._accessToken = accessToken;
this._version = version;
this._http = axios.create({
baseURL: `https://graph.facebook.com/${version}/`,
headers: { 'Content-Type': 'application/json' },
});
}

get version(): string {
return this._version;
}

getHTTPClient: () => Axios = () => this._http;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ describe('constructor', () => {
});
});

describe('#version', () => {
it('should return version of graph api', () => {
expect(new MessengerClient(ACCESS_TOKEN).version).toEqual('v2.10');
expect(new MessengerClient(ACCESS_TOKEN, 'v2.6').version).toEqual('v2.6');
});
});

describe('#getHTTPClient', () => {
it('should return underlying http client', () => {
const client = new MessengerClient(ACCESS_TOKEN);
Expand Down

0 comments on commit b5f5918

Please sign in to comment.