### Authenticate with Weclapp API Source: https://github.com/icosense/weclapp-connect/blob/master/README.md Quickstart example demonstrating how to authenticate with the weclapp API using username, API key, and either tenant or domain. ```javascript const weclapp = require('@icosense/connect') (async () => { // Authenticate const user = weclapp ({ username: '', apikey: '', // One of the following tenant: '', // Example: myapp domain: '', // Example: app.company.com }) // Prints the current user to the console console.log(user) })() ``` -------------------------------- ### Install weclapp-connect Source: https://context7.com/icosense/weclapp-connect/llms.txt Install the library using npm or yarn. ```bash npm install @icosense/connect # or yarn add @icosense/connect ``` -------------------------------- ### Install weclapp-connect via npm Source: https://github.com/icosense/weclapp-connect/blob/master/README.md Use npm to install the weclapp-connect package. ```shell npm install @weclapp/connect ``` -------------------------------- ### Install weclapp-connect via yarn Source: https://github.com/icosense/weclapp-connect/blob/master/README.md Use yarn to add the weclapp-connect package to your project. ```shell yarn add @weclapp/connect ``` -------------------------------- ### Initialize the client with weclapp(config) Source: https://context7.com/icosense/weclapp-connect/llms.txt The default export is a factory function. Call it once with your credentials to get a client instance. Either `tenant` (subdomain of `*.weclapp.com`) or `domain` (a custom hostname) must be provided, together with an `apikey`. ```APIDOC ## weclapp(config) — Initialize the client ### Description The default export is a factory function. Call it once with your credentials to get a client instance. Either `tenant` (subdomain of `*.weclapp.com`) or `domain` (a custom hostname) must be provided, together with an `apikey`. ### Parameters #### Path Parameters - **config** (object) - Required - Configuration object containing `tenant` or `domain`, and `apikey`. - **tenant** (string) - Optional - The tenant subdomain for weclapp. - **domain** (string) - Optional - A custom domain for weclapp. - **apikey** (string) - Required - The API key for authentication. ### Request Example ```javascript const weclapp = require('@icosense/connect') // Using tenant-based URL const client = weclapp({ tenant: 'mycompany', apikey: 'abc123secrettoken' }) // Using a custom domain const client2 = weclapp({ domain: 'erp.mycompany.com', apikey: 'abc123secrettoken' }) // Missing apikey throws synchronously try { weclapp({ tenant: 'mycompany' }) } catch (err) { console.error(err) // 'APIKey missing' } ``` ``` -------------------------------- ### Fetch time records from Weclapp API Source: https://github.com/icosense/weclapp-connect/blob/master/README.md Example showing how to fetch time records after authenticating with the weclapp API. Ensure you have a valid configuration object. ```javascript const weclapp = require('@weclapp/connect') (async () => { const user = weclapp () // Prints time-records to the console console.log(await user.fetch('timeRecord')) })() ``` -------------------------------- ### Instance Functions - Get Operations Source: https://github.com/icosense/weclapp-connect/blob/master/README.md This section details the functions available for retrieving resources within Weclapp. ```APIDOC ## Instance Functions - Get This section lists the functions available for retrieving resources. ### `getArchievedEmailById(fetch, id)` Retrieves an archived email by its ID. ### `getArchievedEmailCount(fetch)` Retrieves the count of archived emails. ### `getArchievedEmails(fetch)` Retrieves a list of archived emails. ### `getArticleById(fetch, id)` Retrieves an article by its ID. ### `getArticleCategories(fetch, {page, pageSize, sort})` Retrieves a list of article categories with pagination and sorting options. ### `getArticleCategoryById(fetch, id)` Retrieves an article category by its ID. ### `getArticleCategoryCount(fetch)` Retrieves the count of article categories. ### `getArticleCount(fetch)` Retrieves the count of articles. ### `getArticleImage(fetch, {id, articleImageId, preview = false, scaleWidth, scaleHeight})` Retrieves an article image with options for preview, width, and height scaling. ### `getArticlePriceById(fetch, id)` Retrieves an article price by its ID. ### `getArticlePriceCount(fetch)` Retrieves the count of article prices. ### `getArticlePrices(fetch, {page, pageSize, sort})` Retrieves a list of article prices with pagination and sorting options. ### `getArticleSupplySourceById(fetch, id)` Retrieves an article supply source by its ID. ### `getArticleSupplySourceCount(fetch)` Retrieves the count of article supply sources. ### `getArticleSupplySources(fetch, {page, pageSize, sort})` Retrieves a list of article supply sources with pagination and sorting options. ### `getArticles(fetch, {page, pageSize = 50, sort})` Retrieves a list of articles with pagination and sorting options. ### `getBatchNumberById(fetch, id)` Retrieves a batch number by its ID. ### `getBatchNumberCount(fetch)` Retrieves the count of batch numbers. ### `getBatchNumbers(fetch, {page, pageSize, sort})` Retrieves a list of batch numbers with pagination and sorting options. ### `getCampaignById(fetch, id)` Retrieves a campaign by its ID. ### `getCampaignParticipantById(fetch, id)` Retrieves a campaign participant by its ID. ### `getCampaignParticipantCount(fetch)` Retrieves the count of campaign participants. ### `getCampaignParticipants(fetch, {page, pageSize, sort})` Retrieves a list of campaign participants with pagination and sorting options. ### `getCampaigns(fetch, {page, pageSize, sort})` Retrieves a list of campaigns with pagination and sorting options. ### `getCampaignsCount(fetch)` Retrieves the count of campaigns. ### `getCommentById(fetch, id)` Retrieves a comment by its ID. ``` -------------------------------- ### Get and Create Incoming Goods Receipts Source: https://context7.com/icosense/weclapp-connect/llms.txt Use `getIncomingGoods` to list existing receipts and `createIncomingGoods` to record new ones. Link receipts to purchase orders using `purchaseOrderId`. ```javascript // List incoming goods records const receipts = await client.getIncomingGoods({ page: 1, pageSize: 20 }) // Create an incoming goods record const receipt = await client.createIncomingGoods({ purchaseOrderId: 'po-001', incomingGoodsItems: [ { articleId: 'art-001', quantity: 50 } ] }) console.log(receipt.id) ``` -------------------------------- ### Get and Create Purchase Orders Source: https://context7.com/icosense/weclapp-connect/llms.txt Use `getPurchaseOrders` to retrieve a list of purchase orders and `createPurchaseOrder` to create a new one. Ensure supplier and article IDs are valid. ```javascript // List purchase orders const orders = await client.getPurchaseOrders({ page: 1, pageSize: 25 }) // Create a purchase order const po = await client.createPurchaseOrder('supplier-001', { supplierId: 'supplier-001', orderItems: [ { articleId: 'art-001', quantity: 50, unitPrice: 500.00 } ] }) console.log(po.id) ``` -------------------------------- ### Raw HTTP Request with client.fetch Source: https://context7.com/icosense/weclapp-connect/llms.txt Use client.fetch for direct API calls. Supports GET and POST requests with optional bodies. ```javascript // GET an arbitrary resource const timeRecords = await client.fetch('timeRecord') console.log(timeRecords) // { result: [...] } // POST with a body const newRecord = await client.fetch('timeRecord', { method: 'POST', body: { durationSeconds: 3600, description: 'Development work', userId: 'user-id-123' } }) console.log(newRecord.id) ``` -------------------------------- ### List or Fetch Users Source: https://context7.com/icosense/weclapp-connect/llms.txt Retrieve a paginated list of users with sorting or fetch a single user by ID. Also includes a method to get the user count. ```javascript // Paginated list const page1 = await client.getUsers({ page: 1, pageSize: 20, sort: 'lastName' }) console.log(page1.result.length) // up to 20 // Single user const user = await client.getUserById('u-001') console.log(user.email) // User count const { result: count } = await client.getUserCount() console.log(count) // e.g. 42 ``` -------------------------------- ### Get the currently authenticated user with getUser() Source: https://context7.com/icosense/weclapp-connect/llms.txt Fetches the profile of the user whose API key is being used. ```APIDOC ## getUser() — Get the currently authenticated user ### Description Fetches the profile of the user whose API key is being used. ### Request Example ```javascript const me = await client.getUser() console.log(me) // { // id: 'u-001', // email: 'jane.doe@mycompany.com', // firstName: 'Jane', // lastName: 'Doe', // status: 'ACTIVE', // username: 'jane.doe' // } ``` ``` -------------------------------- ### Initialize weclapp Client Source: https://context7.com/icosense/weclapp-connect/llms.txt Initialize the client with tenant or domain and an API key. Missing API key throws an error. ```javascript const weclapp = require('@icosense/connect') // Using tenant-based URL (resolves to https://mycompany.weclapp.com/webapp/api/v1/) const client = weclapp({ tenant: 'mycompany', apikey: 'abc123secrettoken' }) // Using a custom domain const client2 = weclapp({ domain: 'erp.mycompany.com', apikey: 'abc123secrettoken' }) // Missing apikey throws synchronously try { weclapp({ tenant: 'mycompany' }) } catch (err) { console.error(err) // 'APIKey missing' } ``` -------------------------------- ### Get Authenticated User Profile Source: https://context7.com/icosense/weclapp-connect/llms.txt Fetches the profile of the user associated with the API key. ```javascript const me = await client.getUser() console.log(me) // { // id: 'u-001', // email: 'jane.doe@mycompany.com', // firstName: 'Jane', // lastName: 'Doe', // status: 'ACTIVE', // username: 'jane.doe' // } ``` -------------------------------- ### Instance Functions - Create Operations Source: https://github.com/icosense/weclapp-connect/blob/master/README.md This section details the functions available for creating new resources within Weclapp. ```APIDOC ## Instance Functions - Create This section lists the functions available for creating new resources. ### `createArticle(fetch, body)` Creates a new article. ### `createArticleCategory(fetch, body)` Creates a new article category. ### `createArticleSupplySource(fetch, body)` Creates a new article supply source. ### `createBookIncomingMovement(fetch, body)` Creates a new book incoming movement. ### `createBookOutgoingMovement(fetch, body)` Creates a new book outgoing movement. ### `createBookTransferMovement(fetch, body)` Creates a new book transfer movement. ### `createCampaign(fetch, body)` Creates a new campaign. ### `createCampaignParticipant(fetch, body)` Creates a new campaign participant. ### `createCancelOrManualSalesOrderForId(fetch, id, body)` Cancels or manually closes a sales order for a given ID. ### `createComment(fetch, body)` Creates a new comment. ### `createCompanySize(fetch, body)` Creates a new company size. ### `createCompensationShipmentForIncomingGood(fetch, id, body)` Creates a compensation shipment for an incoming good. ### `createContact(fetch, body)` Creates a new contact. ### `createContactImageForId(fetch, id, body)` Creates a contact image for a given contact ID. ### `createContract(fetch, body)` Creates a new contract. ### `createContractImageForId(fetch, id, body)` Creates a contract image for a given contract ID. ### `createCreditNoteForIncomingGood(fetch, id, body)` Creates a credit note for an incoming good. ### `createCustomer(fetch, body)` Creates a new customer. ### `createCustomerCategory(fetch, body)` Creates a new customer category. ### `createCustomerForId(fetch, id, body)` Creates a customer for a given ID. ### `createCustomerLeadLossReason(fetch, body)` Creates a customer lead loss reason. ### `createCustomerReturnForId(fetch, id, body)` Creates a customer return for a given ID. ### `createCustomerTopic(fetch, body)` Creates a new customer topic. ### `createCustomsTariffNumber(fetch, body)` Creates a new customs tariff number. ### `createDocument(fetch, {id, comment}, body)` Creates a document with an optional comment. ### `createEntityDocument(fetch, {entityName, entityId, name, description}, body)` Creates a document for a specific entity. ### `createIncomingGoods(fetch, body)` Creates new incoming goods. ### `createLead(fetch, body)` Creates a new lead. ### `createLeadImageForId(fetch, id, body)` Creates a lead image for a given lead ID. ### `createLeadSource(fetch, body)` Creates a new lead source. ### `createManualCloseSalesOrderForId(fetch, id, body)` Manually closes a sales order for a given ID. ### `createManufacturer(fetch, body)` Creates a new manufacturer. ### `createOpportunityWinLossReason(fetch, body)` Creates a new opportunity win/loss reason. ### `createPartPaymentInvoiceForId(fetch, id, body)` Creates a partial payment invoice for a given ID. ### `createPaymentMethod(fetch, body)` Creates a new payment method. ### `createPrepaymentInvoiceForId(fetch, id, body)` Creates a prepayment invoice for a given ID. ### `createProductionOrder(fetch, body)` Creates a new production order. ### `createPurchaseOrder(fetch, id, body)` Creates a purchase order for a given ID. ### `createQuotation(fetch, body)` Creates a new quotation. ### `createSalesInvoice(fetch, body)` Creates a new sales invoice. ### `createSalesInvoiceForId(fetch, id, body)` Creates a sales invoice for a given ID. ### `createSalesOrder(fetch, body)` Creates a new sales order. ### `createSalesStage(fetch, body)` Creates a new sales stage. ### `createSector(fetch, body)` Creates a new sector. ### `createShipment(fetch, body)` Creates a new shipment. ### `createShipmentForId(fetch, id, body)` Creates a shipment for a given ID. ### `createShipmentMethod(fetch, body)` Creates a new shipment method. ### `createSupplier(fetch, body)` Creates a new supplier. ### `createSupplierImageForId(fetch, id, body)` Creates a supplier image for a given supplier ID. ### `createTax(fetch, body)` Creates a new tax. ### `createTermOfPayment(fetch, body)` Creates a new term of payment. ### `createTicket(fetch, body)` Creates a new ticket. ### `createTicketExtraInfoForAppForId(fetch, id, body)` Creates extra ticket information for an app for a given ID. ### `createUnit(fetch, body)` Creates a new unit. ### `createVariantArticle(fetch, body)` Creates a new variant article. ### `createVariantArticleAttribute(fetch, body)` Creates a new variant article attribute. ``` -------------------------------- ### Customer images with getCustomerImageById() / createCustomerForId() Source: https://context7.com/icosense/weclapp-connect/llms.txt Download a (optionally scaled) customer image or upload a new one. ```APIDOC ## Customer images ### Description Download a (optionally scaled) customer image or upload a new one. ### Methods - **getCustomerImageById({ id, scaleWidth, scaleHeight })**: Downloads a customer image, optionally scaled. - **createCustomerForId(id, imageBuffer)**: Uploads a new image for a customer. ### Parameters #### getCustomerImageById - **id** (string) - Required - The ID of the customer. - **scaleWidth** (number) - Optional - The desired width for scaling the image. - **scaleHeight** (number) - Optional - The desired height for scaling the image. #### createCustomerForId - **id** (string) - Required - The ID of the customer. - **imageBuffer** (Buffer|Stream) - Required - The image data as a Buffer or Stream. ### Request Example ```javascript // Download image, scaled to 200x200 px const imageData = await client.getCustomerImageById({ id: 'cust-001', scaleWidth: 200, scaleHeight: 200 }) // Upload an image (body should be a Buffer or stream of the image file) const fs = require('fs') const imageBuffer = fs.readFileSync('./logo.png') await client.createCustomerForId('cust-001', imageBuffer) ``` ``` -------------------------------- ### Manage Support Tickets with JavaScript Source: https://context7.com/icosense/weclapp-connect/llms.txt Use these functions to list, create, update, and retrieve details for support tickets. Also includes fetching ticket priorities. ```javascript // List tickets with filter const openTickets = await client.getTickets({ page: 1, pageSize: 25, 'status-eq': 'OPEN' }) openTickets.result.forEach(t => console.log(t.id, t.subject)) ``` ```javascript // Create a ticket const ticket = await client.createTicket({ subject: 'Cannot log in', description: 'User receives 403 on login page.', customerId: 'cust-001', priorityId: 'prio-high' }) console.log(ticket.id) ``` ```javascript // Update await client.updateTicketForId(ticket.id, { status: 'IN_PROGRESS' }) ``` ```javascript // Get extra app info const extra = await client.getTicketExtraInfoForAppById({ id: ticket.id }) ``` ```javascript // Ticket priorities const priorities = await client.getTicketPriorities({ page: 1, pageSize: 10 }) ``` -------------------------------- ### Instance Functions - Fetch Custom Request Source: https://github.com/icosense/weclapp-connect/blob/master/README.md Details on how to perform customized requests using the fetch function. ```APIDOC ## Instance Functions - Fetch Custom Request ### `fetch(endpoint, {method = 'GET', body})` Allows for customized requests to specified endpoints with options for HTTP method and request body. ``` -------------------------------- ### Currency Information Retrieval with JavaScript Source: https://context7.com/icosense/weclapp-connect/llms.txt Fetch the company's base currency and a comprehensive list of all available currencies. ```javascript const companyCurrency = await client.getCompanyCurrency() console.log(companyCurrency.isoCode) // 'EUR' ``` ```javascript const allCurrencies = await client.getCurrencies({ page: 1, pageSize: 100 }) allCurrencies.result.forEach(c => console.log(c.isoCode, c.name)) ``` -------------------------------- ### Instance Functions for Creating Weclapp Entities Source: https://github.com/icosense/weclapp-connect/blob/master/README.md These functions are used to create new entities within Weclapp. They typically require a fetch instance and a body containing the entity's data. Some functions may also accept an entity ID for related creations. ```javascript async fetch(endpoint, {method = 'GET', body}) async convertLeadToCustomer(fetch, id) async createAdvancePaymentRequestSalesOrderForId(fetch, id, body) async createArticle(fetch, body) async createArticleCategory(fetch, body) async createArticleSupplySource(fetch, body) async createBookIncomingMovement(fetch, body) async createBookOutgoingMovement(fetch, body) async createBookTransferMovement(fetch, body) async createCampaign(fetch, body) async createCampaignParticipant(fetch, body) async createCancelOrManualSalesOrderForId(fetch, id, body) async createComment(fetch, body) async createCompanySize(fetch, body) async createCompensationShipmentForIncomingGood(fetch, id, body) async createContact(fetch, body) async createContactImageForId(fetch, id, body) async createContract(fetch, body) async createContractImageForId(fetch, id, body) async createCreditNoteForIncomingGood(fetch, id, body) async createCustomer(fetch, body) async createCustomerCategory(fetch, body) async createCustomerForId(fetch, id, body) async createCustomerLeadLossReason(fetch, body) async createCustomerReturnForId(fetch, id, body) async createCustomerTopic(fetch, body) async createCustomsTariffNumber(fetch, body) async createDocument(fetch, {id, comment}, body) async createEntityDocument(fetch, {entityName, entityId, name, description}, body) async createIncomingGoods(fetch, body) async createLead(fetch, body) async createLeadImageForId(fetch, id, body) async createLeadSource(fetch, body) async createManualCloseSalesOrderForId(fetch, id, body) async createManufacturer(fetch, body) async createOpportunityWinLossReason(fetch, body) async createPartPaymentInvoiceForId(fetch, id, body) async createPaymentMethod(fetch, body) async createPrepaymentInvoiceForId(fetch, id, body) async createProductionOrder(fetch, body) async createPurchaseOrder(fetch, id, body) async createQuotation(fetch, body) async createSalesInvoice(fetch, body) async createSalesInvoiceForId(fetch, id, body) async createSalesOrder(fetch, body) async createSalesStage(fetch, body) async createSector(fetch, body) async createShipment(fetch, body) async createShipmentForId(fetch, id, body) async createShipmentMethod(fetch, body) async createSupplier(fetch, body) async createSupplierImageForId(fetch, id, body) async createTax(fetch, body) async createTermOfPayment(fetch, body) async createTicket(fetch, body) async createTicketExtraInfoForAppForId(fetch, id, body) async createUnit(fetch, body) async createVariantArticle(fetch, body) async createVariantArticleAttribute(fetch, body) ``` -------------------------------- ### Manage Leads (CRUD and Conversion) Source: https://context7.com/icosense/weclapp-connect/llms.txt Handle CRM leads by listing, creating, updating, and converting them into customers. A lead source ID is required for creation. ```javascript // List open leads const leads = await client.getLeads({ page: 1, pageSize: 20 }) // Create a new lead const lead = await client.createLead({ company: 'Potential Inc.', contactEmail: 'prospect@potential.com', leadSourceId: 'src-001' }) console.log(lead.id) // Update lead await client.updateLeadForId(lead.id, { description: 'Interested in product X' }) // Convert lead to a customer const customer = await client.convertLeadToCustomer(lead.id) console.log(customer.id) // newly created customer ``` -------------------------------- ### Incoming Goods Functions Source: https://github.com/icosense/weclapp-connect/blob/master/README.md Functions for retrieving incoming goods data by ID, counts, and lists with pagination and sorting. ```APIDOC ## getIncomingGoods ### Description Retrieves a list of incoming goods with pagination and sorting options. ### Method `async getIncomingGoods(fetch, {page, pageSize, sort})` ### Parameters - `fetch`: The fetch client to use for the request. - `page` (number): The page number to retrieve. - `pageSize` (number): The number of items per page. - `sort` (string): The sorting criteria. ``` ```APIDOC ## getIncomingGoodsById ### Description Retrieves a specific incoming goods record by its ID. ### Method `async getIncomingGoodsById(fetch, id)` ### Parameters - `fetch`: The fetch client to use for the request. - `id` (string): The ID of the incoming goods record. ``` ```APIDOC ## getIncomingGoodsCount ### Description Retrieves the total count of incoming goods records. ### Method `async getIncomingGoodsCount(fetch)` ### Parameters - `fetch`: The fetch client to use for the request. ``` -------------------------------- ### Lead Functions Source: https://github.com/icosense/weclapp-connect/blob/master/README.md Functions for retrieving lead data by ID, counts, images, sources, and lists with pagination and sorting. ```APIDOC ## getLeadById ### Description Retrieves a specific lead by its ID. ### Method `async getLeadById(fetch, id)` ### Parameters - `fetch`: The fetch client to use for the request. - `id` (string): The ID of the lead. ``` ```APIDOC ## getLeadCount ### Description Retrieves the total count of leads. ### Method `async getLeadCount(fetch)` ### Parameters - `fetch`: The fetch client to use for the request. ``` ```APIDOC ## getLeadImage ### Description Retrieves a lead's image by its ID, with options for scaling. ### Method `async getLeadImage(fetch, {id, scaleWidth, scaleHeight})` ### Parameters - `fetch`: The fetch client to use for the request. - `id` (string): The ID of the lead image. - `scaleWidth` (number): The desired width for the scaled image. - `scaleHeight` (number): The desired height for the scaled image. ``` ```APIDOC ## getLeadSourceById ### Description Retrieves a specific lead source by its ID. ### Method `async getLeadSourceById(fetch, id)` ### Parameters - `fetch`: The fetch client to use for the request. - `id` (string): The ID of the lead source. ``` ```APIDOC ## getLeadSourceCount ### Description Retrieves the total count of lead sources. ### Method `async getLeadSourceCount(fetch)` ### Parameters - `fetch`: The fetch client to use for the request. ``` ```APIDOC ## getLeadSources ### Description Retrieves a list of lead sources with pagination and sorting options. ### Method `async getLeadSources(fetch, {page, pageSize, sort})` ### Parameters - `fetch`: The fetch client to use for the request. - `page` (number): The page number to retrieve. - `pageSize` (number): The number of items per page. - `sort` (string): The sorting criteria. ``` ```APIDOC ## getLeads ### Description Retrieves a list of leads with pagination and sorting options. ### Method `async getLeads(fetch, {page, pageSize, sort})` ### Parameters - `fetch`: The fetch client to use for the request. - `page` (number): The page number to retrieve. - `pageSize` (number): The number of items per page. - `sort` (string): The sorting criteria. ``` -------------------------------- ### Manage Articles (Products/Items - CRUD) Source: https://context7.com/icosense/weclapp-connect/llms.txt Perform CRUD operations on articles, which represent products or items in Weclapp. The default page size for listing articles is 50. You can also count articles with optional filters. ```javascript // List articles, default pageSize is 50 const articles = await client.getArticles({ page: 1 }) articles.result.forEach(a => console.log(a.articleNumber, a.name)) // Create an article const article = await client.createArticle({ name: 'Laptop Pro 15', articleNumber: 'ART-0042', shortDescription1: 'High performance laptop', sellPrice: 1299.00, unitId: 'unit-piece' }) console.log(article.id) // Update await client.updateArticleById({ id: article.id, body: { sellPrice: 1199.00 } }) // Delete await client.deleteArticleById(article.id) // Count with optional filter const { result: count } = await client.getArticleCount({ 'active-eq': true }) console.log(count) ``` -------------------------------- ### Warehouse and Stock Management with JavaScript Source: https://context7.com/icosense/weclapp-connect/llms.txt Manage warehouses, view stock levels, and book stock movements (incoming, outgoing, transfers). Includes fetching stock movement history. ```javascript // List warehouses const warehouses = await client.getWarehouses({ page: 1, pageSize: 10 }) warehouses.result.forEach(w => console.log(w.id, w.name)) ``` ```javascript // Get stock levels const stocks = await client.getWarehouseStocks({ page: 1, pageSize: 50, 'articleId-eq': 'art-001' }) ``` ```javascript // Book incoming goods await client.createBookIncomingMovement({ articleId: 'art-001', warehouseId: 'wh-001', quantity: 100, note: 'PO-2024-001 received' }) ``` ```javascript // Book outgoing stock await client.createBookOutgoingMovement({ articleId: 'art-001', warehouseId: 'wh-001', quantity: 10, note: 'Fulfillment for order SO-9001' }) ``` ```javascript // Transfer between warehouses await client.createBookTransferMovement({ articleId: 'art-001', sourceWarehouseId: 'wh-001', targetWarehouseId: 'wh-002', quantity: 25 }) ``` ```javascript // Get stock movement history const movements = await client.getWarehouseStockMovements({ page: 1, pageSize: 50 }) ``` -------------------------------- ### Raw HTTP request with client.fetch(endpoint, options) Source: https://context7.com/icosense/weclapp-connect/llms.txt A low-level escape hatch for any weclapp API endpoint not covered by a named helper. Accepts a path string relative to `/webapp/api/v1/` and an optional options object with `method` and `body`. ```APIDOC ## client.fetch(endpoint, options) — Raw HTTP request ### Description A low-level escape hatch for any weclapp API endpoint not covered by a named helper. Accepts a path string relative to `/webapp/api/v1/` and an optional options object with `method` and `body`. ### Parameters #### Path Parameters - **endpoint** (string) - Required - The API endpoint path relative to `/webapp/api/v1/`. - **options** (object) - Optional - An object containing `method` and `body`. - **method** (string) - Optional - The HTTP method (e.g., 'GET', 'POST'). Defaults to 'GET'. - **body** (object) - Optional - The request body for methods like 'POST'. ### Request Example ```javascript // GET an arbitrary resource const timeRecords = await client.fetch('timeRecord') console.log(timeRecords) // { result: [...] } // POST with a body const newRecord = await client.fetch('timeRecord', { method: 'POST', body: { durationSeconds: 3600, description: 'Development work', userId: 'user-id-123' } }) console.log(newRecord.id) ``` ``` -------------------------------- ### Manage Article Images Source: https://context7.com/icosense/weclapp-connect/llms.txt Download full-size article images or upload new ones. Supports preview mode and scale dimensions for downloads. Ensure the 'fs' module is required for file uploads. ```javascript // Download full-size image const image = await client.getArticleImage({ id: 'art-001', articleImageId: 'img-001', preview: false, scaleWidth: 400, scaleHeight: 400 }) // Upload a main image const fs = require('fs') await client.uploadArticleImage( { id: 'art-001', name: 'laptop-front.jpg', mainImage: true }, fs.readFileSync('./laptop-front.jpg') ) ``` -------------------------------- ### Instance Functions for Retrieving Weclapp Entities Source: https://github.com/icosense/weclapp-connect/blob/master/README.md These functions are used to retrieve information about Weclapp entities. They require a fetch instance and often an entity ID. Some retrieval functions support pagination and sorting parameters for more specific data fetching. ```javascript async getArchievedEmailById(fetch, id) async getArchievedEmailCount(fetch) async getArchievedEmails(fetch) async getArticleById(fetch, id) async getArticleCategories(fetch, {page, pageSize, sort}) async getArticleCategoryById(fetch, id) async getArticleCategoryCount(fetch) async getArticleCount(fetch) async getArticleImage(fetch, {id, articleImageId, preview = false, scaleWidth, scaleHeight}) async getArticlePriceById(fetch, id) async getArticlePriceCount(fetch) async getArticlePrices(fetch, {page, pageSize, sort}) async getArticleSupplySourceById(fetch, id) async getArticleSupplySourceCount(fetch) async getArticleSupplySources(fetch, {page, pageSize, sort}) async getArticles(fetch, {page, pageSize = 50, sort}) async getBatchNumberById(fetch, id) async getBatchNumberCount(fetch) async getBatchNumbers(fetch, {page, pageSize, sort}) async getCampaignById(fetch, id) async getCampaignParticipantById(fetch, id) async getCampaignParticipantCount(fetch) async getCampaignParticipants(fetch, {page, pageSize, sort}) async getCampaigns(fetch, {page, pageSize, sort}) async getCampaignsCount(fetch) async getCommentById(fetch, id) ``` -------------------------------- ### List or fetch users with getUsers({ page, pageSize, sort }) / getUserById(id) Source: https://context7.com/icosense/weclapp-connect/llms.txt Retrieves the full user list with optional pagination and sorting, or fetches one user by their ID. ```APIDOC ## getUsers({ page, pageSize, sort }) / getUserById(id) — List or fetch users ### Description Retrieves the full user list with optional pagination and sorting, or fetches one user by their ID. ### Parameters #### getUsers - **page** (number) - Optional - The page number for pagination. - **pageSize** (number) - Optional - The number of items per page. - **sort** (string) - Optional - The field to sort the results by. #### getUserById - **id** (string) - Required - The ID of the user to fetch. ### Request Example ```javascript // Paginated list const page1 = await client.getUsers({ page: 1, pageSize: 20, sort: 'lastName' }) console.log(page1.result.length) // up to 20 // Single user const user = await client.getUserById('u-001') console.log(user.email) // User count const { result: count } = await client.getUserCount() console.log(count) // e.g. 42 ``` ``` -------------------------------- ### API Metadata Introspection with JavaScript Source: https://context7.com/icosense/weclapp-connect/llms.txt Discover available API resources and their supported filter and sort properties to understand API capabilities. ```javascript // List all available API resources const resources = await client.getMetaRessources() console.log(resources) // ['article', 'customer', 'salesOrder', ...] ``` ```javascript // Find filterable properties of the 'customer' resource const filters = await client.getMetaQueryFilterProperties('customer') console.log(filters) // [{ name: 'company', ... }, { name: 'status', ... }, ...] ``` ```javascript // Find sortable properties const sortProps = await client.getMetaQuerySortProperties('salesOrder') console.log(sortProps) // [{ name: 'orderDate', ... }, ...] ``` -------------------------------- ### Manage Sales Orders (Workflow) Source: https://context7.com/icosense/weclapp-connect/llms.txt Handle the complete sales fulfillment process, from creating sales orders to generating shipments and invoices. Includes options for cancellation and manual closure. ```javascript // Create a sales order const order = await client.createSalesOrder({ customerId: 'cust-001', orderItems: [ { articleId: 'art-001', quantity: 3, unitPrice: 1199.00 } ] }) console.log(order.id) // Get orders for a specific customer const customerOrders = await client.getSalesOrderForCustomer({ customerId: 'cust-001' }) // Create a shipment from the order const shipment = await client.createShipmentForId(order.id, {}) console.log(shipment.id) // Create a sales invoice const invoice = await client.createSalesInvoiceForId(order.id, {}) console.log(invoice.id) // Download order confirmation PDF const pdf = await client.getLatestOrderConfirmationPdfId(order.id) // Cancel or manually close await client.createCancelOrManualSalesOrderForId(order.id, { reason: 'Customer request' }) await client.createManualCloseSalesOrderForId(order.id, {}) ``` -------------------------------- ### Customer Image Operations Source: https://context7.com/icosense/weclapp-connect/llms.txt Download a scaled customer image or upload a new one. Image upload requires a Buffer or stream. ```javascript // Download image, scaled to 200×200 px const imageData = await client.getCustomerImageById({ id: 'cust-001', scaleWidth: 200, scaleHeight: 200 }) // Upload an image (body should be a Buffer or stream of the image file) const fs = require('fs') const imageBuffer = fs.readFileSync('./logo.png') await client.createCustomerForId('cust-001', imageBuffer) ``` -------------------------------- ### Opportunity Win/Loss Reason Functions Source: https://github.com/icosense/weclapp-connect/blob/master/README.md Functions for retrieving opportunity win/loss reasons by ID, counts, and lists with pagination and sorting. ```APIDOC ## getOpportunityWinLossReasonById ### Description Retrieves a specific opportunity win/loss reason by its ID. ### Method `async getOpportunityWinLossReasonById(fetch, id)` ### Parameters - `fetch`: The fetch client to use for the request. - `id` (string): The ID of the opportunity win/loss reason. ``` ```APIDOC ## getOpportunityWinLossReasonCount ### Description Retrieves the total count of opportunity win/loss reasons. ### Method `async getOpportunityWinLossReasonCount(fetch)` ### Parameters - `fetch`: The fetch client to use for the request. ``` ```APIDOC ## getOpportunityWinLossReasons ### Description Retrieves a list of opportunity win/loss reasons with pagination and sorting options. ### Method `async getOpportunityWinLossReasons(fetch, {page, pageSize, sort})` ### Parameters - `fetch`: The fetch client to use for the request. - `page` (number): The page number to retrieve. - `pageSize` (number): The number of items per page. - `sort` (string): The sorting criteria. ``` -------------------------------- ### Currency Information Source: https://context7.com/icosense/weclapp-connect/llms.txt Retrieve the company's base currency and the full list of available currencies. ```APIDOC ## getCompanyCurrency() / getCurrencies() ### Description Retrieve the company's base currency and the full list of available currencies. ### Methods - `getCompanyCurrency()`: Retrieves the company's base currency. - `getCurrencies(options)`: Retrieves a list of all available currencies. ### Request Example (getCompanyCurrency) ```javascript await client.getCompanyCurrency() ``` ### Request Example (getCurrencies) ```javascript await client.getCurrencies({ page: 1, pageSize: 100 }) ``` ``` -------------------------------- ### Meta Functions Source: https://github.com/icosense/weclapp-connect/blob/master/README.md Functions for retrieving meta information about resources, including query properties and available resources. ```APIDOC ## getMetaQueryFilterProperties ### Description Retrieves the available filter properties for a given resource. ### Method `async getMetaQueryFilterProperties(fetch, resource)` ### Parameters - `fetch`: The fetch client to use for the request. - `resource` (string): The name of the resource. ``` ```APIDOC ## getMetaQuerySortProperties ### Description Retrieves the available sort properties for a given resource. ### Method `async getMetaQuerySortProperties(fetch, resource)` ### Parameters - `fetch`: The fetch client to use for the request. - `resource` (string): The name of the resource. ``` ```APIDOC ## getMetaRessources ### Description Retrieves a list of all available meta resources. ### Method `async getMetaRessources(fetch)` ### Parameters - `fetch`: The fetch client to use for the request. ``` -------------------------------- ### Company Size Functions Source: https://github.com/icosense/weclapp-connect/blob/master/README.md Functions for retrieving company size data by ID, counts, and lists with pagination and sorting. ```APIDOC ## getCompanySizeById ### Description Retrieves a specific company size by its ID. ### Method `async getCompanySizeById(fetch, id)` ### Parameters - `fetch`: The fetch client to use for the request. - `id` (string): The ID of the company size. ``` ```APIDOC ## getCompanySizeCount ### Description Retrieves the total count of company sizes. ### Method `async getCompanySizeCount(fetch)` ### Parameters - `fetch`: The fetch client to use for the request. ``` ```APIDOC ## getCompanySizes ### Description Retrieves a list of company sizes with pagination and sorting options. ### Method `async getCompanySizes(fetch, {page, pageSize, sort})` ### Parameters - `fetch`: The fetch client to use for the request. - `page` (number): The page number to retrieve. - `pageSize` (number): The number of items per page. - `sort` (string): The sorting criteria. ``` -------------------------------- ### Article (Product) CRUD Operations Source: https://context7.com/icosense/weclapp-connect/llms.txt Manage weclapp article (product/item) records, including CRUD operations and counting. ```APIDOC ## Article (Product) CRUD Operations ### Description Manage weclapp article (product/item) records. ### Methods - `getArticles(options)`: List articles with optional pagination. - `createArticle(data)`: Create a new article. - `updateArticleById(options)`: Update an existing article by its ID. - `deleteArticleById(id)`: Delete an article by its ID. - `getArticleCount(options)`: Count articles with optional filters. ### Example Usage ```js // List articles, default pageSize is 50 const articles = await client.getArticles({ page: 1 }); articles.result.forEach(a => console.log(a.articleNumber, a.name)); // Create an article const article = await client.createArticle({ name: 'Laptop Pro 15', articleNumber: 'ART-0042', shortDescription1: 'High performance laptop', sellPrice: 1299.00, unitId: 'unit-piece' }); console.log(article.id); // Update await client.updateArticleById({ id: article.id, body: { sellPrice: 1199.00 } }); // Delete await client.deleteArticleById(article.id); // Count with optional filter const { result: count } = await client.getArticleCount({ 'active-eq': true }); console.log(count); ``` ``` -------------------------------- ### Production Order Functions Source: https://github.com/icosense/weclapp-connect/blob/master/README.md Functions for retrieving production order data by ID, counts, and lists with pagination and sorting. ```APIDOC ## getProductionOrderById ### Description Retrieves a specific production order by its ID. ### Method `async getProductionOrderById(fetch, id)` ### Parameters - `fetch`: The fetch client to use for the request. - `id` (string): The ID of the production order. ``` ```APIDOC ## getProductionOrderCount ### Description Retrieves the total count of production orders. ### Method `async getProductionOrderCount(fetch)` ### Parameters - `fetch`: The fetch client to use for the request. ``` ```APIDOC ## getProductionOrders ### Description Retrieves a list of production orders with pagination and sorting options. ### Method `async getProductionOrders(fetch, {page, pageSize, sort})` ### Parameters - `fetch`: The fetch client to use for the request. - `page` (number): The page number to retrieve. - `pageSize` (number): The number of items per page. - `sort` (string): The sorting criteria. ``` -------------------------------- ### Currency Functions Source: https://github.com/icosense/weclapp-connect/blob/master/README.md Functions for retrieving currency data by ID, counts, and lists with pagination and sorting. ```APIDOC ## getCurrencies ### Description Retrieves a list of currencies with pagination and sorting options. ### Method `async getCurrencies(fetch, {page, pageSize, sort})` ### Parameters - `fetch`: The fetch client to use for the request. - `page` (number): The page number to retrieve. - `pageSize` (number): The number of items per page. - `sort` (string): The sorting criteria. ``` ```APIDOC ## getCurrencyById ### Description Retrieves a specific currency by its ID. ### Method `async getCurrencyById(fetch, id)` ### Parameters - `fetch`: The fetch client to use for the request. - `id` (string): The ID of the currency. ``` ```APIDOC ## getCurrencyCount ### Description Retrieves the total count of currencies. ### Method `async getCurrencyCount(fetch)` ### Parameters - `fetch`: The fetch client to use for the request. ``` -------------------------------- ### Instance Functions - Delete Operations Source: https://github.com/icosense/weclapp-connect/blob/master/README.md This section details the functions available for deleting resources within Weclapp. ```APIDOC ## Instance Functions - Delete This section lists the functions available for deleting resources. ### `deleteArchievedEmailById(fetch, id)` Deletes an archived email by its ID. ### `deleteArticleById(fetch, id)` Deletes an article by its ID. ### `deleteArticleCategoryById(fetch, id)` Deletes an article category by its ID. ### `deleteCampaignById(fetch, id)` Deletes a campaign by its ID. ### `deleteCampaignParticipantById(fetch, id)` Deletes a campaign participant by its ID. ### `deleteCommentById(fetch, id)` Deletes a comment by its ID. ### `deleteCompanySizeById(fetch, id)` Deletes a company size by its ID. ### `deleteContactById(fetch, id)` Deletes a contact by its ID. ### `deleteContractById(fetch, id)` Deletes a contract by its ID. ### `deleteCustomerById(fetch, id)` Deletes a customer by its ID. ### `deleteCustomerCategoryById(fetch, id)` Deletes a customer category by its ID. ### `deleteCustomerLeadLossReasonById(fetch, id)` Deletes a customer lead loss reason by its ID. ### `deleteCustomerTopicById(fetch, id)` Deletes a customer topic by its ID. ### `deleteCustomsTariffNumberById(fetch, id)` Deletes a customs tariff number by its ID. ### `deleteDocumentById(fetch, id)` Deletes a document by its ID. ### `deleteLeadById(fetch, id)` Deletes a lead by its ID. ### `deleteLeadSourceById(fetch, id)` Deletes a lead source by its ID. ### `deleteManufacturerById(fetch, id)` Deletes a manufacturer by its ID. ### `deleteOpportunityWinLossReasonById(fetch, id)` Deletes an opportunity win/loss reason by its ID. ### `deletePaymentMethodById(fetch, id)` Deletes a payment method by its ID. ### `deleteProductionOrderById(fetch, id)` Deletes a production order by its ID. ### `deleteQuotationById(fetch, id)` Deletes a quotation by its ID. ### `deleteSalesStageById(fetch, id)` Deletes a sales stage by its ID. ### `deleteSectorById(fetch, id)` Deletes a sector by its ID. ### `deleteShipmentMethodById(fetch, id)` Deletes a shipment method by its ID. ### `deleteSupplierById(fetch, id)` Deletes a supplier by its ID. ### `deleteTaxById(fetch, id)` Deletes a tax by its ID. ### `deleteTermOfPaymentById(fetch, id)` Deletes a term of payment by its ID. ### `deleteUnitById(fetch, id)` Deletes a unit by its ID. ### `deleteVariantArticleAttributeById(fetch, id)` Deletes a variant article attribute by its ID. ### `deleteVariantArticleById(fetch, id)` Deletes a variant article by its ID. ```