Customer Management
Access detailed customer information including contact details, billing, and relationships.
Table of contents
Getting Customer Details
The primary method for accessing detailed customer information is getCustomerDetail(), which returns complete customer data including organization relationships, billing information, and account details:
val result = zync.customers.getCustomerDetail("customer_550e8400-e29b-41d4-a716-446655440000")
when (result) {
is CustomerDetailResult.Success -> {
val customer = result.data
println("Customer: ${customer.firstName} ${customer.lastName}")
println("Email: ${customer.email}")
println("Company: ${customer.companyName}")
// Access organization relationship
customer.organization?.let { org ->
println("Organization: ${org.organizationName}")
}
// Access billing information
customer.accounts?.let { accounts ->
println("Lifetime Value: $${accounts.lifetimeValue}")
println("Receivables: $${accounts.receivables}")
}
}
is CustomerDetailResult.Failure -> {
println("Failed to get customer: ${result.error.message}")
}
}
let result = try await zync.customers.getCustomerDetail(customerUid: "customer_550e8400-e29b-41d4-a716-446655440000")
switch onEnum(of: result) {
case .success(let success):
let customer = success.data
print("Customer Name: \(customer.firstName) \(customer.lastName)")
print("UID: \(customer.customerUid)")
case .failure(let failure):
print("Error: \(failure.error.message)")
switch onEnum(of: failure.error) {
case .network:
print("Check your internet connection")
case .error(let error):
print("Error: \(error.message)")
if let code = error.code {
print("Error code: \(code)")
}
}
}