cytracid 1.0.0

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.
Files changed (2) hide show
  1. package/index.js +41 -0
  2. package/package.json +19 -0
package/index.js ADDED
@@ -0,0 +1,41 @@
1
+ const axios = require('axios');
2
+
3
+ class CytraCID {
4
+ constructor(apiKey, baseUrl = 'http://31.57.156.109/api/v1/public') {
5
+ this.apiKey = apiKey;
6
+ this.api = axios.create({
7
+ baseURL: baseUrl.replace(/\/$/, ''),
8
+ headers: {
9
+ 'Authorization': `Bearer ${this.apiKey}`,
10
+ 'Content-Type': 'application/json'
11
+ }
12
+ });
13
+ }
14
+
15
+ async getBalance() {
16
+ const res = await this.api.get('/balance');
17
+ return res.data;
18
+ }
19
+
20
+ async getStock() {
21
+ const res = await this.api.get('/stock');
22
+ return res.data;
23
+ }
24
+
25
+ async buy(isReserved = true) {
26
+ const res = await this.api.post('/buy', { is_reserved: isReserved });
27
+ return res.data;
28
+ }
29
+
30
+ async getPurchase(purchaseId) {
31
+ const res = await this.api.get(`/purchase/${purchaseId}`);
32
+ return res.data;
33
+ }
34
+
35
+ async refresh(purchaseId) {
36
+ const res = await this.api.post('/refresh', { purchase_id: purchaseId });
37
+ return res.data;
38
+ }
39
+ }
40
+
41
+ module.exports = CytraCID;
package/package.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "cytracid",
3
+ "version": "1.0.0",
4
+ "description": "Official API Wrapper for CytraCID",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "keywords": [
10
+ "cytracid",
11
+ "growtopia",
12
+ "api"
13
+ ],
14
+ "author": "L33T",
15
+ "license": "ISC",
16
+ "dependencies": {
17
+ "axios": "^1.4.0"
18
+ }
19
+ }