mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 06:10:31 +00:00
fix: customer API schema.
This commit is contained in:
@@ -14,7 +14,8 @@ import {
|
||||
IPaginationMeta,
|
||||
ICustomersFilter,
|
||||
IContactNewDTO,
|
||||
IContactEditDTO
|
||||
IContactEditDTO,
|
||||
IContact
|
||||
} from 'interfaces';
|
||||
import { ServiceError } from 'exceptions';
|
||||
import TenancyService from 'services/Tenancy/TenancyService';
|
||||
@@ -65,6 +66,13 @@ export default class CustomersService {
|
||||
}
|
||||
}
|
||||
|
||||
private transformContactToCustomer(contactModel: IContact) {
|
||||
return {
|
||||
...omit(contactModel, ['contactService', 'contactType']),
|
||||
customerType: contactModel.contactService,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new customer.
|
||||
* @param {number} tenantId
|
||||
@@ -153,7 +161,8 @@ export default class CustomersService {
|
||||
* @param {number} customerId
|
||||
*/
|
||||
public async getCustomer(tenantId: number, customerId: number) {
|
||||
return this.contactService.getContact(tenantId, customerId, 'customer');
|
||||
const contact = await this.contactService.getContact(tenantId, customerId, 'customer');
|
||||
return this.transformContactToCustomer(contact);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -177,7 +186,7 @@ export default class CustomersService {
|
||||
);
|
||||
|
||||
return {
|
||||
customers: results,
|
||||
customers: results.map(this.transformContactToCustomer),
|
||||
pagination,
|
||||
filterMeta: dynamicList.getResponseMeta(),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user