-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from peoray/miscellaneous-methods
Add Miscellaneous methods
- Loading branch information
Showing
9 changed files
with
138 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Bloc } from '../../dist' | ||
|
||
const bloc = new Bloc('secret-keyasfasfbahfb', 'public-key') | ||
|
||
const getExchangeRate = async () => { | ||
try { | ||
const rate = await bloc.getExchangeRate('USD-NGN') | ||
console.log(rate) | ||
} catch (error) { | ||
console.error(error) | ||
} | ||
} | ||
|
||
getExchangeRate() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Bloc } from '../../dist' | ||
|
||
const bloc = new Bloc('secret-keyasfasfbahfb', 'public-key') | ||
|
||
const getListOfBanks = async () => { | ||
try { | ||
const banks = await bloc.getListOfBanks() | ||
console.log(banks) | ||
} catch (error) { | ||
console.error(error) | ||
} | ||
} | ||
|
||
getListOfBanks() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Bloc } from '../../dist' | ||
|
||
const bloc = new Bloc('secret-keyasfasfbahfb', 'public-key') | ||
|
||
const resolveAccount = async () => { | ||
try { | ||
const account = await bloc.resolveAccount() // add query params | ||
console.log(account) | ||
} catch (error) { | ||
console.error(error) | ||
} | ||
} | ||
|
||
resolveAccount() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { HTTPCore } from '../api' | ||
import { | ||
IGetExchangeRateResponse, | ||
IListOfBanksResponse, | ||
IResolveAccountResponse, | ||
} from '../types' | ||
import { IQueryParams } from '../types/base' | ||
|
||
/** | ||
* Class representing operations related to Miscellaneous, extending HTTPCore. | ||
*/ | ||
export class Miscellaneous extends HTTPCore { | ||
/** | ||
* Creates an instance of the Miscellaneous class. | ||
* @param {string} secretKey - The secret key for authentication. | ||
* @param {string} publicKey - The public key for authentication. | ||
*/ | ||
constructor(public secretKey: string, public publicKey: string) { | ||
super(secretKey, publicKey) | ||
} | ||
|
||
/** | ||
* Gets a list of banks. | ||
* @returns {Promise<IListOfBanksResponse>} A promise that resolves to the response containing the list of banks. | ||
*/ | ||
public async getListOfBanks(): Promise<IListOfBanksResponse> { | ||
return this.get<IListOfBanksResponse>(`/banks`) | ||
} | ||
|
||
/** | ||
* Resolves account information. | ||
* @param {IQueryParams} params - Query parameters for resolving account. | ||
* @returns {Promise<IResolveAccountResponse>} A promise that resolves to the response containing the resolved account information. | ||
*/ | ||
public async resolveAccount( | ||
params?: IQueryParams | ||
): Promise<IResolveAccountResponse> { | ||
return this.get<IResolveAccountResponse>(`/resolve-account`, { params }) | ||
} | ||
|
||
/** | ||
* Gets the exchange rate for a currency pair. | ||
* @param {string} currencyPair - The currency pair for which to retrieve the exchange rate. | ||
* @returns {Promise<IGetExchangeRateResponse>} A promise that resolves to the response containing the exchange rate. | ||
*/ | ||
public async getExchangeRate( | ||
currencyPair: string | ||
): Promise<IGetExchangeRateResponse> { | ||
return this.get<IGetExchangeRateResponse>( | ||
`/rates/currencies/${currencyPair}` | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
export interface IListOfBanksResponse { | ||
success: boolean | ||
data: { | ||
bank_name: string | ||
short_code: string | ||
bank_code: string | ||
}[] | ||
message: string | ||
} | ||
|
||
export interface IResolveAccountResponse { | ||
success: boolean | ||
data: { | ||
account_name: string | ||
account_number: string | ||
}[] | ||
message: string | ||
} | ||
|
||
export interface IGetExchangeRateResponse { | ||
success: boolean | ||
data: { | ||
buy: string | ||
sell: string | ||
}[] | ||
message: string | ||
} |