@simpleapps-com/augur-api
Version:
TypeScript client library for Augur microservices API endpoints
128 lines • 4.65 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.createContactsResource = createContactsResource;
exports.createContactsDataResource = createContactsDataResource;
const schemas_1 = require("../schemas");
/**
* Creates the contacts resource methods
* OpenAPI Path: /contacts → contacts.*
* @description Contact-specific operations and static refresh endpoint
*/
function createContactsResource(executeRequest) {
return Object.assign(
// Factory function for contact-specific endpoints
(contactId) => ({
/**
* Contact document endpoint - OpenAPI Path: /contacts/{id}/doc (GET)
* @fullPath api.customers.contacts.doc
* @description Returns contact document with full details
* @service customers
* @domain contact-management
* @dataMethod contactsData.doc.get
* @discoverable true
*/
doc: {
get: async () => {
return executeRequest({
method: 'GET',
path: '/contacts/{id}/doc',
responseSchema: schemas_1.ContactsIdDocResponseSchema,
}, undefined, { id: String(contactId) });
},
},
/**
* Contact web allowance endpoint - OpenAPI Path: /contacts/{id}/web-allowance (GET)
* @fullPath api.customers.contacts.webAllowance
* @description Returns contact web allowance permissions
* @service customers
* @domain contact-management
* @dataMethod contactsData.webAllowance.get
* @discoverable true
*/
webAllowance: {
get: async () => {
return executeRequest({
method: 'GET',
path: '/contacts/{id}/web-allowance',
responseSchema: schemas_1.ContactsIdWebAllowanceResponseSchema,
}, undefined, { id: String(contactId) });
},
},
/**
* Contact customers endpoint - OpenAPI Path: /contacts/{id}/customers (GET)
* @fullPath api.customers.contacts.customers
* @description Returns list of customers associated with this contact
* @service customers
* @domain contact-management
* @dataMethod contactsData.customers.list
* @discoverable true
*/
customers: {
list: async (params) => {
return executeRequest({
method: 'GET',
path: '/contacts/{id}/customers',
paramsSchema: schemas_1.ContactsIdCustomersParamsSchema,
responseSchema: schemas_1.ContactsIdCustomersResponseSchema,
}, params, { id: String(contactId) });
},
},
}),
// Static methods for contacts endpoint
{
/**
* Contacts refresh endpoint - OpenAPI Path: /contacts/refresh (GET)
* @fullPath api.customers.contacts.refresh
* @description Refreshes contact data from source system
* @service customers
* @domain data-refresh
* @dataMethod contactsData.refresh.get
* @discoverable true
*/
refresh: {
get: async () => {
return executeRequest({
method: 'GET',
path: '/contacts/refresh',
responseSchema: schemas_1.ContactsRefreshResponseSchema,
});
},
},
});
}
/**
* Creates the contactsData resource methods (data-only versions)
*/
function createContactsDataResource(contacts) {
return Object.assign((contactId) => {
const contactInstance = contacts(contactId);
return {
doc: {
get: async () => {
const response = await contactInstance.doc.get();
return response.data;
},
},
webAllowance: {
get: async () => {
const response = await contactInstance.webAllowance.get();
return response.data;
},
},
customers: {
list: async (params) => {
const response = await contactInstance.customers.list(params);
return response.data;
},
},
};
}, {
refresh: {
get: async () => {
const response = await contacts.refresh.get();
return response.data;
},
},
});
}
//# sourceMappingURL=contacts.js.map