1.1.7 • Published 9 months ago

@ref247/affiliate-sdk v1.1.7

Weekly downloads
-
License
ISC
Repository
github
Last release
9 months ago

Ref247AffiliateSDK

The Ref247AffiliateSDK is a TypeScript-based SDK designed to interact with the Ref247 Affiliate API. It provides a comprehensive set of methods to manage authentication, users, organizations, affiliates, campaigns, commissions, and more.

Features

  • User Management: Retrieve and update user details.
  • Organization Management: Manage organizations, users, roles, currencies, and event types.
  • Affiliate Management: Handle affiliates, campaigns, referrals, and commissions.
  • Campaign Management: Create, update, and delete campaigns.
  • Commission Management: Manage commission structures, rules, and statuses.
  • File Management: Generate signed URLs for file uploads.
  • Payment Management: Handle Stripe configurations, billing, and subscriptions.
  • Audit Logs: Retrieve audit logs for organizations.

Installation

Install the SDK via npm:

npm install @ref247/affiliate-sdk

Usage

Initialization

To initialize the SDK, use the init method:

import { Ref247AffiliateSDK } from '@ref247/affiliate-sdk';

// Enterprise customers can pass their whitelabel url in the init
// Generate your api key from Settings -> API Keys
const affiliateSdk = await Ref247AffiliateSDK.init(WHITELABEL_URL?, API_KEY?);

User Management

const user = await affiliateSdk.getMe();
await affiliateSdk.updateUser(user.id, { firstName: 'John', lastName: 'Doe' });

Organization Management

const organizations = await affiliateSdk.getOrganizations();
const newOrg = await affiliateSdk.createOrganization('New Organization', 'user-id');

Affiliate Management

const affiliates = await affiliateSdk.getAffiliates('organization-id');
const newAffiliate = await affiliateSdk.createAffiliate({ name: 'Affiliate Name', email: 'email@example.com' });

Campaign Management

const campaigns = await affiliateSdk.getAllCampaignsOfOrganization('organization-id');
const newCampaign = await affiliateSdk.createCampaign({ name: 'Campaign Name', budget: 1000 });

Commission Management

const commissionStructures = await affiliateSdk.getCommissionStructuresOfOrganization('organization-id');
const newStructure = await affiliateSdk.addCommissionStructure({ name: 'Structure Name', rules: [] });

File Management

const signedUrl = await affiliateSdk.getOrganizationSignedUrl('organization-id');

Payment Management

const stripeConfig = await affiliateSdk.getStripeConfig();
const billingSession = await affiliateSdk.createBillingSession({ planId: 'plan-id' });

Audit Logs

const auditLogs = await affiliateSdk.getAuditLogsByOrganizationId('organization-id');

API Reference

For a detailed list of all available methods and their parameters, refer to the source code in src/index.ts.

Contributing

Contributions are welcome! Please submit a pull request or open an issue for any bugs or feature requests.

License

This project is licensed under the MIT License.

1.1.7

9 months ago

1.1.6

9 months ago

1.1.5

9 months ago

1.1.4

9 months ago

1.1.3

9 months ago

1.1.2

9 months ago

1.1.1

9 months ago

1.1.0

9 months ago

1.0.10

10 months ago

1.0.9

10 months ago

1.0.8

10 months ago

1.0.7

10 months ago

1.0.6

11 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago