Skip to content

guivinicius/c7-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

c7-api

A JavaScript wrapper for the Commerce7 API that works in both Node.js and browser environments.

Installation

npm install c7-api

Usage

Node.js

// Import the Node.js adapter first
import '@c7-api/adapters/node';
import { Commerce7 } from 'c7-api';

const client = new Commerce7({
  tenantId: process.env.COMMERCE7_TENANT_ID,
  clientId: process.env.COMMERCE7_CLIENT_ID,
  clientSecret: process.env.COMMERCE7_CLIENT_SECRET,
  debug: true, // Optional, enables debug logging
  apiVersion: 'v1' // Optional, defaults to v1
});

Using Environment Variables

In Node.js environments, you can use environment variables:

COMMERCE7_TENANT_ID=your-tenant-id
COMMERCE7_CLIENT_ID=your-client-id
COMMERCE7_CLIENT_SECRET=your-client-secret

Then initialize without passing config:

import '@c7-api/adapters/node';
import { Commerce7 } from 'c7-api';

const client = new Commerce7();

Debug Mode

Enable debug mode to see detailed logs of requests and responses:

const client = new Commerce7({
  // ...other config
  debug: true
});

API Documentation

For more details about the Commerce7 API, please refer to the official documentation.

Error Handling

The API wrapper includes built-in error handling that will throw errors with detailed information about API failures. Errors will include the HTTP status code and the error message from the Commerce7 API.

Release Instructions

To release a new version of the package:

  1. Update version in package.json:
npm version patch  # for bug fixes
npm version minor  # for new features
npm version major  # for breaking changes
  1. Push changes and tags:
git push origin main --tags
  1. Publish to npm:
npm publish --access public

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published