Skip to content

m8ty_client_customer

m8ty_client_customer solves this by retrieving the customers linked to the authenticated user and their addresses, allowing apps to present products in the right customer context.

Customers information API is used to get a list of all users having access to the currently logged in user. Every product is assigned to a specific user.

Check the documentation of the m8ty_client_customer library to get an idea about the available models and their properties.

import 'package:dio/dio.dart';
import 'package:m8ty_client_customer/m8ty_client_customer.dart';
import 'package:m8ty_client_common/m8ty_client_common.dart';
import 'package:built_collection/built_collection.dart';
final client = M8tyClientCustomer();
client.setOAuthToken('ApiOAuth2', oauthToken);
Method Description
retrieveCustomerOverview Retrieve a list of all customers linked to the current user
retrieveCustomerById Retrieve a specific customer by ID
retrieveCustomerAddresses Get addresses of a given customer

Here some examples how the dart client can be used

final client = M8tyClientCustomer();
client.setOAuthToken('ApiOAuth2', oauthToken);
final api = client.getCustomerApi();
final Response<CustomersOfUserListModel> customers = await api.retrieveCustomerOverview(
page: 1,
size: 100,
);
final client = M8tyClientCustomer();
client.setOAuthToken('ApiOAuth2', oauthToken);
final api = client.getCustomerApi();
final Response<CustomersOfUserListModel> customers = await api.retrieveCustomerById(
customerId: "1234",
page: 1,
size: 100,
);
final client = M8tyClientCustomer();
client.setOAuthToken('ApiOAuth2', oauthToken);
final api = client.getCustomerApi();
try {
final response = await api.retrieveCustomerAddresses(
customerId: '1234',
);
print('Addresses: ${response.data}');
} on DioException catch (e) {
throw Exception(
'Request failed (status: ${e.response?.statusCode}): ${e.response?.data}',
);
}