iOS SDK: Request Constructor Framework

IDS

IDS is a structure used to pass a set of identifiers as a dictionary in the [String: String] format.
An initializer accepting a customerId parameter is also available for passing a Maestra customer identifier.

let ids = IDS(["externalUserId": "12345", "customerId":"222"])

You can also handle IDS as an ordinary collection:

let ids: IDS = ["someId": "someValue"]
let someValue = ids["someId"] // "someValue"

Custom Fields

CustomFields is used to pass additional custom variables in requests.
The data type is [String: Any]. Reading values is not supported — the object is used for sending only.

let customFields: CustomFields = ["someId": 1, "someId2": "2"]

DateOnly

DateOnly is a class used to pass "yyyy-MM-dd" date values to the server.

Creating and using the class:

let date = Date()
// option 1
let only = DateOnly(date)
// option 2
date.asDateOnly()

DateTime

DateTime is a class used to pass a date & time to the server.

Creating and using the class:

let date = Date()
// option 1
let dateTime = DateTime(date)
// option 2
date.asDateTime()

CustomerRequest

Used to create or update customer data.
It is created using a constructor that accepts the required customer data.

DiscountRequest

Used when working with discounts.

Two different constructors are available, depending on whether you use:

  • promoCode, or
  • externalPromoAction

LineRequest

Created by specifying the quantity value and the quantity type (quantityType).
QuantityType is an enum that is selected during initialization.

ProductListItemRequest

Offers multiple constructors.
The appropriate one depends on which fields are required for a given flow.

ViewProductRequest

Provides four constructors.
Choose the appropriate one based on the data available when creating the event.