Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/resources/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ export class ActionsResource {
* Create a new action
*/
async create(data: ActionCreateData): Promise<Action> {
const response = await this.httpClient.request<{ actions: Action[] }>('/Actions', {
const response = await this.httpClient.request<Action | { actions: Action[] }>('/Actions', {
method: 'POST',
body: [data],
});
const action = response.actions[0];
const action = unwrapSingle<Action>(response, 'actions');
if (!action) {
throw new Error('Failed to create action');
}
Expand All @@ -76,11 +76,11 @@ export class ActionsResource {
* Update an existing action
*/
async update(id: number, data: ActionUpdateData): Promise<Action> {
const response = await this.httpClient.request<{ actions: Action[] }>('/Actions', {
const response = await this.httpClient.request<Action | { actions: Action[] }>('/Actions', {
method: 'POST',
body: [{ id, ...data }],
});
const action = response.actions[0];
const action = unwrapSingle<Action>(response, 'actions');
if (!action) {
throw new Error('Failed to update action');
}
Expand Down
12 changes: 6 additions & 6 deletions src/resources/agents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ export class AgentsResource {
* Get the current authenticated agent
*/
async me(): Promise<Agent> {
const response = await this.httpClient.request<{ agents: Agent[] }>('/Agent/me');
const agent = response.agents[0];
const response = await this.httpClient.request<Agent | { agents: Agent[] }>('/Agent/me');
const agent = unwrapSingle<Agent>(response, 'agents');
if (!agent) {
throw new Error('Failed to get current agent');
}
Expand All @@ -78,11 +78,11 @@ export class AgentsResource {
* Create a new agent
*/
async create(data: AgentCreateData): Promise<Agent> {
const response = await this.httpClient.request<{ agents: Agent[] }>('/Agent', {
const response = await this.httpClient.request<Agent | { agents: Agent[] }>('/Agent', {
method: 'POST',
body: [data],
});
const agent = response.agents[0];
const agent = unwrapSingle<Agent>(response, 'agents');
if (!agent) {
throw new Error('Failed to create agent');
}
Expand All @@ -93,11 +93,11 @@ export class AgentsResource {
* Update an existing agent
*/
async update(id: number, data: AgentUpdateData): Promise<Agent> {
const response = await this.httpClient.request<{ agents: Agent[] }>('/Agent', {
const response = await this.httpClient.request<Agent | { agents: Agent[] }>('/Agent', {
method: 'POST',
body: [{ id, ...data }],
});
const agent = response.agents[0];
const agent = unwrapSingle<Agent>(response, 'agents');
if (!agent) {
throw new Error('Failed to update agent');
}
Expand Down
8 changes: 4 additions & 4 deletions src/resources/appointments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ export class AppointmentsResource {
* Create a new appointment
*/
async create(data: AppointmentCreateData): Promise<Appointment> {
const response = await this.httpClient.request<{ appointments: Appointment[] }>('/Appointment', {
const response = await this.httpClient.request<Appointment | { appointments: Appointment[] }>('/Appointment', {
method: 'POST',
body: [data],
});
const appointment = response.appointments[0];
const appointment = unwrapSingle<Appointment>(response, 'appointments');
if (!appointment) {
throw new Error('Failed to create appointment');
}
Expand All @@ -81,11 +81,11 @@ export class AppointmentsResource {
* Update an existing appointment
*/
async update(id: number, data: AppointmentUpdateData): Promise<Appointment> {
const response = await this.httpClient.request<{ appointments: Appointment[] }>('/Appointment', {
const response = await this.httpClient.request<Appointment | { appointments: Appointment[] }>('/Appointment', {
method: 'POST',
body: [{ id, ...data }],
});
const appointment = response.appointments[0];
const appointment = unwrapSingle<Appointment>(response, 'appointments');
if (!appointment) {
throw new Error('Failed to update appointment');
}
Expand Down
8 changes: 4 additions & 4 deletions src/resources/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ export class AssetsResource {
* Create a new asset
*/
async create(data: AssetCreateData): Promise<Asset> {
const response = await this.httpClient.request<{ assets: Asset[] }>('/Asset', {
const response = await this.httpClient.request<Asset | { assets: Asset[] }>('/Asset', {
method: 'POST',
body: [data],
});
const asset = response.assets[0];
const asset = unwrapSingle<Asset>(response, 'assets');
if (!asset) {
throw new Error('Failed to create asset');
}
Expand All @@ -84,11 +84,11 @@ export class AssetsResource {
* Update an existing asset
*/
async update(id: number, data: AssetUpdateData): Promise<Asset> {
const response = await this.httpClient.request<{ assets: Asset[] }>('/Asset', {
const response = await this.httpClient.request<Asset | { assets: Asset[] }>('/Asset', {
method: 'POST',
body: [{ id, ...data }],
});
const asset = response.assets[0];
const asset = unwrapSingle<Asset>(response, 'assets');
if (!asset) {
throw new Error('Failed to update asset');
}
Expand Down
8 changes: 4 additions & 4 deletions src/resources/clients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ export class ClientsResource {
* Create a new client
*/
async create(data: ClientCreateData): Promise<Client> {
const response = await this.httpClient.request<{ clients: Client[] }>('/Client', {
const response = await this.httpClient.request<Client | { clients: Client[] }>('/Client', {
method: 'POST',
body: [data],
});
const client = response.clients[0];
const client = unwrapSingle<Client>(response, 'clients');
if (!client) {
throw new Error('Failed to create client');
}
Expand All @@ -81,11 +81,11 @@ export class ClientsResource {
* Update an existing client
*/
async update(id: number, data: ClientUpdateData): Promise<Client> {
const response = await this.httpClient.request<{ clients: Client[] }>('/Client', {
const response = await this.httpClient.request<Client | { clients: Client[] }>('/Client', {
method: 'POST',
body: [{ id, ...data }],
});
const client = response.clients[0];
const client = unwrapSingle<Client>(response, 'clients');
if (!client) {
throw new Error('Failed to update client');
}
Expand Down
8 changes: 4 additions & 4 deletions src/resources/contacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ export class ContactsResource {
* Create a new contact
*/
async create(data: ContactCreateData): Promise<Contact> {
const response = await this.httpClient.request<{ users: Contact[] }>('/Users', {
const response = await this.httpClient.request<Contact | { users: Contact[] }>('/Users', {
method: 'POST',
body: [data],
});
const contact = response.users[0];
const contact = unwrapSingle<Contact>(response, 'users');
if (!contact) {
throw new Error('Failed to create contact');
}
Expand All @@ -81,11 +81,11 @@ export class ContactsResource {
* Update an existing contact
*/
async update(id: number, data: ContactUpdateData): Promise<Contact> {
const response = await this.httpClient.request<{ users: Contact[] }>('/Users', {
const response = await this.httpClient.request<Contact | { users: Contact[] }>('/Users', {
method: 'POST',
body: [{ id, ...data }],
});
const contact = response.users[0];
const contact = unwrapSingle<Contact>(response, 'users');
if (!contact) {
throw new Error('Failed to update contact');
}
Expand Down
8 changes: 4 additions & 4 deletions src/resources/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ export class ContractsResource {
* Create a new contract
*/
async create(data: ContractCreateData): Promise<Contract> {
const response = await this.httpClient.request<{ contracts: Contract[] }>('/ClientContract', {
const response = await this.httpClient.request<Contract | { contracts: Contract[] }>('/ClientContract', {
method: 'POST',
body: [data],
});
const contract = response.contracts[0];
const contract = unwrapSingle<Contract>(response, 'contracts');
if (!contract) {
throw new Error('Failed to create contract');
}
Expand All @@ -81,11 +81,11 @@ export class ContractsResource {
* Update an existing contract
*/
async update(id: number, data: ContractUpdateData): Promise<Contract> {
const response = await this.httpClient.request<{ contracts: Contract[] }>('/ClientContract', {
const response = await this.httpClient.request<Contract | { contracts: Contract[] }>('/ClientContract', {
method: 'POST',
body: [{ id, ...data }],
});
const contract = response.contracts[0];
const contract = unwrapSingle<Contract>(response, 'contracts');
if (!contract) {
throw new Error('Failed to update contract');
}
Expand Down
8 changes: 4 additions & 4 deletions src/resources/invoices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ export class InvoicesResource {
* Create a new invoice
*/
async create(data: InvoiceCreateData): Promise<Invoice> {
const response = await this.httpClient.request<{ invoices: Invoice[] }>('/Invoice', {
const response = await this.httpClient.request<Invoice | { invoices: Invoice[] }>('/Invoice', {
method: 'POST',
body: [data],
});
const invoice = response.invoices[0];
const invoice = unwrapSingle<Invoice>(response, 'invoices');
if (!invoice) {
throw new Error('Failed to create invoice');
}
Expand All @@ -81,11 +81,11 @@ export class InvoicesResource {
* Update an existing invoice
*/
async update(id: number, data: InvoiceUpdateData): Promise<Invoice> {
const response = await this.httpClient.request<{ invoices: Invoice[] }>('/Invoice', {
const response = await this.httpClient.request<Invoice | { invoices: Invoice[] }>('/Invoice', {
method: 'POST',
body: [{ id, ...data }],
});
const invoice = response.invoices[0];
const invoice = unwrapSingle<Invoice>(response, 'invoices');
if (!invoice) {
throw new Error('Failed to update invoice');
}
Expand Down
8 changes: 4 additions & 4 deletions src/resources/items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ export class ItemsResource {
* Create a new item
*/
async create(data: ItemCreateData): Promise<Item> {
const response = await this.httpClient.request<{ items: Item[] }>('/Item', {
const response = await this.httpClient.request<Item | { items: Item[] }>('/Item', {
method: 'POST',
body: [data],
});
const item = response.items[0];
const item = unwrapSingle<Item>(response, 'items');
if (!item) {
throw new Error('Failed to create item');
}
Expand All @@ -81,11 +81,11 @@ export class ItemsResource {
* Update an existing item
*/
async update(id: number, data: ItemUpdateData): Promise<Item> {
const response = await this.httpClient.request<{ items: Item[] }>('/Item', {
const response = await this.httpClient.request<Item | { items: Item[] }>('/Item', {
method: 'POST',
body: [{ id, ...data }],
});
const item = response.items[0];
const item = unwrapSingle<Item>(response, 'items');
if (!item) {
throw new Error('Failed to update item');
}
Expand Down
8 changes: 4 additions & 4 deletions src/resources/opportunities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ export class OpportunitiesResource {
* Create a new opportunity
*/
async create(data: OpportunityCreateData): Promise<Opportunity> {
const response = await this.httpClient.request<{ opportunities: Opportunity[] }>('/Opportunities', {
const response = await this.httpClient.request<Opportunity | { opportunities: Opportunity[] }>('/Opportunities', {
method: 'POST',
body: [data],
});
const opportunity = response.opportunities[0];
const opportunity = unwrapSingle<Opportunity>(response, 'opportunities');
if (!opportunity) {
throw new Error('Failed to create opportunity');
}
Expand All @@ -81,11 +81,11 @@ export class OpportunitiesResource {
* Update an existing opportunity
*/
async update(id: number, data: OpportunityUpdateData): Promise<Opportunity> {
const response = await this.httpClient.request<{ opportunities: Opportunity[] }>('/Opportunities', {
const response = await this.httpClient.request<Opportunity | { opportunities: Opportunity[] }>('/Opportunities', {
method: 'POST',
body: [{ id, ...data }],
});
const opportunity = response.opportunities[0];
const opportunity = unwrapSingle<Opportunity>(response, 'opportunities');
if (!opportunity) {
throw new Error('Failed to update opportunity');
}
Expand Down
8 changes: 4 additions & 4 deletions src/resources/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ export class ProjectsResource {
* Create a new project
*/
async create(data: ProjectCreateData): Promise<Project> {
const response = await this.httpClient.request<{ projects: Project[] }>('/Projects', {
const response = await this.httpClient.request<Project | { projects: Project[] }>('/Projects', {
method: 'POST',
body: [data],
});
const project = response.projects[0];
const project = unwrapSingle<Project>(response, 'projects');
if (!project) {
throw new Error('Failed to create project');
}
Expand All @@ -83,11 +83,11 @@ export class ProjectsResource {
* Update an existing project
*/
async update(id: number, data: ProjectUpdateData): Promise<Project> {
const response = await this.httpClient.request<{ projects: Project[] }>('/Projects', {
const response = await this.httpClient.request<Project | { projects: Project[] }>('/Projects', {
method: 'POST',
body: [{ id, ...data }],
});
const project = response.projects[0];
const project = unwrapSingle<Project>(response, 'projects');
if (!project) {
throw new Error('Failed to update project');
}
Expand Down
8 changes: 4 additions & 4 deletions src/resources/quotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ export class QuotesResource {
* Create a new quote
*/
async create(data: QuoteCreateData): Promise<Quote> {
const response = await this.httpClient.request<{ quotations: Quote[] }>('/Quotation', {
const response = await this.httpClient.request<Quote | { quotations: Quote[] }>('/Quotation', {
method: 'POST',
body: [data],
});
const quote = response.quotations[0];
const quote = unwrapSingle<Quote>(response, 'quotations');
if (!quote) {
throw new Error('Failed to create quote');
}
Expand All @@ -82,11 +82,11 @@ export class QuotesResource {
* Update an existing quote
*/
async update(id: number, data: QuoteUpdateData): Promise<Quote> {
const response = await this.httpClient.request<{ quotations: Quote[] }>('/Quotation', {
const response = await this.httpClient.request<Quote | { quotations: Quote[] }>('/Quotation', {
method: 'POST',
body: [{ id, ...data }],
});
const quote = response.quotations[0];
const quote = unwrapSingle<Quote>(response, 'quotations');
if (!quote) {
throw new Error('Failed to update quote');
}
Expand Down
Loading