Skip to content

Commit

Permalink
Updated get campaign requests
Browse files Browse the repository at this point in the history
  • Loading branch information
mrz1836 committed Jun 3, 2021
1 parent ecdf99a commit 83ae547
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/api-client.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const axios = require('axios'); // .default (@mrz what does this affect?)

// Current version for requests from the API
export const pkgVersion = 'v0.2.1';
export const pkgVersion = 'v0.2.2';
export const apiVersion = 'v1';

// getOptions is a factory for axios default options
Expand Down
19 changes: 17 additions & 2 deletions lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,21 @@ class TonicPow {
* @returns {Promise}
*/
async getCampaign(campaignId) {
return this.apiClient.get('/campaigns/details/' + campaignId);
return this.apiClient.get('/campaigns/details/?id=' + campaignId);
}

/**
* getCampaignBySlug will get an existing campaign by it's url slug
*
* This will return an error if the campaign is not found (404)
*
* For more information: https://docs.tonicpow.com/#b827446b-be34-4678-b347-33c4f63dbf9e
*
* @param campaignSlug
* @returns {Promise}
*/
async getCampaignBySlug(campaignSlug) {
return this.apiClient.get('/campaigns/details/?slug=' + campaignSlug);
}

/**
Expand All @@ -140,7 +154,8 @@ class TonicPow {
* @returns {Promise}
*/
async refreshBalance(campaignId, lastBalance = 0) {
return this.apiClient.get('/campaigns/balance/' + campaignId + '?last_balance=' + lastBalance);
return this.apiClient.get('/campaigns/balance/?id=' + campaignId
+ '?last_balance=' + lastBalance);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion test/api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ describe('basic tests', function () {
const response = await tonicPow.getCampaign(243);
expect(response).toEqual(campaignData.return);
expect(mockAxios.get).toHaveBeenCalledWith(
`https://api.tonicpow.com/v1/campaigns/details/243`,
`https://api.tonicpow.com/v1/campaigns/details/?id=243`,
options,
);
});
Expand Down

0 comments on commit 83ae547

Please sign in to comment.