@vhiweb/magami-client-js
TypeScript icon, indicating that this package has built-in type declarations

2.3.2 • Public • Published

Magami Client JS

Welcome to Magami Software Development Kit (SDK), This library contains core API needed to create a mini game campaign. This developer-friendly resource empowers you to efficiently retrieve and manipulate data to create tailored solutions.

Prerequisites

To use this package, you must have a registered Magami client application. Make sure you already have the API Key and Campaign Slug.

Installation

You can install Magami Client JS using npm or yarn, depending on your preference. Open your terminal or command prompt and navigate to your project directory.

npm i magami-client-js
or if you are using yarn
yarn add magami-client-js

Importing Magami Client JS

After successfully installing Magami Client JS, you can import it into your JavaScript or TypeScript code as follows:

import Magami from 'magami-client-js';
const magami = new Magami();

Initalizing Magami

To initialize Magami, you need to provide your apiKey and campaignSlug, which can be obtained from the Magami dashboard or by contacting Magami support. Use the magami.init() function for this purpose:

magami.init({
    apiKey: 'example',
    campaignSlug: 'example'
});

Usage

Now that you have Magami Client JS installed and initialized, you can use its functions to interact with the Magami platform, including claiming coupons, setting user data, redeeming coupons, and more. Refer to the library's documentation or README for detailed information on how to use each function.

Example

magami.claim('coupon_code_here')
    .then(response => {
        console.log('Coupon claimed successfully:', response);
    })
    .catch(error => {
        console.error('Error claiming coupon:', error);
    });

Methods

Claiming Coupon

To claim coupon from a campaign use claim() function.

claim(coupon_code)
Param Description Data Type Required
coupon_code - String yes

Microsite Configuration

To get your microsite configuration including app key and campaign slug, use getConfiguration() to get all information you need about your campaign.

getConfiguration(host, username, password) 
Param Description Data Type Required
host String
username String yes
password String yes

Validate Signnature

To validate your signature that you get from claim() response, use validateSignature() to revalidate your coupon/token (in case you wan't it to be more secure)

validateSignature(signature) 
Param Description Data Type Required
signature String yes

Welcome Form

To set user data from a user use welcomeForm()

welcomeForm({ coupon_code, name, phone, province_id, city_id, district_id })
Param Description Data Type Required
coupon_code String yes
name String yes
phone String yes
province_id String yes
city_id String yes
district_id String yes

Redeem

To redeem a coupon use redeem() function.

redeem(redemption_id)
Param Description Data Type Required
redemption_id String yes

Validate Winner

Incase your user reload or close the page by some reason, you can re-validate your winner coupon code using validateWinner().

validateWinner({ coupon_code, phone })
Param Description Data Type Required
coupon_code String yes
phone String yes

Winner Form

To complete the user data after a user won a prize, you can use winnerForm() to complete their data.

winnerForm({ redemption_id, email,id_number, address})
Param Description Data Type Required
redemption_id String yes
email String yes
id_number String yes
address String yes
province_id String yes
city_id String yes
district_id String yes

Get Winner

To get list of winners you can use getWinner() function.

getWinner()

FAQ

To get list of all your Frequently Asked Question, use faq() function.

faq()
// or you can pass a string into faq to filter faq data
faq('keyword')
Param Description Data Type Required
keyword - String no

Readme

Keywords

none

Package Sidebar

Install

npm i @vhiweb/magami-client-js

Weekly Downloads

1

Version

2.3.2

License

none

Unpacked Size

20.6 kB

Total Files

10

Last publish

Collaborators

  • davidnasrulloh
  • adityarizqi
  • angellicaos
  • vhiweb-account
  • triasrahman
  • prasiman
  • 2ureternity