UNPKG

@simpleapps-com/augur-api

Version:

TypeScript client library for Augur microservices API endpoints

124 lines 4.57 kB
import { ContactsIdDocResponseSchema, ContactsIdCustomersParamsSchema, ContactsIdCustomersResponseSchema, ContactsIdWebAllowanceResponseSchema, ContactsRefreshResponseSchema, } from '../schemas'; /** * Creates the contacts resource methods * OpenAPI Path: /contacts → contacts.* * @description Contact-specific operations and static refresh endpoint */ export 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: 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: 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: ContactsIdCustomersParamsSchema, responseSchema: 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: ContactsRefreshResponseSchema, }); }, }, }); } /** * Creates the contactsData resource methods (data-only versions) */ export 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