forked from Wirepay/maplerad-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.ts
63 lines (56 loc) · 2.09 KB
/
client.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import Axios from "axios";
import Issuing from "./lib/issuing";
import Transfers from "./lib/transfer";
import Bills from "./lib/bills";
import Fx from "./lib/fx";
import Misc from "./lib/misc";
import Collections from "./lib/collections";
import Customers from "./lib/customers";
import Institution from "./lib/institution";
import Counterparty from "./lib/counterparty";
import Wallets from "./lib/wallets";
import Transactions from "./lib/transactions";
type Env = "live" | "sandbox"
export default class Maplerad {
private readonly secretKey: string;
public Issuing: Issuing;
public Transfers: Transfers;
public Bills: Bills;
public Fx: Fx;
public Misc: Misc;
public Collections: Collections
public Customers: Customers
public Institution: Institution
public Counterparty: Counterparty
public Wallets: Wallets
public Transactions: Transactions
// key can be gotten from your Maplerad dashboard.
// environment can only be "live" or "sandbox".
constructor(key:string, environment: Env) {
this.secretKey = key
const live = "https://api.maplerad.com/v1"
const sandbox = "https://sandbox.api.maplerad.com/v1"
const axios = Axios.create({
baseURL : environment.toLowerCase() === "live" ? live : sandbox ,
headers: {
Authorization: `Bearer ${(this.secretKey)}`,
'Content-Type': 'application/json'
},
})
axios.interceptors.request.use(request => {
console.log('Starting Request', JSON.stringify(request, null, 2))
return request
})
this.Issuing = new Issuing(axios)
this.Transfers = new Transfers(axios)
this.Bills = new Bills(axios)
this.Fx = new Fx(axios)
this.Misc = new Misc(axios)
this.Collections = new Collections(axios)
this.Customers = new Customers(axios)
this.Institution = new Institution(axios)
this.Counterparty = new Counterparty(axios)
this.Wallets = new Wallets(axios)
this.Transactions = new Transactions(axios)
}
}