/* tslint:disable */
/* eslint-disable */
/**
 * Ticketing System API
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: 1.0.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 type {
  Comment,
  CommentUpdate,
  Config,
  DashboardCounts,
  ExtendedComment,
  ExtendedTask,
  ExtendedTicket,
  Group,
  GroupRelation,
  GroupUpdate,
  GroupUser,
  Link,
  LinkUpdate,
  NewComment,
  NewFile,
  NewGroup,
  NewLink,
  NewReaction,
  NewTask,
  NewTicket,
  NewTimelineEntry,
  NewType,
  NewUser,
  NewWebhook,
  Reaction,
  ReactionUpdate,
  Settings,
  Sidebar,
  Task,
  TaskUpdate,
  Ticket,
  TicketSearch,
  TicketUpdate,
  TimelineEntry,
  TimelineEntryUpdate,
  Type,
  TypeUpdate,
  User,
  UserGroup,
  UserUpdate,
  Webhook,
  WebhookUpdate
} from '../models/index'
import {
  CommentFromJSON,
  CommentToJSON,
  CommentUpdateFromJSON,
  CommentUpdateToJSON,
  ConfigFromJSON,
  ConfigToJSON,
  DashboardCountsFromJSON,
  DashboardCountsToJSON,
  ExtendedCommentFromJSON,
  ExtendedCommentToJSON,
  ExtendedTaskFromJSON,
  ExtendedTaskToJSON,
  ExtendedTicketFromJSON,
  ExtendedTicketToJSON,
  GroupFromJSON,
  GroupRelationFromJSON,
  GroupRelationToJSON,
  GroupToJSON,
  GroupUpdateFromJSON,
  GroupUpdateToJSON,
  GroupUserFromJSON,
  GroupUserToJSON,
  LinkFromJSON,
  LinkToJSON,
  LinkUpdateFromJSON,
  LinkUpdateToJSON,
  NewCommentFromJSON,
  NewCommentToJSON,
  NewFileFromJSON,
  NewFileToJSON,
  NewGroupFromJSON,
  NewGroupToJSON,
  NewLinkFromJSON,
  NewLinkToJSON,
  NewReactionFromJSON,
  NewReactionToJSON,
  NewTaskFromJSON,
  NewTaskToJSON,
  NewTicketFromJSON,
  NewTicketToJSON,
  NewTimelineEntryFromJSON,
  NewTimelineEntryToJSON,
  NewTypeFromJSON,
  NewTypeToJSON,
  NewUserFromJSON,
  NewUserToJSON,
  NewWebhookFromJSON,
  NewWebhookToJSON,
  ReactionFromJSON,
  ReactionToJSON,
  ReactionUpdateFromJSON,
  ReactionUpdateToJSON,
  SettingsFromJSON,
  SettingsToJSON,
  SidebarFromJSON,
  SidebarToJSON,
  TaskFromJSON,
  TaskToJSON,
  TaskUpdateFromJSON,
  TaskUpdateToJSON,
  TicketFromJSON,
  TicketSearchFromJSON,
  TicketSearchToJSON,
  TicketToJSON,
  TicketUpdateFromJSON,
  TicketUpdateToJSON,
  TimelineEntryFromJSON,
  TimelineEntryToJSON,
  TimelineEntryUpdateFromJSON,
  TimelineEntryUpdateToJSON,
  TypeFromJSON,
  TypeToJSON,
  TypeUpdateFromJSON,
  TypeUpdateToJSON,
  UserFromJSON,
  UserGroupFromJSON,
  UserGroupToJSON,
  UserToJSON,
  UserUpdateFromJSON,
  UserUpdateToJSON,
  WebhookFromJSON,
  WebhookToJSON,
  WebhookUpdateFromJSON,
  WebhookUpdateToJSON
} from '../models/index'
import * as runtime from '../runtime'

export interface AddGroupParentRequest {
  id: string
  groupRelation: GroupRelation
}

export interface AddUserGroupRequest {
  id: string
  groupRelation: GroupRelation
}

export interface CreateCommentRequest {
  newComment: NewComment
}

export interface CreateFileRequest {
  newFile: NewFile
}

export interface CreateGroupRequest {
  newGroup: NewGroup
}

export interface CreateLinkRequest {
  newLink: NewLink
}

export interface CreateReactionRequest {
  newReaction: NewReaction
}

export interface CreateTaskRequest {
  newTask: NewTask
}

export interface CreateTicketRequest {
  newTicket: NewTicket
}

export interface CreateTimelineRequest {
  newTimelineEntry: NewTimelineEntry
}

export interface CreateTypeRequest {
  newType: NewType
}

export interface CreateUserRequest {
  newUser: NewUser
}

export interface CreateWebhookRequest {
  newWebhook: NewWebhook
}

export interface DeleteCommentRequest {
  id: string
}

export interface DeleteFileRequest {
  id: string
}

export interface DeleteGroupRequest {
  id: string
}

export interface DeleteLinkRequest {
  id: string
}

export interface DeleteReactionRequest {
  id: string
}

export interface DeleteTaskRequest {
  id: string
}

export interface DeleteTicketRequest {
  id: string
}

export interface DeleteTimelineRequest {
  id: string
}

export interface DeleteTypeRequest {
  id: string
}

export interface DeleteUserRequest {
  id: string
}

export interface DeleteWebhookRequest {
  id: string
}

export interface DownloadFileRequest {
  id: string
}

export interface GetCommentRequest {
  id: string
}

export interface GetFileRequest {
  id: string
}

export interface GetGroupRequest {
  id: string
}

export interface GetLinkRequest {
  id: string
}

export interface GetReactionRequest {
  id: string
}

export interface GetTaskRequest {
  id: string
}

export interface GetTicketRequest {
  id: string
}

export interface GetTimelineRequest {
  id: string
}

export interface GetTypeRequest {
  id: string
}

export interface GetUserRequest {
  id: string
}

export interface GetWebhookRequest {
  id: string
}

export interface ListChildGroupsRequest {
  id: string
}

export interface ListCommentsRequest {
  ticket?: string
  offset?: number
  limit?: number
}

export interface ListFilesRequest {
  ticket?: string
  offset?: number
  limit?: number
}

export interface ListGroupUsersRequest {
  id: string
}

export interface ListGroupsRequest {
  offset?: number
  limit?: number
}

export interface ListLinksRequest {
  ticket?: string
  offset?: number
  limit?: number
}

export interface ListParentGroupsRequest {
  id: string
}

export interface ListParentPermissionsRequest {
  id: string
}

export interface ListReactionsRequest {
  offset?: number
  limit?: number
}

export interface ListTasksRequest {
  ticket?: string
  offset?: number
  limit?: number
}

export interface ListTicketsRequest {
  offset?: number
  limit?: number
}

export interface ListTimelineRequest {
  ticket?: string
  offset?: number
  limit?: number
}

export interface ListTypesRequest {
  offset?: number
  limit?: number
}

export interface ListUserGroupsRequest {
  id: string
}

export interface ListUserPermissionsRequest {
  id: string
}

export interface ListUsersRequest {
  offset?: number
  limit?: number
}

export interface ListWebhooksRequest {
  offset?: number
  limit?: number
}

export interface RemoveGroupParentRequest {
  id: string
  parentGroupId: string
}

export interface RemoveUserGroupRequest {
  id: string
  groupId: string
}

export interface SearchTicketsRequest {
  query?: string
  type?: string
  open?: boolean
  offset?: number
  limit?: number
}

export interface UpdateCommentRequest {
  id: string
  commentUpdate: CommentUpdate
}

export interface UpdateGroupRequest {
  id: string
  groupUpdate: GroupUpdate
}

export interface UpdateLinkRequest {
  id: string
  linkUpdate: LinkUpdate
}

export interface UpdateReactionRequest {
  id: string
  reactionUpdate: ReactionUpdate
}

export interface UpdateSettingsRequest {
  settings: Settings
}

export interface UpdateTaskRequest {
  id: string
  taskUpdate: TaskUpdate
}

export interface UpdateTicketRequest {
  id: string
  ticketUpdate: TicketUpdate
}

export interface UpdateTimelineRequest {
  id: string
  timelineEntryUpdate: TimelineEntryUpdate
}

export interface UpdateTypeRequest {
  id: string
  typeUpdate: TypeUpdate
}

export interface UpdateUserRequest {
  id: string
  userUpdate: UserUpdate
}

export interface UpdateWebhookRequest {
  id: string
  webhookUpdate: WebhookUpdate
}

/**
 *
 */
export class DefaultApi extends runtime.BaseAPI {
  /**
   * Add a parent group to another group
   */
  async addGroupParentRaw(
    requestParameters: AddGroupParentRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<void>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling addGroupParent().'
      )
    }

    if (requestParameters['groupRelation'] == null) {
      throw new runtime.RequiredError(
        'groupRelation',
        'Required parameter "groupRelation" was null or undefined when calling addGroupParent().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    headerParameters['Content-Type'] = 'application/json'

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'group:write'
      ])
    }

    let urlPath = `/groups/{id}/parents`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'POST',
        headers: headerParameters,
        query: queryParameters,
        body: GroupRelationToJSON(requestParameters['groupRelation'])
      },
      initOverrides
    )

    return new runtime.VoidApiResponse(response)
  }

  /**
   * Add a parent group to another group
   */
  async addGroupParent(
    requestParameters: AddGroupParentRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<void> {
    await this.addGroupParentRaw(requestParameters, initOverrides)
  }

  /**
   * Add a group to a user
   */
  async addUserGroupRaw(
    requestParameters: AddUserGroupRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<void>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling addUserGroup().'
      )
    }

    if (requestParameters['groupRelation'] == null) {
      throw new runtime.RequiredError(
        'groupRelation',
        'Required parameter "groupRelation" was null or undefined when calling addUserGroup().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    headerParameters['Content-Type'] = 'application/json'

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'user:write'
      ])
    }

    let urlPath = `/users/{id}/groups`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'POST',
        headers: headerParameters,
        query: queryParameters,
        body: GroupRelationToJSON(requestParameters['groupRelation'])
      },
      initOverrides
    )

    return new runtime.VoidApiResponse(response)
  }

  /**
   * Add a group to a user
   */
  async addUserGroup(
    requestParameters: AddUserGroupRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<void> {
    await this.addUserGroupRaw(requestParameters, initOverrides)
  }

  /**
   * Create a new comment
   */
  async createCommentRaw(
    requestParameters: CreateCommentRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Comment>> {
    if (requestParameters['newComment'] == null) {
      throw new runtime.RequiredError(
        'newComment',
        'Required parameter "newComment" was null or undefined when calling createComment().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    headerParameters['Content-Type'] = 'application/json'

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'ticket:write'
      ])
    }

    let urlPath = `/comments`

    const response = await this.request(
      {
        path: urlPath,
        method: 'POST',
        headers: headerParameters,
        query: queryParameters,
        body: NewCommentToJSON(requestParameters['newComment'])
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => CommentFromJSON(jsonValue))
  }

  /**
   * Create a new comment
   */
  async createComment(
    requestParameters: CreateCommentRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Comment> {
    const response = await this.createCommentRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * Create a new file
   */
  async createFileRaw(
    requestParameters: CreateFileRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<any>> {
    if (requestParameters['newFile'] == null) {
      throw new runtime.RequiredError(
        'newFile',
        'Required parameter "newFile" was null or undefined when calling createFile().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    headerParameters['Content-Type'] = 'application/json'

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'file:write'
      ])
    }

    let urlPath = `/files`

    const response = await this.request(
      {
        path: urlPath,
        method: 'POST',
        headers: headerParameters,
        query: queryParameters,
        body: NewFileToJSON(requestParameters['newFile'])
      },
      initOverrides
    )

    if (this.isJsonMime(response.headers.get('content-type'))) {
      return new runtime.JSONApiResponse<any>(response)
    } else {
      return new runtime.TextApiResponse(response) as any
    }
  }

  /**
   * Create a new file
   */
  async createFile(
    requestParameters: CreateFileRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<any> {
    const response = await this.createFileRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * Create a new group
   */
  async createGroupRaw(
    requestParameters: CreateGroupRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Group>> {
    if (requestParameters['newGroup'] == null) {
      throw new runtime.RequiredError(
        'newGroup',
        'Required parameter "newGroup" was null or undefined when calling createGroup().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    headerParameters['Content-Type'] = 'application/json'

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'group:write'
      ])
    }

    let urlPath = `/groups`

    const response = await this.request(
      {
        path: urlPath,
        method: 'POST',
        headers: headerParameters,
        query: queryParameters,
        body: NewGroupToJSON(requestParameters['newGroup'])
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => GroupFromJSON(jsonValue))
  }

  /**
   * Create a new group
   */
  async createGroup(
    requestParameters: CreateGroupRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Group> {
    const response = await this.createGroupRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * Create a new link
   */
  async createLinkRaw(
    requestParameters: CreateLinkRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Link>> {
    if (requestParameters['newLink'] == null) {
      throw new runtime.RequiredError(
        'newLink',
        'Required parameter "newLink" was null or undefined when calling createLink().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    headerParameters['Content-Type'] = 'application/json'

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'ticket:write'
      ])
    }

    let urlPath = `/links`

    const response = await this.request(
      {
        path: urlPath,
        method: 'POST',
        headers: headerParameters,
        query: queryParameters,
        body: NewLinkToJSON(requestParameters['newLink'])
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => LinkFromJSON(jsonValue))
  }

  /**
   * Create a new link
   */
  async createLink(
    requestParameters: CreateLinkRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Link> {
    const response = await this.createLinkRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * Create a new reaction
   */
  async createReactionRaw(
    requestParameters: CreateReactionRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Reaction>> {
    if (requestParameters['newReaction'] == null) {
      throw new runtime.RequiredError(
        'newReaction',
        'Required parameter "newReaction" was null or undefined when calling createReaction().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    headerParameters['Content-Type'] = 'application/json'

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'reaction:write'
      ])
    }

    let urlPath = `/reactions`

    const response = await this.request(
      {
        path: urlPath,
        method: 'POST',
        headers: headerParameters,
        query: queryParameters,
        body: NewReactionToJSON(requestParameters['newReaction'])
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => ReactionFromJSON(jsonValue))
  }

  /**
   * Create a new reaction
   */
  async createReaction(
    requestParameters: CreateReactionRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Reaction> {
    const response = await this.createReactionRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * Create a new task
   */
  async createTaskRaw(
    requestParameters: CreateTaskRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Task>> {
    if (requestParameters['newTask'] == null) {
      throw new runtime.RequiredError(
        'newTask',
        'Required parameter "newTask" was null or undefined when calling createTask().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    headerParameters['Content-Type'] = 'application/json'

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'ticket:write'
      ])
    }

    let urlPath = `/tasks`

    const response = await this.request(
      {
        path: urlPath,
        method: 'POST',
        headers: headerParameters,
        query: queryParameters,
        body: NewTaskToJSON(requestParameters['newTask'])
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => TaskFromJSON(jsonValue))
  }

  /**
   * Create a new task
   */
  async createTask(
    requestParameters: CreateTaskRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Task> {
    const response = await this.createTaskRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * Create a new ticket
   */
  async createTicketRaw(
    requestParameters: CreateTicketRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Ticket>> {
    if (requestParameters['newTicket'] == null) {
      throw new runtime.RequiredError(
        'newTicket',
        'Required parameter "newTicket" was null or undefined when calling createTicket().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    headerParameters['Content-Type'] = 'application/json'

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'ticket:write'
      ])
    }

    let urlPath = `/tickets`

    const response = await this.request(
      {
        path: urlPath,
        method: 'POST',
        headers: headerParameters,
        query: queryParameters,
        body: NewTicketToJSON(requestParameters['newTicket'])
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => TicketFromJSON(jsonValue))
  }

  /**
   * Create a new ticket
   */
  async createTicket(
    requestParameters: CreateTicketRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Ticket> {
    const response = await this.createTicketRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * Create a new timeline item
   */
  async createTimelineRaw(
    requestParameters: CreateTimelineRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<TimelineEntry>> {
    if (requestParameters['newTimelineEntry'] == null) {
      throw new runtime.RequiredError(
        'newTimelineEntry',
        'Required parameter "newTimelineEntry" was null or undefined when calling createTimeline().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    headerParameters['Content-Type'] = 'application/json'

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'ticket:write'
      ])
    }

    let urlPath = `/timeline`

    const response = await this.request(
      {
        path: urlPath,
        method: 'POST',
        headers: headerParameters,
        query: queryParameters,
        body: NewTimelineEntryToJSON(requestParameters['newTimelineEntry'])
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => TimelineEntryFromJSON(jsonValue))
  }

  /**
   * Create a new timeline item
   */
  async createTimeline(
    requestParameters: CreateTimelineRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<TimelineEntry> {
    const response = await this.createTimelineRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * Create a new type
   */
  async createTypeRaw(
    requestParameters: CreateTypeRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Type>> {
    if (requestParameters['newType'] == null) {
      throw new runtime.RequiredError(
        'newType',
        'Required parameter "newType" was null or undefined when calling createType().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    headerParameters['Content-Type'] = 'application/json'

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [])
    }

    let urlPath = `/types`

    const response = await this.request(
      {
        path: urlPath,
        method: 'POST',
        headers: headerParameters,
        query: queryParameters,
        body: NewTypeToJSON(requestParameters['newType'])
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => TypeFromJSON(jsonValue))
  }

  /**
   * Create a new type
   */
  async createType(
    requestParameters: CreateTypeRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Type> {
    const response = await this.createTypeRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * Create a new user
   */
  async createUserRaw(
    requestParameters: CreateUserRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<User>> {
    if (requestParameters['newUser'] == null) {
      throw new runtime.RequiredError(
        'newUser',
        'Required parameter "newUser" was null or undefined when calling createUser().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    headerParameters['Content-Type'] = 'application/json'

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'user:write'
      ])
    }

    let urlPath = `/users`

    const response = await this.request(
      {
        path: urlPath,
        method: 'POST',
        headers: headerParameters,
        query: queryParameters,
        body: NewUserToJSON(requestParameters['newUser'])
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => UserFromJSON(jsonValue))
  }

  /**
   * Create a new user
   */
  async createUser(
    requestParameters: CreateUserRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<User> {
    const response = await this.createUserRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * Create a new webhook
   */
  async createWebhookRaw(
    requestParameters: CreateWebhookRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Webhook>> {
    if (requestParameters['newWebhook'] == null) {
      throw new runtime.RequiredError(
        'newWebhook',
        'Required parameter "newWebhook" was null or undefined when calling createWebhook().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    headerParameters['Content-Type'] = 'application/json'

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'webhook:write'
      ])
    }

    let urlPath = `/webhooks`

    const response = await this.request(
      {
        path: urlPath,
        method: 'POST',
        headers: headerParameters,
        query: queryParameters,
        body: NewWebhookToJSON(requestParameters['newWebhook'])
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => WebhookFromJSON(jsonValue))
  }

  /**
   * Create a new webhook
   */
  async createWebhook(
    requestParameters: CreateWebhookRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Webhook> {
    const response = await this.createWebhookRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * Delete a comment by ID
   */
  async deleteCommentRaw(
    requestParameters: DeleteCommentRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<void>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling deleteComment().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'ticket:write'
      ])
    }

    let urlPath = `/comments/{id}`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'DELETE',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.VoidApiResponse(response)
  }

  /**
   * Delete a comment by ID
   */
  async deleteComment(
    requestParameters: DeleteCommentRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<void> {
    await this.deleteCommentRaw(requestParameters, initOverrides)
  }

  /**
   * Delete a file by ID
   */
  async deleteFileRaw(
    requestParameters: DeleteFileRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<void>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling deleteFile().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'file:write'
      ])
    }

    let urlPath = `/files/{id}`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'DELETE',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.VoidApiResponse(response)
  }

  /**
   * Delete a file by ID
   */
  async deleteFile(
    requestParameters: DeleteFileRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<void> {
    await this.deleteFileRaw(requestParameters, initOverrides)
  }

  /**
   * Delete a group by ID
   */
  async deleteGroupRaw(
    requestParameters: DeleteGroupRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<void>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling deleteGroup().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'group:write'
      ])
    }

    let urlPath = `/groups/{id}`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'DELETE',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.VoidApiResponse(response)
  }

  /**
   * Delete a group by ID
   */
  async deleteGroup(
    requestParameters: DeleteGroupRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<void> {
    await this.deleteGroupRaw(requestParameters, initOverrides)
  }

  /**
   * Delete a link by ID
   */
  async deleteLinkRaw(
    requestParameters: DeleteLinkRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<void>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling deleteLink().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'ticket:write'
      ])
    }

    let urlPath = `/links/{id}`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'DELETE',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.VoidApiResponse(response)
  }

  /**
   * Delete a link by ID
   */
  async deleteLink(
    requestParameters: DeleteLinkRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<void> {
    await this.deleteLinkRaw(requestParameters, initOverrides)
  }

  /**
   * Delete a reaction by ID
   */
  async deleteReactionRaw(
    requestParameters: DeleteReactionRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<void>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling deleteReaction().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'reaction:write'
      ])
    }

    let urlPath = `/reactions/{id}`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'DELETE',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.VoidApiResponse(response)
  }

  /**
   * Delete a reaction by ID
   */
  async deleteReaction(
    requestParameters: DeleteReactionRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<void> {
    await this.deleteReactionRaw(requestParameters, initOverrides)
  }

  /**
   * Delete a task by ID
   */
  async deleteTaskRaw(
    requestParameters: DeleteTaskRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<void>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling deleteTask().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'ticket:write'
      ])
    }

    let urlPath = `/tasks/{id}`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'DELETE',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.VoidApiResponse(response)
  }

  /**
   * Delete a task by ID
   */
  async deleteTask(
    requestParameters: DeleteTaskRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<void> {
    await this.deleteTaskRaw(requestParameters, initOverrides)
  }

  /**
   * Delete a ticket by ID
   */
  async deleteTicketRaw(
    requestParameters: DeleteTicketRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<void>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling deleteTicket().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'ticket:write'
      ])
    }

    let urlPath = `/tickets/{id}`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'DELETE',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.VoidApiResponse(response)
  }

  /**
   * Delete a ticket by ID
   */
  async deleteTicket(
    requestParameters: DeleteTicketRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<void> {
    await this.deleteTicketRaw(requestParameters, initOverrides)
  }

  /**
   * Delete a timeline item by ID
   */
  async deleteTimelineRaw(
    requestParameters: DeleteTimelineRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<void>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling deleteTimeline().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'ticket:write'
      ])
    }

    let urlPath = `/timeline/{id}`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'DELETE',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.VoidApiResponse(response)
  }

  /**
   * Delete a timeline item by ID
   */
  async deleteTimeline(
    requestParameters: DeleteTimelineRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<void> {
    await this.deleteTimelineRaw(requestParameters, initOverrides)
  }

  /**
   * Delete a type by ID
   */
  async deleteTypeRaw(
    requestParameters: DeleteTypeRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<void>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling deleteType().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [])
    }

    let urlPath = `/types/{id}`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'DELETE',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.VoidApiResponse(response)
  }

  /**
   * Delete a type by ID
   */
  async deleteType(
    requestParameters: DeleteTypeRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<void> {
    await this.deleteTypeRaw(requestParameters, initOverrides)
  }

  /**
   * Delete a user by ID
   */
  async deleteUserRaw(
    requestParameters: DeleteUserRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<void>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling deleteUser().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'user:write'
      ])
    }

    let urlPath = `/users/{id}`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'DELETE',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.VoidApiResponse(response)
  }

  /**
   * Delete a user by ID
   */
  async deleteUser(
    requestParameters: DeleteUserRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<void> {
    await this.deleteUserRaw(requestParameters, initOverrides)
  }

  /**
   * Delete a webhook by ID
   */
  async deleteWebhookRaw(
    requestParameters: DeleteWebhookRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<void>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling deleteWebhook().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'webhook:write'
      ])
    }

    let urlPath = `/webhooks/{id}`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'DELETE',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.VoidApiResponse(response)
  }

  /**
   * Delete a webhook by ID
   */
  async deleteWebhook(
    requestParameters: DeleteWebhookRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<void> {
    await this.deleteWebhookRaw(requestParameters, initOverrides)
  }

  /**
   * Download a file by ID
   */
  async downloadFileRaw(
    requestParameters: DownloadFileRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<void>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling downloadFile().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'file:read'
      ])
    }

    let urlPath = `/files/{id}/download`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'GET',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.VoidApiResponse(response)
  }

  /**
   * Download a file by ID
   */
  async downloadFile(
    requestParameters: DownloadFileRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<void> {
    await this.downloadFileRaw(requestParameters, initOverrides)
  }

  /**
   * Get a single comment by ID
   */
  async getCommentRaw(
    requestParameters: GetCommentRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<ExtendedComment>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling getComment().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'ticket:read'
      ])
    }

    let urlPath = `/comments/{id}`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'GET',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => ExtendedCommentFromJSON(jsonValue))
  }

  /**
   * Get a single comment by ID
   */
  async getComment(
    requestParameters: GetCommentRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<ExtendedComment> {
    const response = await this.getCommentRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * Get the configuration
   */
  async getConfigRaw(
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Config>> {
    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    let urlPath = `/config`

    const response = await this.request(
      {
        path: urlPath,
        method: 'GET',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => ConfigFromJSON(jsonValue))
  }

  /**
   * Get the configuration
   */
  async getConfig(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Config> {
    const response = await this.getConfigRaw(initOverrides)
    return await response.value()
  }

  /**
   * Get dashboard summary counts
   */
  async getDashboardCountsRaw(
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Array<DashboardCounts>>> {
    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'ticket:read'
      ])
    }

    let urlPath = `/dashboard_counts`

    const response = await this.request(
      {
        path: urlPath,
        method: 'GET',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) =>
      jsonValue.map(DashboardCountsFromJSON)
    )
  }

  /**
   * Get dashboard summary counts
   */
  async getDashboardCounts(
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Array<DashboardCounts>> {
    const response = await this.getDashboardCountsRaw(initOverrides)
    return await response.value()
  }

  /**
   * Get a single file by ID
   */
  async getFileRaw(
    requestParameters: GetFileRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<any>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling getFile().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'file:read'
      ])
    }

    let urlPath = `/files/{id}`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'GET',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    if (this.isJsonMime(response.headers.get('content-type'))) {
      return new runtime.JSONApiResponse<any>(response)
    } else {
      return new runtime.TextApiResponse(response) as any
    }
  }

  /**
   * Get a single file by ID
   */
  async getFile(
    requestParameters: GetFileRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<any> {
    const response = await this.getFileRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * Get a single group by ID
   */
  async getGroupRaw(
    requestParameters: GetGroupRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Group>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling getGroup().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'group:read'
      ])
    }

    let urlPath = `/groups/{id}`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'GET',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => GroupFromJSON(jsonValue))
  }

  /**
   * Get a single group by ID
   */
  async getGroup(
    requestParameters: GetGroupRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Group> {
    const response = await this.getGroupRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * Get a single link by ID
   */
  async getLinkRaw(
    requestParameters: GetLinkRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Link>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling getLink().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'ticket:read'
      ])
    }

    let urlPath = `/links/{id}`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'GET',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => LinkFromJSON(jsonValue))
  }

  /**
   * Get a single link by ID
   */
  async getLink(
    requestParameters: GetLinkRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Link> {
    const response = await this.getLinkRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * Get a single reaction by ID
   */
  async getReactionRaw(
    requestParameters: GetReactionRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Reaction>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling getReaction().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'reaction:read'
      ])
    }

    let urlPath = `/reactions/{id}`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'GET',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => ReactionFromJSON(jsonValue))
  }

  /**
   * Get a single reaction by ID
   */
  async getReaction(
    requestParameters: GetReactionRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Reaction> {
    const response = await this.getReactionRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * Get system settings
   */
  async getSettingsRaw(
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Settings>> {
    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'settings:read'
      ])
    }

    let urlPath = `/settings`

    const response = await this.request(
      {
        path: urlPath,
        method: 'GET',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => SettingsFromJSON(jsonValue))
  }

  /**
   * Get system settings
   */
  async getSettings(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Settings> {
    const response = await this.getSettingsRaw(initOverrides)
    return await response.value()
  }

  /**
   * Get sidebar data
   */
  async getSidebarRaw(
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Array<Sidebar>>> {
    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'ticket:read'
      ])
    }

    let urlPath = `/sidebar`

    const response = await this.request(
      {
        path: urlPath,
        method: 'GET',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(SidebarFromJSON))
  }

  /**
   * Get sidebar data
   */
  async getSidebar(
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Array<Sidebar>> {
    const response = await this.getSidebarRaw(initOverrides)
    return await response.value()
  }

  /**
   * Get a single task by ID
   */
  async getTaskRaw(
    requestParameters: GetTaskRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<ExtendedTask>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling getTask().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'ticket:read'
      ])
    }

    let urlPath = `/tasks/{id}`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'GET',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => ExtendedTaskFromJSON(jsonValue))
  }

  /**
   * Get a single task by ID
   */
  async getTask(
    requestParameters: GetTaskRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<ExtendedTask> {
    const response = await this.getTaskRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * Get a single ticket by ID
   */
  async getTicketRaw(
    requestParameters: GetTicketRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<ExtendedTicket>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling getTicket().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'ticket:read'
      ])
    }

    let urlPath = `/tickets/{id}`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'GET',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => ExtendedTicketFromJSON(jsonValue))
  }

  /**
   * Get a single ticket by ID
   */
  async getTicket(
    requestParameters: GetTicketRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<ExtendedTicket> {
    const response = await this.getTicketRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * Get a single timeline item by ID
   */
  async getTimelineRaw(
    requestParameters: GetTimelineRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<TimelineEntry>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling getTimeline().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'ticket:read'
      ])
    }

    let urlPath = `/timeline/{id}`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'GET',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => TimelineEntryFromJSON(jsonValue))
  }

  /**
   * Get a single timeline item by ID
   */
  async getTimeline(
    requestParameters: GetTimelineRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<TimelineEntry> {
    const response = await this.getTimelineRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * Get a single type by ID
   */
  async getTypeRaw(
    requestParameters: GetTypeRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Type>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling getType().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [])
    }

    let urlPath = `/types/{id}`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'GET',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => TypeFromJSON(jsonValue))
  }

  /**
   * Get a single type by ID
   */
  async getType(
    requestParameters: GetTypeRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Type> {
    const response = await this.getTypeRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * Get a single user by ID
   */
  async getUserRaw(
    requestParameters: GetUserRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<User>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling getUser().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'user:read'
      ])
    }

    let urlPath = `/users/{id}`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'GET',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => UserFromJSON(jsonValue))
  }

  /**
   * Get a single user by ID
   */
  async getUser(
    requestParameters: GetUserRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<User> {
    const response = await this.getUserRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * Get a single webhook by ID
   */
  async getWebhookRaw(
    requestParameters: GetWebhookRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Webhook>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling getWebhook().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'webhook:read'
      ])
    }

    let urlPath = `/webhooks/{id}`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'GET',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => WebhookFromJSON(jsonValue))
  }

  /**
   * Get a single webhook by ID
   */
  async getWebhook(
    requestParameters: GetWebhookRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Webhook> {
    const response = await this.getWebhookRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * List all child groups for a group
   */
  async listChildGroupsRaw(
    requestParameters: ListChildGroupsRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Array<UserGroup>>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling listChildGroups().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'group:read'
      ])
    }

    let urlPath = `/groups/{id}/children`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'GET',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(UserGroupFromJSON))
  }

  /**
   * List all child groups for a group
   */
  async listChildGroups(
    requestParameters: ListChildGroupsRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Array<UserGroup>> {
    const response = await this.listChildGroupsRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * List all comments
   */
  async listCommentsRaw(
    requestParameters: ListCommentsRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Array<ExtendedComment>>> {
    const queryParameters: any = {}

    if (requestParameters['ticket'] != null) {
      queryParameters['ticket'] = requestParameters['ticket']
    }

    if (requestParameters['offset'] != null) {
      queryParameters['offset'] = requestParameters['offset']
    }

    if (requestParameters['limit'] != null) {
      queryParameters['limit'] = requestParameters['limit']
    }

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'ticket:read'
      ])
    }

    let urlPath = `/comments`

    const response = await this.request(
      {
        path: urlPath,
        method: 'GET',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) =>
      jsonValue.map(ExtendedCommentFromJSON)
    )
  }

  /**
   * List all comments
   */
  async listComments(
    requestParameters: ListCommentsRequest = {},
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Array<ExtendedComment>> {
    const response = await this.listCommentsRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * List all files
   */
  async listFilesRaw(
    requestParameters: ListFilesRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Array<any>>> {
    const queryParameters: any = {}

    if (requestParameters['ticket'] != null) {
      queryParameters['ticket'] = requestParameters['ticket']
    }

    if (requestParameters['offset'] != null) {
      queryParameters['offset'] = requestParameters['offset']
    }

    if (requestParameters['limit'] != null) {
      queryParameters['limit'] = requestParameters['limit']
    }

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'file:read'
      ])
    }

    let urlPath = `/files`

    const response = await this.request(
      {
        path: urlPath,
        method: 'GET',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.JSONApiResponse<any>(response)
  }

  /**
   * List all files
   */
  async listFiles(
    requestParameters: ListFilesRequest = {},
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Array<any>> {
    const response = await this.listFilesRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * List all users for a group
   */
  async listGroupUsersRaw(
    requestParameters: ListGroupUsersRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Array<GroupUser>>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling listGroupUsers().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'group:read'
      ])
    }

    let urlPath = `/groups/{id}/users`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'GET',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(GroupUserFromJSON))
  }

  /**
   * List all users for a group
   */
  async listGroupUsers(
    requestParameters: ListGroupUsersRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Array<GroupUser>> {
    const response = await this.listGroupUsersRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * List all groups
   */
  async listGroupsRaw(
    requestParameters: ListGroupsRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Array<Group>>> {
    const queryParameters: any = {}

    if (requestParameters['offset'] != null) {
      queryParameters['offset'] = requestParameters['offset']
    }

    if (requestParameters['limit'] != null) {
      queryParameters['limit'] = requestParameters['limit']
    }

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'group:read'
      ])
    }

    let urlPath = `/groups`

    const response = await this.request(
      {
        path: urlPath,
        method: 'GET',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(GroupFromJSON))
  }

  /**
   * List all groups
   */
  async listGroups(
    requestParameters: ListGroupsRequest = {},
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Array<Group>> {
    const response = await this.listGroupsRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * List all links
   */
  async listLinksRaw(
    requestParameters: ListLinksRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Array<Link>>> {
    const queryParameters: any = {}

    if (requestParameters['ticket'] != null) {
      queryParameters['ticket'] = requestParameters['ticket']
    }

    if (requestParameters['offset'] != null) {
      queryParameters['offset'] = requestParameters['offset']
    }

    if (requestParameters['limit'] != null) {
      queryParameters['limit'] = requestParameters['limit']
    }

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'ticket:read'
      ])
    }

    let urlPath = `/links`

    const response = await this.request(
      {
        path: urlPath,
        method: 'GET',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(LinkFromJSON))
  }

  /**
   * List all links
   */
  async listLinks(
    requestParameters: ListLinksRequest = {},
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Array<Link>> {
    const response = await this.listLinksRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * List all parent groups for a group
   */
  async listParentGroupsRaw(
    requestParameters: ListParentGroupsRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Array<UserGroup>>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling listParentGroups().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'group:read'
      ])
    }

    let urlPath = `/groups/{id}/parents`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'GET',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(UserGroupFromJSON))
  }

  /**
   * List all parent groups for a group
   */
  async listParentGroups(
    requestParameters: ListParentGroupsRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Array<UserGroup>> {
    const response = await this.listParentGroupsRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * List all permissions for a group
   */
  async listParentPermissionsRaw(
    requestParameters: ListParentPermissionsRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Array<string>>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling listParentPermissions().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'group:read'
      ])
    }

    let urlPath = `/groups/{id}/permissions`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'GET',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.JSONApiResponse<any>(response)
  }

  /**
   * List all permissions for a group
   */
  async listParentPermissions(
    requestParameters: ListParentPermissionsRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Array<string>> {
    const response = await this.listParentPermissionsRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * List all reactions
   */
  async listReactionsRaw(
    requestParameters: ListReactionsRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Array<Reaction>>> {
    const queryParameters: any = {}

    if (requestParameters['offset'] != null) {
      queryParameters['offset'] = requestParameters['offset']
    }

    if (requestParameters['limit'] != null) {
      queryParameters['limit'] = requestParameters['limit']
    }

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'reaction:read'
      ])
    }

    let urlPath = `/reactions`

    const response = await this.request(
      {
        path: urlPath,
        method: 'GET',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(ReactionFromJSON))
  }

  /**
   * List all reactions
   */
  async listReactions(
    requestParameters: ListReactionsRequest = {},
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Array<Reaction>> {
    const response = await this.listReactionsRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * List all tasks
   */
  async listTasksRaw(
    requestParameters: ListTasksRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Array<ExtendedTask>>> {
    const queryParameters: any = {}

    if (requestParameters['ticket'] != null) {
      queryParameters['ticket'] = requestParameters['ticket']
    }

    if (requestParameters['offset'] != null) {
      queryParameters['offset'] = requestParameters['offset']
    }

    if (requestParameters['limit'] != null) {
      queryParameters['limit'] = requestParameters['limit']
    }

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'ticket:read'
      ])
    }

    let urlPath = `/tasks`

    const response = await this.request(
      {
        path: urlPath,
        method: 'GET',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(ExtendedTaskFromJSON))
  }

  /**
   * List all tasks
   */
  async listTasks(
    requestParameters: ListTasksRequest = {},
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Array<ExtendedTask>> {
    const response = await this.listTasksRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * List all tickets
   */
  async listTicketsRaw(
    requestParameters: ListTicketsRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Array<ExtendedTicket>>> {
    const queryParameters: any = {}

    if (requestParameters['offset'] != null) {
      queryParameters['offset'] = requestParameters['offset']
    }

    if (requestParameters['limit'] != null) {
      queryParameters['limit'] = requestParameters['limit']
    }

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'ticket:read'
      ])
    }

    let urlPath = `/tickets`

    const response = await this.request(
      {
        path: urlPath,
        method: 'GET',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) =>
      jsonValue.map(ExtendedTicketFromJSON)
    )
  }

  /**
   * List all tickets
   */
  async listTickets(
    requestParameters: ListTicketsRequest = {},
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Array<ExtendedTicket>> {
    const response = await this.listTicketsRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * List all timeline items
   */
  async listTimelineRaw(
    requestParameters: ListTimelineRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Array<TimelineEntry>>> {
    const queryParameters: any = {}

    if (requestParameters['ticket'] != null) {
      queryParameters['ticket'] = requestParameters['ticket']
    }

    if (requestParameters['offset'] != null) {
      queryParameters['offset'] = requestParameters['offset']
    }

    if (requestParameters['limit'] != null) {
      queryParameters['limit'] = requestParameters['limit']
    }

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'ticket:read'
      ])
    }

    let urlPath = `/timeline`

    const response = await this.request(
      {
        path: urlPath,
        method: 'GET',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) =>
      jsonValue.map(TimelineEntryFromJSON)
    )
  }

  /**
   * List all timeline items
   */
  async listTimeline(
    requestParameters: ListTimelineRequest = {},
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Array<TimelineEntry>> {
    const response = await this.listTimelineRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * List all types
   */
  async listTypesRaw(
    requestParameters: ListTypesRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Array<Type>>> {
    const queryParameters: any = {}

    if (requestParameters['offset'] != null) {
      queryParameters['offset'] = requestParameters['offset']
    }

    if (requestParameters['limit'] != null) {
      queryParameters['limit'] = requestParameters['limit']
    }

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [])
    }

    let urlPath = `/types`

    const response = await this.request(
      {
        path: urlPath,
        method: 'GET',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(TypeFromJSON))
  }

  /**
   * List all types
   */
  async listTypes(
    requestParameters: ListTypesRequest = {},
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Array<Type>> {
    const response = await this.listTypesRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * List all groups for a user
   */
  async listUserGroupsRaw(
    requestParameters: ListUserGroupsRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Array<UserGroup>>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling listUserGroups().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'user:read'
      ])
    }

    let urlPath = `/users/{id}/groups`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'GET',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(UserGroupFromJSON))
  }

  /**
   * List all groups for a user
   */
  async listUserGroups(
    requestParameters: ListUserGroupsRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Array<UserGroup>> {
    const response = await this.listUserGroupsRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * List all permissions for a user
   */
  async listUserPermissionsRaw(
    requestParameters: ListUserPermissionsRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Array<string>>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling listUserPermissions().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'user:read'
      ])
    }

    let urlPath = `/users/{id}/permissions`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'GET',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.JSONApiResponse<any>(response)
  }

  /**
   * List all permissions for a user
   */
  async listUserPermissions(
    requestParameters: ListUserPermissionsRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Array<string>> {
    const response = await this.listUserPermissionsRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * List all users
   */
  async listUsersRaw(
    requestParameters: ListUsersRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Array<User>>> {
    const queryParameters: any = {}

    if (requestParameters['offset'] != null) {
      queryParameters['offset'] = requestParameters['offset']
    }

    if (requestParameters['limit'] != null) {
      queryParameters['limit'] = requestParameters['limit']
    }

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'user:read'
      ])
    }

    let urlPath = `/users`

    const response = await this.request(
      {
        path: urlPath,
        method: 'GET',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(UserFromJSON))
  }

  /**
   * List all users
   */
  async listUsers(
    requestParameters: ListUsersRequest = {},
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Array<User>> {
    const response = await this.listUsersRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * List all webhooks
   */
  async listWebhooksRaw(
    requestParameters: ListWebhooksRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Array<Webhook>>> {
    const queryParameters: any = {}

    if (requestParameters['offset'] != null) {
      queryParameters['offset'] = requestParameters['offset']
    }

    if (requestParameters['limit'] != null) {
      queryParameters['limit'] = requestParameters['limit']
    }

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'webhook:read'
      ])
    }

    let urlPath = `/webhooks`

    const response = await this.request(
      {
        path: urlPath,
        method: 'GET',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(WebhookFromJSON))
  }

  /**
   * List all webhooks
   */
  async listWebhooks(
    requestParameters: ListWebhooksRequest = {},
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Array<Webhook>> {
    const response = await this.listWebhooksRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * Remove a parent group from another group
   */
  async removeGroupParentRaw(
    requestParameters: RemoveGroupParentRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<void>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling removeGroupParent().'
      )
    }

    if (requestParameters['parentGroupId'] == null) {
      throw new runtime.RequiredError(
        'parentGroupId',
        'Required parameter "parentGroupId" was null or undefined when calling removeGroupParent().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'group:write'
      ])
    }

    let urlPath = `/groups/{id}/groups/{parentGroupId}`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))
    urlPath = urlPath.replace(
      `{${'parentGroupId'}}`,
      encodeURIComponent(String(requestParameters['parentGroupId']))
    )

    const response = await this.request(
      {
        path: urlPath,
        method: 'DELETE',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.VoidApiResponse(response)
  }

  /**
   * Remove a parent group from another group
   */
  async removeGroupParent(
    requestParameters: RemoveGroupParentRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<void> {
    await this.removeGroupParentRaw(requestParameters, initOverrides)
  }

  /**
   * Remove a group from a user
   */
  async removeUserGroupRaw(
    requestParameters: RemoveUserGroupRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<void>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling removeUserGroup().'
      )
    }

    if (requestParameters['groupId'] == null) {
      throw new runtime.RequiredError(
        'groupId',
        'Required parameter "groupId" was null or undefined when calling removeUserGroup().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'user:write'
      ])
    }

    let urlPath = `/users/{id}/groups/{groupId}`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))
    urlPath = urlPath.replace(
      `{${'groupId'}}`,
      encodeURIComponent(String(requestParameters['groupId']))
    )

    const response = await this.request(
      {
        path: urlPath,
        method: 'DELETE',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.VoidApiResponse(response)
  }

  /**
   * Remove a group from a user
   */
  async removeUserGroup(
    requestParameters: RemoveUserGroupRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<void> {
    await this.removeUserGroupRaw(requestParameters, initOverrides)
  }

  /**
   * Search tickets with full join data
   */
  async searchTicketsRaw(
    requestParameters: SearchTicketsRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Array<TicketSearch>>> {
    const queryParameters: any = {}

    if (requestParameters['query'] != null) {
      queryParameters['query'] = requestParameters['query']
    }

    if (requestParameters['type'] != null) {
      queryParameters['type'] = requestParameters['type']
    }

    if (requestParameters['open'] != null) {
      queryParameters['open'] = requestParameters['open']
    }

    if (requestParameters['offset'] != null) {
      queryParameters['offset'] = requestParameters['offset']
    }

    if (requestParameters['limit'] != null) {
      queryParameters['limit'] = requestParameters['limit']
    }

    const headerParameters: runtime.HTTPHeaders = {}

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'ticket:read'
      ])
    }

    let urlPath = `/ticket_search`

    const response = await this.request(
      {
        path: urlPath,
        method: 'GET',
        headers: headerParameters,
        query: queryParameters
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(TicketSearchFromJSON))
  }

  /**
   * Search tickets with full join data
   */
  async searchTickets(
    requestParameters: SearchTicketsRequest = {},
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Array<TicketSearch>> {
    const response = await this.searchTicketsRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * Update a comment by ID
   */
  async updateCommentRaw(
    requestParameters: UpdateCommentRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Comment>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling updateComment().'
      )
    }

    if (requestParameters['commentUpdate'] == null) {
      throw new runtime.RequiredError(
        'commentUpdate',
        'Required parameter "commentUpdate" was null or undefined when calling updateComment().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    headerParameters['Content-Type'] = 'application/json'

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'ticket:write'
      ])
    }

    let urlPath = `/comments/{id}`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'PATCH',
        headers: headerParameters,
        query: queryParameters,
        body: CommentUpdateToJSON(requestParameters['commentUpdate'])
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => CommentFromJSON(jsonValue))
  }

  /**
   * Update a comment by ID
   */
  async updateComment(
    requestParameters: UpdateCommentRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Comment> {
    const response = await this.updateCommentRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * Update a group by ID
   */
  async updateGroupRaw(
    requestParameters: UpdateGroupRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Group>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling updateGroup().'
      )
    }

    if (requestParameters['groupUpdate'] == null) {
      throw new runtime.RequiredError(
        'groupUpdate',
        'Required parameter "groupUpdate" was null or undefined when calling updateGroup().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    headerParameters['Content-Type'] = 'application/json'

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'group:write'
      ])
    }

    let urlPath = `/groups/{id}`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'PATCH',
        headers: headerParameters,
        query: queryParameters,
        body: GroupUpdateToJSON(requestParameters['groupUpdate'])
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => GroupFromJSON(jsonValue))
  }

  /**
   * Update a group by ID
   */
  async updateGroup(
    requestParameters: UpdateGroupRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Group> {
    const response = await this.updateGroupRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * Update a link by ID
   */
  async updateLinkRaw(
    requestParameters: UpdateLinkRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Link>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling updateLink().'
      )
    }

    if (requestParameters['linkUpdate'] == null) {
      throw new runtime.RequiredError(
        'linkUpdate',
        'Required parameter "linkUpdate" was null or undefined when calling updateLink().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    headerParameters['Content-Type'] = 'application/json'

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'ticket:write'
      ])
    }

    let urlPath = `/links/{id}`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'PATCH',
        headers: headerParameters,
        query: queryParameters,
        body: LinkUpdateToJSON(requestParameters['linkUpdate'])
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => LinkFromJSON(jsonValue))
  }

  /**
   * Update a link by ID
   */
  async updateLink(
    requestParameters: UpdateLinkRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Link> {
    const response = await this.updateLinkRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * Update a reaction by ID
   */
  async updateReactionRaw(
    requestParameters: UpdateReactionRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Reaction>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling updateReaction().'
      )
    }

    if (requestParameters['reactionUpdate'] == null) {
      throw new runtime.RequiredError(
        'reactionUpdate',
        'Required parameter "reactionUpdate" was null or undefined when calling updateReaction().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    headerParameters['Content-Type'] = 'application/json'

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'reaction:write'
      ])
    }

    let urlPath = `/reactions/{id}`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'PATCH',
        headers: headerParameters,
        query: queryParameters,
        body: ReactionUpdateToJSON(requestParameters['reactionUpdate'])
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => ReactionFromJSON(jsonValue))
  }

  /**
   * Update a reaction by ID
   */
  async updateReaction(
    requestParameters: UpdateReactionRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Reaction> {
    const response = await this.updateReactionRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * Update system settings
   */
  async updateSettingsRaw(
    requestParameters: UpdateSettingsRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Settings>> {
    if (requestParameters['settings'] == null) {
      throw new runtime.RequiredError(
        'settings',
        'Required parameter "settings" was null or undefined when calling updateSettings().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    headerParameters['Content-Type'] = 'application/json'

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'settings:write'
      ])
    }

    let urlPath = `/settings`

    const response = await this.request(
      {
        path: urlPath,
        method: 'POST',
        headers: headerParameters,
        query: queryParameters,
        body: SettingsToJSON(requestParameters['settings'])
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => SettingsFromJSON(jsonValue))
  }

  /**
   * Update system settings
   */
  async updateSettings(
    requestParameters: UpdateSettingsRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Settings> {
    const response = await this.updateSettingsRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * Update a task by ID
   */
  async updateTaskRaw(
    requestParameters: UpdateTaskRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Task>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling updateTask().'
      )
    }

    if (requestParameters['taskUpdate'] == null) {
      throw new runtime.RequiredError(
        'taskUpdate',
        'Required parameter "taskUpdate" was null or undefined when calling updateTask().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    headerParameters['Content-Type'] = 'application/json'

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'ticket:write'
      ])
    }

    let urlPath = `/tasks/{id}`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'PATCH',
        headers: headerParameters,
        query: queryParameters,
        body: TaskUpdateToJSON(requestParameters['taskUpdate'])
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => TaskFromJSON(jsonValue))
  }

  /**
   * Update a task by ID
   */
  async updateTask(
    requestParameters: UpdateTaskRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Task> {
    const response = await this.updateTaskRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * Update a ticket by ID
   */
  async updateTicketRaw(
    requestParameters: UpdateTicketRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Ticket>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling updateTicket().'
      )
    }

    if (requestParameters['ticketUpdate'] == null) {
      throw new runtime.RequiredError(
        'ticketUpdate',
        'Required parameter "ticketUpdate" was null or undefined when calling updateTicket().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    headerParameters['Content-Type'] = 'application/json'

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'ticket:write'
      ])
    }

    let urlPath = `/tickets/{id}`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'PATCH',
        headers: headerParameters,
        query: queryParameters,
        body: TicketUpdateToJSON(requestParameters['ticketUpdate'])
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => TicketFromJSON(jsonValue))
  }

  /**
   * Update a ticket by ID
   */
  async updateTicket(
    requestParameters: UpdateTicketRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Ticket> {
    const response = await this.updateTicketRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * Update a timeline item by ID
   */
  async updateTimelineRaw(
    requestParameters: UpdateTimelineRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<TimelineEntry>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling updateTimeline().'
      )
    }

    if (requestParameters['timelineEntryUpdate'] == null) {
      throw new runtime.RequiredError(
        'timelineEntryUpdate',
        'Required parameter "timelineEntryUpdate" was null or undefined when calling updateTimeline().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    headerParameters['Content-Type'] = 'application/json'

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'ticket:write'
      ])
    }

    let urlPath = `/timeline/{id}`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'PATCH',
        headers: headerParameters,
        query: queryParameters,
        body: TimelineEntryUpdateToJSON(requestParameters['timelineEntryUpdate'])
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => TimelineEntryFromJSON(jsonValue))
  }

  /**
   * Update a timeline item by ID
   */
  async updateTimeline(
    requestParameters: UpdateTimelineRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<TimelineEntry> {
    const response = await this.updateTimelineRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * Update a type by ID
   */
  async updateTypeRaw(
    requestParameters: UpdateTypeRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Type>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling updateType().'
      )
    }

    if (requestParameters['typeUpdate'] == null) {
      throw new runtime.RequiredError(
        'typeUpdate',
        'Required parameter "typeUpdate" was null or undefined when calling updateType().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    headerParameters['Content-Type'] = 'application/json'

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [])
    }

    let urlPath = `/types/{id}`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'PATCH',
        headers: headerParameters,
        query: queryParameters,
        body: TypeUpdateToJSON(requestParameters['typeUpdate'])
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => TypeFromJSON(jsonValue))
  }

  /**
   * Update a type by ID
   */
  async updateType(
    requestParameters: UpdateTypeRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Type> {
    const response = await this.updateTypeRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * Update a user by ID
   */
  async updateUserRaw(
    requestParameters: UpdateUserRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<User>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling updateUser().'
      )
    }

    if (requestParameters['userUpdate'] == null) {
      throw new runtime.RequiredError(
        'userUpdate',
        'Required parameter "userUpdate" was null or undefined when calling updateUser().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    headerParameters['Content-Type'] = 'application/json'

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'user:write'
      ])
    }

    let urlPath = `/users/{id}`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'PATCH',
        headers: headerParameters,
        query: queryParameters,
        body: UserUpdateToJSON(requestParameters['userUpdate'])
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => UserFromJSON(jsonValue))
  }

  /**
   * Update a user by ID
   */
  async updateUser(
    requestParameters: UpdateUserRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<User> {
    const response = await this.updateUserRaw(requestParameters, initOverrides)
    return await response.value()
  }

  /**
   * Update a webhook by ID
   */
  async updateWebhookRaw(
    requestParameters: UpdateWebhookRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<runtime.ApiResponse<Webhook>> {
    if (requestParameters['id'] == null) {
      throw new runtime.RequiredError(
        'id',
        'Required parameter "id" was null or undefined when calling updateWebhook().'
      )
    }

    if (requestParameters['webhookUpdate'] == null) {
      throw new runtime.RequiredError(
        'webhookUpdate',
        'Required parameter "webhookUpdate" was null or undefined when calling updateWebhook().'
      )
    }

    const queryParameters: any = {}

    const headerParameters: runtime.HTTPHeaders = {}

    headerParameters['Content-Type'] = 'application/json'

    if (this.configuration && this.configuration.accessToken) {
      // oauth required
      headerParameters['Authorization'] = await this.configuration.accessToken('OAuth2', [
        'webhook:write'
      ])
    }

    let urlPath = `/webhooks/{id}`
    urlPath = urlPath.replace(`{${'id'}}`, encodeURIComponent(String(requestParameters['id'])))

    const response = await this.request(
      {
        path: urlPath,
        method: 'PATCH',
        headers: headerParameters,
        query: queryParameters,
        body: WebhookUpdateToJSON(requestParameters['webhookUpdate'])
      },
      initOverrides
    )

    return new runtime.JSONApiResponse(response, (jsonValue) => WebhookFromJSON(jsonValue))
  }

  /**
   * Update a webhook by ID
   */
  async updateWebhook(
    requestParameters: UpdateWebhookRequest,
    initOverrides?: RequestInit | runtime.InitOverrideFunction
  ): Promise<Webhook> {
    const response = await this.updateWebhookRaw(requestParameters, initOverrides)
    return await response.value()
  }
}
