UNPKG

juapp-freelancer-service-client

Version:
1,069 lines (1,030 loc) 30.9 kB
/* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ import type { Client } from '../models/Client'; import type { ClientInvoices } from '../models/ClientInvoices'; import type { ClientTimesheet } from '../models/ClientTimesheet'; import type { ClientTimesheetEntriesResponse } from '../models/ClientTimesheetEntriesResponse'; import type { ClientTimesheetEntry } from '../models/ClientTimesheetEntry'; import type { CreateClientRequest } from '../models/CreateClientRequest'; import type { CreateProjectRequest } from '../models/CreateProjectRequest'; import type { CreateUserInvoiceRequest } from '../models/CreateUserInvoiceRequest'; import type { GetClients } from '../models/GetClients'; import type { GetInvoicesResponse } from '../models/GetInvoicesResponse'; import type { GetProjects } from '../models/GetProjects'; import type { Project } from '../models/Project'; import type { Timesheet } from '../models/Timesheet'; import type { TimesheetEntry } from '../models/TimesheetEntry'; import type { UpdateClientRequest } from '../models/UpdateClientRequest'; import type { UpdateClientTimesheetEntriesRequest } from '../models/UpdateClientTimesheetEntriesRequest'; import type { UpdateProjectRequest } from '../models/UpdateProjectRequest'; import type { UpdateUserRequest } from '../models/UpdateUserRequest'; import type { User } from '../models/User'; import type { UserInvoices } from '../models/UserInvoices'; import type { UserInvoiceTemplate } from '../models/UserInvoiceTemplate'; import type { Users } from '../models/Users'; import { request as __request } from '../core/request'; export class Service { /** * Clients * @param limit Items per page * @param page Page * @returns GetClients Get clients * @throws ApiError */ public static async getClients( limit?: number, page?: number, ): Promise<GetClients> { const result = await __request({ method: 'GET', path: `/v1.0.0/clients`, query: { 'limit': limit, 'page': page, }, errors: { 400: `Bad request`, 401: `Unauthorized`, 403: `Forbidden`, 404: `Not Found`, 500: `Internal server error`, 503: `Service unavailable`, }, }); return result.body; } /** * Create client * @param requestBody * @returns Client Client was created * @throws ApiError */ public static async createClient( requestBody?: CreateClientRequest, ): Promise<Client> { const result = await __request({ method: 'POST', path: `/v1.0.0/clients`, body: requestBody, errors: { 400: `Bad request`, 401: `Unauthorized`, 403: `Forbidden`, 404: `Not Found`, 500: `Internal server error`, 503: `Service unavailable`, }, }); return result.body; } /** * Get client by id * @param id client id * @returns Client client was successfully retrieved * @throws ApiError */ public static async getClientById( id: string, ): Promise<Client> { const result = await __request({ method: 'GET', path: `/v1.0.0/clients/${id}`, errors: { 400: `Bad request`, 401: `Unauthorized`, 403: `Forbidden`, 404: `Not Found`, 500: `Internal server error`, 503: `Service unavailable`, }, }); return result.body; } /** * Update client * @param id client id * @param requestBody * @returns Client Client was updated * @throws ApiError */ public static async updateClientById( id: string, requestBody?: UpdateClientRequest, ): Promise<Client> { const result = await __request({ method: 'PATCH', path: `/v1.0.0/clients/${id}`, body: requestBody, errors: { 400: `Bad request`, 401: `Unauthorized`, 403: `Forbidden`, 404: `Not Found`, 500: `Internal server error`, 503: `Service unavailable`, }, }); return result.body; } /** * Delete client * @param id client id * @returns any Client was deleted * @throws ApiError */ public static async deleteClientById( id: string, ): Promise<any> { const result = await __request({ method: 'DELETE', path: `/v1.0.0/clients/${id}`, errors: { 400: `Bad request`, 401: `Unauthorized`, 403: `Forbidden`, 404: `Not Found`, 500: `Internal server error`, 503: `Service unavailable`, }, }); return result.body; } /** * Client invoices * @param id client id * @param limit Items per page * @param page Page * @returns ClientInvoices Get client invoices * @throws ApiError */ public static async getClientInvoices( id: string, limit?: number, page?: number, ): Promise<ClientInvoices> { const result = await __request({ method: 'GET', path: `/v1.0.0/clients/${id}/invoices`, query: { 'limit': limit, 'page': page, }, errors: { 400: `Bad request`, 401: `Unauthorized`, 403: `Forbidden`, 404: `Not Found`, 500: `Internal server error`, 503: `Service unavailable`, }, }); return result.body; } /** * Download client invoice * @param id client id * @param number invoice number * @returns any client invoice was successfully downloaded * @throws ApiError */ public static async downloadClientInvoice( id: string, number: string, ): Promise<any> { const result = await __request({ method: 'GET', path: `/v1.0.0/clients/${id}/invoices/${number}`, errors: { 400: `Bad request`, 401: `Unauthorized`, 403: `Forbidden`, 404: `Not Found`, 500: `Internal server error`, 503: `Service unavailable`, }, }); return result.body; } /** * Projects * @param limit Items per page * @param page Page * @returns GetProjects Get projects * @throws ApiError */ public static async getProjects( limit?: number, page?: number, ): Promise<GetProjects> { const result = await __request({ method: 'GET', path: `/v1.0.0/projects`, query: { 'limit': limit, 'page': page, }, errors: { 400: `Bad request`, 401: `Unauthorized`, 403: `Forbidden`, 404: `Not Found`, 500: `Internal server error`, 503: `Service unavailable`, }, }); return result.body; } /** * Create project * @param requestBody * @returns Project Project was created * @throws ApiError */ public static async createProject( requestBody?: CreateProjectRequest, ): Promise<Project> { const result = await __request({ method: 'POST', path: `/v1.0.0/projects`, body: requestBody, errors: { 400: `Bad request`, 401: `Unauthorized`, 403: `Forbidden`, 404: `Not Found`, 500: `Internal server error`, 503: `Service unavailable`, }, }); return result.body; } /** * Get project by id * @param id project id * @returns Project project was successfully retrieved * @throws ApiError */ public static async getProjectById( id: string, ): Promise<Project> { const result = await __request({ method: 'GET', path: `/v1.0.0/projects/${id}`, errors: { 400: `Bad request`, 401: `Unauthorized`, 403: `Forbidden`, 404: `Not Found`, 500: `Internal server error`, 503: `Service unavailable`, }, }); return result.body; } /** * Update project * @param id project id * @param requestBody * @returns Project Project was updated * @throws ApiError */ public static async updateProjectById( id: string, requestBody?: UpdateProjectRequest, ): Promise<Project> { const result = await __request({ method: 'PATCH', path: `/v1.0.0/projects/${id}`, body: requestBody, errors: { 400: `Bad request`, 401: `Unauthorized`, 403: `Forbidden`, 404: `Not Found`, 500: `Internal server error`, 503: `Service unavailable`, }, }); return result.body; } /** * Delete project * @param id project id * @returns any Project was deleted * @throws ApiError */ public static async deleteProjectById( id: string, ): Promise<any> { const result = await __request({ method: 'DELETE', path: `/v1.0.0/projects/${id}`, errors: { 400: `Bad request`, 401: `Unauthorized`, 403: `Forbidden`, 404: `Not Found`, 500: `Internal server error`, 503: `Service unavailable`, }, }); return result.body; } /** * Add project associate * @param id project id * @param userId user id * @returns any Associate was added to project * @throws ApiError */ public static async addProjectAssociate( id: string, userId: string, ): Promise<any> { const result = await __request({ method: 'POST', path: `/v1.0.0/projects/${id}/associates/${userId}`, errors: { 400: `Bad request`, 401: `Unauthorized`, 403: `Forbidden`, 404: `Not Found`, 500: `Internal server error`, 503: `Service unavailable`, }, }); return result.body; } /** * Remove project associate from project * @param id project id * @param userId user id * @returns any Associate was removed from project * @throws ApiError */ public static async removeProjectAssociate( id: string, userId: string, ): Promise<any> { const result = await __request({ method: 'DELETE', path: `/v1.0.0/projects/${id}/associates/${userId}`, errors: { 400: `Bad request`, 401: `Unauthorized`, 403: `Forbidden`, 404: `Not Found`, 500: `Internal server error`, 503: `Service unavailable`, }, }); return result.body; } /** * Get users * @param limit Items per page * @param page Page * @param email User's email * @returns Users users were successfully retrieved * @throws ApiError */ public static async getUsers( limit?: number, page?: number, email?: string, ): Promise<Users> { const result = await __request({ method: 'GET', path: `/v1.0.0/users`, query: { 'limit': limit, 'page': page, 'email': email, }, errors: { 400: `Bad request`, 401: `Unauthorized`, 403: `Forbidden`, 404: `Not Found`, 500: `Internal server error`, 503: `Service unavailable`, }, }); return result.body; } /** * Get user by id * @param id user id * @returns User user was successfully retrieved * @throws ApiError */ public static async getUserById( id: string, ): Promise<User> { const result = await __request({ method: 'GET', path: `/v1.0.0/users/${id}`, errors: { 400: `Bad request`, 401: `Unauthorized`, 403: `Forbidden`, 404: `Not Found`, 500: `Internal server error`, 503: `Service unavailable`, }, }); return result.body; } /** * Update user * @param id user id * @param requestBody * @returns User User was updated * @throws ApiError */ public static async updateUserById( id: string, requestBody?: UpdateUserRequest, ): Promise<User> { const result = await __request({ method: 'PATCH', path: `/v1.0.0/users/${id}`, body: requestBody, errors: { 400: `Bad request`, 401: `Unauthorized`, 403: `Forbidden`, 404: `Not Found`, 500: `Internal server error`, 503: `Service unavailable`, }, }); return result.body; } /** * Get user associates * @param id user id * @param limit Items per page * @param page Page * @returns Users user's associates were successfully retrieved * @throws ApiError */ public static async getUserAssociates( id: string, limit?: number, page?: number, ): Promise<Users> { const result = await __request({ method: 'GET', path: `/v1.0.0/users/${id}/associates`, query: { 'limit': limit, 'page': page, }, errors: { 400: `Bad request`, 401: `Unauthorized`, 403: `Forbidden`, 404: `Not Found`, 500: `Internal server error`, 503: `Service unavailable`, }, }); return result.body; } /** * Create user invoice * @param id user id * @param requestBody * @returns any User invoice was created * @throws ApiError */ public static async createUserInvoice( id: string, requestBody?: CreateUserInvoiceRequest, ): Promise<any> { const result = await __request({ method: 'POST', path: `/v1.0.0/users/${id}/invoices`, body: requestBody, errors: { 400: `Bad request`, 401: `Unauthorized`, 403: `Forbidden`, 404: `Not Found`, 500: `Internal server error`, 503: `Service unavailable`, }, }); return result.body; } /** * Get user invoices * @param id user id * @param limit Items per page * @param page Page * @param template user invoice template * @returns UserInvoices user invoices were successfully retrieved * @throws ApiError */ public static async getUserInvoices( id: string, limit?: number, page?: number, template?: UserInvoiceTemplate, ): Promise<UserInvoices> { const result = await __request({ method: 'GET', path: `/v1.0.0/users/${id}/invoices`, query: { 'limit': limit, 'page': page, 'template': template, }, errors: { 400: `Bad request`, 401: `Unauthorized`, 403: `Forbidden`, 404: `Not Found`, 500: `Internal server error`, 503: `Service unavailable`, }, }); return result.body; } /** * Download user invoice * @param id user id * @param number invoice number * @param template user invoice template * @returns any user invoice was successfully downloaded * @throws ApiError */ public static async downloadUserInvoice( id: string, number: string, template: UserInvoiceTemplate, ): Promise<any> { const result = await __request({ method: 'GET', path: `/v1.0.0/users/${id}/invoices/${number}`, query: { 'template': template, }, errors: { 400: `Bad request`, 401: `Unauthorized`, 403: `Forbidden`, 404: `Not Found`, 500: `Internal server error`, 503: `Service unavailable`, }, }); return result.body; } /** * Get timesheets * @param project project id * @param limit Items per page * @param page Page * @param from Timesheet's start date * @param to Timesheet's to date * @param status Timesheet's status * @returns any timesheets were successfully retrieved * @throws ApiError */ public static async getTimesheets( project: string, limit?: number, page?: number, from?: any, to?: any, status?: string, ): Promise<{ total?: number, items?: Array<Timesheet>, }> { const result = await __request({ method: 'GET', path: `/v1.0.0/timesheets`, query: { 'project': project, 'limit': limit, 'page': page, 'from': from, 'to': to, 'status': status, }, errors: { 400: `Bad request`, 401: `Unauthorized`, 403: `Forbidden`, 404: `Not Found`, 500: `Internal server error`, 503: `Service unavailable`, }, }); return result.body; } /** * Get timesheet by id * @param id timesheet id * @returns Timesheet timesheet was successfully retrieved * @throws ApiError */ public static async getTimesheetById( id: string, ): Promise<Timesheet> { const result = await __request({ method: 'GET', path: `/v1.0.0/timesheets/${id}`, errors: { 400: `Bad request`, 401: `Unauthorized`, 403: `Forbidden`, 404: `Not Found`, 500: `Internal server error`, 503: `Service unavailable`, }, }); return result.body; } /** * Send timesheet by id * @param id timesheet id * @returns Timesheet Timesheet was sent * @throws ApiError */ public static async sendTimesheetById( id: string, ): Promise<Timesheet> { const result = await __request({ method: 'PATCH', path: `/v1.0.0/timesheets/${id}/send`, errors: { 400: `Bad request`, 401: `Unauthorized`, 403: `Forbidden`, 404: `Not Found`, 500: `Internal server error`, 503: `Service unavailable`, }, }); return result.body; } /** * Approve timesheet by id * @param id timesheet id * @returns Timesheet Timesheet was approved * @throws ApiError */ public static async approveTimesheetById( id: string, ): Promise<Timesheet> { const result = await __request({ method: 'PATCH', path: `/v1.0.0/timesheets/${id}/approve`, errors: { 400: `Bad request`, 401: `Unauthorized`, 403: `Forbidden`, 404: `Not Found`, 500: `Internal server error`, 503: `Service unavailable`, }, }); return result.body; } /** * Get timesheet entries * @param id timesheet id * @returns any timesheet entries were successfully retrieved * @throws ApiError */ public static async getTimesheetEntriesById( id: string, ): Promise<{ total?: number, items?: Array<TimesheetEntry>, }> { const result = await __request({ method: 'GET', path: `/v1.0.0/timesheets/${id}/entries`, errors: { 400: `Bad request`, 401: `Unauthorized`, 403: `Forbidden`, 404: `Not Found`, 500: `Internal server error`, 503: `Service unavailable`, }, }); return result.body; } /** * Update timesheet entry * @param id timesheet id * @param entryId entryId id * @param requestBody * @returns TimesheetEntry Timesheet entry was updated * @throws ApiError */ public static async updateTimesheetEntryById( id: string, entryId: string, requestBody?: { checkIn?: string, checkOut?: string, /** * pause in minutes */ pause?: number, comments?: string, remote?: boolean, }, ): Promise<TimesheetEntry> { const result = await __request({ method: 'PATCH', path: `/v1.0.0/timesheets/${id}/entries/${entryId}`, body: requestBody, errors: { 400: `Bad request`, 401: `Unauthorized`, 403: `Forbidden`, 404: `Not Found`, 500: `Internal server error`, 503: `Service unavailable`, }, }); return result.body; } /** * Get invoices * @param limit Items per page * @param page Page * @returns GetInvoicesResponse invoice was successfully retrieved * @throws ApiError */ public static async getInvoices( limit?: number, page?: number, ): Promise<GetInvoicesResponse> { const result = await __request({ method: 'GET', path: `/v1.0.0/invoices`, query: { 'limit': limit, 'page': page, }, errors: { 400: `Bad request`, 404: `Not Found`, 500: `Internal server error`, 503: `Service unavailable`, }, }); return result.body; } /** * Delete invoice * @param id invoice id * @returns any Invoice was deleted * @throws ApiError */ public static async deleteInvoiceById( id: string, ): Promise<any> { const result = await __request({ method: 'DELETE', path: `/v1.0.0/invoices/${id}`, errors: { 400: `Bad request`, 404: `Not Found`, 500: `Internal server error`, 503: `Service unavailable`, }, }); return result.body; } /** * Download invoice * @param id invoice id * @returns any Invoice was downloaded * @throws ApiError */ public static async downloadInvoiceById( id: string, ): Promise<any> { const result = await __request({ method: 'GET', path: `/v1.0.0/invoices/${id}/download`, errors: { 400: `Bad request`, 404: `Not Found`, 500: `Internal server error`, 503: `Service unavailable`, }, }); return result.body; } /** * Get client timesheets * @param project project id * @param limit Items per page * @param page Page * @param from Client timesheet start date * @param to Client timesheet to date * @param status Client timesheet status * @returns any timesheets were successfully retrieved * @throws ApiError */ public static async getClientTimesheets( project: string, limit?: number, page?: number, from?: any, to?: any, status?: string, ): Promise<{ total?: number, items?: Array<ClientTimesheet>, }> { const result = await __request({ method: 'GET', path: `/v1.0.0/clientTimesheets`, query: { 'project': project, 'limit': limit, 'page': page, 'from': from, 'to': to, 'status': status, }, errors: { 400: `Bad request`, 401: `Unauthorized`, 403: `Forbidden`, 404: `Not Found`, 500: `Internal server error`, 503: `Service unavailable`, }, }); return result.body; } /** * Get client timesheet by id * @param id client timesheet id * @returns ClientTimesheet client timesheet was successfully retrieved * @throws ApiError */ public static async getClientTimesheetById( id: string, ): Promise<ClientTimesheet> { const result = await __request({ method: 'GET', path: `/v1.0.0/clientTimesheets/${id}`, errors: { 400: `Bad request`, 401: `Unauthorized`, 403: `Forbidden`, 404: `Not Found`, 500: `Internal server error`, 503: `Service unavailable`, }, }); return result.body; } /** * Approve client timesheet by id * @param id client timesheet id * @returns ClientTimesheet Client timesheet was approved * @throws ApiError */ public static async approveClientTimesheetById( id: string, ): Promise<ClientTimesheet> { const result = await __request({ method: 'PATCH', path: `/v1.0.0/clientTimesheets/${id}/approve`, errors: { 400: `Bad request`, 401: `Unauthorized`, 403: `Forbidden`, 404: `Not Found`, 500: `Internal server error`, 503: `Service unavailable`, }, }); return result.body; } /** * Get client timesheet entries * @param id client timesheet id * @returns ClientTimesheetEntriesResponse client timesheet entries were successfully retrieved * @throws ApiError */ public static async getClientTimesheetEntriesById( id: string, ): Promise<ClientTimesheetEntriesResponse> { const result = await __request({ method: 'GET', path: `/v1.0.0/clientTimesheets/${id}/entries`, errors: { 400: `Bad request`, 401: `Unauthorized`, 403: `Forbidden`, 404: `Not Found`, 500: `Internal server error`, 503: `Service unavailable`, }, }); return result.body; } /** * Update client timesheet entries * @param id client timesheet id * @param requestBody * @returns ClientTimesheetEntriesResponse Timesheet entries were updated * @throws ApiError */ public static async updateClientTimesheetEntries( id: string, requestBody?: UpdateClientTimesheetEntriesRequest, ): Promise<ClientTimesheetEntriesResponse> { const result = await __request({ method: 'PATCH', path: `/v1.0.0/clientTimesheets/${id}/entries`, body: requestBody, errors: { 400: `Bad request`, 401: `Unauthorized`, 403: `Forbidden`, 404: `Not Found`, 500: `Internal server error`, 503: `Service unavailable`, }, }); return result.body; } /** * Download client timesheet * @param id client timesheet id * @returns any client timesheet was successfully downloaded * @throws ApiError */ public static async downloadClientTimesheet( id: string, ): Promise<any> { const result = await __request({ method: 'GET', path: `/v1.0.0/clientTimesheets/${id}/download`, errors: { 400: `Bad request`, 401: `Unauthorized`, 403: `Forbidden`, 404: `Not Found`, 500: `Internal server error`, 503: `Service unavailable`, }, }); return result.body; } /** * Update client timesheet entry * @param id client timesheet id * @param entryId entryId id * @param requestBody * @returns ClientTimesheetEntry Timesheet entry was updated * @throws ApiError */ public static async updateClientTimesheetEntryById( id: string, entryId: string, requestBody?: { checkIn?: string, checkOut?: string, /** * pause in minutes */ pause?: number, comments?: string, remote?: boolean, }, ): Promise<ClientTimesheetEntry> { const result = await __request({ method: 'PATCH', path: `/v1.0.0/clientTimesheets/${id}/entries/${entryId}`, body: requestBody, errors: { 400: `Bad request`, 401: `Unauthorized`, 403: `Forbidden`, 404: `Not Found`, 500: `Internal server error`, 503: `Service unavailable`, }, }); return result.body; } }