Class GiftcardsPagerPresenter<V extends GiftcardsPagerView>
- java.lang.Object
-
- com.cheetahdigital.uikit.architecture.mvp.MvpNullObjectBasePresenter<V>
-
- com.cheetahdigital.uikit.architecture.mvp.Presenter<V>
-
- com.cheetahdigital.uikit.architecture.lce.LcePresenter<V>
-
- com.cheetahdigital.uikit.architecture.refreshable.RefreshablePresenter<V>
-
- com.cheetahdigital.giftcards.ui.viewpager.GiftcardsPagerPresenter<V>
-
- All Implemented Interfaces:
MvpPresenter<V>
public class GiftcardsPagerPresenter<V extends GiftcardsPagerView> extends RefreshablePresenter<V>
This presenter class contains all the API calls for the managing the listGiftcard
. This is a child class ofRefreshablePresenter
which is bound to theGiftcardsPagerView
, which means that this will be used to display theGiftcard
object to a view of typeGiftcardsPagerView
-
-
Constructor Summary
Constructors Constructor Description GiftcardsPagerPresenter()
Default constructor of this presenterGiftcardsPagerPresenter(GiftcardParams giftcardListParams, GiftcardParams clientTokenParams)
Constructor of this presenter
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getClientToken()
Gets the client token required for the Braintree SDKprotected ListenerModel<BaseModel<ClientToken>,ClientToken>
getClientTokenReceivedListener()
Create a listener forGiftcardsAPI
protected ListenerModel<BaseModel<Giftcard>,Giftcard>
getGiftcardLinkReceivedListener()
Create a listener forGiftcardsAPI
protected GiftcardsAPI
getGiftcardsAPI()
Get current instance ofGiftcardsAPI
protected ListenerModel<BaseModel<Giftcards>,Giftcards>
getGiftcardsReceivedListener()
Create a listener forGiftcardsAPI
protected ListenerModel<BaseModel<PurchaseResponse>,PurchaseResponse>
getPurchaseGiftcardListener()
Create a listener forGiftcardsAPI
protected ListenerModel<BaseModel<GiftcardReload>,GiftcardReload>
getReloadGiftcardListener()
Create a listener forGiftcardsAPI
void
linkGiftcard(java.lang.String cardNumber, java.lang.String pin)
Links a gift card to the member's account.void
linkGiftcard(java.lang.String cardNumber, java.lang.String pin, GiftcardFields fieldParams, GiftcardParams giftcardParams)
Links a gift card to the member's account.void
loadData()
Load initial view data.protected void
onClientTokenDownloadSuccess(ClientToken clientToken)
Called whenGiftcardsAPI.getGiftcardsClientToken(GiftcardParams, boolean, ListenerModel)
was successful.protected void
onGiftcardsDownloadSuccess(Giftcards data)
Called whenGiftcardsAPI.getGiftcards(GiftcardParams, boolean, ListenerModel)
was successful.protected void
onGiftcardsResponse(retrofit2.Call<BaseModel<Giftcards>> call, retrofit2.Response<BaseModel<Giftcards>> response)
Invoked for a received HTTP response.protected void
onLinkGiftcardFailure(java.lang.String error)
Called whenGiftcardsAPI.linkGiftcard(GiftcardParams, GiftcardFields, ListenerModel)
failed.protected void
onLinkGiftcardSuccess(Giftcard data)
Called whenGiftcardsAPI.linkGiftcard(GiftcardParams, GiftcardFields, ListenerModel)
was successful.protected void
onPurchaseGiftcardFailure(java.lang.String error)
Called whenGiftcardsAPI.purchaseGiftcard(GiftcardParams, GiftcardFields, ListenerModel)
failed.protected void
onPurchaseGiftcardSuccess(PurchaseResponse data)
Called whenGiftcardsAPI.purchaseGiftcard(GiftcardParams, GiftcardFields, ListenerModel)
was successful.void
onRefreshSuccess(BaseData data)
End of refresh with success request.protected void
onReloadGiftcardFailure(java.lang.String error)
Called whenGiftcardsAPI.reloadGiftcard(GiftcardParams, GiftcardFields, ListenerModel)
failed.protected void
onReloadGiftcardSuccess(GiftcardReload data)
Called whenGiftcardsAPI.reloadGiftcard(GiftcardParams, GiftcardFields, ListenerModel)
was successful.void
purchaseGiftcard(java.lang.Float amount, java.lang.String nonce)
Purchase a digital gift card.void
purchaseGiftcard(java.lang.Float amount, java.lang.String nonce, GiftcardFields fieldParams, GiftcardParams giftcardParams)
Purchase a digital gift card.void
refreshData()
Start the refresh view data.void
refreshDataAtBackground()
Refreshed the list ofGiftcard
void
reloadGiftcard(java.lang.String cardNumber, java.lang.Float amount)
Reloads the gift card with the specified amount.void
reloadGiftcard(java.lang.String cardNumber, java.lang.Float amount, java.lang.String nonce)
Reloads the gift card with the specified amount.void
reloadGiftcard(java.lang.String cardNumber, java.lang.Float amount, java.lang.String nonce, GiftcardFields fieldParams, GiftcardParams giftcardParams)
Reloads the gift card with the specified amount.-
Methods inherited from class com.cheetahdigital.uikit.architecture.refreshable.RefreshablePresenter
isRefreshing, onRefreshFailed
-
Methods inherited from class com.cheetahdigital.uikit.architecture.lce.LcePresenter
onLoadFailed, onLoadSuccess
-
Methods inherited from class com.cheetahdigital.uikit.architecture.mvp.MvpNullObjectBasePresenter
attachView, detachView, getView
-
-
-
-
Constructor Detail
-
GiftcardsPagerPresenter
public GiftcardsPagerPresenter()
Default constructor of this presenter
-
GiftcardsPagerPresenter
public GiftcardsPagerPresenter(GiftcardParams giftcardListParams, GiftcardParams clientTokenParams)
Constructor of this presenter- Parameters:
clientTokenParams
- customGiftcardParams
for getting the client token inloadData()
giftcardListParams
- customGiftcardParams
for getting the list of giftcards inloadData()
-
-
Method Detail
-
getClientTokenReceivedListener
protected ListenerModel<BaseModel<ClientToken>,ClientToken> getClientTokenReceivedListener()
Create a listener forGiftcardsAPI
- Returns:
- listener to handle
GiftcardsAPI
requests
-
getGiftcardsReceivedListener
protected ListenerModel<BaseModel<Giftcards>,Giftcards> getGiftcardsReceivedListener()
Create a listener forGiftcardsAPI
- Returns:
- listener to handle
GiftcardsAPI
requests
-
getReloadGiftcardListener
protected ListenerModel<BaseModel<GiftcardReload>,GiftcardReload> getReloadGiftcardListener()
Create a listener forGiftcardsAPI
- Returns:
- listener to handle
GiftcardsAPI
requests
-
getGiftcardLinkReceivedListener
protected ListenerModel<BaseModel<Giftcard>,Giftcard> getGiftcardLinkReceivedListener()
Create a listener forGiftcardsAPI
- Returns:
- listener to handle
GiftcardsAPI
requests
-
getPurchaseGiftcardListener
protected ListenerModel<BaseModel<PurchaseResponse>,PurchaseResponse> getPurchaseGiftcardListener()
Create a listener forGiftcardsAPI
- Returns:
- listener to handle
GiftcardsAPI
requests
-
getGiftcardsAPI
protected GiftcardsAPI getGiftcardsAPI()
Get current instance ofGiftcardsAPI
- Returns:
GiftcardsAPI
used on this presenter
-
onClientTokenDownloadSuccess
protected void onClientTokenDownloadSuccess(ClientToken clientToken)
Called whenGiftcardsAPI.getGiftcardsClientToken(GiftcardParams, boolean, ListenerModel)
was successful.- Parameters:
clientToken
- client token required for the Braintree SDK
-
onGiftcardsDownloadSuccess
protected void onGiftcardsDownloadSuccess(Giftcards data)
Called whenGiftcardsAPI.getGiftcards(GiftcardParams, boolean, ListenerModel)
was successful.- Parameters:
data
-Giftcards
-
onReloadGiftcardFailure
protected void onReloadGiftcardFailure(java.lang.String error)
Called whenGiftcardsAPI.reloadGiftcard(GiftcardParams, GiftcardFields, ListenerModel)
failed.- Parameters:
error
- error message
-
onReloadGiftcardSuccess
protected void onReloadGiftcardSuccess(GiftcardReload data)
Called whenGiftcardsAPI.reloadGiftcard(GiftcardParams, GiftcardFields, ListenerModel)
was successful.- Parameters:
data
-GiftcardReload
-
onLinkGiftcardFailure
protected void onLinkGiftcardFailure(java.lang.String error)
Called whenGiftcardsAPI.linkGiftcard(GiftcardParams, GiftcardFields, ListenerModel)
failed.- Parameters:
error
- error message
-
onLinkGiftcardSuccess
protected void onLinkGiftcardSuccess(Giftcard data)
Called whenGiftcardsAPI.linkGiftcard(GiftcardParams, GiftcardFields, ListenerModel)
was successful.- Parameters:
data
-Giftcard
-
onPurchaseGiftcardFailure
protected void onPurchaseGiftcardFailure(java.lang.String error)
Called whenGiftcardsAPI.purchaseGiftcard(GiftcardParams, GiftcardFields, ListenerModel)
failed.- Parameters:
error
- error message
-
onPurchaseGiftcardSuccess
protected void onPurchaseGiftcardSuccess(PurchaseResponse data)
Called whenGiftcardsAPI.purchaseGiftcard(GiftcardParams, GiftcardFields, ListenerModel)
was successful.- Parameters:
data
-Giftcard
-
onGiftcardsResponse
protected void onGiftcardsResponse(retrofit2.Call<BaseModel<Giftcards>> call, retrofit2.Response<BaseModel<Giftcards>> response)
Invoked for a received HTTP response.
-
loadData
public void loadData()
Description copied from class:LcePresenter
Load initial view data.- Specified by:
loadData
in classLcePresenter<V extends GiftcardsPagerView>
-
refreshData
public void refreshData()
Description copied from class:RefreshablePresenter
Start the refresh view data.- Overrides:
refreshData
in classRefreshablePresenter<V extends GiftcardsPagerView>
-
refreshDataAtBackground
public void refreshDataAtBackground()
Refreshed the list ofGiftcard
-
onRefreshSuccess
public void onRefreshSuccess(BaseData data)
Description copied from class:RefreshablePresenter
End of refresh with success request.- Overrides:
onRefreshSuccess
in classRefreshablePresenter<V extends GiftcardsPagerView>
- Parameters:
data
- theBaseData
.
-
getClientToken
public java.lang.String getClientToken()
Gets the client token required for the Braintree SDK- Returns:
- client token required for the Braintree SDK
-
reloadGiftcard
public void reloadGiftcard(java.lang.String cardNumber, @NonNull java.lang.Float amount)
Reloads the gift card with the specified amount. Remember to set the followingGiftcardFields
:- amount using
GiftcardFields.setAmount(Float)
- nonce using
GiftcardFields.setPaymentMethodNonce(String)
- Parameters:
cardNumber
- code of gift cardamount
- amount to reload
- amount using
-
reloadGiftcard
public void reloadGiftcard(java.lang.String cardNumber, @NonNull java.lang.Float amount, java.lang.String nonce)
Reloads the gift card with the specified amount. Remember to set the followingGiftcardFields
:- amount using
GiftcardFields.setAmount(Float)
- nonce using
GiftcardFields.setPaymentMethodNonce(String)
- Parameters:
cardNumber
- code of gift cardamount
- amount to reloadnonce
- value obtained from braintree
- amount using
-
reloadGiftcard
public void reloadGiftcard(java.lang.String cardNumber, @NonNull java.lang.Float amount, java.lang.String nonce, GiftcardFields fieldParams, GiftcardParams giftcardParams)
Reloads the gift card with the specified amount. Remember to set the followingGiftcardFields
:- amount using
GiftcardFields.setAmount(Float)
- nonce using
GiftcardFields.setPaymentMethodNonce(String)
- Parameters:
cardNumber
- code of gift cardamount
- amount to reloadnonce
- value obtained from braintreefieldParams
-GiftcardFields
to reload the gift cardgiftcardParams
-GiftcardParams
to use for reloading gift card
- amount using
-
linkGiftcard
public void linkGiftcard(java.lang.String cardNumber, @NonNull java.lang.String pin)
Links a gift card to the member's account. Remember to set the followingGiftcardFields
:- pin using
GiftcardFields.setPin(String)
- Parameters:
cardNumber
- code of gift cardpin
- theGiftcardFields
to link a gift card to an account
- pin using
-
linkGiftcard
public void linkGiftcard(java.lang.String cardNumber, @NonNull java.lang.String pin, GiftcardFields fieldParams, GiftcardParams giftcardParams)
Links a gift card to the member's account. Remember to set the followingGiftcardFields
:- pin using
GiftcardFields.setPin(String)
- Parameters:
cardNumber
- code of gift cardpin
- theGiftcardFields
to link a gift card to an accountfieldParams
-GiftcardFields
to link the gift cardgiftcardParams
-GiftcardParams
to use when linking giftcard
- pin using
-
purchaseGiftcard
public void purchaseGiftcard(@NonNull java.lang.Float amount, @NonNull java.lang.String nonce)
Purchase a digital gift card. Remember to set the followingGiftcardFields
:- amount using
GiftcardFields.setAmount(Float)
- nonce using
GiftcardFields.setPaymentMethodNonce(String)
- Parameters:
amount
- cost of the digital gift cardnonce
- obtained from braintree
- amount using
-
purchaseGiftcard
public void purchaseGiftcard(java.lang.Float amount, java.lang.String nonce, GiftcardFields fieldParams, GiftcardParams giftcardParams)
Purchase a digital gift card.- Parameters:
amount
- cost of the digital gift cardnonce
- obtained from braintreefieldParams
-GiftcardFields
to purchase a gift cardgiftcardParams
-GiftcardParams
to use for calling purchase giftcard api
-
-