Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public final class CustomerInfo
- Object
- CustomerInfo
What the Codename One Commerce service knows about one customer: the entitlements held, the subscriptions that are active and the attributes the application attached.
Instances are immutable. CommerceManager.getCustomerInfo() returns the
last one the service answered with, and an empty one before any answer.
Methods
public String getAppUserId() | The id the service knows this customer by, or null for the empty customer. |
public String getOriginalAppUserId() | The first id this customer was known by, when a later one replaced it (an anonymous id that became an account), or null. |
public String getManagementUrl() | The page where the customer manages the subscription with the store, or null when there is none. |
public long getServerTime() | The service’s clock when it answered, in milliseconds since the epoch, or 0 for the empty customer. |
public EntitlementInfo getEntitlement(String entitlementId) | The entitlement with this id, active or not. |
public boolean isEntitled(String entitlementId) | Whether the service reported this entitlement as active. |
public Map<String, EntitlementInfo> getEntitlements() | Every entitlement the service reported, active or not, by id. |
public List<EntitlementInfo> getActiveEntitlements() | The entitlements the service reported as active. |
public List<String> getActiveSubscriptions() | The store product ids of the subscriptions that are active. |
public Map<String, String> getAttributes() | The attributes attached to this customer. |
public long getCurrencyBalance(String code) | The customer’s balance of a virtual currency. |
public Map<String, Long> getCurrencies() | The customer’s virtual currency balances, by currency code. |
public List<ReferralReward> getReferralRewards() | The rewards the service granted this customer for referrals: an entitlement or an amount of a virtual currency each, as configured in the console. |
public Map<String, Object> toMap() | This customer as the JSON object it was built from, for storage. |
public String toString() | Returns a string representation of the object. |
Inherited methods
Method details
getAppUserId
public String getAppUserId()The id the service knows this customer by, or null for the empty
customer.
getOriginalAppUserId
public String getOriginalAppUserId()The first id this customer was known by, when a later one replaced it
(an anonymous id that became an account), or null.
getManagementUrl
public String getManagementUrl()The page where the customer manages the subscription with the store,
or null when there is none.
getServerTime
public long getServerTime()The service’s clock when it answered, in milliseconds since the
epoch, or 0 for the empty customer.
getEntitlement
public EntitlementInfo getEntitlement(String entitlementId)The entitlement with this id, active or not.
Returns
the entitlement, or null when the service reported none by that id
isEntitled
public boolean isEntitled(String entitlementId)Whether the service reported this entitlement as active.
getEntitlements
public Map<String, EntitlementInfo> getEntitlements()Every entitlement the service reported, active or not, by id.
Returns
a new map, which the caller may change
getActiveEntitlements
public List<EntitlementInfo> getActiveEntitlements()The entitlements the service reported as active.
Returns
a new list, which the caller may change
getActiveSubscriptions
public List<String> getActiveSubscriptions()The store product ids of the subscriptions that are active.
Returns
a new list, which the caller may change
getAttributes
public Map<String, String> getAttributes()The attributes attached to this customer.
Returns
a new map, which the caller may change
getCurrencyBalance
public long getCurrencyBalance(String code)The customer’s balance of a virtual currency.
Parameters
codeString- the code of the currency, as defined in the console
Returns
the balance, or 0 when the customer holds none of that currency
getCurrencies
public Map<String, Long> getCurrencies()The customer’s virtual currency balances, by currency code.
Returns
a new map, which the caller may change
getReferralRewards
public List<ReferralReward> getReferralRewards()The rewards the service granted this customer for referrals: an
entitlement or an amount of a virtual currency each, as configured in
the console. A reward that is an entitlement is also among
getEntitlements(), and a currency reward is already part of
getCurrencyBalance(String); this list says where they came from.Returns
a new list, which the caller may change; empty when the service
reported no reward
toMap
public Map<String, Object> toMap()This customer as the JSON object it was built from, for storage.
Passing the result to the constructor gives an equal customer.
Returns
a new map, which the caller may change
toString
public String toString()Returns a string representation of the object. In general, the toString method returns a string that “textually represents” this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.
The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@’, and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + ‘@’ + Integer.toHexString(hashCode())