-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
195 additions
and
9 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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
node_modules/ | ||
src | ||
# Ignore files with sensitive environment variables | ||
.env | ||
.env.test | ||
|
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,183 @@ | ||
var constants = require("../constants"); | ||
var axios = require('axios'); | ||
|
||
const ONEC_AUTH_USERS_BASE_URL = constants.ONEC_NAAS_BASE_URL | ||
|
||
class naas { | ||
constructor(api_key) { | ||
this.api_key = api_key; | ||
} | ||
|
||
async mintNFT(data) { | ||
const url = `${ONEC_AUTH_USERS_BASE_URL}mintNFT/` | ||
const resData = await axios.post(url, data, { | ||
headers: { | ||
"Content-Type": "application/json", | ||
"NAAS-APIKEY": this.api_key | ||
} | ||
}) | ||
.then((response) => { | ||
return response.data; | ||
}) | ||
|
||
return resData | ||
} | ||
|
||
async mintRefNFT(data) { | ||
const url = `${ONEC_AUTH_USERS_BASE_URL}mintRefNFT/` | ||
const resData = await axios.post(url, data, { | ||
headers: { | ||
"Content-Type": "application/json", | ||
"NAAS-APIKEY": this.api_key | ||
} | ||
}) | ||
.then((response) => { | ||
return response.data; | ||
}) | ||
|
||
return resData | ||
} | ||
|
||
async checkMintStatus(txn_tracker) { | ||
const url = `${ONEC_AUTH_USERS_BASE_URL}checkMintStatus/${txn_tracker}/` | ||
const resData = await axios.get(url, { | ||
headers: { | ||
"Content-Type": "application/json", | ||
"NAAS-APIKEY": this.api_key | ||
} | ||
}) | ||
.then((response) => { | ||
return response.data; | ||
}) | ||
|
||
return resData | ||
} | ||
|
||
async fetchTokenID(nft_id) { | ||
const url = `${ONEC_AUTH_USERS_BASE_URL}fetchTokenId/${nft_id}/` | ||
const resData = await axios.get(url, { | ||
headers: { | ||
"Content-Type": "application/json", | ||
"NAAS-APIKEY": this.api_key | ||
} | ||
}) | ||
.then((response) => { | ||
return response.data; | ||
}) | ||
|
||
return resData | ||
} | ||
|
||
async fetchRefTokenID(refnft_id) { | ||
const url = `${ONEC_AUTH_USERS_BASE_URL}fetchRefTokenId/${refnft_id}/` | ||
const resData = await axios.get(url, { | ||
headers: { | ||
"Content-Type": "application/json", | ||
"NAAS-APIKEY": this.api_key | ||
} | ||
}) | ||
.then((response) => { | ||
return response.data; | ||
}) | ||
|
||
return resData | ||
} | ||
|
||
async getTokenMetadataHash(token_id) { | ||
const url = `${ONEC_AUTH_USERS_BASE_URL}getTokenMetadataHash/${token_id}/` | ||
const resData = await axios.get(url, { | ||
headers: { | ||
"Content-Type": "application/json", | ||
"NAAS-APIKEY": this.api_key | ||
} | ||
}) | ||
.then((response) => { | ||
return response.data; | ||
}) | ||
|
||
return resData | ||
} | ||
|
||
async getRefNFTs(parent_id) { | ||
const url = `${ONEC_AUTH_USERS_BASE_URL}getRefNFTs/${parent_id}/` | ||
const resData = await axios.get(url, { | ||
headers: { | ||
"Content-Type": "application/json", | ||
"NAAS-APIKEY": this.api_key | ||
} | ||
}) | ||
.then((response) => { | ||
return response.data; | ||
}) | ||
|
||
return resData | ||
} | ||
|
||
async getIpfsFiles() { | ||
const url = `${ONEC_AUTH_USERS_BASE_URL}ipfsFile/` | ||
const resData = await axios.get(url, { | ||
headers: { | ||
"Content-Type": "application/json", | ||
"NAAS-APIKEY": this.api_key | ||
} | ||
}) | ||
.then((response) => { | ||
return response.data; | ||
}) | ||
|
||
return resData | ||
} | ||
|
||
async uploadIpfsFiles(files) { | ||
const url = `${ONEC_AUTH_USERS_BASE_URL}ipfsFile/` | ||
const resData = await axios.post(url, files, { | ||
headers: { | ||
"Content-Type": "multipart/form-data", | ||
"NAAS-APIKEY": this.api_key | ||
} | ||
}) | ||
.then((response) => { | ||
return response.data; | ||
}) | ||
|
||
return resData | ||
} | ||
|
||
async getIpfsMetaData() { | ||
const url = `${ONEC_AUTH_USERS_BASE_URL}ipfsMetaData/` | ||
const resData = await axios.get(url, { | ||
headers: { | ||
"Content-Type": "application/json", | ||
"NAAS-APIKEY": this.api_key | ||
} | ||
}) | ||
.then((response) => { | ||
return response.data; | ||
}) | ||
|
||
return resData | ||
} | ||
|
||
async uploadIpfsMetaData(data) { | ||
const url = `${ONEC_AUTH_USERS_BASE_URL}ipfsMetaData/` | ||
const resData = await axios.post(url, data, { | ||
headers: { | ||
"Content-Type": "application/json", | ||
"NAAS-APIKEY": this.api_key | ||
} | ||
}) | ||
.then((response) => { | ||
return response.data; | ||
}) | ||
|
||
return resData | ||
} | ||
|
||
verifyKey() { | ||
return this.api_key | ||
} | ||
} | ||
|
||
module.exports = { | ||
naas | ||
} |
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