JSPM

@warriorteam/getfly-crm-sdk

1.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 215
  • Score
    100M100P100Q96935F
  • License MIT

Complete TypeScript SDK for Getfly CRM API v4.0 with Call Center, Tickets, Funds, and Campaigns support

Package Exports

  • @warriorteam/getfly-crm-sdk
  • @warriorteam/getfly-crm-sdk/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@warriorteam/getfly-crm-sdk) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Getfly CRM TypeScript SDK

npm version License: MIT TypeScript

A powerful, type-safe TypeScript SDK for Getfly CRM API v6.1. This SDK provides a clean, modern interface for interacting with Getfly CRM's REST API.

โœจ Features

  • ๐Ÿš€ Full TypeScript Support - 100% type safety with IntelliSense
  • ๐ŸŽฏ Strict Mode - Enforced type checking for better reliability
  • โœ… Runtime Validation - Zod schemas for request/response validation
  • ๐Ÿ” Auto-completion - Full IDE support with comprehensive typing
  • ๐Ÿ›ก๏ธ Error Handling - Detailed error information and proper error types
  • ๐Ÿ“„ Custom Fields Support - Dynamic custom fields integration
  • ๐Ÿ” Query Builder - Powerful filtering, sorting, and pagination
  • ๐Ÿ“ฆ Modular Design - Organized by API version and modules
  • ๐Ÿงช Well Tested - Comprehensive unit tests with Jest
  • ๐Ÿ“– Complete Documentation - Detailed API documentation and examples

๐Ÿ“ฆ Installation

npm install getfly-crm-sdk
# or
yarn add getfly-crm-sdk
# or
pnpm add getfly-crm-sdk

๐Ÿš€ Quick Start

import { GetflyClient } from 'getfly-crm-sdk';

// Initialize the client
const client = new GetflyClient({
  subdomain: 'your-company', // your-company.getflycrm.com
  apiKey: 'your-api-key',
  version: '6.1', // optional, defaults to '6.1'
});

// Test connection
const isConnected = await client.testConnection();
console.log('Connected:', isConnected);

// Get all accounts
const accounts = await client.v61.accounts.list({
  fields: ['id', 'account_name', 'email'],
  limit: 20,
});

console.log('Accounts:', accounts);

// Create a new account
const newAccount = await client.v61.accounts.create({
  account_name: 'Acme Corporation',
  account_type: 1, // 1: Customer
  email: 'contact@acme.com',
  phone_office: '+1234567890',
});

console.log('New account:', newAccount);

๐Ÿ“š API Modules

v6.1 API

Accounts (client.v61.accounts)

  • List, create, update, delete accounts
  • Advanced filtering by type, status, date range
  • Search by name, email, phone
  • Custom fields support
// Get customers with filtering
const customers = await client.v61.accounts.getByType(1, {
  filtering: {
    'created_at:gte': '2023-01-01',
    'account_status:eq': 1,
  },
  sort: 'account_name',
  direction: 'ASC',
});

// Search accounts by name
const searchResults = await client.v61.accounts.searchByName('Acme');

Products (client.v61.products)

  • Complete product management
  • Variants and attributes support
  • Inventory tracking
  • Price range filtering
// Get products by category
const electronics = await client.v61.products.getByCategory('Electronics');

// Get low stock products
const lowStock = await client.v61.products.getLowStock(5);

// Search products by SKU or name
const products = await client.v61.products.search('LAPTOP-001');

Sale Orders (client.v61.saleOrders)

  • Order management and tracking
  • Payment status management
  • Date range filtering
  • Customer-specific orders
// Get pending orders
const pendingOrders = await client.v61.saleOrders.getByStatus(1);

// Get orders by customer
const customerOrders = await client.v61.saleOrders.getByAccount(123);

// Get orders in date range
const monthlyOrders = await client.v61.saleOrders.getByDateRange(
  '2023-01-01',
  '2023-01-31'
);

Purchase Orders (client.v61.purchaseOrders)

  • Purchase order management
  • Approval workflow
  • Vendor-specific orders
  • Order status tracking
// Get orders pending approval
const pendingApproval = await client.v61.purchaseOrders.getPendingApproval();

// Approve an order
await client.v61.purchaseOrders.approve(456, 789); // order_id, approved_by

// Reject an order with reason
await client.v61.purchaseOrders.reject(457, 'Budget exceeded', 789);

๐Ÿ”ง Configuration Options

const client = new GetflyClient({
  // Required
  subdomain: 'your-company',     // Your Getfly CRM subdomain
  apiKey: 'your-api-key',        // Your API key from Getfly CRM

  // Optional
  version: '6.1',                // API version (defaults to '6.1')
  timeout: 30000,                // Request timeout in ms (defaults to 30000)
  headers: {                     // Additional headers
    'User-Agent': 'MyApp/1.0',
  },
  baseURL: 'https://custom.domain.com', // Custom base URL (overrides subdomain)
});

๐Ÿ“ Advanced Usage

Filtering and Pagination

All list methods support powerful filtering:

const accounts = await client.v61.accounts.list({
  // Select specific fields
  fields: ['id', 'account_name', 'email', 'account_type'],

  // Filter with various operations
  filtering: {
    'account_name:contains': 'corp',     // Contains
    'account_type:eq': 1,                // Equals
    'created_at:gte': '2023-01-01',      // Greater than or equal
    'created_at:lte': '2023-12-31',      // Less than or equal
    'annual_revenue:between': [10000, 50000], // Between values
    'tags:in': ['VIP', 'Premium'],       // In array
  },

  // Sorting
  sort: 'created_at',
  direction: 'DESC',

  // Pagination
  limit: 50,
  offset: 0,
});

Custom Fields

Getfly CRM supports dynamic custom fields:

// Get custom fields schema
const customFieldsSchema = await client.v61.accounts.getCustomFields();

// Create account with custom fields
const account = await client.v61.accounts.create({
  account_name: 'Custom Corp',
  account_type: 1,
  custom_fields: {
    'custom_industry': 'Technology',
    'custom_website_visits': 1250,
    'custom_priority': 'High',
  },
});

Error Handling

The SDK provides detailed error information:

import { GetflyApiError, GetflyValidationError } from 'getfly-crm-sdk';

try {
  const account = await client.v61.accounts.create(invalidData);
} catch (error) {
  if (error instanceof GetflyValidationError) {
    console.error('Validation failed:', error.getErrorSummary());
    error.validationErrors.forEach(err => {
      console.error(`${err.field}: ${err.message}`);
    });
  } else if (error instanceof GetflyApiError) {
    console.error('API Error:', error.message);
    console.error('Status:', error.status);
    console.error('Code:', error.code);
  }
}

Connection Testing

Test your API connection:

const isConnected = await client.testConnection();
if (!isConnected) {
  console.error('Failed to connect to Getfly CRM API');
}

// Get detailed API info
const apiInfo = await client.getApiInfo();
console.log('API Info:', apiInfo);
/*
{
  version: '6.1',
  baseURL: 'https://your-company.getflycrm.com',
  connected: true
}
*/

๐Ÿงช Development

Setup

# Clone the repository
git clone https://github.com/getfly-crm/typescript-sdk.git
cd typescript-sdk

# Install dependencies
npm install

# Run tests
npm test

# Run tests in watch mode
npm run test:watch

# Build the project
npm run build

# Check types
npm run typecheck

# Lint code
npm run lint

# Format code
npm run format

Project Structure

src/
โ”œโ”€โ”€ client/                 # Main client class
โ”œโ”€โ”€ utils/                  # HTTP client and validation utilities
โ”œโ”€โ”€ versions/
โ”‚   โ””โ”€โ”€ v6.1/              # API v6.1 implementation
โ”‚       โ”œโ”€โ”€ modules/       # API modules (accounts, products, etc.)
โ”‚       โ”œโ”€โ”€ types/         # TypeScript type definitions
โ”‚       โ””โ”€โ”€ index.ts       # Version entry point
โ””โ”€โ”€ index.ts               # Main entry point

tests/                     # Unit tests
examples/                 # Usage examples
docs/                     # Documentation

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ†˜ Support

If you have any questions or need help:

๐Ÿ™ Acknowledgments

  • Getfly CRM for providing the API
  • Zod team for the excellent validation library
  • TypeScript team for the amazing language