An open API service indexing awesome lists of open source software.

https://github.com/code-gio/siteflow-js


https://github.com/code-gio/siteflow-js

Last synced: 4 months ago
JSON representation

Awesome Lists containing this project

README

          

Siteflow HP API Client

A TypeScript library for interacting with the Siteflow HP API.

Installation

npm install siteflow-hp-client

Usage

Initializing the client



import SiteflowClient from 'siteflow-hp-client';

const config = {
token: 'your-api-token',
secret: 'your-api-secret',
baseUrl: 'https://api.siteflow.com' // Optional, defaults to production URL
};

const options = {
retries: 3,
retryDelay: 1000,
retryCondition: (error) => error.response && error.response.status >= 500,
serviceUser: true,
accountId: 'your-account-id',
routingRule: 'custom-routing-rule'
};

const client = new SiteflowClient(config, options);

Making API calls

Orders



// Get all orders
const orders = await client.order.getAll();

// Get a specific order
const order = await client.order.get('order-id');

// Create a new order
const newOrder = {
// Order details
};
const createdOrder = await client.order.create(newOrder);

// Validate an order
const validationResult = await client.order.validate(newOrder);

// Cancel an order
await client.order.cancel('source-account-name', 'source-order-id');

API Reference

SiteflowClient

The main client class for interacting with the Siteflow HP API.

Constructor



constructor(config: SiteflowConfig, options?: ClientOptions)

Parameters:




  • config: Configuration object containing API credentials


    • token: Your API token


    • secret: Your API secret


    • baseUrl: (Optional) API base URL




  • options: (Optional) Client options


    • retries: Number of retry attempts for failed requests


    • retryDelay: Delay between retry attempts (in milliseconds)


    • retryCondition: Function to determine if a request should be retried


    • serviceUser: Boolean indicating if the client is a service user


    • accountId: Account ID for the request


    • routingRule: Custom routing rule for the request



Order Methods



  • getAll(): Retrieve all orders


  • get(id: string): Retrieve a specific order by ID


  • create(order: Order): Create a new order


  • validate(order: Order): Validate an order


  • cancel(sourceAccountName: string, sourceOrderId: string): Cancel an order

Error Handling

The library uses a custom error handling mechanism. Errors thrown by the API will be wrapped in a SiteflowError class, which includes additional information about the request and response.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License.