@vermaysha/hoyolab-api
Advanced tools
Comparing version 2.0.1 to 2.1.0
export * from './DiaryMonth'; | ||
export * from './DiaryType'; | ||
export * from './ScheduleType'; | ||
export * from './Games'; |
@@ -8,3 +8,2 @@ import { HoyoError } from './HoyoError'; | ||
* | ||
* @throws {@link HoyoError} - if given UID is invalid | ||
* @category Main | ||
@@ -21,2 +20,8 @@ */ | ||
region; | ||
/** | ||
* Get Genshin Impact some in-game data through HoYoLab API. | ||
* | ||
* @param options Options & GenshinOption | ||
* @throws {@link HoyoError} - if given UID or Cookie is invalid | ||
*/ | ||
constructor(options) { | ||
@@ -27,2 +32,7 @@ super(options); | ||
} | ||
/** | ||
* Get daily check-in event information. | ||
* | ||
* @throws {@link HoyoError} - If an error occurs | ||
*/ | ||
async getDailyInfo() { | ||
@@ -32,2 +42,7 @@ const response = await this.request.send(GenshinRoutes.dailyInfo); | ||
} | ||
/** | ||
* Get daily check-in event all rewards. | ||
* | ||
* @throws {@link HoyoError} - If an error occurs | ||
*/ | ||
async getDailyRewards() { | ||
@@ -37,2 +52,8 @@ const response = await this.request.send(GenshinRoutes.dailyRewards); | ||
} | ||
/** | ||
* Get daily check-in event single rewards. | ||
* | ||
* @param day Types.NumericRange<0, 30> | ||
* @throws {@link HoyoError} - If an error occurs | ||
*/ | ||
async getDailyReward(day = null) { | ||
@@ -56,2 +77,7 @@ const response = await this.getDailyRewards(); | ||
} | ||
/** | ||
* Claim daily check-in event. | ||
* | ||
* @throws {@link HoyoError} - If an error occurs | ||
*/ | ||
async claimDaily() { | ||
@@ -87,2 +113,8 @@ const response = await this.request.send(GenshinRoutes.dailyClaim, 'post'); | ||
/* c8 ignore stop */ | ||
/** | ||
* Get all the characters owned by the user with complete information, | ||
* such as: constellation, artefact, weapon, and skin. | ||
* | ||
* @throws {@link HoyoError} - If an error occurs | ||
*/ | ||
async getCharacters() { | ||
@@ -97,2 +129,8 @@ this.request.withDS(); | ||
} | ||
/** | ||
* Displays a summary about the selected character. | ||
* | ||
* @param characterIds number[] | ||
* @throws {@link HoyoError} - If an error occurs | ||
*/ | ||
async getCharactersInfo(characterIds) { | ||
@@ -108,2 +146,8 @@ this.request.withDS(); | ||
} | ||
/** | ||
* Get daily notes from character, | ||
* such as: resins, expeditions, transformers recovery time. | ||
* | ||
* @throws {@link HoyoError} - If an error occurs | ||
*/ | ||
async getDailyNotes() { | ||
@@ -118,2 +162,9 @@ this.request.setParams({ | ||
} | ||
/** | ||
* Get diary summary information, | ||
* such as: current month obtained mora or primogems | ||
* | ||
* @param month DiaryMonth | ||
* @throws {@link HoyoError} - If an error occurs | ||
*/ | ||
async getDiaryInfo(month = DiaryMonth.CURRENT) { | ||
@@ -134,2 +185,10 @@ /* c8 ignore start */ | ||
} | ||
/** | ||
* Get detailed diary information, | ||
* such as: primogems history and mora history. | ||
* | ||
* @param type DiaryType | ||
* @param month DiaryMonth | ||
* @throws {@link HoyoError} - If an error occurs | ||
*/ | ||
async getDiaryDetail(type, month = DiaryMonth.CURRENT) { | ||
@@ -188,2 +247,8 @@ /* c8 ignore start */ | ||
} | ||
/** | ||
* Get detailed spiral abyss information, | ||
* such as: characters, max floor, total star, timestamp, etc. | ||
* | ||
* @param scheduleType ScheduleType | ||
*/ | ||
async getSpiralAbyss(scheduleType = ScheduleType.CURRENT) { | ||
@@ -190,0 +255,0 @@ /* c8 ignore start */ |
import { HoyoError } from './HoyoError'; | ||
import { Base } from './Base'; | ||
import { HoyolabRoutes } from './Utils'; | ||
import { Games } from './Enum'; | ||
/** | ||
@@ -16,3 +17,13 @@ * Get data from Hoyolab API | ||
*/ | ||
async getGames() { | ||
async getGames(games = Games.ALL) { | ||
/* c8 ignore start */ | ||
if (Object.values(Games).includes(games) === false) { | ||
throw new HoyoError('The given games parameter is invalid !'); | ||
} | ||
if (games !== Games.ALL) { | ||
this.request.setParams({ | ||
region: games, | ||
}); | ||
} | ||
/* c8 ignore stop */ | ||
const response = await this.request.send(HoyolabRoutes.gamesList); | ||
@@ -19,0 +30,0 @@ return response.data; |
import { HoyoError } from '../HoyoError'; | ||
import { camel2Snake } from './String'; | ||
export class Cookie { | ||
/** | ||
* Parse document.cookie string to acceptable object | ||
* | ||
* @param cookieString string | ||
* @throws {@link HoyoError} - If an error occurs | ||
*/ | ||
static parseFromString(cookieString) { | ||
@@ -46,2 +52,7 @@ const cookies = cookieString.match(/([^;\s?]+)=([^;]+)/gim); | ||
} | ||
/** | ||
* Parse Cookie object to cookie string | ||
* | ||
* @param cookie ICookie | ||
*/ | ||
static parseToString(cookie) { | ||
@@ -48,0 +59,0 @@ if (!cookie.accountId) { |
@@ -0,1 +1,6 @@ | ||
/** | ||
* Transform camel case to snake case | ||
* | ||
* @param text string | ||
*/ | ||
export function camel2Snake(text) { | ||
@@ -2,0 +7,0 @@ return text |
{ | ||
"name": "@vermaysha/hoyolab-api", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"description": "Its unofficial HoYoLab API Wrapper for getting hoyoverse some in-game data, including Genshin Impact, Honkai Impact 3rd.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -5,8 +5,11 @@ <div align="center"> | ||
<p> | ||
<a href="https://packagist.org/packages/vermaysha/hoyolab-api"> | ||
<img src="https://img.shields.io/npm/v/@vermaysha/hoyolab-api.svg?style=flat-square" alt="Latest Version on Packagist"> | ||
</a> | ||
<a href="https://github.com/vermaysha/hoyolab-api/actions/workflows/build.yml"> | ||
<img src="https://img.shields.io/github/actions/workflow/status/vermaysha/hoyolab-api/build.yml?branch=master&label=build&style=flat-square" alt="GitHub Build Action Status"> | ||
</a> | ||
<a href="https://github.com/vermaysha/hoyolab-api/actions/workflows/test.yml"> | ||
<img src="https://img.shields.io/github/actions/workflow/status/vermaysha/hoyolab-api/test.yml?branch=master&label=test&style=flat-square" alt="GitHub Test Action Status"> | ||
</a> | ||
<a href="https://github.com/vermaysha/hoyolab-api/actions/workflows/test.yml"> | ||
<img src="https://raw.githubusercontent.com/vermaysha/hoyolab-api/gh-pages/badges.svg" alt="Coverage"> | ||
</a> | ||
<a href="https://www.npmjs.com/package/@vermaysha/hoyolab-api"> | ||
@@ -18,7 +21,13 @@ <img src="https://img.shields.io/npm/dt/@vermaysha/hoyolab-api.svg?style=flat-square" alt="Total Downloads"> | ||
</a> | ||
<a href="https://github.com/vermaysha/hoyolab-api/releases/latest"> | ||
<img src="https://img.shields.io/github/release-date/vermaysha/hoyolab-api?style=flat-square" alt="GitHub Release Date - Published_At"> | ||
</a> | ||
</p> | ||
<p> | ||
<a href="https://packagist.org/packages/vermaysha/hoyolab-api"> | ||
<img src="https://img.shields.io/npm/v/@vermaysha/hoyolab-api.svg?style=flat-square" alt="Latest Version on Packagist"> | ||
</a> | ||
<img alt="GitHub package.json version" src="https://img.shields.io/github/package-json/v/vermaysha/hoyolab-api?label=github"> | ||
<a href="https://github.com/vermaysha/hoyolab-api/releases/latest"> | ||
<img src="https://img.shields.io/github/release-date/vermaysha/hoyolab-api?style=flat-square" alt="GitHub Release Date - Published_At"> | ||
</a> | ||
<img alt="node-current" src="https://img.shields.io/node/v/@vermaysha/hoyolab-api?style=flat-square"> | ||
</p> | ||
</div> | ||
@@ -45,1 +54,24 @@ | ||
5. Finally, you can copy your cookie | ||
## Documentation | ||
[![view - Documentation](https://img.shields.io/badge/view-Documentation-blue?style=for-the-badge)](https://vermaysha.github.io/hoyolab-api/stable/ 'Go to project documentation') | ||
## License | ||
@vermaysha/hoyolab-api | ||
Copyright (C) 2022 Ashary Vermaysha | ||
This library is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU Lesser General Public | ||
License as published by the Free Software Foundation; either | ||
version 2.1 of the License. | ||
This library is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public | ||
License along with this library; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
54132
52
763
75