-
Notifications
You must be signed in to change notification settings - Fork 18
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
[Done] API response types + Typescript #55
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @jameslinimk,
Thanks for the Typescript rewrite many of us are waiting for it :D
I went through the whole code and saw some bugs and Indentation errors.
Indentation
First of all, this package does not use tabs to indent the code. It uses 4 spaces, so you should too.
@Henrik-3 Should add a editorconfig file to specify this.
And also your indentations are sometimes wrong and the code is horrible to read at that parts.
Maybe adding a pre-commit hook?
Typing
Your types are looking good so far (saw one bug, see comment).
Just for you too know we have all those types already in Python code here: https://github.com/raimannma/ValorantAPI/tree/master/valo_api/responses
package/src/types/general.ts
Outdated
type BaseRank = "Iron" | "Bronze" | "Silver" | "Gold" | "Platinum" | "Diamond" | "Ascendant" | "Immortal" | ||
type SubRank = "1" | "2" | "3" | ||
export type Rank = `${BaseRank} ${SubRank}` | "Radiant" | "Unrated" | ||
|
||
type Episodes = "e1" | "e2" | "e3" | "e4" | "e5" | ||
type Acts = "a1" | "a2" | "a3" | ||
export type Season = `${Episodes}${Acts}` | ||
|
||
export type Mode = "Escalation" | "Spikerush" | "Deathmatch" | "Competitive" | "Unrated" | "Replication" | "Custom" | "Newmap" | "Snowball" | ||
export type ValorantMap = "Ascent" | "Split" | "Fracture" | "Bind" | "Breeze" | "Icebox" | "Haven" | "Pearl" | ||
export type Region = "eu" | "na" | "kr" | "ap" | "latam" | "br" | ||
export type Characters = "Astra" | "Breach" | "Brimstone" | "Chamber" | "Cypher" | "Fade" | "Jett" | "KAY/O" | "Killjoy" | "Neon" | "Omen" | "Phoenix" | "Raze" | "Reyna" | "Sage" | "Skye" | "Sova" | "Viper" | "Yoru" | ||
/** | ||
* TODO Check "Golden Gun" and "Tactical Knife" | ||
*/ | ||
export type Weapon = "Classic" | "Shorty" | "Frenzy" | "Ghost" | "Sheriff" | "Golden Gun" | "Stinger" | "Spectre" | "Bucky" | "Judge" | "Bulldog" | "Guardian" | "Phantom" | "Vandal" | "Marshal" | "Operator" | "Ares" | "Odin" | "Melee" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe doing this a bit more dynamically, cause you have to add an episode id every season
package/src/types/v3-matches.ts
Outdated
} | ||
|
||
interface KillEventMatch extends KillEvent { | ||
round: number |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It isn't. It just extends the existing KillEvent (that doesnt have the attribute round
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It isn't. It just extends the existing KillEvent (that doesnt have the attribute
round
)
Oh yeah I didn't saw the extend.
package/src/util.ts
Outdated
large: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/3/largeicon.png", | ||
small: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/3/smallicon.png" | ||
}, | ||
"Iron 2": { | ||
large: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/4/largeicon.png", | ||
small: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/4/smallicon.png" | ||
}, | ||
"Iron 3": { | ||
large: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/5/largeicon.png", | ||
small: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/5/smallicon.png" | ||
}, | ||
"Bronze 1": { | ||
large: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/6/largeicon.png", | ||
small: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/6/smallicon.png" | ||
}, | ||
"Bronze 2": { | ||
large: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/7/largeicon.png", | ||
small: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/7/smallicon.png" | ||
}, | ||
"Bronze 3": { | ||
large: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/8/largeicon.png", | ||
small: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/8/smallicon.png" | ||
}, | ||
"Silver 1": { | ||
large: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/9/largeicon.png", | ||
small: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/9/smallicon.png" | ||
}, | ||
"Silver 2": { | ||
large: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/10/largeicon.png", | ||
small: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/10/smallicon.png" | ||
}, | ||
"Silver 3": { | ||
large: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/11/largeicon.png", | ||
small: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/11/smallicon.png" | ||
}, | ||
"Gold 1": { | ||
large: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/12/largeicon.png", | ||
small: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/12/smallicon.png" | ||
}, | ||
"Gold 2": { | ||
large: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/13/largeicon.png", | ||
small: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/13/smallicon.png" | ||
}, | ||
"Gold 3": { | ||
large: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/14/largeicon.png", | ||
small: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/14/smallicon.png" | ||
}, | ||
"Platinum 1": { | ||
large: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/15/largeicon.png", | ||
small: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/15/smallicon.png" | ||
}, | ||
"Platinum 2": { | ||
large: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/16/largeicon.png", | ||
small: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/16/smallicon.png" | ||
}, | ||
"Platinum 3": { | ||
large: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/17/largeicon.png", | ||
small: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/17/smallicon.png" | ||
}, | ||
"Diamond 1": { | ||
large: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/18/largeicon.png", | ||
small: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/18/smallicon.png" | ||
}, | ||
"Diamond 2": { | ||
large: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/19/largeicon.png", | ||
small: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/19/smallicon.png" | ||
}, | ||
"Diamond 3": { | ||
large: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/20/largeicon.png", | ||
small: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/20/smallicon.png" | ||
}, | ||
"Ascendant 1": { | ||
large: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/21/largeicon.png", | ||
small: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/21/smallicon.png" | ||
}, | ||
"Ascendant 2": { | ||
large: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/22/largeicon.png", | ||
small: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/22/smallicon.png" | ||
}, | ||
"Ascendant 3": { | ||
large: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/23/largeicon.png", | ||
small: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/23/smallicon.png" | ||
}, | ||
"Immortal 1": { | ||
large: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/24/largeicon.png", | ||
small: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/24/smallicon.png" | ||
}, | ||
"Immortal 2": { | ||
large: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/25/largeicon.png", | ||
small: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/25/smallicon.png" | ||
}, | ||
"Immortal 3": { | ||
large: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/26/largeicon.png", | ||
small: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/26/smallicon.png" | ||
}, | ||
"Radiant": { | ||
large: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/27/largeicon.png", | ||
small: "https://media.valorant-api.com/competitivetiers/03621f52-342b-cf4e-4f86-9350a49c6d04/27/smallicon.png" | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also be dynamic via a get request to valorant-api.com
package/tsconfig.json
Outdated
"node_modules", | ||
"./node_modules", | ||
"./node_modules/*" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why 3 times?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly, I don't know. I just took this from the typescript website, I'll fix it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think just the first line is enough.
package/test/test.ts
Outdated
import _VAPI from "../src/index.js" | ||
const VAPI = new _VAPI() | ||
|
||
const res = await VAPI.getMMR("jameslinimk", "8868", "na") | ||
console.log(res) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be removed or replaced by real tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just using it to make sure the function works, I'll write real tests soon
package/src/index.ts
Outdated
* - Current rank and info about their rank | ||
* - RR change on their last game | ||
* - Their PUUID | ||
* - Their peak rank from every season | ||
* @param {string} name - The Riot ID username of the player | ||
* @param {string} tag - The Riot ID tag of the player | ||
* @param {Region} region - The region of the player | ||
* @param {Season} seasonFilter - Filter results based on episode and act | ||
*/ | ||
async getMMR(name: string, tag: string, region: Region, seasonFilter?: Season) { | ||
this._validateArgs({ name, tag, region }) | ||
return this._fetch<MMRResponse>(`v2/mmr/${region}/${name}/${tag}`, { filter: seasonFilter }) | ||
} | ||
|
||
/** | ||
* Gets general info about a player's rank by their PUUID | ||
* - **Returns:** | ||
* - Current rank and info about their rank | ||
* - RR change on their last game | ||
* - Their PUUID | ||
* - Their peak rank from every season | ||
* @param {string} puuid - The PUUID of the player | ||
* @param {Region} region - The region of the player | ||
* @param {Season} seasonFilter - Filter results based on episode and act | ||
*/ | ||
async getMMRByPUUID(puuid: string, region: Region, seasonFilter?: Season) { | ||
this._validateArgs({ puuid, region }) | ||
return this._fetch<MMRResponse>(`v2/by-puuid/mmr/${region}/${puuid}`, { filter: seasonFilter }) | ||
} | ||
|
||
/** | ||
* Gets the most recent 5 matches by a players Riot ID | ||
* - **Returns:** | ||
* - Info about most recent 5 matches including: | ||
* - Metadata info about the match such as length, time, map, score, etc | ||
* - Information about every player including their PUUID, Riot ID, kills, ability usage, etc | ||
* - Information about every round in the match such as plant/defuse info, etc | ||
* - Information about every kill in the game including killer, victim, assist, etc | ||
* @param {string} name - The Riot ID username of the player | ||
* @param {string} tag - The Riot ID tag of the player | ||
* @param {Region} region - The region of the player | ||
* @param {Mode} gamemodeFilter - Filter results based on gamemode | ||
* @param {ValorantMap} mapFilter - Filter results based on map | ||
* @param {any} size - Filter results based on ?? **{needs testing)** | ||
*/ | ||
async getMatches(name: string, tag: string, region: Region, gamemodeFilter?: Mode, mapFilter?: ValorantMap, size?: any) { | ||
this._validateArgs({ name, tag, region }) | ||
return this._fetch<MatchesResponse>(`v3/matches/${region}/${name}/${tag}`, { filter: gamemodeFilter, map: mapFilter, size }) | ||
} | ||
|
||
/** | ||
* Gets the most recent 5 matches by a players PUUID | ||
* - **Returns:** | ||
* - Info about most recent 5 matches including: | ||
* - Metadata info about the match such as length, time, map, score, etc | ||
* - Information about every player including their PUUID, Riot ID, kills, ability usage, etc | ||
* - Information about every round in the match such as plant/defuse info, etc | ||
* - Information about every kill in the game including killer, victim, assist, etc | ||
* @param {string} puuid - The PUUID username of the player | ||
* @param {Region} region - The region of the player | ||
* @param {Mode} gamemodeFilter - Filter results based on gamemode | ||
* @param {ValorantMap} mapFilter - Filter results based on map | ||
* @param {any} size - Filter results based on ?? **{needs testing)** | ||
*/ | ||
async getMatchesByPUUID(puuid: string, region: Region, gamemodeFilter?: Mode, mapFilter?: ValorantMap, size?: any) { | ||
this._validateArgs({ name: puuid, region }) | ||
return this._fetch<MatchesResponse>(`by-puuid/matches/${region}/${puuid}`, { filter: gamemodeFilter, map: mapFilter, size }) | ||
} | ||
|
||
/** | ||
* Get general information about a player from their Riot ID | ||
* - **Returns:** | ||
* - Their PUUID | ||
* - Their region | ||
* - Their account level | ||
* - Their current card | ||
* @param {string} name The Riot ID username of the player | ||
* @param {string} tag The Riot ID tag of the player | ||
* @param {boolean} force Force data update? | ||
*/ | ||
async getProfile(name: string, tag: string, force?: boolean) { | ||
this._validateArgs({ name, tag }) | ||
return this._fetch<ProfileResponse>(`v1/account/${name}/${tag}`, { force }) | ||
} | ||
|
||
/** | ||
* Get general information about a player from their PUUID | ||
* - **Returns:** | ||
* - Their PUUID | ||
* - Their region | ||
* - Their account level | ||
* - Their current card | ||
* @param {string} puuid The PUUID of the player | ||
* @param {boolean} force Force data update? | ||
*/ | ||
async getProfileByPUUID(puuid: string, force?: boolean) { | ||
this._validateArgs({ name: puuid }) | ||
return this._fetch<ProfileResponse>(`v1/by-puuid/account/${puuid}`, { force }) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are multiple Indentation errors in this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comment
package/src/types/v1-store-offers.ts
Outdated
@@ -0,0 +1,27 @@ | |||
export interface Cost { | |||
"85ad13f7-3d1b-5128-9eb2-7cd8ee0b5741": number |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think this is ok, it wouldn't change.
package/src/index.ts
Outdated
import type { Mode, Region, Season, ValorantMap } from "./types/general.js" | ||
import type { CrosshairResponse } from "./types/v1-crosshair.js" | ||
import type { FeaturedItemsResponse } from "./types/v1-featured-items.js" | ||
import type { ProfileResponse } from "./types/v1-profile.js" | ||
import type { StoreOffersResponse } from "./types/v1-store-offers.js" | ||
import type { VersionResponse } from "./types/v1-version.js" | ||
import type { WebsiteResponse } from "./types/v1-website.js" | ||
import type { MMRResponse } from "./types/v2-mmr.js" | ||
import type { MatchesResponse } from "./types/v3-matches.js" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you importing javascript files here?
Also this files doesn't even exist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comment
package/src/types/v1-profile.ts
Outdated
@@ -0,0 +1,19 @@ | |||
import { Region } from "./general.js" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you importing javascript files here?
Also this files doesn't even exist.
package/src/types/v2-mmr.ts
Outdated
@@ -0,0 +1,38 @@ | |||
import { Rank, Season } from "./general.js" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you importing javascript files here?
Also this files doesn't even exist.
package/src/types/v3-matches.ts
Outdated
@@ -0,0 +1,232 @@ | |||
import type { Characters, Mode, Rank, Region, ValorantMap, Weapon } from "./general.js" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you importing javascript files here?
Also this files doesn't even exist.
package/src/util.ts
Outdated
@@ -0,0 +1,161 @@ | |||
import type { Rank, ValorantMap } from "./types/general.js" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you importing javascript files here?
Also this files doesn't even exist.
.gitignore
Outdated
*.js | ||
*.js.map |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ignoring all js files?? When there are js files in this project?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comment
|
Also, do you have any answers for the 2 issues in the first message? |
|
I plan to finish all the methods by today |
@raimannma I just finished implementing all the methods and making changes, may you review them? Also, I have 2 questions,
|
The dist folder should only contain automatically built files and should not be tracked via git in my understanding. |
Oh yeah, I forgot about that. I'm currently working on better comments using tsdoc instead of jsdoc. Perhaps documentation can be made typedoc if you would like. After that, I believe it should be ready |
@raimannma Done. I changed the README a bit, if you wouldn't mind taking a look. I'm going to go to bed now. |
- name: Deploy to GH pages | ||
uses: JamesIves/github-pages-deploy-action@v4 | ||
with: | ||
folder: ./doc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If ou use this you should delete the other git push action
Done |
Holy Shit what happened here.... I have to be honest i never used TS for big projects like because of the lack of time to learn the TS stuff so for the next API update i am gonna be fcked :D @jameslinimk if u wish i will give u the |
I can also help with the TS stuff. |
Feel free to do so :D |
Just also for completeness here is the link to the auto generated docs from @jameslinimk's fork: https://jameslinimk.github.io/unofficial-valorant-api/ |
I also have a comment about endpoint versioning. In the current code you only are able to fetch the latest endpoint version so for leaderboard v2, for mmr v2 and so. But that should be possible for all endpoints. Also I would like to add the version to the method name, cause that decreases compatibility issues. If @Henrik-3 adds a new endpoint version to the api and changes the endpoint also in this package, then the users automatically fetch the new endpoint. I hope this is understandable. See also my method naming in the Python Wrapper: |
As a reminder: The current version should be 100% compatible with the last update, so we kinda need a version field in the parameter. We can change this in the future with a new major release or add them as an optional thing |
Also what needs to be done is automatic deployment to npm or at least a script to do so, but maybe doing that in a seperate PR. |
Yeah, the response should be exactly the same to do it in a minor release. |
I said that because of your idea with the method names, we can add them as an optional thing but should keep normal one without the version in it's name for now too |
Yeah, I also support both in the python wrapper. As a method name or as parameter. |
Aight so I'll
For leaderboard v2, I'll add new errors so it'll throw if any of the optional parameters are set and version is v2 as only v1 has functionality for those Maybe keep the new functions and add deprecated functions to keep backwards compatibility? I'm just making a checklist for myself here cause I'll work on this tommorow, I just came back from a flight |
Also @Henrik-3 I know it's pretty small of an issue, but some return types use different naming conventions. Like some will be camal cause while others snake case |
You mean raw & store endpoints are different to the other? |
Bro I stg I'm so tired. I thought when i was typing the endpoints I saw some camal case in non raw api stuff Sorry |
out.txt | ||
checked.txt | ||
doc/ | ||
_test.ts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used _test for other things ill remove
package/src/vapi.ts
Outdated
async getAccount({ name, tag, force }: { name: string, tag: string, force?: boolean }): Promise<APIResponse<V1AccountResponse>> { | ||
this.validateArgs({ name, tag }); | ||
return this.fetch<V1AccountResponse>(`v1/account/${name}/${tag}`, { force }); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
force here can be undefined if it's not defined.
you can add a !!
so if it's not defined
async getAccount({ name, tag, force }: { name: string, tag: string, force?: boolean }): Promise<APIResponse<V1AccountResponse>> { | |
this.validateArgs({ name, tag }); | |
return this.fetch<V1AccountResponse>(`v1/account/${name}/${tag}`, { force }); | |
} | |
async getAccount({ name, tag, force }: { name: string, tag: string, force?: boolean }): Promise<APIResponse<V1AccountResponse>> { | |
this.validateArgs({ name, tag }); | |
return this.fetch<V1AccountResponse>(`v1/account/${name}/${tag}`, { force: !!force }); | |
} |
that way if it's not passed it will be false
package/src/vapi.ts
Outdated
async getAccountByPUUID({ puuid, force }: { puuid: string, force?: boolean }): Promise<APIResponse<V1AccountResponse>> { | ||
this.validateArgs({ name: puuid }); | ||
return this.fetch<V1AccountResponse>(`v1/by-puuid/account/${puuid}`, { force }); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function used to deduce args from the object auto eliminates null values. Also default values dont work in deconstructed stuff
Getting back to this: I try (!!!) to update this to v3 that is coming soon. |
Hey, I've been using this package for a bit and saw there were no types, so I decided to make them. I was able to generate a Typescript client from the Swagger Docs, but some responses are incomplete, so I'm just going through them one by one.
Methods done