Merge branch 'feature/no-ref/add-some-mutations' into 'master'
add some mutations for already implemented fields See merge request AnimeWatchingClub/anilist-api-wrapper!2
This commit is contained in:
commit
15fc48e7e5
220
src/anilist.ts
220
src/anilist.ts
|
@ -1,5 +1,16 @@
|
|||
import {
|
||||
MutationRateReviewArgs,
|
||||
MutationSaveActivityReplyArgs,
|
||||
MutationSaveMediaListEntryArgs,
|
||||
MutationSaveRecommendationArgs,
|
||||
MutationSaveReviewArgs,
|
||||
MutationSaveThreadArgs,
|
||||
MutationSaveThreadCommentArgs,
|
||||
MutationToggleFollowArgs,
|
||||
MutationToggleLikeArgs,
|
||||
MutationToggleThreadSubscriptionArgs,
|
||||
MutationUpdateMediaListEntriesArgs,
|
||||
MutationUpdateUserArgs,
|
||||
QueryActivityReplyArgs,
|
||||
QueryAiringScheduleArgs,
|
||||
QueryCharacterArgs,
|
||||
|
@ -619,16 +630,61 @@ export const Client = function (auth?: { token: string }) {
|
|||
})
|
||||
},
|
||||
/** Update current user options */
|
||||
UpdateUser() {
|
||||
throw "To be Implemented"
|
||||
UpdateUser(
|
||||
args: MutationUpdateUserArgs,
|
||||
fn?: Fn<typeof User>,
|
||||
) {
|
||||
operation = operation.set({
|
||||
level: 1,
|
||||
subField: "UpdateUser",
|
||||
hasSubField: true,
|
||||
variables: args,
|
||||
})
|
||||
if (!fn) operation = operation.set({ level: 2, subField: "id" })
|
||||
else {
|
||||
let tmpQuery
|
||||
fn(User({ query: tmpQuery = [operation], level: 2 }))
|
||||
operation = tmpQuery[0]
|
||||
}
|
||||
return this
|
||||
},
|
||||
/** Create or update a media list entry */
|
||||
SaveMediaListEntry() {
|
||||
throw "To be Implemented"
|
||||
SaveMediaListEntry(
|
||||
args: MutationSaveMediaListEntryArgs,
|
||||
fn?: Fn<typeof MediaList>,
|
||||
) {
|
||||
operation = operation.set({
|
||||
level: 1,
|
||||
subField: "SaveMediaListEntry",
|
||||
hasSubField: true,
|
||||
variables: args,
|
||||
})
|
||||
if (!fn) operation = operation.set({ level: 2, subField: "id" })
|
||||
else {
|
||||
let tmpQuery
|
||||
fn(MediaList({ query: tmpQuery = [operation], level: 2 }))
|
||||
operation = tmpQuery[0]
|
||||
}
|
||||
return this
|
||||
},
|
||||
/** Update multiple media list entries to the same values */
|
||||
UpdateMediaListEntries() {
|
||||
throw "To be Implemented"
|
||||
UpdateMediaListEntries(
|
||||
args: MutationUpdateMediaListEntriesArgs,
|
||||
fn?: Fn<typeof MediaList>,
|
||||
) {
|
||||
operation = operation.set({
|
||||
level: 1,
|
||||
subField: "UpdateMediaListEntries",
|
||||
hasSubField: true,
|
||||
variables: args,
|
||||
})
|
||||
if (!fn) operation = operation.set({ level: 2, subField: "id" })
|
||||
else {
|
||||
let tmpQuery
|
||||
fn(MediaList({ query: tmpQuery = [operation], level: 2 }))
|
||||
operation = tmpQuery[0]
|
||||
}
|
||||
return this
|
||||
},
|
||||
/** Delete a media list entry */
|
||||
DeleteMediaListEntry() {
|
||||
|
@ -663,24 +719,69 @@ export const Client = function (auth?: { token: string }) {
|
|||
throw "To be Implemented"
|
||||
},
|
||||
/** Create or update an activity reply */
|
||||
SaveActivityReply() {
|
||||
throw "To be Implemented"
|
||||
SaveActivityReply(
|
||||
args: MutationSaveActivityReplyArgs,
|
||||
fn?: Fn<typeof ActivityReply>,
|
||||
) {
|
||||
operation = operation.set({
|
||||
level: 1,
|
||||
subField: "SaveActivityReply",
|
||||
hasSubField: true,
|
||||
variables: args,
|
||||
})
|
||||
if (!fn) operation = operation.set({ level: 2, subField: "id" })
|
||||
else {
|
||||
let tmpQuery
|
||||
fn(ActivityReply({ query: tmpQuery = [operation], level: 2 }))
|
||||
operation = tmpQuery[0]
|
||||
}
|
||||
return this
|
||||
},
|
||||
/** Delete an activity reply of the authenticated users */
|
||||
DeleteActivityReply() {
|
||||
throw "To be Implemented"
|
||||
},
|
||||
/** Add or remove a like from a likeable type. Returns all the users who liked the same model */
|
||||
ToggleLike() {
|
||||
throw "To be Implemented"
|
||||
ToggleLike(
|
||||
args: MutationToggleLikeArgs,
|
||||
fn?: Fn<typeof User>,
|
||||
) {
|
||||
operation = operation.set({
|
||||
level: 1,
|
||||
subField: "ToggleLike",
|
||||
hasSubField: true,
|
||||
variables: args,
|
||||
})
|
||||
if (!fn) operation = operation.set({ level: 2, subField: "id" })
|
||||
else {
|
||||
let tmpQuery
|
||||
fn(User({ query: tmpQuery = [operation], level: 2 }))
|
||||
operation = tmpQuery[0]
|
||||
}
|
||||
return this
|
||||
},
|
||||
/** Add or remove a like from a likeable type. */
|
||||
ToggleLikeV2() {
|
||||
throw "To be Implemented"
|
||||
},
|
||||
/** Toggle the un/following of a user */
|
||||
ToggleFollow() {
|
||||
throw "To be Implemented"
|
||||
ToggleFollow(
|
||||
args: MutationToggleFollowArgs,
|
||||
fn?: Fn<typeof User>,
|
||||
) {
|
||||
operation = operation.set({
|
||||
level: 1,
|
||||
subField: "ToggleFollow",
|
||||
hasSubField: true,
|
||||
variables: args,
|
||||
})
|
||||
if (!fn) operation = operation.set({ level: 2, subField: "id" })
|
||||
else {
|
||||
let tmpQuery
|
||||
fn(User({ query: tmpQuery = [operation], level: 2 }))
|
||||
operation = tmpQuery[0]
|
||||
}
|
||||
return this
|
||||
},
|
||||
/** Favourite or unfavourite an anime, manga, character, staff member, or studio */
|
||||
ToggleFavourite() {
|
||||
|
@ -691,32 +792,107 @@ export const Client = function (auth?: { token: string }) {
|
|||
throw "To be Implemented"
|
||||
},
|
||||
/** Create or update a review */
|
||||
SaveReview() {
|
||||
throw "To be Implemented"
|
||||
SaveReview(
|
||||
args: MutationSaveReviewArgs,
|
||||
fn?: Fn<typeof Review>,
|
||||
) {
|
||||
operation = operation.set({
|
||||
level: 1,
|
||||
subField: "SaveReview",
|
||||
hasSubField: true,
|
||||
variables: args,
|
||||
})
|
||||
if (!fn) operation = operation.set({ level: 2, subField: "id" })
|
||||
else {
|
||||
let tmpQuery
|
||||
fn(Review({ query: tmpQuery = [operation], level: 2 }))
|
||||
operation = tmpQuery[0]
|
||||
}
|
||||
return this
|
||||
},
|
||||
/** Delete a review */
|
||||
DeleteReview() {
|
||||
throw "To be Implemented"
|
||||
},
|
||||
/** Rate a review */
|
||||
RateReview() {
|
||||
throw "To be Implemented"
|
||||
RateReview(
|
||||
args: MutationRateReviewArgs,
|
||||
fn?: Fn<typeof Review>,
|
||||
) {
|
||||
operation = operation.set({
|
||||
level: 1,
|
||||
subField: "RateReview",
|
||||
hasSubField: true,
|
||||
variables: args,
|
||||
})
|
||||
if (!fn) operation = operation.set({ level: 2, subField: "id" })
|
||||
else {
|
||||
let tmpQuery
|
||||
fn(Review({ query: tmpQuery = [operation], level: 2 }))
|
||||
operation = tmpQuery[0]
|
||||
}
|
||||
return this
|
||||
},
|
||||
/** Recommendation a media */
|
||||
SaveRecommendation() {
|
||||
throw "To be Implemented"
|
||||
SaveRecommendation(
|
||||
args: MutationSaveRecommendationArgs,
|
||||
fn?: Fn<typeof Recommendation>,
|
||||
) {
|
||||
operation = operation.set({
|
||||
level: 1,
|
||||
subField: "SaveRecommendation",
|
||||
hasSubField: true,
|
||||
variables: args,
|
||||
})
|
||||
if (!fn) operation = operation.set({ level: 2, subField: "id" })
|
||||
else {
|
||||
let tmpQuery
|
||||
fn(Recommendation({ query: tmpQuery = [operation], level: 2 }))
|
||||
operation = tmpQuery[0]
|
||||
}
|
||||
return this
|
||||
},
|
||||
/** Create or update a forum thread */
|
||||
SaveThread() {
|
||||
throw "To be Implemented"
|
||||
SaveThread(
|
||||
args: MutationSaveThreadArgs,
|
||||
fn?: Fn<typeof Thread>,
|
||||
) {
|
||||
operation = operation.set({
|
||||
level: 1,
|
||||
subField: "SaveThread",
|
||||
hasSubField: true,
|
||||
variables: args,
|
||||
})
|
||||
if (!fn) operation = operation.set({ level: 2, subField: "id" })
|
||||
else {
|
||||
let tmpQuery
|
||||
fn(Thread({ query: tmpQuery = [operation], level: 2 }))
|
||||
operation = tmpQuery[0]
|
||||
}
|
||||
return this
|
||||
},
|
||||
/** Delete a thread */
|
||||
DeleteThread() {
|
||||
throw "To be Implemented"
|
||||
},
|
||||
/** Toggle the subscription of a forum thread */
|
||||
ToggleThreadSubscription() {
|
||||
throw "To be Implemented"
|
||||
ToggleThreadSubscription(
|
||||
args: MutationToggleThreadSubscriptionArgs,
|
||||
fn?: Fn<typeof Thread>,
|
||||
) {
|
||||
operation = operation.set({
|
||||
level: 1,
|
||||
subField: "ToggleThreadSubscription",
|
||||
hasSubField: true,
|
||||
variables: args,
|
||||
})
|
||||
if (!fn) operation = operation.set({ level: 2, subField: "id" })
|
||||
else {
|
||||
let tmpQuery
|
||||
fn(Thread({ query: tmpQuery = [operation], level: 2 }))
|
||||
operation = tmpQuery[0]
|
||||
}
|
||||
return this
|
||||
},
|
||||
/** Create or update a thread comment */
|
||||
SaveThreadComment(
|
||||
|
|
Loading…
Reference in New Issue