m8ty_client_customer
Package overview
Section titled “Package overview”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.
Before you start
Section titled “Before you start”Check the documentation of the m8ty_client_customer library to get an idea about the available models and their properties.
Import all needed libraries
Section titled “Import all needed libraries” 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';Client Setup
Section titled “Client Setup”final client = M8tyClientCustomer();client.setOAuthToken('ApiOAuth2', oauthToken);API Surface
Section titled “API Surface”CustomerApi
Section titled “CustomerApi”| 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 |
How to perform different tasks
Section titled “How to perform different tasks”Here some examples how the dart client can be used
Get list of all customers
Section titled “Get list of all customers” final client = M8tyClientCustomer(); client.setOAuthToken('ApiOAuth2', oauthToken);
final api = client.getCustomerApi(); final Response<CustomersOfUserListModel> customers = await api.retrieveCustomerOverview( page: 1, size: 100, );Get specific customer by id
Section titled “Get specific customer by id” final client = M8tyClientCustomer(); client.setOAuthToken('ApiOAuth2', oauthToken);
final api = client.getCustomerApi(); final Response<CustomersOfUserListModel> customers = await api.retrieveCustomerById( customerId: "1234", page: 1, size: 100, );Get customer addresses
Section titled “Get customer addresses” 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}', ); }© m8ty GmbH 2023 · m8ty.eu
