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 these steps:

Mindbox SDK offers the following 2 options to call API methods from a mobile app:

  • executeAsyncOperation to send data to the system,
  • executeSyncOperation to get 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 in the app

fun authorizeCustomer() {
    Mindbox.executeAsyncOperation(
        context,
        operationSystemName = "CheckGuide.auth",
        operationBody = OperationBodyRequest(
            customer = CustomerRequest(
                mobilePhone = "12025550159"
            )
        )
    )
}

Product and Category View actions

fun viewProduct() {
    Mindbox.executeAsyncOperation(
        context,
        operationSystemName = "CheckGuide.viewProduct",
        operationBody = OperationBodyRequest(
            viewProductRequest = ViewProductRequest(
                product = ProductRequest(
                    ids = Ids(
                        "website" to "123"
                    )
                )
            )
        )
    )
}

fun viewProductCategory() {
    Mindbox.executeAsyncOperation(
        context,
        operationSystemName = "CheckGuide.viewCategory",
        operationBody = OperationBodyRequest(
            viewProductCategory = ViewProductCategoryRequest(
                productCategory = ProductCategoryRequest(
                    Ids(
                        "website" to "123"
                    )
                )
            )
        )
    )
}

Submitting Item Added actions

Maestra offers 2 methods to handle product lists (customers’ carts, favorites, etc.):

  • Add / delete individual products;
  • Set up list via a single request.

Popular product lists: Cart and Favorites.

fun addProductToCart() {
    Mindbox.executeAsyncOperation(
        context,
        operationSystemName = "CheckGuide.addProductToCart",
        operationBody = OperationBodyRequest(
            addProductToList = ProductListItemRequest(
                product = ProductRequest(
                    Ids(
                        "website" to "<Product Id on Website>"
                    )
                ),
                pricePerItem = 10.0

            )
        )
    )
}

fun setCart() {
    Mindbox.executeAsyncOperation(
        context,
        operationSystemName = "CheckGuide.setUpCart",
        operationBody = OperationBodyRequest(
            productList = arrayListOf(
                ProductListItemRequest(
                    count = 2.0, // <Number of items>
                    product = ProductRequest(
                        Ids(
                            "website" to "<Product Id on Website>"
                        )
                    ),
                    isPricePerItem = false, // if price per item is passed
                    price = 10.0
                ),
                ProductListItemRequest(
                    count = 2.0, // <Number of items>
                    product = ProductRequest(
                        Ids(
                            "website" to "<Product Id on Website>"
                        )
                    ),
                    isPricePerItem = true, // if price per line is passed
                    price = 10.0
                ),
                ProductListItemRequest(
                    count = 2.0, // <Number of items>
                    productGroup = ProductGroupRequest(
                        Ids(
                            "website" to "<Product Id on Website>"
                        )
                    ),
                    isPricePerItem = true, // if price per line is passed
                    price = 10.0
                ),
            )
        )
    )
}

Checking customer in segment

Run this request to check whether a customer belongs to a specific segment.

fun checkSegment() {
    Mindbox.executeSyncOperation(
        operationSystemName = "CheckGuide.checkSegment",
        context = context,
        operationBody = OperationBodyRequest(),
        onSuccess = { response -> Log.i("Success ", response.toString())},
        onError = {error -> Log.i("Error", error.toString())}
    )
}

Receiving personal recommendations

Run this request to return a personalized list of products compiled using one of the product recommendation algorithms.

fun getReco() {
    Mindbox.executeSyncOperation(
        operationSystemName = "CheckGuide.getReco",
        context = context,
        operationBody = OperationBodyRequest(
            recommendation = RecommendationRequest(
                limit = 3
            )
        ),
        onSuccess = { response -> Log.i("getReco Success", response.toString())},
        onError = {error -> Log.i("getReco Error", error.toString())}
    )
}