Skip to content

Latest commit

 

History

History
147 lines (110 loc) · 2.74 KB

README.md

File metadata and controls

147 lines (110 loc) · 2.74 KB

Madefire Web SDK

This SDK is in the early stages of development. Documentation is still in progress. If you have any questions, email David Furfero ([email protected]) or Max Mautner ([email protected]).

Installation

Using a package manager:

yarn add Madefire/web-sdk -S
npm install Madefire/web-sdk.git -S

Using git:

git clone [email protected]:Madefire/web-sdk.git madefire-web-sdk

Usage

  1. Include Madefire SDK.
<script src="madefire.js"></script>
import Madefire from 'madefire-web-sdk';
  1. Instantiate the API.
// For production, use the default configuration.
const mf = new Madefire();

// For development, you may use an alternative API host.
const mf = new Madefire({
  apiHost: 'http://localhost:3000',
});
  1. Make API requests.
mf.coupon.getCampaign(campaignID)
  .then(campaign => renderCampaign(campaign))
  .catch(error => renderError(error));

API Documentation

Madefire.coupon

Madefire.coupon contains methods for accessing Madefire's coupon code redemption APIs.

getCampaign(campaignSlug)

Retrieves information about a specified campaign.

const campaignSlug = 'ccisd-2017';

Madefire.coupon.getCampaign(campaignSlug)
  .then(function(campaign) {
    renderCampaign(campaign);
  })
  .catch(function(error) {
    renderError(error);
  });

Example response:

{
  "activationDate": "2017-07-20T08:00:00Z",
  "active": true,
  "app": "mf",
  "bundle": "e-e55ed5d05eab46c1bdfeb37e331fca17",
  "expirationDate": "2017-10-20T08:00:00Z",
  "name": "2017 Comic-Con International: San Diego",
  "numberOfCharacters": 5,
  "redemptionsPerCoupon": null,
  "slug": "ccisd-2017"
}

Example error:

TBD

postRedemption(campaignSlug, redemptionData)

Redeems a coupon code for a specified campaign and registers the user (if not previously registered) and retrieves the new (or existing) user's data.

const campaignSlug = 'ccisd-2017';
const redemptionData = {
  code: 'da440',
  name: 'Fizzle Bop',
  email: '[email protected]',
  password: 'fizz1eB0p',
};

Madefire.coupon.postRedemption(campaignSlug, redemptionData)
  .then(function handleSuccess(user) {
    renderUser(user);
  })
  .catch(function handleError(error) {
    renderError(error);
  });

Example response:

{
  "compedApps": "",
  "created": "2017-07-21T23:24:12Z",
  "email": "[email protected]",
  "firstApp": "mf",
  "groups": [],
  "id": "u-fc1a9db2e2c0fc1ba55de5d62d2317ad",
  "isActive": true
  "isAuthor": false,
  "isStaff": false,
  "lastLogin": "2017-07-21T08:21:51.152930Z",
  "name": "Fizzle Bop",
  "okToEmail": true,
  "updated": "2017-07-21T23:24:12Z",
}

Example error:

TBD