All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ecwid.apiclient.v3.converter.FetchedCustomer.kt Maven / Gradle / Ivy

There is a newer version: 0.347.0
Show newest version
package com.ecwid.apiclient.v3.converter

import com.ecwid.apiclient.v3.dto.customer.request.UpdatedCustomer
import com.ecwid.apiclient.v3.dto.customer.result.FetchedCustomer

fun FetchedCustomer.toUpdated(): UpdatedCustomer {
	return UpdatedCustomer(
		email = email,
		customerGroupId = customerGroupId,
		billingPerson = billingPerson?.toUpdated(),
		shippingAddresses = shippingAddresses?.map(FetchedCustomer.ShippingAddress::toUpdated),
		contacts = contacts?.map(FetchedCustomer.CustomerContact::toUpdated),
		taxId = taxId,
		taxIdValid = taxIdValid,
		taxExempt = taxExempt,
		acceptMarketing = acceptMarketing,
		lang = lang,
		privateAdminNotes = privateAdminNotes,
		commercialRelationshipScheme = commercialRelationshipScheme,
		extrafields = extrafields?.map(FetchedCustomer.CustomerExtrafield::toUpdated)
	)
}

fun FetchedCustomer.BillingPerson.toUpdated(): UpdatedCustomer.BillingPerson {
	return UpdatedCustomer.BillingPerson(
		name = name,
		companyName = companyName,
		street = street,
		city = city,
		countryCode = countryCode,
		postalCode = postalCode,
		stateOrProvinceCode = stateOrProvinceCode,
		phone = phone
	)
}

fun FetchedCustomer.ShippingAddress.toUpdated(): UpdatedCustomer.ShippingAddress {
	return UpdatedCustomer.ShippingAddress(
		id = id,
		name = name,
		companyName = companyName,
		street = street,
		city = city,
		countryCode = countryCode,
		postalCode = postalCode,
		stateOrProvinceCode = stateOrProvinceCode,
		phone = phone,
		note = note,
		defaultAddress = defaultAddress,
		orderBy = orderBy,
	)
}

fun FetchedCustomer.CustomerContact.toUpdated(): UpdatedCustomer.CustomerContact {
	return UpdatedCustomer.CustomerContact(
		id = id,
		contact = contact,
		handle = handle,
		note = note,
		type = type,
		default = default,
		orderBy = orderBy,
	)
}

fun FetchedCustomer.CustomerExtrafield.toUpdated(): UpdatedCustomer.CustomerExtrafield {
	return UpdatedCustomer.CustomerExtrafield(
		key = key,
		title = title,
		value = value,
		type = type,
	)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy