@morambacrypto/connect 0.0.10 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -0
- package/dist/MorambaClient.d.ts +2 -0
- package/dist/MorambaClient.js +2 -0
- package/dist/apis/company.api.d.ts +9 -0
- package/dist/apis/company.api.js +17 -0
- package/dist/client/HttpClient.d.ts +1 -1
- package/dist/client/HttpClient.js +4 -2
- package/dist/types/company.types.d.ts +23 -0
- package/dist/types/company.types.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -35,6 +35,40 @@ const response = await client.auth.createJwtToken({ userid: "test@gmail.com" });
|
|
|
35
35
|
console.log(response.data.token);
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
+
### Creating a Company
|
|
39
|
+
|
|
40
|
+
``` javascript
|
|
41
|
+
import { MorambaClient } from "@morambacrypto/connect";
|
|
42
|
+
|
|
43
|
+
const client = new MorambaClient({
|
|
44
|
+
baseURL: "https://crypto.moramba.io",
|
|
45
|
+
apiKey: process.env.API_KEY!,
|
|
46
|
+
partnerId: process.env.PARTNER_ID!,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// STEP 1 — Get JWT token
|
|
50
|
+
const jwt = await client.auth.createJwtToken({ userid: "admin@moramba.xyz" });
|
|
51
|
+
const token = jwt.data.token;
|
|
52
|
+
|
|
53
|
+
// STEP 2 — Create company
|
|
54
|
+
const company = await client.company.createCompany(
|
|
55
|
+
{
|
|
56
|
+
payment_method: {
|
|
57
|
+
network: "monad",
|
|
58
|
+
token: "moramba",
|
|
59
|
+
address: "0x62F6c82114809C00a1293be02A43C05a3F917202"
|
|
60
|
+
},
|
|
61
|
+
name: "Aeropres",
|
|
62
|
+
email: "admin@moramba.xyz",
|
|
63
|
+
},
|
|
64
|
+
token
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
console.log(company);
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
|
|
38
72
|
## API Reference
|
|
39
73
|
|
|
40
74
|
### MorambaClient
|
package/dist/MorambaClient.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AuthAPI } from "./apis/auth.api";
|
|
2
|
+
import { CompanyAPI } from "./apis/company.api";
|
|
2
3
|
export interface MorambaClientConfig {
|
|
3
4
|
baseURL: string;
|
|
4
5
|
apiKey: string;
|
|
@@ -7,5 +8,6 @@ export interface MorambaClientConfig {
|
|
|
7
8
|
export declare class MorambaClient {
|
|
8
9
|
auth: AuthAPI;
|
|
9
10
|
private http;
|
|
11
|
+
company: CompanyAPI;
|
|
10
12
|
constructor(config: MorambaClientConfig);
|
|
11
13
|
}
|
package/dist/MorambaClient.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { HttpClient } from "./client/HttpClient";
|
|
2
2
|
import { AuthAPI } from "./apis/auth.api";
|
|
3
|
+
import { CompanyAPI } from "./apis/company.api";
|
|
3
4
|
export class MorambaClient {
|
|
4
5
|
constructor(config) {
|
|
5
6
|
this.http = new HttpClient(config.baseURL, {
|
|
6
7
|
"Content-Type": "application/json",
|
|
7
8
|
});
|
|
8
9
|
this.auth = new AuthAPI(this.http, config.partnerId, config.apiKey);
|
|
10
|
+
this.company = new CompanyAPI(this.http, config.partnerId, config.apiKey);
|
|
9
11
|
}
|
|
10
12
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { HttpClient } from "../client/HttpClient";
|
|
2
|
+
import { CreateCompanyPayload, CreateCompanyResponse } from "../types/company.types";
|
|
3
|
+
export declare class CompanyAPI {
|
|
4
|
+
private http;
|
|
5
|
+
private partnerId;
|
|
6
|
+
private apiKey;
|
|
7
|
+
constructor(http: HttpClient, partnerId: string, apiKey: string);
|
|
8
|
+
createCompany(payload: CreateCompanyPayload, jwtToken: string): Promise<CreateCompanyResponse>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export class CompanyAPI {
|
|
2
|
+
constructor(http, partnerId, apiKey) {
|
|
3
|
+
this.http = http;
|
|
4
|
+
this.partnerId = partnerId;
|
|
5
|
+
this.apiKey = apiKey;
|
|
6
|
+
}
|
|
7
|
+
createCompany(payload, jwtToken) {
|
|
8
|
+
const fullBody = {
|
|
9
|
+
...payload,
|
|
10
|
+
partner_id: this.partnerId,
|
|
11
|
+
api_key: this.apiKey,
|
|
12
|
+
};
|
|
13
|
+
return this.http.post("/api/v1/morambacypto/create/company", fullBody, {
|
|
14
|
+
Authorization: `Bearer ${jwtToken}`,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -7,6 +7,6 @@ export declare class HttpClient {
|
|
|
7
7
|
retryDelay?: number);
|
|
8
8
|
get axiosInstance(): AxiosInstance;
|
|
9
9
|
private setupRetryInterceptor;
|
|
10
|
-
post<T = any>(url: string, data: any): Promise<T>;
|
|
10
|
+
post<T = any>(url: string, data: any, extraHeaders?: Record<string, string>): Promise<T>;
|
|
11
11
|
get<T = any>(url: string): Promise<T>;
|
|
12
12
|
}
|
|
@@ -34,8 +34,10 @@ export class HttpClient {
|
|
|
34
34
|
return this.client(config);
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
|
-
post(url, data) {
|
|
38
|
-
return this.client
|
|
37
|
+
post(url, data, extraHeaders = {}) {
|
|
38
|
+
return this.client
|
|
39
|
+
.post(url, data, { headers: extraHeaders })
|
|
40
|
+
.then((res) => res.data);
|
|
39
41
|
}
|
|
40
42
|
get(url) {
|
|
41
43
|
return this.client.get(url).then((res) => res.data);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface PaymentMethod {
|
|
2
|
+
network: string;
|
|
3
|
+
token: string;
|
|
4
|
+
address: string;
|
|
5
|
+
}
|
|
6
|
+
export interface CreateCompanyPayload {
|
|
7
|
+
payment_method: PaymentMethod;
|
|
8
|
+
name: string;
|
|
9
|
+
email: string;
|
|
10
|
+
}
|
|
11
|
+
export interface CompanyData {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
email: string;
|
|
15
|
+
partner_id: string;
|
|
16
|
+
created_at: string;
|
|
17
|
+
updated_at: string;
|
|
18
|
+
}
|
|
19
|
+
export interface CreateCompanyResponse {
|
|
20
|
+
success: boolean;
|
|
21
|
+
message: string;
|
|
22
|
+
data: CompanyData | null;
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|