Offers
This page describes all of the offer methods available within the Limio SDK.
groupOffers
Function
groupOffers
FunctionThe groupOffers
function is used to organise a list of offers into groups based on their group__limio
attribute. This function is particularly useful when you need to display offers categorised by their group in a component, such as a Switch component.
Function Signature
Parameters
offers
(optional): An array ofLimioObject<Offer>
objects to be grouped.Type:
Array<LimioObject<Offer>>
Default:
[]
groupLabels
(optional): An array ofGroup
objects that define the possible groups and their labels.Type:
Array<{ id: string, label: string, thumbnail?: string }>
Default:
[]
LimioObject Structure
The LimioObject<Offer>
type represents an offer in the Limio system. It has the following structure:
Key points about LimioObject<Offer>
:
The
group__limio
attribute is used for grouping offers.The
display_name__limio
attribute typically contains the display name of the offer.There may be other attributes and properties specific to offers that are not used by the
groupOffers
function.
Return Value
The function returns an array of GroupInfo
objects, where each object contains:
groupId
: The identifier of the group (string)id
: The same asgroupId
(string)label
: The display label for the group (string)offers
: An array ofLimioObject<Offer>
objects belonging to that groupthumbnail
: The thumbnail URL for the group (string, optional)
Usage Example
Behaviour Notes
Offers are grouped based on their
group__limio
attribute.If an offer doesn't have a
group__limio
attribute, it's grouped under "other".For each unique group (including "other"), a
GroupInfo
object is created.If a matching
groupLabel
is found:The
label
is set to the matching group's label.The
thumbnail
is set to the matching group's thumbnail (or an empty string if not provided).
If no matching
groupLabel
is found:The
label
is set to "Other".The
thumbnail
is set to an empty string.
The
groupId
andid
are always set to the original group value from the offer.If the
offers
array is empty, an empty array is returned.If the
groupLabels
array is empty, all groups will have the label "Other" and an empty thumbnail.
Last updated