Submitting Customer Actions
You should have a project-specific integration guide from your Maestra Forward Deployed Marketer covering all required API methods before proceeding. API methods must be integrated strictly according to this document.
The methods listed below are provided as examples.
Before you begin, make sure you’ve completed the following steps:
To submit details on customers’ actions, you’ll need to create API methods. For more information, please refer to the API v3 Methods: Basics article.
Maestra’s SDK offers the following 2 methods to call API methods from a mobile app:
executeAsyncOperationto send data to the system;executeSyncOperationto receive data from the system.
Use the OperationBodyRequest constructor to create a request body when calling an API method.
Integration Guide
In this guide, we’ll demonstrate an example of how to call the SDK’s API to transmit data.
To submit data to Maestra, relevant API methods must be set up by your marketer. This setup is done individually for each project.
Please note that if you copy the code from these examples, your integration will not work.
Basic customer-related calls
Authentication
Expected results:
- You can find a customer in Maestra by searching using their phone number.
- This customer’s profile contains mobile app details.
private func auth() {
let body = OperationBodyRequest();
body.customer = .init(
mobilePhone: "12025550159"
)
Mindbox.shared.executeAsyncOperation(
operationSystemName: "CheckGuide.auth",
operationBody: body
)
}Submitting Product and Category View actions
Expected result:
- Customers that can be found by their deviceUUID will have product and category view actions displayed in the Actions tab of their profiles in Maestra.
private func viewProduct() {
let body = OperationBodyRequest();
body.viewProduct = .init(
product: .init(ids: ["website": "123"])
)
Mindbox.shared.executeAsyncOperation(
operationSystemName: "CheckGuide.viewProduct",
operationBody: body
)
}
private func viewCategary() {
let body = OperationBodyRequest();
body.viewProductCategory = .init(
productCategory: .init(ids: ["website": "123"])
)
Mindbox.shared.executeAsyncOperation(
operationSystemName: "CheckGuide.viewCategory",
operationBody: body
)
}Submitting Added to / Deleted from Cart actions
Maestra offers 2 methods to handle product lists:
- Add / delete individual products;
- Set up a list by a single request.
Popular product lists: Cart and Favorites.
Expected result:
- Customers that can be found by their deviceUUID will have "product added to cart" and "product deleted from cart" actions displayed in the Actions tab of their profiles in Maestra.
private func addProductToCart() {
let body = OperationBodyRequest();
body.addProductToList = .init(product: .init(ids: ["website": "123"]), pricePerItem: 100)
Mindbox.shared.executeAsyncOperation(
operationSystemName: "CheckGuide.addProductToCart",
operationBody: body
)
}
private func setUpCart() {
let body = OperationBodyRequest();
body.productListItems = [
.init(
product: .init(ids: ["website": "123"]),
count: 1,
priceOfLine: 100
),
.init(
product: .init(ids: ["website": "321"]),
count: 1,
priceOfLine: 100
)
]
Mindbox.shared.executeAsyncOperation(
operationSystemName: "CheckGuide.setUpCart",
operationBody: body
)
}Checking customer in segment
Run this request to check whether a customer belongs to a specific segment.
Expected result:
- The response from Maestra is displayed in the Xcode developer console.
private func checkSegment() {
let body = OperationBodyRequest()
Mindbox.shared.executeSyncOperation(
operationSystemName: "CheckGuide.checkSegment",
operationBody: body) {
result in
switch result {
case let .success(response):
print(response.createJSON())
case let .failure(error):
print(error.errorDescription)
}
}
}Receiving personal recommendations
Run this request to return a personalized list of products compiled using one of the product recommendation algorithms.
Expected result:
- The response from Maestra is displayed in the Xcode developer console.
private func getReco() {
let body = OperationBodyRequest()
body.recommendation = .init(limit: 3)
Mindbox.shared.executeSyncOperation(
operationSystemName: "CheckGuide.getReco",
operationBody: body) {
result in
switch result {
case let .success(response):
print(response.createJSON())
case let .failure(error):
print(error.errorDescription)
}
}
}The examples above demonstrate methods that allow you to submit customer actions to Maestra. You can send any other business-relevant actions you need. Please contact your marketer, and they will add the required methods to your technical specification.
Updated 16 days ago

