2.3.2 • Published 1 year ago

@vhiweb/magami-client-js v2.3.2

Weekly downloads
-
License
-
Repository
github
Last release
1 year ago

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)
ParamDescriptionData TypeRequired
coupon_code-Stringyes

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) 
ParamDescriptionData TypeRequired
hostStringyes
usernameStringyes
passwordStringyes

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) 
ParamDescriptionData TypeRequired
signatureStringyes

Welcome Form

To set user data from a user use welcomeForm()

welcomeForm({ coupon_code, name, phone, province_id, city_id, district_id })
ParamDescriptionData TypeRequired
coupon_codeStringyes
nameStringyes
phoneStringyes
province_idStringyes
city_idStringyes
district_idStringyes

Redeem

To redeem a coupon use redeem() function.

redeem(redemption_id)
ParamDescriptionData TypeRequired
redemption_idStringyes

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 })
ParamDescriptionData TypeRequired
coupon_codeStringyes
phoneStringyes

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})
ParamDescriptionData TypeRequired
redemption_idStringyes
emailStringyes
id_numberStringyes
addressStringyes
province_idStringyes
city_idStringyes
district_idStringyes

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')
ParamDescriptionData TypeRequired
keyword-Stringno
2.3.2

1 year ago

2.3.1

1 year ago

2.3.0

1 year ago

2.2.5

2 years ago

2.2.4

2 years ago

2.2.3

2 years ago

2.2.2

2 years ago

2.2.1

2 years ago

2.2.0

2 years ago

2.1.3

2 years ago

2.1.2

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago