/* tslint:disable */ // @ts-nocheck /* eslint-disable */ /** * Audius API * * The version of the OpenAPI document: 1.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ import * as runtime from '../runtime'; import type { CommentRepliesResponse, CommentResponse, CreateCommentRequestBody, CreateCommentResponse, PinCommentRequestBody, ReactCommentRequestBody, UnclaimedIdResponse, UpdateCommentRequestBody, WriteResponse, } from '../models'; import { CommentRepliesResponseFromJSON, CommentRepliesResponseToJSON, CommentResponseFromJSON, CommentResponseToJSON, CreateCommentRequestBodyFromJSON, CreateCommentRequestBodyToJSON, CreateCommentResponseFromJSON, CreateCommentResponseToJSON, PinCommentRequestBodyFromJSON, PinCommentRequestBodyToJSON, ReactCommentRequestBodyFromJSON, ReactCommentRequestBodyToJSON, UnclaimedIdResponseFromJSON, UnclaimedIdResponseToJSON, UpdateCommentRequestBodyFromJSON, UpdateCommentRequestBodyToJSON, WriteResponseFromJSON, WriteResponseToJSON, } from '../models'; export interface CreateCommentRequest { userId: string; metadata: CreateCommentRequestBody; } export interface DeleteCommentRequest { commentId: string; userId: string; } export interface GetCommentRequest { commentId: string; } export interface GetCommentRepliesRequest { commentId: string; offset?: number; limit?: number; userId?: string; } export interface PinCommentRequest { commentId: string; userId: string; metadata: PinCommentRequestBody; } export interface ReactToCommentRequest { commentId: string; userId: string; metadata: ReactCommentRequestBody; } export interface ReportCommentRequest { commentId: string; userId: string; } export interface UnpinCommentRequest { commentId: string; userId: string; metadata: PinCommentRequestBody; } export interface UnreactToCommentRequest { commentId: string; userId: string; metadata: ReactCommentRequestBody; } export interface UpdateCommentRequest { commentId: string; userId: string; metadata: UpdateCommentRequestBody; } /** * */ export class CommentsApi extends runtime.BaseAPI { /** * @hidden * Creates a new comment */ async createCommentRaw(params: CreateCommentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (params.userId === null || params.userId === undefined) { throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling createComment.'); } if (params.metadata === null || params.metadata === undefined) { throw new runtime.RequiredError('metadata','Required parameter params.metadata was null or undefined when calling createComment.'); } const queryParameters: any = {}; if (params.userId !== undefined) { queryParameters['user_id'] = params.userId; } const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (!headerParameters["Authorization"] && this.configuration && this.configuration.accessToken) { const token = await this.configuration.accessToken("OAuth2", ["write"]); if (token) { headerParameters["Authorization"] = token; } } if (!headerParameters["Authorization"] && this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); } if (!headerParameters["Authorization"] && this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("BearerAuth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/comments`, method: 'POST', headers: headerParameters, query: queryParameters, body: CreateCommentRequestBodyToJSON(params.metadata), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => CreateCommentResponseFromJSON(jsonValue)); } /** * Creates a new comment */ async createComment(params: CreateCommentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.createCommentRaw(params, initOverrides); return await response.value(); } /** * @hidden * Deletes a comment */ async deleteCommentRaw(params: DeleteCommentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (params.commentId === null || params.commentId === undefined) { throw new runtime.RequiredError('commentId','Required parameter params.commentId was null or undefined when calling deleteComment.'); } if (params.userId === null || params.userId === undefined) { throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling deleteComment.'); } const queryParameters: any = {}; if (params.userId !== undefined) { queryParameters['user_id'] = params.userId; } const headerParameters: runtime.HTTPHeaders = {}; if (!headerParameters["Authorization"] && this.configuration && this.configuration.accessToken) { const token = await this.configuration.accessToken("OAuth2", ["write"]); if (token) { headerParameters["Authorization"] = token; } } if (!headerParameters["Authorization"] && this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); } if (!headerParameters["Authorization"] && this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("BearerAuth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/comments/{comment_id}`.replace(`{${"comment_id"}}`, encodeURIComponent(String(params.commentId))), method: 'DELETE', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); } /** * Deletes a comment */ async deleteComment(params: DeleteCommentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.deleteCommentRaw(params, initOverrides); return await response.value(); } /** * @hidden * Gets a comment by ID */ async getCommentRaw(params: GetCommentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (params.commentId === null || params.commentId === undefined) { throw new runtime.RequiredError('commentId','Required parameter params.commentId was null or undefined when calling getComment.'); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ path: `/comments/{comment_id}`.replace(`{${"comment_id"}}`, encodeURIComponent(String(params.commentId))), method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => CommentResponseFromJSON(jsonValue)); } /** * Gets a comment by ID */ async getComment(params: GetCommentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.getCommentRaw(params, initOverrides); return await response.value(); } /** * @hidden * Gets replies to a parent comment */ async getCommentRepliesRaw(params: GetCommentRepliesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (params.commentId === null || params.commentId === undefined) { throw new runtime.RequiredError('commentId','Required parameter params.commentId was null or undefined when calling getCommentReplies.'); } const queryParameters: any = {}; if (params.offset !== undefined) { queryParameters['offset'] = params.offset; } if (params.limit !== undefined) { queryParameters['limit'] = params.limit; } if (params.userId !== undefined) { queryParameters['user_id'] = params.userId; } const headerParameters: runtime.HTTPHeaders = {}; if (!headerParameters["Authorization"] && this.configuration && this.configuration.accessToken) { const token = await this.configuration.accessToken("OAuth2", ["read"]); if (token) { headerParameters["Authorization"] = token; } } const response = await this.request({ path: `/comments/{comment_id}/replies`.replace(`{${"comment_id"}}`, encodeURIComponent(String(params.commentId))), method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => CommentRepliesResponseFromJSON(jsonValue)); } /** * Gets replies to a parent comment */ async getCommentReplies(params: GetCommentRepliesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.getCommentRepliesRaw(params, initOverrides); return await response.value(); } /** * @hidden * Gets an unclaimed blockchain comment ID */ async getUnclaimedCommentIDRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; const response = await this.request({ path: `/comments/unclaimed_id`, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => UnclaimedIdResponseFromJSON(jsonValue)); } /** * Gets an unclaimed blockchain comment ID */ async getUnclaimedCommentID(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.getUnclaimedCommentIDRaw(initOverrides); return await response.value(); } /** * @hidden * Pin a comment */ async pinCommentRaw(params: PinCommentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (params.commentId === null || params.commentId === undefined) { throw new runtime.RequiredError('commentId','Required parameter params.commentId was null or undefined when calling pinComment.'); } if (params.userId === null || params.userId === undefined) { throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling pinComment.'); } if (params.metadata === null || params.metadata === undefined) { throw new runtime.RequiredError('metadata','Required parameter params.metadata was null or undefined when calling pinComment.'); } const queryParameters: any = {}; if (params.userId !== undefined) { queryParameters['user_id'] = params.userId; } const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (!headerParameters["Authorization"] && this.configuration && this.configuration.accessToken) { const token = await this.configuration.accessToken("OAuth2", ["write"]); if (token) { headerParameters["Authorization"] = token; } } if (!headerParameters["Authorization"] && this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); } if (!headerParameters["Authorization"] && this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("BearerAuth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/comments/{comment_id}/pin`.replace(`{${"comment_id"}}`, encodeURIComponent(String(params.commentId))), method: 'POST', headers: headerParameters, query: queryParameters, body: PinCommentRequestBodyToJSON(params.metadata), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); } /** * Pin a comment */ async pinComment(params: PinCommentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.pinCommentRaw(params, initOverrides); return await response.value(); } /** * @hidden * React to a comment */ async reactToCommentRaw(params: ReactToCommentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (params.commentId === null || params.commentId === undefined) { throw new runtime.RequiredError('commentId','Required parameter params.commentId was null or undefined when calling reactToComment.'); } if (params.userId === null || params.userId === undefined) { throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling reactToComment.'); } if (params.metadata === null || params.metadata === undefined) { throw new runtime.RequiredError('metadata','Required parameter params.metadata was null or undefined when calling reactToComment.'); } const queryParameters: any = {}; if (params.userId !== undefined) { queryParameters['user_id'] = params.userId; } const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (!headerParameters["Authorization"] && this.configuration && this.configuration.accessToken) { const token = await this.configuration.accessToken("OAuth2", ["write"]); if (token) { headerParameters["Authorization"] = token; } } if (!headerParameters["Authorization"] && this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); } if (!headerParameters["Authorization"] && this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("BearerAuth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/comments/{comment_id}/react`.replace(`{${"comment_id"}}`, encodeURIComponent(String(params.commentId))), method: 'POST', headers: headerParameters, query: queryParameters, body: ReactCommentRequestBodyToJSON(params.metadata), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); } /** * React to a comment */ async reactToComment(params: ReactToCommentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.reactToCommentRaw(params, initOverrides); return await response.value(); } /** * @hidden * Report a comment */ async reportCommentRaw(params: ReportCommentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (params.commentId === null || params.commentId === undefined) { throw new runtime.RequiredError('commentId','Required parameter params.commentId was null or undefined when calling reportComment.'); } if (params.userId === null || params.userId === undefined) { throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling reportComment.'); } const queryParameters: any = {}; if (params.userId !== undefined) { queryParameters['user_id'] = params.userId; } const headerParameters: runtime.HTTPHeaders = {}; if (!headerParameters["Authorization"] && this.configuration && this.configuration.accessToken) { const token = await this.configuration.accessToken("OAuth2", ["write"]); if (token) { headerParameters["Authorization"] = token; } } if (!headerParameters["Authorization"] && this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); } if (!headerParameters["Authorization"] && this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("BearerAuth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/comments/{comment_id}/report`.replace(`{${"comment_id"}}`, encodeURIComponent(String(params.commentId))), method: 'POST', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); } /** * Report a comment */ async reportComment(params: ReportCommentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.reportCommentRaw(params, initOverrides); return await response.value(); } /** * @hidden * Unpin a comment */ async unpinCommentRaw(params: UnpinCommentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (params.commentId === null || params.commentId === undefined) { throw new runtime.RequiredError('commentId','Required parameter params.commentId was null or undefined when calling unpinComment.'); } if (params.userId === null || params.userId === undefined) { throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling unpinComment.'); } if (params.metadata === null || params.metadata === undefined) { throw new runtime.RequiredError('metadata','Required parameter params.metadata was null or undefined when calling unpinComment.'); } const queryParameters: any = {}; if (params.userId !== undefined) { queryParameters['user_id'] = params.userId; } const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (!headerParameters["Authorization"] && this.configuration && this.configuration.accessToken) { const token = await this.configuration.accessToken("OAuth2", ["write"]); if (token) { headerParameters["Authorization"] = token; } } if (!headerParameters["Authorization"] && this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); } if (!headerParameters["Authorization"] && this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("BearerAuth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/comments/{comment_id}/pin`.replace(`{${"comment_id"}}`, encodeURIComponent(String(params.commentId))), method: 'DELETE', headers: headerParameters, query: queryParameters, body: PinCommentRequestBodyToJSON(params.metadata), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); } /** * Unpin a comment */ async unpinComment(params: UnpinCommentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.unpinCommentRaw(params, initOverrides); return await response.value(); } /** * @hidden * Unreact to a comment */ async unreactToCommentRaw(params: UnreactToCommentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (params.commentId === null || params.commentId === undefined) { throw new runtime.RequiredError('commentId','Required parameter params.commentId was null or undefined when calling unreactToComment.'); } if (params.userId === null || params.userId === undefined) { throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling unreactToComment.'); } if (params.metadata === null || params.metadata === undefined) { throw new runtime.RequiredError('metadata','Required parameter params.metadata was null or undefined when calling unreactToComment.'); } const queryParameters: any = {}; if (params.userId !== undefined) { queryParameters['user_id'] = params.userId; } const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (!headerParameters["Authorization"] && this.configuration && this.configuration.accessToken) { const token = await this.configuration.accessToken("OAuth2", ["write"]); if (token) { headerParameters["Authorization"] = token; } } if (!headerParameters["Authorization"] && this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); } if (!headerParameters["Authorization"] && this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("BearerAuth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/comments/{comment_id}/react`.replace(`{${"comment_id"}}`, encodeURIComponent(String(params.commentId))), method: 'DELETE', headers: headerParameters, query: queryParameters, body: ReactCommentRequestBodyToJSON(params.metadata), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); } /** * Unreact to a comment */ async unreactToComment(params: UnreactToCommentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.unreactToCommentRaw(params, initOverrides); return await response.value(); } /** * @hidden * Updates a comment */ async updateCommentRaw(params: UpdateCommentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { if (params.commentId === null || params.commentId === undefined) { throw new runtime.RequiredError('commentId','Required parameter params.commentId was null or undefined when calling updateComment.'); } if (params.userId === null || params.userId === undefined) { throw new runtime.RequiredError('userId','Required parameter params.userId was null or undefined when calling updateComment.'); } if (params.metadata === null || params.metadata === undefined) { throw new runtime.RequiredError('metadata','Required parameter params.metadata was null or undefined when calling updateComment.'); } const queryParameters: any = {}; if (params.userId !== undefined) { queryParameters['user_id'] = params.userId; } const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (!headerParameters["Authorization"] && this.configuration && this.configuration.accessToken) { const token = await this.configuration.accessToken("OAuth2", ["write"]); if (token) { headerParameters["Authorization"] = token; } } if (!headerParameters["Authorization"] && this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); } if (!headerParameters["Authorization"] && this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("BearerAuth", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/comments/{comment_id}`.replace(`{${"comment_id"}}`, encodeURIComponent(String(params.commentId))), method: 'PUT', headers: headerParameters, query: queryParameters, body: UpdateCommentRequestBodyToJSON(params.metadata), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => WriteResponseFromJSON(jsonValue)); } /** * Updates a comment */ async updateComment(params: UpdateCommentRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.updateCommentRaw(params, initOverrides); return await response.value(); } }