npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rewardful-ts

v0.0.13

Published

Unofficial Rewardful's API client for Node.js and Browser

Downloads

785

Readme

Rewardful API SDK for TypeScript

An unofficial TypeScript SDK for the Rewardful API, providing a streamlined and type-safe interface to interact with Rewardful's resources.

Built with Zod & OpenAPI and OpenAPI Generator.

Installation

pnpm install rewardful-ts

Feature Support

| Method | Implemented | Mock Tested | Live Tested | |------------------------|-------------|-------------|-------------| | getAffiliates | ✅ | ✅ | ✅ | | getAffiliatesId | ✅ | ✅ | ✅ | | postAffiliates | ✅ | ✅ | ✅ | | putAffiliatesId | ✅ | ✅ | ✅ | | getCampaigns | ✅ | ✅ | ✅ | | getCampaignsId | ✅ | ✅ | ✅ | | postCampaigns | ✅ | ✅ | ✅ | | putCampaignsId | ✅ | ✅ | ✅ | | getCommissions | ✅ | ✅ | ✅ | | getCommissionsId | ✅ | ✅ | ✅ | | putCommissionsId | ✅ | ✅ | ❌ | | getAffiliate_coupons | ✅ | ✅ | ❌ | | getAffiliate_couponsId | ✅ | ✅ | ❌ | | postAffiliate_coupons | ✅ | ✅ | ❌ | | getAffiliate_links | ✅ | ✅ | ❌ | | getAffiliate_linksId | ✅ | ✅ | ❌ | | postAffiliate_links | ✅ | ✅ | ❌ | | putAffiliate_linksId | ✅ | ✅ | ❌ | | getPayouts | ✅ | ✅ | ❌ | | getPayoutsId | ✅ | ✅ | ❌ | | putPayoutsIdpay | ✅ | ✅ | ❌ | | getReferrals | ✅ | ✅ | ❌ |

Quick Start

import { createRewardfulClient } from 'rewardful-ts';

const api = createRewardfulClient('my-secret-api-key');

const affiliates = await api.getAffiliates();
console.log("My affiliates", affiliates.data);

API Methods

This SDK provides an intuitive way to access Rewardful resources, categorized by endpoint:

Affiliates

List Affiliates:

const affiliates = await api.getAffiliates({ queries: { expand: 'campaign' } });

Get Affiliate by ID:

const affiliate = await api.getAffiliatesId({ params: { id: "affiliate_id" } });

Create Affiliate:

const newAffiliate = await api.postAffiliates({
  first_name: "Jane",
  last_name: "Doe",
  email: "[email protected]",
});

Update Affiliate:

const updatedAffiliate = await api.putAffiliatesId(
  { first_name: "John", last_name: "Doe" },
  { params: { id: "affiliate_id" } }
);

Campaigns

List Campaigns:

const campaigns = await api.getCampaigns();

Get Campaign by ID:

const campaign = await api.getCampaignsId({ params: { id: "campaign_id" } });

Create Campaign:

const newCampaign = await api.postCampaigns({
  name: "Exclusive Campaign",
  url: "https://rewardful.com/exclusive",
  private: true,
  reward_type: "percent",
  commission_percent: 20.0,
});

Update Campaign:

const updatedCampaign = await api.putCampaignsId(
  { name: "Updated Campaign" },
  { params: { id: "campaign_id" } }
);

Commissions

List Commissions:

const commissions = await api.getCommissions({ queries: { page: 1, limit: 50 } });

Get Commission by ID:

const commission = await api.getCommissionsId({ params: { id: "commission_id" } });

Mark Commission as Paid:

const payout = await api.putPayoutsIdpay(undefined, { params: { id: "payout_id" } });

Update Commission:

const updatedCommission = await api.putCommissionsId(
  { paid_at: "2023-01-01T00:00:00Z" },
  { params: { id: "commission_id" } }
);

Affiliate Coupons

List Affiliate Coupons:

const coupons = await api.getAffiliate_coupons();

Get Affiliate Coupon by ID:

const coupon = await api.getAffiliate_couponsId({ params: { id: "coupon_id" } });

Create Affiliate Coupon:

const newCoupon = await api.postAffiliate_coupons({
  affiliate_id: "affiliate_id",
  token: "NEWCODE",
});

Affiliate Links

List Affiliate Links:

const links = await api.getAffiliate_links();

Get Affiliate Link by ID:

const link = await api.getAffiliate_linksId({ params: { id: "link_id" } });

Create Affiliate Link:

const newLink = await api.postAffiliate_links({
  affiliate_id: "affiliate_id",
  token: "mylinktoken",
});

Update Affiliate Link:

const updatedLink = await api.putAffiliate_linksId(
  { token: "new-token" },
  { params: { id: "link_id" } }
);

Payouts

List Payouts:

const payouts = await api.getPayouts({ queries: { expand: ["affiliate", "commissions"] } });

Get Payout by ID:

const payout = await api.getPayoutsId({ params: { id: "payout_id" } });

Mark Payout as Paid:

const markedPayout = await api.putPayoutsIdpay(undefined, { params: { id: "payout_id" } });

Referrals

List Referrals:

const referrals = await api.getReferrals({ queries: { expand: ["affiliate"], page: 1 } });

Testing

This SDK includes comprehensive unit tests using mocked responses to ensure reliable functionality.

To run the tests:

pnpm test

Tests are structured to verify each API endpoint, simulating responses to ensure consistency with expected API behavior.

License

MIT License