SelectOfferInfo

public SelectOfferResult SelectOfferInfo(
    string player_uuid,
    string language
);

Description

SelectOfferInfo retrieves information about the valid offers currently available within the client’s database by descending order of creation date.

Parameters

Name Description Required

player_uuid

Player’s unique ID (not a character’s ID) such as Steam user ID and Google Play user ID

Required

language

Two-letter language code that you set up in personalized offer console

Required

Code example

public class SelectOfferResult (1)
{
    public TPResult tpResult;
    public List<OfferInfo> offer_info = new List<OfferInfo>();
    public int succeeded_offers_num = 0;
    public int failed_offers_num = 0;
}

// Classes used in SelectOfferResult
public enum TPResult
{
    OK,
    ERROR
}

public class OfferInfo (2)
{
    public offerType offer_type;
    public int offer_id;
    public DateTime? offer_expires_in; (3)
    // By comparing "valid_until" and "valid for". It's null if there is no set expiration date
    public string title;
    public List<RecommendedProduct> recommended_products; (3)
    // It's for AI in-game shop only. For personalized offers, this list gets empty
    public bool has_opened;
    public bool checked_dont_show_today;
}

public enum offerType (4)
{
    AI = 0,
    Manual = 1
}

public class RecommendedProduct (5)
    {
        public string purchasable_slug;
        public string product_index;
        public string purchase_link;
        public string store;
        public DateTime? start_datetime;
        public DateTime? end_datetime;
        public bool is_in_sale_now; //By comparing "start_datetime" and "end_datetime" with UTC now
    }
1 If the retrieval is successful, the number of valid offers will be return in succeeded_offers_num.

If the retrieval succeeds but there is a problem with offer data integrity, the number of invalid offers will be return in failed_offers_num, and the following message will be printed on the Unity editor console in TentuPlay debug mode: TPWarn||Skipping a recommended product for 'store' store in Offer ID 'id': error_message.

If the retrieval fails,TPResult.ERROR will be returned to tpResult of SelectOfferResult, and offer_info will have an empty list, and both succeeded_offers_num, and failed_offers_num will have the default value (that is, 0) in return.

2 OfferInfo denotes an offer information
3 OfferInfo.offer_expires_in exhibits the expiry of offer period only. As for products period, you can find it in OfferInfo.recommended_products.
4 Use offerType enum to differentiate between an AI in-Game shop offer (offerType.AI) and a personalized offer (offerType.Manual).
5 To use AI product recommendations, do the steps that follows:
  1. Invoke SelectOfferInfo.

  2. Make sure that the recommended products are not expired.

  3. Perform further validation such as checking whether there are any available purchases left to the user by using in-game logics.

For more code examples using SelectOfferInfo, you can locate them in TentuPlayCRMPlayerController that ShingGoongDemo provides.