Cheetah CES Docs Portal

Navigation
Home
GitHub
Email
Corporate Site


Gift Cards

« Back to Kits References

The Gift Cards kit is used to fetch gift card information for the members. The basic functions in this kit includes displaying available gift cards for purchase, displaying purchased gift cards, displaying gift card balances, configuring gift card properties (autoreload), reloading and deleting gift cards.

To include the Gift Cards kit, open the Gradle Scripts | build.gradle (Module: app) and add the following to the dependencies section:

   implementation 'com.cheetahdigital.android:giftcards:<version>'


On this page:

Overview

The Gift Cards kit is presented using a View Pager.

Launching the Gift Cards Activity

Assuming that the Gift Cards kit will be launched from a MainActivity, you can follow the succeeding steps to launch the GiftcardsListActivity from a Button’s OnClickListener:

  1. In your MainActivity, add a Button to launch the starting Activity - GiftcardsListActivity.
    mButton.setOnClickListener(new View.OnClickListener() {
               @Override
               public void onClick(View v) {
                   startActivity(new Intent(StellarActions.Giftcards.getGiftCardListAction(MainActivity.this)));
               }
           }); 
    
  2. Gift card classes are available to group gift cards. To specify the gift card class to be used to fetch the gift card list, use the following intent extra
 intent.putExtra(GiftcardsListFragment.GIFTCARD_CLASS, "class_name");

For the rest of the available pre-made Activity and Fragment for Gift Cards, please see Class Reference.

Theme Customization

The Kits leverage on Android’s built-in support for Styles and Themes. Overriding the Styles and Themes of the app will also change the corresponding Views used in this kit.

Layout Customization

Customizing Layouts via XML

You can customize the layouts of the different screens in the Gift Cards Kit by copying the layout XML’s and overriding as desired. To read more about this, please visit the Layout Customization via XML document. The XML’s used are:

  • fragment_giftcard.xml - layout for an item in the list of gift cards
  • fragment_giftcards.xml - layout for displaying the list of gift cards
  • activity_giftcards.xml - container for stellar_fragment_giftcards
  • activity_giftcard_details.xml - layout for displaying the details of a gift card
  • activity_giftcard_manage.xml - layout for managing gift cards
  • activity_giftcard_auto_reload.xml - layout for auto reloading gift cards
  • list_item_giftcard_transaction.xml - layout for an item in the list of gift card transactions

Customizing Layouts via Code

There are certain cases that you may want to use a highly-customized layout for an Activity. To read more about this, please visit the Layout Customization via Code document. The classes used for the Gift Cards kit are:

  • GiftcardsActivity and GiftcardsFragment for displaying the list of gift cards
  • GiftcardFragment is a single gift card item in the list of gift cards
  • GiftcardDetailsActivity for displaying the details of a gift card
  • GiftcardAutoReloadActivity used when reloading a gift card
  • GiftcardHistoryActivity for displaying the list of gift card transactions
  • GiftcardManageActivity for displaying the gift cards manage screen

Customizing Handlers

There are certain cases that you may want to change the default behavior of an Activity. You can achieve this by extending the Activity/Fragment that you want to customize and override as necessary.

Handlers may occur in different places:

  • Adapters - for lists
  • Member variables inside Activities or Fragments
  • Member variables inside custom Widgets - for stand-alone custom Widgets

To start with, you may look at the classes mentioned in Customizing Layouts via Code, along with AddGiftcardDialogFragment for the dialog shown when adding a new gift card, and GiftcardHistoryAdapter - the adapter used when displaying the list of past gift card transactions.

Fully Custom UI

If changing the layout does not suffice for your case, you can always do a full customization. The following are the methods you can use from the GiftcardsAPI class:

Getting Client Token

getGiftcardsClientToken(GiftcardParams queryParams, boolean clearCache,
                                        ListenerModel<BaseModel<ClientToken>, ClientToken> listener)

Querying Gift Cards

getGiftcards(GiftcardParams queryParams, boolean clearCache,
                             ListenerModel<BaseModel<Giftcards>, Giftcards> listener)

getGiftcard(GiftcardParams queryParams, boolean clearCache,
                            ListenerModel<BaseModel<Giftcard>, Giftcard> listener)

Reloading a Gift Card

reloadGiftcard(GiftcardParams queryParams, GiftcardFields fieldParams,
                               ListenerModel<BaseModel<GiftcardReload>, GiftcardReload> listener)

Purchasing a Gift Card

purchaseGiftcard(GiftcardParams queryParams, GiftcardFields fieldParams,
                                 ListenerModel<BaseModel<PurchaseResponse>, PurchaseResponse> listener)
linkGiftcard(GiftcardParams queryParams, GiftcardFields fieldParams,
                             ListenerModel<BaseModel<Giftcard>, Giftcard> listener)

unlinkGiftcard(GiftcardParams queryParams, ListenerModel<BaseModel<Giftcard>, Giftcard> listener)

Querying Transactions

getTransactions(GiftcardParams queryParams, boolean clearCache,
                                ListenerModel<BaseModel<Transactions>, Transactions> listener)

Updating Gift Card Auto Reload Details

updateGiftcard(GiftcardParams queryParams, GiftcardFields fieldParams,
                               ListenerModel<BaseModel<Giftcard>, Giftcard> listener)

Fetch Available Gift Card classes

getClasses(GiftcardParams queryParams, boolean clearCache,
                           ListenerModel<BaseModel<CardClasses>, CardClasses> listener)


« Back to Kits References