Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add getSupportedCoins, and createDepositAddress Methods #5

Merged
merged 1 commit into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
246 changes: 246 additions & 0 deletions api-spec/Flincap API.postman_collection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
{
"info": {
"_postman_id": "238791cc-18c5-4082-816a-30ccfd0c8c66",
"name": "Flincap API",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "25720052"
},
"item": [
{
"name": "Get Rate",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{apiKey}}",
"type": "string"
}
]
},
"method": "GET",
"header": [],
"url": {
"raw": "{{baseUrl}}/v1/get-rate?selectedCrypt=USDT&selectedFiat=NGN",
"host": [
"{{baseUrl}}"
],
"path": [
"v1",
"get-rate"
],
"query": [
{
"key": "selectedCrypt",
"value": "USDT"
},
{
"key": "selectedFiat",
"value": "NGN"
}
]
}
},
"response": []
},
{
"name": "Get Exchange",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{apiKey}}",
"type": "string"
}
]
},
"method": "GET",
"header": [],
"url": {
"raw": "{{baseUrl}}/v1/get-exchange",
"host": [
"{{baseUrl}}"
],
"path": [
"v1",
"get-exchange"
]
}
},
"response": []
},
{
"name": "Record Transaction",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{apiKey}}",
"type": "string"
}
]
},
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"selectedCrypt\": \"USDT\",\n \"selectedFiat\": \"NGN\",\n \"email\": \"string\",\n \"bankName\": \"string\",\n \"bankCode\": \"string\",\n \"accNum\": \"string\",\n \"accName\": \"string\",\n \"amountFiat\": \"string\",\n \"amountCrypt\": \"string\",\n \"rate\": \"string\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/v1/create-transaction",
"host": [
"{{baseUrl}}"
],
"path": [
"v1",
"create-transaction"
]
}
},
"response": []
},
{
"name": "Get Transaction",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{apiKey}}",
"type": "string"
}
]
},
"method": "GET",
"header": [],
"url": {
"raw": "{{baseUrl}}/v1/get-transactions/{transaction_id}",
"host": [
"{{baseUrl}}"
],
"path": [
"v1",
"get-transactions",
"{transaction_id}"
]
}
},
"response": []
},
{
"name": "Get History",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{apiKey}}",
"type": "string"
}
]
},
"method": "GET",
"header": [],
"url": {
"raw": "{{baseUrl}}/api/v1/get-transactions?transactionType=DEPOSIT&selectedFiat=CRYPTO",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v1",
"get-transactions"
],
"query": [
{
"key": "transactionType",
"value": "DEPOSIT"
},
{
"key": "selectedFiat",
"value": "CRYPTO"
}
]
}
},
"response": []
},
{
"name": "Get Supported Coins",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{apiKey}}",
"type": "string"
}
]
},
"method": "GET",
"header": [],
"url": {
"raw": "{{baseUrl}}/v1/supported-coins",
"host": [
"{{baseUrl}}"
],
"path": [
"v1",
"supported-coins"
]
}
},
"response": []
},
{
"name": "Create Deposit Address",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{apiKey}}",
"type": "string"
}
]
},
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"selectedCrypt\": \"USDT\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/v1/create-deposit-address",
"host": [
"{{baseUrl}}"
],
"path": [
"v1",
"create-deposit-address"
]
}
},
"response": []
}
]
}
34 changes: 33 additions & 1 deletion openapi.yml → api-spec/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ info:
title: Flincap API
version: 1.0.0
servers:
- url: http://flincap.app
- url: http://{{baseurl}}
components:
securitySchemes:
bearerAuth:
Expand Down Expand Up @@ -114,3 +114,35 @@ paths:
description: Successful response
content:
application/json: {}
/v1/supported-coins:
get:
tags:
- default
summary: Get Supported Coins
security:
- bearerAuth: []
responses:
'200':
description: Successful response
content:
application/json: {}
/v1/create-deposit-address:
post:
tags:
- default
summary: Create Deposit Address
requestBody:
content:
application/json:
schema:
type: object
example:
selectedCrypt: USDT
security:
- bearerAuth: []
responses:
'200':
description: Successful response
content:
application/json: {}

6 changes: 5 additions & 1 deletion examples/backend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ apiClient.getRate('USDT', 'NGN').then((response) => {
console.log(response.data); // Process the rate data here
}).catch((error) => {
console.error(error.message, error.code);
});
});

apiClient.getSupportedCoins().then(response => {
console.log(response);
}).catch(err => console.error(err));
22 changes: 22 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,28 @@ export class FlincapApiClient {
}
}

// New method to fetch supported coins
public async getSupportedCoins(): Promise<FlincapApiResponse<any>> {
try {
const response: AxiosResponse<FlincapApiResponse<any>> = await this.axiosInstance.get('/v1/supported-coins');

return response.data;
} catch (error) {
throw this.handleRequestError(error);
}
}

// New method to create deposit address
public async createDepositAddress(selectedCrypt: string): Promise<FlincapApiResponse<any>> {
try {
const response: AxiosResponse<FlincapApiResponse<any>> = await this.axiosInstance.post('/v1/create-deposit-address', { selectedCrypt });

return response.data;
} catch (error) {
throw this.handleRequestError(error);
}
}

private handleRequestError(error: any): FlincapError {
if (error.response && error.response.data) {
return {
Expand Down