Gift Management Service

App42 Gift Service facilitates complete Gift Management for any mobile or web app. It enables gift creation, retrieval, updation and distribution to users in their apps & games.

Import Statement
  • create User Api for Android
  • create User Api for Windows
  • create User Api for iOS
  • create User Api for Swift
  • create User Api for Java
  • create User Api for Unity
  • create User Api for JS
  • create User Api for Corona
  • create User Api for Cocos2DX
  • create User Api for .Net
  • create User Api for PHP
  • create User Api for Marmalade
  •  create User Api for Ruby
  •  create User Api for Flash
  1. using com.shephertz.app42.paas.sdk.csharp;  
  2. using com.shephertz.app42.paas.sdk.csharp.gift;  
Initialize

In order to use the various functions available in a specific API, the developer has to initialize with App42API by passing the apiKey and the secretKey which will become available after the app creation from AppHQ dashboard.

Required Parameters

apiKey - The Application key given when the application was created. secretKey - The secret key corresponding to the application key given when the application was created.

  • create User Api for Android
  • create User Api for Windows
  • create User Api for iOS
  • create User Api for Swift
  • create User Api for Java
  • create User Api for Unity
  • create User Api for JS
  • create User Api for Corona
  • create User Api for Cocos2DX
  • create User Api for .Net
  • create User Api for PHP
  • create User Api for Marmalade
  •  create User Api for Ruby
  •  create User Api for Flash
  1. App42API.Initialize("API_KEY","SECRET_KEY");  
Build Service

After initialization, the developer will have to call the buildXXXService method on App42API to get the instance of the particular API that they wish to build. For example, to build an instance of GiftService, buildGiftService() method needs to be called.

  • create User Api for Android
  • create User Api for Windows
  • create User Api for iOS
  • create User Api for Swift
  • create User Api for Java
  • create User Api for Unity
  • create User Api for JS
  • create User Api for Corona
  • create User Api for Cocos2DX
  • create User Api for .Net
  • create User Api for PHP
  • create User Api for Marmalade
  •  create User Api for Ruby
  •  create User Api for Flash
  1. GiftService giftService = App42API.BuildGiftService();   
Create Gift

Create a gift for distributing among friends in app & games.

Required Parameters

giftName - Name of the gift which has to be created. icon - Local path for the file. displayName - Name of the gift which you want to display. description - Description of your gift. tagName - Specify the tag name for which you want to create the gift e.g. Entertainment , News , Sports.

  • create User Api for Android
  • create User Api for Windows
  • create User Api for iOS
  • create User Api for Swift
  • create User Api for Java
  • create User Api for Unity
  • create User Api for JS
  • create User Api for Corona
  • create User Api for Cocos2DX
  • create User Api for .Net
  • create User Api for PHP
  • create User Api for Marmalade
  •  create User Api for Ruby
  •  create User Api for Flash
  1. String giftName = "Power";  
  2. String icon = "File path from gallery /sd card";    
  3. String displayName = "Power Up";  
  4. String description = "Gift is created in App42 DataBase.";  
  5. String tagName = "Entertainment";  
  6. App42Log.SetDebug(true);        //Print output in your editor console  
  7. App42API.Initialize("API_KEY","SECRET_KEY");  
  8. GiftService giftService = App42API.BuildGiftService();   
  9. giftService.CreateGift(giftName, icon, displayName, description, tagName, new UnityCallBack());   
  10. public class UnityCallBack : App42CallBack  
  11. {  
  12.     public void OnSuccess(object response)  
  13.     {  
  14.         Gift gift = (Gift)response;  
  15.         App42Log.Console ("Gift Name is : " + gift.GetName ());  
  16.         App42Log.Console ("CreatedOn is : " + gift.GetCreatedOn ());  
  17.         App42Log.Console ("Tag is : " + gift.GetTag ());  
  18.         App42Log.Console ("Icon url is : " + gift.GetIcon ());  
  19.         App42Log.Console ("Description is : " + gift.GetDescription ());  
  20.         App42Log.Console ("Display name is : " + gift.GetDisplayName ());  
  21.     }  
  22.     public void OnException(Exception e)  
  23.     {  
  24.         App42Log.Console("Exception : " + e);  
  25.     }  
  26. }  
Distribute Gifts

Once gift is created, you can distribute gifts among the users with specifying the number of counts & recipients.

Required Parameters

giftName - Name of the gift which has to be distributed recipientsList - List of the users among which gift is to be distributed. counts - Number of same gift count to a recipients list.

  • create User Api for Android
  • create User Api for Windows
  • create User Api for iOS
  • create User Api for Swift
  • create User Api for Java
  • create User Api for Unity
  • create User Api for JS
  • create User Api for Corona
  • create User Api for Cocos2DX
  • create User Api for .Net
  • create User Api for PHP
  • create User Api for Marmalade
  •  create User Api for Ruby
  •  create User Api for Flash
  1. String giftName = "Power";  
  2. IList<string> recipientsList = new List<string>();  
  3. recipientsList.add("Nick");  
  4. recipientsList.add("John");  
  5. recipientsList.add("Pamila");  
  6. int counts = 2;  
  7. App42Log.SetDebug(true);        //Print output in your editor console  
  8. App42API.Initialize("API_KEY","SECRET_KEY");  
  9. GiftService giftService = App42API.BuildGiftService();   
  10. giftService.DistributeGifts(giftName, recipientsList, counts, new UnityCallBack());   
  11. public class UnityCallBack : App42CallBack  
  12. {  
  13.     public void OnSuccess(object response)  
  14.     {  
  15.         Gift gift = (Gift)response;  
  16.         App42Log.Console ("Gift Name is : " + gift.GetName ());  
  17.         App42Log.Console ("Display name is : " + gift.GetDisplayName ());  
  18.         App42Log.Console ("Icon URL is : " + gift.GetIcon ());  
  19.         App42Log.Console ("Tag is : " + gift.GetTag ());  
  20.         App42Log.Console ("Description is : " + gift.GetDescription ());  
  21.         App42Log.Console ("CreatedOn is : " + gift.GetCreatedOn ());  
  22.         for(int i=0;i<gift.GetRequestsList ().Count; i++)  
  23.         {  
  24.             App42Log.Console ("Sender : " + gift.GetRequestsList ()[i].GetSender());  
  25.             App42Log.Console ("Recipient : " + gift.GetRequestsList ()[i].GetRecipient());  
  26.             App42Log.Console ("RequestId : " + gift.GetRequestsList ()[i].GetRequestId());  
  27.             App42Log.Console ("SentOn : " + gift.GetRequestsList ()[i].GetSentOn());  
  28.         }  
  29.     }  
  30.     public void OnException(Exception e)  
  31.     {  
  32.         App42Log.Console("Exception : " + e);  
  33.     }  
  34. }  
Send Gift

Send gift among the recipients.
Note: You cannot send the gift until you have received at least one gift.

Required Parameters

giftName - Name of the gift which you need to send. senderName - Name of the sender who wants to send the gift. recipientList - List of the users among which gift is to be sent. message - Message which you want to send with the gift.

  • create User Api for Android
  • create User Api for Windows
  • create User Api for iOS
  • create User Api for Swift
  • create User Api for Java
  • create User Api for Unity
  • create User Api for JS
  • create User Api for Corona
  • create User Api for Cocos2DX
  • create User Api for .Net
  • create User Api for PHP
  • create User Api for Marmalade
  •  create User Api for Ruby
  •  create User Api for Flash
  1. String giftName = "Power";  
  2. String senderName = "Nick";  
  3. IList<string> recipientsList = new List<string>();  
  4. recipientsList.add("John");  
  5. recipientsList.add("Pamila");  
  6. String message = "Keep going";  
  7. int counts = 2;  
  8. App42Log.SetDebug(true);        //Print output in your editor console  
  9. App42API.Initialize("API_KEY","SECRET_KEY");  
  10. GiftService giftService = App42API.BuildGiftService();   
  11. giftService.SendGift(giftName, senderName, recipientList, message, new UnityCallBack());   
  12. public class UnityCallBack : App42CallBack  
  13. {  
  14.     public void OnSuccess(object response)  
  15.     {  
  16.         Gift gift = (Gift)response;  
  17.         App42Log.Console ("Gift Name is : " + gift.GetName ());  
  18.         App42Log.Console ("Display name is : " + gift.GetDisplayName ());  
  19.         App42Log.Console ("Icon URL is : " + gift.GetIcon ());  
  20.         App42Log.Console ("Tag is : " + gift.GetTag ());  
  21.         App42Log.Console ("Description is : " + gift.GetDescription ());  
  22.         App42Log.Console ("CreatedOn is : " + gift.GetCreatedOn ());  
  23.         for(int i=0;i<gift.GetRequestsList ().Count; i++)  
  24.         {  
  25.             App42Log.Console ("Sender : " + gift.GetRequestsList ()[i].GetSender());  
  26.             App42Log.Console ("Recipient : " + gift.GetRequestsList ()[i].GetRecipient());  
  27.             App42Log.Console ("Message : " + gift.GetRequestsList ()[i].GetMessage());  
  28.             App42Log.Console ("RequestId : " + gift.GetRequestsList ()[i].GetRequestId());  
  29.             App42Log.Console ("SentOn : " + gift.GetRequestsList ()[i].GetSentOn());  
  30.         }  
  31.     }  
  32.     public void OnException(Exception e)  
  33.     {  
  34.         App42Log.Console("Exception : " + e);  
  35.     }  
  36. }  
Request Gift

User can request a gift from friends, such as”lives”.

Required Parameters

giftName - Name of the gift which you need to request. senderName - Name of the sender who wants to request the gift. recipientList - List of the users among which gift is to be requested. message - Message which you want to request with the gift.

  • create User Api for Android
  • create User Api for Windows
  • create User Api for iOS
  • create User Api for Swift
  • create User Api for Java
  • create User Api for Unity
  • create User Api for JS
  • create User Api for Corona
  • create User Api for Cocos2DX
  • create User Api for .Net
  • create User Api for PHP
  • create User Api for Marmalade
  •  create User Api for Ruby
  •  create User Api for Flash
  1. String giftName = "Power";  
  2. String senderName = "Nick";  
  3. IList<string> recipientsList = new List<string>();  
  4. recipientsList.add("John");  
  5. recipientsList.add("Pamila");  
  6. String message = "Keep going";  
  7. int counts = 2;  
  8. App42Log.SetDebug(true);        //Print output in your editor console  
  9. App42API.Initialize("API_KEY","SECRET_KEY");  
  10. GiftService giftService = App42API.BuildGiftService();   
  11. giftService.RequestGift(giftName, senderName, recipientList, message, new UnityCallBack());   
  12. public class UnityCallBack : App42CallBack  
  13. {  
  14.     public void OnSuccess(object response)  
  15.     {  
  16.         Gift gift = (Gift)response;  
  17.         App42Log.Console ("Gift Name is : " + gift.GetName ());  
  18.         App42Log.Console ("Display name is : " + gift.GetDisplayName ());  
  19.         App42Log.Console ("Icon URL is : " + gift.GetIcon ());  
  20.         App42Log.Console ("Tag is : " + gift.GetTag ());  
  21.         App42Log.Console ("Description is : " + gift.GetDescription ());  
  22.         App42Log.Console ("CreatedOn is : " + gift.GetCreatedOn ());  
  23.         for(int i=0;i<gift.GetRequestsList ().Count; i++)  
  24.         {  
  25.             App42Log.Console ("Sender : " + gift.GetRequestsList ()[i].GetSender());  
  26.             App42Log.Console ("Recipient : " + gift.GetRequestsList ()[i].GetRecipient());  
  27.             App42Log.Console ("Message : " + gift.GetRequestsList ()[i].GetMessage());  
  28.             App42Log.Console ("RequestId : " + gift.GetRequestsList ()[i].GetRequestId());  
  29.             App42Log.Console ("SentOn : " + gift.GetRequestsList ()[i].GetSentOn());  
  30.             App42Log.Console ("Type is : "+ gift.GetRequestsList ()[i].GetType());        
  31.         }  
  32.     }  
  33.     public void OnException(Exception e)  
  34.     {  
  35.         App42Log.Console("Exception : " + e);  
  36.     }  
  37. }  
Get Gift Request

Fetch all the pending request of gifts that you have received from friends.

Required Parameters

giftName - Name of the gift which you want to fetch the request. userName - Name of the user for whom you want to fetch the pending request.

  • create User Api for Android
  • create User Api for Windows
  • create User Api for iOS
  • create User Api for Swift
  • create User Api for Java
  • create User Api for Unity
  • create User Api for JS
  • create User Api for Corona
  • create User Api for Cocos2DX
  • create User Api for .Net
  • create User Api for PHP
  • create User Api for Marmalade
  •  create User Api for Ruby
  •  create User Api for Flash
  1. String giftName = "Power";  
  2. String userName = "John";  
  3. App42Log.SetDebug(true);        //Print output in your editor console  
  4. App42API.Initialize("API_KEY","SECRET_KEY");  
  5. GiftService giftService = App42API.BuildGiftService();   
  6. giftService.GetGiftRequest(giftName, userName, new UnityCallBack());   
  7. public class UnityCallBack : App42CallBack  
  8. {  
  9.     public void OnSuccess(object response)  
  10.     {  
  11.         Gift gift = (Gift)response;  
  12.         App42Log.Console ("Gift Name is : " + gift.GetName ());  
  13.         App42Log.Console ("Display name is : " + gift.GetDisplayName ());  
  14.         App42Log.Console ("Icon URL is : " + gift.GetIcon ());  
  15.         App42Log.Console ("Tag is : " + gift.GetTag ());  
  16.         App42Log.Console ("Description is : " + gift.GetDescription ());  
  17.         App42Log.Console ("CreatedOn is : " + gift.GetCreatedOn ());  
  18.         for(int i=0;i<gift.GetRequestsList ().Count; i++)  
  19.         {  
  20.             App42Log.Console ("Sender : " + gift.GetRequestsList ()[i].GetSender());  
  21.             App42Log.Console ("Recipient : " + gift.GetRequestsList ()[i].GetRecipient());  
  22.             App42Log.Console ("Message : " + gift.GetRequestsList ()[i].GetMessage());  
  23.             App42Log.Console ("RequestId : " + gift.GetRequestsList ()[i].GetRequestId());  
  24.             App42Log.Console ("SentOn : " + gift.GetRequestsList ()[i].GetSentOn());  
  25.             App42Log.Console ("Type is : "+ gift.GetRequestsList ()[i].GetType());        
  26.         }  
  27.     }  
  28.     public void OnException(Exception e)  
  29.     {  
  30.         App42Log.Console("Exception : " + e);  
  31.     }  
  32. }  
Accept Gift Request

Accept the Gift Request by the recipient, which is requested by his friend.

Required Parameters

requestId - Request ID of the Gift which has to be accepted. recipient - Name of the recipient who wants to accept the request of a gift.

  • create User Api for Android
  • create User Api for Windows
  • create User Api for iOS
  • create User Api for Swift
  • create User Api for Java
  • create User Api for Unity
  • create User Api for JS
  • create User Api for Corona
  • create User Api for Cocos2DX
  • create User Api for .Net
  • create User Api for PHP
  • create User Api for Marmalade
  •  create User Api for Ruby
  •  create User Api for Flash
  1. String requestId ="requestId";  
  2. String recipient ="Steve";  
  3. App42Log.SetDebug(true);        //Print output in your editor console  
  4. App42API.Initialize("API_KEY","SECRET_KEY");  
  5. GiftService giftService = App42API.BuildGiftService();   
  6. giftService.AcceptGiftRequest(requestId, recipient, new UnityCallBack());   
  7. public class UnityCallBack : App42CallBack  
  8. {  
  9.     public void OnSuccess(object response)  
  10.     {  
  11.         Gift gift = (Gift)response;  
  12.         App42Log.Console ("Gift Name is : " + gift.GetName ());  
  13.         App42Log.Console ("Display name is : " + gift.GetDisplayName ());  
  14.         App42Log.Console ("Icon URL is : " + gift.GetIcon ());  
  15.         App42Log.Console ("Tag is : " + gift.GetTag ());  
  16.         App42Log.Console ("Description is : " + gift.GetDescription ());  
  17.         App42Log.Console ("CreatedOn is : " + gift.GetCreatedOn ());  
  18.         for(int i=0;i<gift.GetRequestsList ().Count; i++)  
  19.         {  
  20.             App42Log.Console ("Sender : " + gift.GetRequestsList ()[i].GetSender());  
  21.             App42Log.Console ("Recipient : " + gift.GetRequestsList ()[i].GetRecipient());  
  22.             App42Log.Console ("Message : " + gift.GetRequestsList ()[i].GetMessage());  
  23.             App42Log.Console ("RequestId : " + gift.GetRequestsList ()[i].GetRequestId());  
  24.             App42Log.Console ("SentOn : " + gift.GetRequestsList ()[i].GetSentOn());  
  25.             App42Log.Console ("ReceivedOn : " + gift.GetRequestsList ()[i].GetReceivedOn());  
  26.             App42Log.Console ("Type is : "+ gift.GetRequestsList ()[i].GetType());        
  27.         }  
  28.     }  
  29.     public void OnException(Exception e)  
  30.     {  
  31.         App42Log.Console("Exception : " + e);  
  32.     }  
  33. }  
Reject Gift Request

Reject the Gift Request by the recipient which is requested by his friend.

Required Parameters

requestId - Request ID of the Gift which has to be rejected. recipient - Name of the recipient who wants to reject the request of a friend.

  • create User Api for Android
  • create User Api for Windows
  • create User Api for iOS
  • create User Api for Swift
  • create User Api for Java
  • create User Api for Unity
  • create User Api for JS
  • create User Api for Corona
  • create User Api for Cocos2DX
  • create User Api for .Net
  • create User Api for PHP
  • create User Api for Marmalade
  •  create User Api for Ruby
  •  create User Api for Flash
  1. String requestId ="requestId";  
  2. String recipient ="Steve";  
  3. App42Log.SetDebug(true);        //Print output in your editor console  
  4. App42API.Initialize("API_KEY","SECRET_KEY");  
  5. GiftService giftService = App42API.BuildGiftService();   
  6. giftService.RejectGiftRequest(requestId, recipient, new UnityCallBack());   
  7. public class UnityCallBack : App42CallBack  
  8. {  
  9.     public void OnSuccess(object response)  
  10.     {  
  11.         Gift gift = (Gift)response;  
  12.         App42Log.Console ("Gift Name is : " + gift.GetName ());  
  13.         App42Log.Console ("Display name is : " + gift.GetDisplayName ());  
  14.         App42Log.Console ("Icon URL is : " + gift.GetIcon ());  
  15.         App42Log.Console ("Tag is : " + gift.GetTag ());  
  16.         App42Log.Console ("Description is : " + gift.GetDescription ());  
  17.         App42Log.Console ("CreatedOn is : " + gift.GetCreatedOn ());  
  18.         for(int i=0;i<gift.GetRequestsList ().Count; i++)  
  19.         {  
  20.             App42Log.Console ("Sender : " + gift.GetRequestsList ()[i].GetSender());  
  21.             App42Log.Console ("Recipient : " + gift.GetRequestsList ()[i].GetRecipient());  
  22.             App42Log.Console ("Message : " + gift.GetRequestsList ()[i].GetMessage());  
  23.             App42Log.Console ("RequestId : " + gift.GetRequestsList ()[i].GetRequestId());  
  24.             App42Log.Console ("SentOn : " + gift.GetRequestsList ()[i].GetSentOn());  
  25.             App42Log.Console ("ReceivedOn : " + gift.GetRequestsList ()[i].GetReceivedOn());  
  26.             App42Log.Console ("Type is : "+ gift.GetRequestsList ()[i].GetType());        
  27.         }  
  28.     }  
  29.     public void OnException(Exception e)  
  30.     {  
  31.         App42Log.Console("Exception : " + e);  
  32.     }  
  33. }  
Remove Gift

Remove the Gift by the recipient which is sent by his friend.

Required Parameters

requestId - Request ID of the Gift which has to be removed. recipient - Name of the recipient who wants to remove the gift from his friend.

  • create User Api for Android
  • create User Api for Windows
  • create User Api for iOS
  • create User Api for Swift
  • create User Api for Java
  • create User Api for Unity
  • create User Api for JS
  • create User Api for Corona
  • create User Api for Cocos2DX
  • create User Api for .Net
  • create User Api for PHP
  • create User Api for Marmalade
  •  create User Api for Ruby
  •  create User Api for Flash
  1. String requestId ="requestId";  
  2. String recipient ="Steve";  
  3. App42Log.SetDebug(true);        //Print output in your editor console  
  4. App42API.Initialize("API_KEY","SECRET_KEY");  
  5. GiftService giftService = App42API.BuildGiftService();   
  6. giftService.RemoveGift(requestId, recipient, new UnityCallBack());   
  7. public class UnityCallBack : App42CallBack  
  8. {  
  9.     public void OnSuccess(object response)  
  10.     {  
  11.         App42Response app42Response = (App42Response)response;  
  12.         App42Log.Console ("App42Response is : " + app42Response.ToString());  
  13.     }  
  14.     public void OnException(Exception e)  
  15.     {  
  16.         App42Log.Console("Exception : " + e);  
  17.     }  
  18. }  
Get All Gifts

Fetch all the gifts and their details.

  • create User Api for Android
  • create User Api for Windows
  • create User Api for iOS
  • create User Api for Swift
  • create User Api for Java
  • create User Api for Unity
  • create User Api for JS
  • create User Api for Corona
  • create User Api for Cocos2DX
  • create User Api for .Net
  • create User Api for PHP
  • create User Api for Marmalade
  •  create User Api for Ruby
  •  create User Api for Flash
  1. App42Log.SetDebug(true);        //Print output in your editor console  
  2. App42API.Initialize("API_KEY","SECRET_KEY");  
  3. GiftService giftService = App42API.BuildGiftService();   
  4. giftService.GetAllGifts(new UnityCallBack());   
  5. public class UnityCallBack : App42CallBack  
  6. {  
  7.     public void OnSuccess(object response)  
  8.     {  
  9.         IList<Gift> giftList = (IList<Gift>)response;  
  10.         for (int i=0; i<giftList.Count;i++)  
  11.         {  
  12.             Gift gift = (Gift)giftList[i];  
  13.             App42Log.Console ("Name : " + gift.GetName ());  
  14.             App42Log.Console ("DisplayName : " + gift.GetDisplayName ());  
  15.             App42Log.Console ("Icon URL : " + gift.GetIcon ());  
  16.             App42Log.Console ("Tag : " + gift.GetTag ());  
  17.             App42Log.Console ("Description : " + gift.GetDescription ());  
  18.             App42Log.Console ("CreatedOn : " + gift.GetCreatedOn ());  
  19.         }  
  20.     }  
  21.     public void OnException(Exception e)  
  22.     {  
  23.         App42Log.Console("Exception : " + e);  
  24.     }  
  25. }  
Get Gift Count

Get the count of all the gifts.

Required Parameters

giftName - Name of the gift for which you need to fetch the count. userName - Name of the user for whom you need to fetch the count.

  • create User Api for Android
  • create User Api for Windows
  • create User Api for iOS
  • create User Api for Swift
  • create User Api for Java
  • create User Api for Unity
  • create User Api for JS
  • create User Api for Corona
  • create User Api for Cocos2DX
  • create User Api for .Net
  • create User Api for PHP
  • create User Api for Marmalade
  •  create User Api for Ruby
  •  create User Api for Flash
  1. String giftName = "Power";  
  2. String userName = "John";  
  3. App42Log.SetDebug(true);        //Print output in your editor console  
  4. App42API.Initialize("API_KEY","SECRET_KEY");  
  5. GiftService giftService = App42API.BuildGiftService();   
  6. giftService.GetGiftCount(giftName, userName, new UnityCallBack());   
  7. public class UnityCallBack : App42CallBack  
  8. {  
  9.     public void OnSuccess(object response)  
  10.     {  
  11.         App42Response app42Response = (App42Response)response;  
  12.         App42Log.Console("App42Response is : " + app42Response.ToString());  
  13.         App42Log.Console("Total Gifts are : " + app42Response.GetTotalRecords());  
  14.     }  
  15.     public void OnException(Exception e)  
  16.     {  
  17.         App42Log.Console("Exception : " + e);  
  18.     }  
  19. }  
Get Gift By Name

Get gift details based on gift name.

Required Parameters

giftName - Name of the gift for which you want to fetch the details.

  • create User Api for Android
  • create User Api for Windows
  • create User Api for iOS
  • create User Api for Swift
  • create User Api for Java
  • create User Api for Unity
  • create User Api for JS
  • create User Api for Corona
  • create User Api for Cocos2DX
  • create User Api for .Net
  • create User Api for PHP
  • create User Api for Marmalade
  •  create User Api for Ruby
  •  create User Api for Flash
  1. String giftName = "Power";  
  2. App42Log.SetDebug(true);        //Print output in your editor console  
  3. App42API.Initialize("API_KEY","SECRET_KEY");  
  4. GiftService giftService = App42API.BuildGiftService();   
  5. giftService.GetGiftByName(giftName, new UnityCallBack());   
  6. public class UnityCallBack : App42CallBack  
  7. {  
  8.     public void OnSuccess(object response)  
  9.     {  
  10.         Gift gift = (Gift)response;  
  11.         App42Log.Console ("Gift Name is : " + gift.GetName ());  
  12.         App42Log.Console ("CreatedOn is : " + gift.GetCreatedOn ());  
  13.         App42Log.Console ("Tag is : " + gift.GetTag ());  
  14.         App42Log.Console ("Icon URL is : " + gift.GetIcon ());  
  15.         App42Log.Console ("Description is : " + gift.GetDescription ());  
  16.         App42Log.Console ("Display name is : " + gift.GetDisplayName ());  
  17.     }  
  18.     public void OnException(Exception e)  
  19.     {  
  20.         App42Log.Console("Exception : " + e);  
  21.     }  
  22. }  
Get Gifts By Tag

Fetch the details of gift based on tag name.

Required Parameters

tagName - Name of the tag for which you want to fetch the gifts.

  • create User Api for Android
  • create User Api for Windows
  • create User Api for iOS
  • create User Api for Swift
  • create User Api for Java
  • create User Api for Unity
  • create User Api for JS
  • create User Api for Corona
  • create User Api for Cocos2DX
  • create User Api for .Net
  • create User Api for PHP
  • create User Api for Marmalade
  •  create User Api for Ruby
  •  create User Api for Flash
  1. String tagName = "Entertainment";  
  2. App42Log.SetDebug(true);        //Print output in your editor console  
  3. App42API.Initialize("API_KEY","SECRET_KEY");  
  4. GiftService giftService = App42API.BuildGiftService();   
  5. giftService.GetGiftsByTag(tagName, new UnityCallBack());   
  6. public class UnityCallBack : App42CallBack  
  7. {  
  8.     public void OnSuccess(object response)  
  9.     {  
  10.         IList<Gift> giftList = (IList<Gift>)response;  
  11.         for (int i=0; i<giftList.Count;i++)  
  12.         {  
  13.             Gift gift = (Gift)giftList[i];  
  14.             App42Log.Console ("Name : " + gift.GetName ());  
  15.             App42Log.Console ("DisplayName : " + gift.GetDisplayName ());  
  16.             App42Log.Console ("Icon URL : " + gift.GetIcon ());  
  17.             App42Log.Console ("Tag : " + gift.GetTag ());  
  18.             App42Log.Console ("Description : " + gift.GetDescription ());  
  19.             App42Log.Console ("CreatedOn : " + gift.GetCreatedOn ());  
  20.         }  
  21.     }  
  22.     public void OnException(Exception e)  
  23.     {  
  24.         App42Log.Console("Exception : " + e);  
  25.     }  
  26. }  
Delete Gift By Name

Remove particular gift based on its name. This will also delete all the records of gift.

Required Parameters

giftName - Name of the gift which you want to delete.

  • create User Api for Android
  • create User Api for Windows
  • create User Api for iOS
  • create User Api for Swift
  • create User Api for Java
  • create User Api for Unity
  • create User Api for JS
  • create User Api for Corona
  • create User Api for Cocos2DX
  • create User Api for .Net
  • create User Api for PHP
  • create User Api for Marmalade
  •  create User Api for Ruby
  •  create User Api for Flash
  1. String giftName = "Power";  
  2. App42Log.SetDebug(true);        //Print output in your editor console  
  3. App42API.Initialize("API_KEY","SECRET_KEY");  
  4. GiftService giftService = App42API.BuildGiftService();   
  5. giftService.DeleteGiftByName(giftName, new UnityCallBack());   
  6. public class UnityCallBack : App42CallBack  
  7. {  
  8.     public void OnSuccess(object response)  
  9.     {  
  10.         App42Response app42Response = (App42Response)response;  
  11.         App42Log.Console ("App42Response is : " + app42Response.ToString());  
  12.     }  
  13.     public void OnException(Exception e)  
  14.     {  
  15.         App42Log.Console("Exception : " + e);  
  16.     }  
  17. }  
Exception Handling

The functions available under Gift API can throw some exceptions in abnormal conditions. For example, if a developer is creating a gift with a gift name which is already in the database, the function will throw the App42Exception (as shown below) with the message as “Bad Request” and the appErrorCode as “4900” and the details as “The request parameters are invalid. Gift by the name ‘Power’ already exists”.

  • create User Api for Android
  • create User Api for Windows
  • create User Api for iOS
  • create User Api for Swift
  • create User Api for Java
  • create User Api for Unity
  • create User Api for JS
  • create User Api for Corona
  • create User Api for Cocos2DX
  • create User Api for .Net
  • create User Api for PHP
  • create User Api for Marmalade
  •  create User Api for Ruby
  •  create User Api for Flash
  1. String giftName = "Power";  
  2. String displayName = "Power Up";  
  3. String tagName = "Entertainment";  
  4. String icon = "File path from gallery /sd card";    
  5. String description = "Gift is created in App42 DataBase.";  
  6. App42Log.SetDebug(true);        //Print output in your editor console  
  7. App42API.Initialize("API_KEY","SECRET_KEY");  
  8. GiftService giftService = App42API.BuildGiftService();   
  9. giftService.CreateGift(giftName, icon, displayName, description, tagName, new UnityCallBack());   
  10. public class UnityCallBack : App42CallBack  
  11. {  
  12.     public void OnSuccess(object response)  
  13.     {  
  14.         Gift gift = (Gift) response;  
  15.         App42Log.Console("Response is " + gift.ToString());  
  16.     }  
  17.     public void OnException(Exception e)  
  18.     {     
  19.         App42Exception exception = (App42Exception)e;  
  20.         int appErrorCode = exception.GetAppErrorCode();  
  21.         int httpErrorCode = exception.GetHttpErrorCode();  
  22.         if(appErrorCode == 4900)  
  23.         {  
  24.             // Handle here for Bad Request (The request parameters are invalid. Gift by the name 'Power' already exists.)  
  25.         }  
  26.         else if(appErrorCode == 1401)  
  27.         {  
  28.             // handle here for Client is not authorized  
  29.         }  
  30.         else if(appErrorCode == 1500)  
  31.         {  
  32.             // handle here for Internal Server Error  
  33.         }  
  34.         String jsonText = exception.GetMessage();     
  35.     }  
  36. }  
Error Codes

Functions in Gift API might throw exceptions with following HTTP and Application Error Codes (along with their descriptions):

1400 - BAD REQUEST - The Request parameters are invalid 1401 - UNAUTHORIZED - Client is not authorized 1500 - INTERNAL SERVER ERROR - Internal Server Error. Please try again 4900 - Bad Request - The Request parameters are invalid. Gift by the name 'Power' already exists. 4901 - NOT FOUND - Gifts does not exist. 4902 - Not Found - Gifts by the name 'Power' does not exist. 4903 - NOT FOUND - Gifts by the tag 'Entertainment'does not exist. 4904 - Not Found - Sender by the name 'Nick' does not have gift by the name 'Power'. 4905 - Bad Request - The Request parameters are invalid. Number of recipient are more than gifts you have. 4906 - Not Found - Gifts by the name 'Power' you don't have any request yet." 4907 - NOT FOUND - Can not request gift to itself. 4908 - NOT FOUND - Gift by the requestId 'requestId' for the 'John' does not exist. 4909 - NOT FOUND - Gift by the requestId 'requestId' for the 'John' does not have any gift to accept. 4910 - NOT FOUND - Gift can not be remove because this is sent by owner.