ps99-api 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.
- package/.github/workflows/release-on-main.yml +29 -0
- package/.idea/modules.xml +8 -0
- package/.idea/node-ps99-api.iml +12 -0
- package/.idea/vcs.xml +6 -0
- package/.release.rc +8 -0
- package/LICENSE.txt +21 -0
- package/README.md +25 -0
- package/dist/__tests__/ps99-api.js +150 -0
- package/dist/common.js +2 -0
- package/dist/index.js +17 -0
- package/dist/params/clans.js +2 -0
- package/dist/ps99-api.js +71 -0
- package/dist/request-client/axios.js +28 -0
- package/dist/request-client/common.js +2 -0
- package/dist/responses/activeClanBattle.js +2 -0
- package/dist/responses/clan.js +2 -0
- package/dist/responses/clans.js +2 -0
- package/dist/responses/collection.js +2 -0
- package/dist/responses/collections.js +2 -0
- package/dist/responses/exists.js +2 -0
- package/dist/responses/rap.js +2 -0
- package/jest.config.js +5 -0
- package/package.json +48 -0
- package/src/__tests__/ps99-api.ts +159 -0
- package/src/common.ts +2 -0
- package/src/index.ts +1 -0
- package/src/params/clans.ts +9 -0
- package/src/ps99-api.ts +104 -0
- package/src/request-client/axios.ts +27 -0
- package/src/request-client/common.ts +13 -0
- package/src/responses/activeClanBattle.ts +20 -0
- package/src/responses/clan.ts +65 -0
- package/src/responses/clans.ts +25 -0
- package/src/responses/collection.ts +1261 -0
- package/src/responses/collections.ts +3 -0
- package/src/responses/exists.ts +21 -0
- package/src/responses/rap.ts +30 -0
- package/tsconfig.build.json +10 -0
- package/tsconfig.json +9 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
name: Semantic Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: write # to be able to publish a GitHub release
|
|
11
|
+
issues: write # to be able to comment on released issues
|
|
12
|
+
pull-requests: write # to be able to comment on released pull requests
|
|
13
|
+
id-token: write # to enable use of OIDC for npm provenance
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
release:
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
|
+
- uses: actions/setup-node@v4
|
|
21
|
+
with:
|
|
22
|
+
node-version: 20
|
|
23
|
+
- run: npm ci
|
|
24
|
+
- run: npm run test
|
|
25
|
+
- run: npm run build
|
|
26
|
+
- env:
|
|
27
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
28
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
29
|
+
run: npx semantic-release
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/node-ps99-api.iml" filepath="$PROJECT_DIR$/.idea/node-ps99-api.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="WEB_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$">
|
|
5
|
+
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
|
6
|
+
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
|
7
|
+
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
|
8
|
+
</content>
|
|
9
|
+
<orderEntry type="inheritedJdk" />
|
|
10
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
11
|
+
</component>
|
|
12
|
+
</module>
|
package/.idea/vcs.xml
ADDED
package/.release.rc
ADDED
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Joseph Lawson
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# ps99-api
|
|
2
|
+
|
|
3
|
+
Pet Simulator Public API wrapper written in Typescript.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
`npm install ps99-api` or `yarn add ps99-api`
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import {PetSimulator99API} from 'ps99-api';
|
|
13
|
+
|
|
14
|
+
const ps99api = new PetSimulator99API()
|
|
15
|
+
await ps99api.getClan('CAT');
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Notes
|
|
19
|
+
|
|
20
|
+
1. `{{URL}}/api/exists` seems to only return pets for now.
|
|
21
|
+
|
|
22
|
+
## Links
|
|
23
|
+
|
|
24
|
+
* [ps99-public-api-docs](https://github.com/BIG-Games-LLC/ps99-public-api-docs)
|
|
25
|
+
* [Pet Simulator Public API](https://docs.biggamesapi.io/)
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const globals_1 = require("@jest/globals");
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const ps99_api_1 = require("../ps99-api");
|
|
9
|
+
const axios_2 = require("../request-client/axios");
|
|
10
|
+
globals_1.jest.mock("axios");
|
|
11
|
+
let api;
|
|
12
|
+
const mockedAxios = axios_1.default;
|
|
13
|
+
(0, globals_1.beforeEach)(() => {
|
|
14
|
+
mockedAxios.mockClear();
|
|
15
|
+
mockedAxios.mockReturnValue(Promise.resolve({ data: {} }));
|
|
16
|
+
api = new ps99_api_1.PetSimulator99API({ requestClient: (0, axios_2.getAxiosRequest)(mockedAxios) });
|
|
17
|
+
});
|
|
18
|
+
(0, globals_1.describe)("Pet Simulator Public API Tests", () => {
|
|
19
|
+
(0, globals_1.test)("get Collections", async () => {
|
|
20
|
+
await api.getCollections();
|
|
21
|
+
(0, globals_1.expect)(axios_1.default).toBeCalledWith({
|
|
22
|
+
method: "GET",
|
|
23
|
+
params: {},
|
|
24
|
+
responseEncoding: "utf8",
|
|
25
|
+
responseType: "json",
|
|
26
|
+
url: "https://biggamesapi.io/api/collections",
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
(0, globals_1.test)("get Collection Achievements", async () => {
|
|
30
|
+
await api.getCollection("Achievements");
|
|
31
|
+
(0, globals_1.expect)(axios_1.default).toBeCalledWith({
|
|
32
|
+
method: "GET",
|
|
33
|
+
params: {},
|
|
34
|
+
responseEncoding: "utf8",
|
|
35
|
+
responseType: "json",
|
|
36
|
+
url: "https://biggamesapi.io/api/collection/Achievements",
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
(0, globals_1.describe)("get Clans", () => {
|
|
40
|
+
(0, globals_1.test)("defaults", async () => {
|
|
41
|
+
await api.getClans();
|
|
42
|
+
(0, globals_1.expect)(axios_1.default).toBeCalledWith({
|
|
43
|
+
method: "GET",
|
|
44
|
+
params: {
|
|
45
|
+
page: 1,
|
|
46
|
+
pageSize: 10,
|
|
47
|
+
sort: "Points",
|
|
48
|
+
sortOrder: "desc",
|
|
49
|
+
},
|
|
50
|
+
responseEncoding: "utf8",
|
|
51
|
+
responseType: "json",
|
|
52
|
+
url: "https://biggamesapi.io/api/clans",
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
(0, globals_1.test)("different options", async () => {
|
|
56
|
+
await api.getClans({
|
|
57
|
+
page: 1,
|
|
58
|
+
pageSize: 10,
|
|
59
|
+
sort: "Created",
|
|
60
|
+
sortOrder: "desc",
|
|
61
|
+
});
|
|
62
|
+
(0, globals_1.expect)(axios_1.default).toBeCalledWith({
|
|
63
|
+
method: "GET",
|
|
64
|
+
params: {
|
|
65
|
+
page: 1,
|
|
66
|
+
pageSize: 10,
|
|
67
|
+
sort: "Created",
|
|
68
|
+
sortOrder: "desc",
|
|
69
|
+
},
|
|
70
|
+
responseEncoding: "utf8",
|
|
71
|
+
responseType: "json",
|
|
72
|
+
url: "https://biggamesapi.io/api/clans",
|
|
73
|
+
});
|
|
74
|
+
await api.getClans({
|
|
75
|
+
page: 2,
|
|
76
|
+
sortOrder: "desc",
|
|
77
|
+
});
|
|
78
|
+
(0, globals_1.expect)(axios_1.default).toBeCalledWith({
|
|
79
|
+
method: "GET",
|
|
80
|
+
params: {
|
|
81
|
+
page: 2,
|
|
82
|
+
pageSize: 10,
|
|
83
|
+
sort: "Points",
|
|
84
|
+
sortOrder: "desc",
|
|
85
|
+
},
|
|
86
|
+
responseEncoding: "utf8",
|
|
87
|
+
responseType: "json",
|
|
88
|
+
url: "https://biggamesapi.io/api/clans",
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
(0, globals_1.test)("get Clan", async () => {
|
|
93
|
+
await api.getClan("CAT");
|
|
94
|
+
(0, globals_1.expect)(axios_1.default).toBeCalledWith({
|
|
95
|
+
method: "GET",
|
|
96
|
+
params: {},
|
|
97
|
+
responseEncoding: "utf8",
|
|
98
|
+
responseType: "json",
|
|
99
|
+
url: "https://biggamesapi.io/api/clan/CAT",
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
(0, globals_1.test)("get Exists", async () => {
|
|
103
|
+
await api.getExists();
|
|
104
|
+
(0, globals_1.expect)(axios_1.default).toBeCalledWith({
|
|
105
|
+
method: "GET",
|
|
106
|
+
params: {},
|
|
107
|
+
responseEncoding: "utf8",
|
|
108
|
+
responseType: "json",
|
|
109
|
+
url: "https://biggamesapi.io/api/exists",
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
(0, globals_1.test)("get RAP", async () => {
|
|
113
|
+
await api.getRAP();
|
|
114
|
+
(0, globals_1.expect)(axios_1.default).toBeCalledWith({
|
|
115
|
+
method: "GET",
|
|
116
|
+
params: {},
|
|
117
|
+
responseEncoding: "utf8",
|
|
118
|
+
responseType: "json",
|
|
119
|
+
url: "https://biggamesapi.io/api/rap",
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
(0, globals_1.test)("get ActiveClanBattle", async () => {
|
|
123
|
+
await api.getActiveClanBattle();
|
|
124
|
+
(0, globals_1.expect)(axios_1.default).toBeCalledWith({
|
|
125
|
+
method: "GET",
|
|
126
|
+
params: {},
|
|
127
|
+
responseEncoding: "utf8",
|
|
128
|
+
responseType: "json",
|
|
129
|
+
url: "https://biggamesapi.io/api/activeClanBattle",
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
(0, globals_1.test)("get Image", async () => {
|
|
133
|
+
await api.getImage("14615650278");
|
|
134
|
+
(0, globals_1.expect)(axios_1.default).toBeCalledWith({
|
|
135
|
+
method: "GET",
|
|
136
|
+
params: {},
|
|
137
|
+
responseEncoding: "BINARY",
|
|
138
|
+
responseType: "arraybuffer",
|
|
139
|
+
url: "https://biggamesapi.io/api/image/14615650278",
|
|
140
|
+
});
|
|
141
|
+
await api.getImage("rbxassetid://14976576332");
|
|
142
|
+
(0, globals_1.expect)(axios_1.default).toBeCalledWith({
|
|
143
|
+
method: "GET",
|
|
144
|
+
params: {},
|
|
145
|
+
responseEncoding: "BINARY",
|
|
146
|
+
responseType: "arraybuffer",
|
|
147
|
+
url: "https://biggamesapi.io/api/image/14976576332",
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
});
|
package/dist/common.js
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./ps99-api"), exports);
|
package/dist/ps99-api.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PetSimulator99API = void 0;
|
|
4
|
+
const axios_1 = require("./request-client/axios");
|
|
5
|
+
class PetSimulator99API {
|
|
6
|
+
requestClient;
|
|
7
|
+
constructor(params) {
|
|
8
|
+
this.requestClient =
|
|
9
|
+
params && params.requestClient ? params.requestClient : (0, axios_1.getAxiosRequest)();
|
|
10
|
+
}
|
|
11
|
+
request(path, { params, responseType, responseEncoding, } = {
|
|
12
|
+
params: {},
|
|
13
|
+
responseType: "json",
|
|
14
|
+
responseEncoding: "utf8",
|
|
15
|
+
}) {
|
|
16
|
+
params = params || {};
|
|
17
|
+
responseType = responseType || "json";
|
|
18
|
+
responseEncoding = responseEncoding || "utf8";
|
|
19
|
+
return this.requestClient.send({
|
|
20
|
+
method: "GET",
|
|
21
|
+
url: `https://biggamesapi.io${path}`,
|
|
22
|
+
params,
|
|
23
|
+
responseType,
|
|
24
|
+
responseEncoding,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
getCollections() {
|
|
28
|
+
return this.request("/api/collections");
|
|
29
|
+
}
|
|
30
|
+
getCollection(collection) {
|
|
31
|
+
return this.request(`/api/collection/${collection}`);
|
|
32
|
+
}
|
|
33
|
+
getClans(params) {
|
|
34
|
+
let page;
|
|
35
|
+
let pageSize;
|
|
36
|
+
let sort;
|
|
37
|
+
let sortOrder;
|
|
38
|
+
if (params) {
|
|
39
|
+
({ page, pageSize, sort, sortOrder } = params);
|
|
40
|
+
}
|
|
41
|
+
params = {
|
|
42
|
+
page: page || 1,
|
|
43
|
+
pageSize: pageSize || 10,
|
|
44
|
+
sort: sort || "Points",
|
|
45
|
+
sortOrder: sortOrder || "desc",
|
|
46
|
+
};
|
|
47
|
+
return this.request("/api/clans", { params });
|
|
48
|
+
}
|
|
49
|
+
getClan(name) {
|
|
50
|
+
return this.request(`/api/clan/${name}`);
|
|
51
|
+
}
|
|
52
|
+
getExists() {
|
|
53
|
+
return this.request(`/api/exists`);
|
|
54
|
+
}
|
|
55
|
+
getRAP() {
|
|
56
|
+
return this.request(`/api/rap`);
|
|
57
|
+
}
|
|
58
|
+
getActiveClanBattle() {
|
|
59
|
+
return this.request(`/api/activeClanBattle`);
|
|
60
|
+
}
|
|
61
|
+
getImage(rbxassetid) {
|
|
62
|
+
if (rbxassetid.startsWith("rbxassetid://")) {
|
|
63
|
+
rbxassetid = rbxassetid.slice(13);
|
|
64
|
+
}
|
|
65
|
+
return this.request(`/api/image/${rbxassetid}`, {
|
|
66
|
+
responseType: "arraybuffer",
|
|
67
|
+
responseEncoding: "BINARY",
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.PetSimulator99API = PetSimulator99API;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getAxiosRequest = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
function getAxiosRequest(instance) {
|
|
9
|
+
return {
|
|
10
|
+
async send(options) {
|
|
11
|
+
try {
|
|
12
|
+
const { data } = await (instance ? instance(options) : (0, axios_1.default)(options));
|
|
13
|
+
return data;
|
|
14
|
+
}
|
|
15
|
+
catch (e) {
|
|
16
|
+
if (isAxiosError(e)) {
|
|
17
|
+
const message = e?.response?.data?.message || e.message;
|
|
18
|
+
throw new Error(`${options.method} ${options.url}: ${message}`);
|
|
19
|
+
}
|
|
20
|
+
throw e;
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
exports.getAxiosRequest = getAxiosRequest;
|
|
26
|
+
function isAxiosError(err) {
|
|
27
|
+
return Object.prototype.hasOwnProperty.call(err, "isAxiosError");
|
|
28
|
+
}
|
package/jest.config.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ps99-api",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Pet Simulator Public API wrapper written in Typescript.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"author": "joekiller",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "npx jest",
|
|
11
|
+
"build": "npx tsc --project tsconfig.build.json",
|
|
12
|
+
"semantic-release": "npx semantic-release",
|
|
13
|
+
"format": "npx prettier --write \"src/**/*.ts\""
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"pet simulator 99"
|
|
17
|
+
],
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@jest/globals": "^29.7.0",
|
|
20
|
+
"@semantic-release/git": "^10.0.1",
|
|
21
|
+
"@tsconfig/node20": "^20.1.3",
|
|
22
|
+
"@types/jest": "^29.5.12",
|
|
23
|
+
"@types/node": "^20.0.0",
|
|
24
|
+
"cz-conventional-changelog": "^3.3.0",
|
|
25
|
+
"jest": "^29.7.0",
|
|
26
|
+
"prettier": "^3.2.5",
|
|
27
|
+
"semantic-release": "^23.0.6",
|
|
28
|
+
"ts-jest": "^29.1.2",
|
|
29
|
+
"typescript": "^5.4.3"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"axios": "^1.6.8"
|
|
33
|
+
},
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "https://github.com/joekiller/node-ps99-api.git"
|
|
37
|
+
},
|
|
38
|
+
"config": {
|
|
39
|
+
"commitizen": {
|
|
40
|
+
"path": "./node_modules/cz-conventional-changelog"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"release": {
|
|
44
|
+
"branches": [
|
|
45
|
+
"main"
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, jest, test } from "@jest/globals";
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
import { PetSimulator99API } from "../ps99-api";
|
|
4
|
+
import { getAxiosRequest } from "../request-client/axios";
|
|
5
|
+
|
|
6
|
+
jest.mock("axios");
|
|
7
|
+
|
|
8
|
+
let api: PetSimulator99API;
|
|
9
|
+
|
|
10
|
+
const mockedAxios = axios as jest.Mocked<typeof axios>;
|
|
11
|
+
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
mockedAxios.mockClear();
|
|
14
|
+
mockedAxios.mockReturnValue(Promise.resolve({ data: {} }));
|
|
15
|
+
api = new PetSimulator99API({ requestClient: getAxiosRequest(mockedAxios) });
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
describe("Pet Simulator Public API Tests", () => {
|
|
19
|
+
test("get Collections", async () => {
|
|
20
|
+
await api.getCollections();
|
|
21
|
+
expect(axios).toBeCalledWith({
|
|
22
|
+
method: "GET",
|
|
23
|
+
params: {},
|
|
24
|
+
responseEncoding: "utf8",
|
|
25
|
+
responseType: "json",
|
|
26
|
+
url: "https://biggamesapi.io/api/collections",
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test("get Collection Achievements", async () => {
|
|
31
|
+
await api.getCollection("Achievements");
|
|
32
|
+
expect(axios).toBeCalledWith({
|
|
33
|
+
method: "GET",
|
|
34
|
+
params: {},
|
|
35
|
+
responseEncoding: "utf8",
|
|
36
|
+
responseType: "json",
|
|
37
|
+
url: "https://biggamesapi.io/api/collection/Achievements",
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
describe("get Clans", () => {
|
|
42
|
+
test("defaults", async () => {
|
|
43
|
+
await api.getClans();
|
|
44
|
+
expect(axios).toBeCalledWith({
|
|
45
|
+
method: "GET",
|
|
46
|
+
params: {
|
|
47
|
+
page: 1,
|
|
48
|
+
pageSize: 10,
|
|
49
|
+
sort: "Points",
|
|
50
|
+
sortOrder: "desc",
|
|
51
|
+
},
|
|
52
|
+
responseEncoding: "utf8",
|
|
53
|
+
responseType: "json",
|
|
54
|
+
url: "https://biggamesapi.io/api/clans",
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test("different options", async () => {
|
|
59
|
+
await api.getClans({
|
|
60
|
+
page: 1,
|
|
61
|
+
pageSize: 10,
|
|
62
|
+
sort: "Created",
|
|
63
|
+
sortOrder: "desc",
|
|
64
|
+
});
|
|
65
|
+
expect(axios).toBeCalledWith({
|
|
66
|
+
method: "GET",
|
|
67
|
+
params: {
|
|
68
|
+
page: 1,
|
|
69
|
+
pageSize: 10,
|
|
70
|
+
sort: "Created",
|
|
71
|
+
sortOrder: "desc",
|
|
72
|
+
},
|
|
73
|
+
responseEncoding: "utf8",
|
|
74
|
+
responseType: "json",
|
|
75
|
+
url: "https://biggamesapi.io/api/clans",
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
await api.getClans({
|
|
79
|
+
page: 2,
|
|
80
|
+
sortOrder: "desc",
|
|
81
|
+
});
|
|
82
|
+
expect(axios).toBeCalledWith({
|
|
83
|
+
method: "GET",
|
|
84
|
+
params: {
|
|
85
|
+
page: 2,
|
|
86
|
+
pageSize: 10,
|
|
87
|
+
sort: "Points",
|
|
88
|
+
sortOrder: "desc",
|
|
89
|
+
},
|
|
90
|
+
responseEncoding: "utf8",
|
|
91
|
+
responseType: "json",
|
|
92
|
+
url: "https://biggamesapi.io/api/clans",
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test("get Clan", async () => {
|
|
98
|
+
await api.getClan("CAT");
|
|
99
|
+
expect(axios).toBeCalledWith({
|
|
100
|
+
method: "GET",
|
|
101
|
+
params: {},
|
|
102
|
+
responseEncoding: "utf8",
|
|
103
|
+
responseType: "json",
|
|
104
|
+
url: "https://biggamesapi.io/api/clan/CAT",
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
test("get Exists", async () => {
|
|
109
|
+
await api.getExists();
|
|
110
|
+
expect(axios).toBeCalledWith({
|
|
111
|
+
method: "GET",
|
|
112
|
+
params: {},
|
|
113
|
+
responseEncoding: "utf8",
|
|
114
|
+
responseType: "json",
|
|
115
|
+
url: "https://biggamesapi.io/api/exists",
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
test("get RAP", async () => {
|
|
120
|
+
await api.getRAP();
|
|
121
|
+
expect(axios).toBeCalledWith({
|
|
122
|
+
method: "GET",
|
|
123
|
+
params: {},
|
|
124
|
+
responseEncoding: "utf8",
|
|
125
|
+
responseType: "json",
|
|
126
|
+
url: "https://biggamesapi.io/api/rap",
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test("get ActiveClanBattle", async () => {
|
|
131
|
+
await api.getActiveClanBattle();
|
|
132
|
+
expect(axios).toBeCalledWith({
|
|
133
|
+
method: "GET",
|
|
134
|
+
params: {},
|
|
135
|
+
responseEncoding: "utf8",
|
|
136
|
+
responseType: "json",
|
|
137
|
+
url: "https://biggamesapi.io/api/activeClanBattle",
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
test("get Image", async () => {
|
|
142
|
+
await api.getImage("14615650278");
|
|
143
|
+
expect(axios).toBeCalledWith({
|
|
144
|
+
method: "GET",
|
|
145
|
+
params: {},
|
|
146
|
+
responseEncoding: "BINARY",
|
|
147
|
+
responseType: "arraybuffer",
|
|
148
|
+
url: "https://biggamesapi.io/api/image/14615650278",
|
|
149
|
+
});
|
|
150
|
+
await api.getImage("rbxassetid://14976576332");
|
|
151
|
+
expect(axios).toBeCalledWith({
|
|
152
|
+
method: "GET",
|
|
153
|
+
params: {},
|
|
154
|
+
responseEncoding: "BINARY",
|
|
155
|
+
responseType: "arraybuffer",
|
|
156
|
+
url: "https://biggamesapi.io/api/image/14976576332",
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
});
|
package/src/common.ts
ADDED
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./ps99-api";
|