{"_id":"@dannychirkov/salesdrive-api-client","name":"@dannychirkov/salesdrive-api-client","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@dannychirkov/salesdrive-api-client","version":"0.1.0","description":"TypeScript API client for SalesDrive CRM","main":"dist/index.js","types":"dist/index.d.ts","license":"Apache-2.0","author":{"name":"Danny Chirkov"},"repository":{"type":"git","url":"git+https://github.com/dannychirkov/salesdrive-api.git","directory":"packages/salesdrive-api-client"},"homepage":"https://github.com/dannychirkov/salesdrive-api#readme","bugs":{"url":"https://github.com/dannychirkov/salesdrive-api/issues"},"keywords":["salesdrive","crm","api","typescript","client"],"scripts":{"build":"tsc","test":"jest","test:integration":"jest --testPathPattern=integration","type-check":"tsc --noEmit","clean":"rimraf dist"},"devDependencies":{"typescript":"^5.3.0","@types/node":"^20.10.0","jest":"^29.7.0","@types/jest":"^29.5.11","ts-jest":"^29.1.1","rimraf":"^5.0.5","dotenv":"^16.3.1"},"engines":{"node":">=18.0.0"},"_id":"@dannychirkov/salesdrive-api-client@0.1.0","gitHead":"c71db20321b4850f9e586de442a4c05b07a37a70","_nodeVersion":"22.17.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-U66LXZq6a8ajZRku4urM/ds44FygmQpbGyJ6b5vW5lm1qaweZJHA1WFSy+W+Ucx7oizbMjHYVV7hHH7oflNFVw==","shasum":"0a548bbbfd265714b23fc514ecd2ca99720174a4","tarball":"https://registry.npmjs.org/@dannychirkov/salesdrive-api-client/-/salesdrive-api-client-0.1.0.tgz","fileCount":142,"unpackedSize":146932,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIGRiFBQDG1MoK2oqciu2N0A6LDgVg/EfQQRD6Apgy1U4AiBd2M9HfuhAT3WfJ2dS1U4nz5/FErH49JJVZMbYCSZ8qw=="}]},"_npmUser":{"name":"dannychirkov","email":"dannychirkov@gmail.com"},"directories":{},"maintainers":[{"name":"dannychirkov","email":"dannychirkov@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/salesdrive-api-client_0.1.0_1768112088061_0.3398293437031634"},"_hasShrinkwrap":false}},"time":{"created":"2026-01-11T06:14:47.961Z","0.1.0":"2026-01-11T06:14:48.219Z","modified":"2026-01-11T06:14:48.545Z"},"maintainers":[{"name":"dannychirkov","email":"dannychirkov@gmail.com"}],"description":"TypeScript API client for SalesDrive CRM","homepage":"https://github.com/dannychirkov/salesdrive-api#readme","keywords":["salesdrive","crm","api","typescript","client"],"repository":{"type":"git","url":"git+https://github.com/dannychirkov/salesdrive-api.git","directory":"packages/salesdrive-api-client"},"author":{"name":"Danny Chirkov"},"bugs":{"url":"https://github.com/dannychirkov/salesdrive-api/issues"},"license":"Apache-2.0","readme":"# @dannychirkov/salesdrive-api-client\n\nTypeScript API client for [SalesDrive CRM](https://salesdrive.ua).\n\n## Installation\n\n```bash\nnpm install @dannychirkov/salesdrive-api-client @dannychirkov/salesdrive-transport-fetch\n```\n\n## Quick Start\n\n```typescript\nimport { createClient, orderService, referenceService } from '@dannychirkov/salesdrive-api-client';\nimport { createFetchTransport } from '@dannychirkov/salesdrive-transport-fetch';\n\n// Create transport\nconst transport = createFetchTransport({\n  apiKey: 'your-api-key',\n  baseUrl: 'https://your-account.salesdrive.me',\n});\n\n// Create client with services\nconst client = createClient({\n  transport,\n  apiKey: 'your-api-key',\n  baseUrl: 'https://your-account.salesdrive.me',\n})\n  .extend(orderService)\n  .extend(referenceService);\n\n// List orders\nconst orders = await client.orders.list({ limit: 10 });\nconsole.log(orders.data);\n```\n\n## Available Services\n\n### Order Service\n\n```typescript\nimport { orderService } from '@dannychirkov/salesdrive-api-client';\n\nconst client = createClient(ctx).extend(orderService);\n\n// List orders\nconst orders = await client.orders.list({\n  page: 1,\n  limit: 50,\n  'filter[statusId]': '2',\n});\n\n// Create order\nconst result = await client.orders.create({\n  phone: '0501234567',\n  fName: 'John',\n  lName: 'Doe',\n  products: [\n    { id: '101', costPerItem: 500, amount: 2 },\n  ],\n  payment_method: 'card',\n  shipping_method: 'novaposhta',\n});\n\n// Update order\nawait client.orders.update({\n  id: 1001,\n  data: {\n    statusId: 3,\n    comment: 'Updated',\n  },\n});\n```\n\n### Product Service\n\n```typescript\nimport { productService } from '@dannychirkov/salesdrive-api-client';\n\nconst client = createClient(ctx).extend(productService);\n\n// Update products (batch)\nawait client.products.update([\n  { id: '101', name: 'Product 1', costPerItem: 500 },\n  { id: '102', name: 'Product 2', costPerItem: 750 },\n]);\n\n// Delete products\nawait client.products.delete(['101', '102']);\n```\n\n### Payment Service\n\n```typescript\nimport { paymentService } from '@dannychirkov/salesdrive-api-client';\n\nconst client = createClient(ctx).extend(paymentService);\n\n// Add payment\nawait client.payments.add({\n  sum: 500,\n  orderId: 1001,\n});\n\n// List payments\nconst payments = await client.payments.list({\n  type: 'incoming',\n  page: 1,\n});\n```\n\n### Reference Service\n\n```typescript\nimport { referenceService } from '@dannychirkov/salesdrive-api-client';\n\nconst client = createClient(ctx).extend(referenceService);\n\n// Get payment methods\nconst paymentMethods = await client.reference.getPaymentMethods();\n\n// Get delivery methods\nconst deliveryMethods = await client.reference.getDeliveryMethods();\n\n// Get order statuses\nconst statuses = await client.reference.getStatuses();\n```\n\n### Currency Service\n\n```typescript\nimport { currencyService } from '@dannychirkov/salesdrive-api-client';\n\nconst client = createClient(ctx).extend(currencyService);\n\n// Get rates\nconst rates = await client.currencies.get();\n\n// Update rates\nawait client.currencies.update({\n  currencies: [\n    { code: 'USD', rate: 42 },\n    { code: 'EUR', rate: 45 },\n  ],\n});\n```\n\n## All Available Services\n\n- `orderService` - Orders management\n- `productService` - Products management\n- `categoryService` - Categories management\n- `paymentService` - Payments management\n- `referenceService` - Reference data (payment methods, delivery methods, statuses)\n- `currencyService` - Currency rates\n- `invoiceService` - Invoices listing\n- `salesInvoiceService` - Sales invoices listing\n- `cashOrderService` - Cash orders listing\n- `contractService` - Contracts listing\n- `checkService` - Fiscal receipts listing\n- `actService` - Acts listing\n- `arrivalService` - Product arrivals listing\n\n## Types\n\nAll types are exported from the package:\n\n```typescript\nimport type {\n  Order,\n  CreateOrderRequest,\n  Product,\n  Payment,\n  PaymentMethod,\n  DeliveryMethod,\n  OrderStatus,\n} from '@dannychirkov/salesdrive-api-client';\n```\n\n## Error Handling\n\n```typescript\nimport { ApiError, RateLimitError, AuthenticationError } from '@dannychirkov/salesdrive-api-client';\n\ntry {\n  await client.orders.list();\n} catch (error) {\n  if (error instanceof RateLimitError) {\n    console.log('Rate limited, try again later');\n  } else if (error instanceof AuthenticationError) {\n    console.log('Invalid API key');\n  } else if (error instanceof ApiError) {\n    console.log('API error:', error.message);\n  }\n}\n```\n\n## License\n\n[Apache License 2.0](../../LICENSE)\n","readmeFilename":"README.md","_rev":"1-ab4fd727c1c38467c9a36b59da80fc8f"}