Skip to content

Commit

Permalink
Merge pull request #22 from brandonrobinson5060/master
Browse files Browse the repository at this point in the history
Adding initiateExchange EP to client lib
  • Loading branch information
ruigomeseu authored Sep 15, 2022
2 parents a4549f5 + 412840f commit da26ca9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ async function initiateWithdrawal(withdrawal) {
return await instance.initiateWithdrawal(withdrawal);
}

async function initiateExchange(exchange) {
return await instance.initiateExchange(exchange);
}

async function withdrawalInfo(id) {
return await instance.withdrawalInfo(id);
}
Expand Down Expand Up @@ -82,6 +86,7 @@ module.exports = {
chargeInfo: chargeInfo,
listCharges: listCharges,
initiateWithdrawal: initiateWithdrawal,
initiateExchange: initiateExchange,
initiateWithdrawalAsync: initiateWithdrawalAsync,
withdrawalInfo: withdrawalInfo,
listWithdrawals: listWithdrawals,
Expand Down
16 changes: 16 additions & 0 deletions submodules/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,22 @@ class OpenNodeClient {
}
}

async initiateExchange(exchange) {
try {
let new_instance = axios.create();
new_instance.defaults.baseURL = (this.env === 'live') ? 'https://api.opennode.com/v2' : 'https://dev-api.opennode.com/v2';
new_instance.defaults.timeout = 15000;
new_instance.defaults.headers = { 'Authorization': this.api_key, 'user_agent': version };

const response = await new_instance.post('/exchanges', exchange);
return response.data;

}
catch (error) {
throw Exception(error.response.status, error.response.statusText, error.response.data.message);
}
}

async withdrawalInfo(id) {
try {

Expand Down

0 comments on commit da26ca9

Please # to comment.