cliente más completo

This commit is contained in:
Mireya Serrano 2026-05-24 12:49:35 +02:00
parent 300714c6c1
commit 51959292e0
4 changed files with 17 additions and 5 deletions

View File

@ -121,7 +121,7 @@ public class DolibarrClient {
* @param email customer email from the PrestaShop order
* @param name full name to use if the customer must be created
*/
public DolibarrThirdpartyDto getOrCreateThirdparty(String email, String name) {
public DolibarrThirdpartyDto getOrCreateThirdparty(String email, String name, String address, String city, String zip) {
log.debug("Looking up Dolibarr thirdparty email={}", email);
List<DolibarrThirdpartyDto> matches = null;
try {
@ -144,7 +144,7 @@ public class DolibarrClient {
}
log.debug("Thirdparty not found, creating for email={}", email);
DolibarrThirdpartyDto newThirdparty = new DolibarrThirdpartyDto(null, name, email, 1, null);
DolibarrThirdpartyDto newThirdparty = new DolibarrThirdpartyDto(null, name, email, 1, null, address, zip, city, null, null);
Integer newId = restClient.post()
.uri("/thirdparties")
.body(newThirdparty)

View File

@ -16,5 +16,10 @@ public record DolibarrThirdpartyDto(
String email,
/** 1 = customer */
Integer client,
@JsonProperty("code_client") String codeClient
@JsonProperty("code_client") String codeClient,
String address,
String zip,
String city,
@JsonProperty("id_country") Integer idCountry,
String phone
) {}

View File

@ -1,6 +1,7 @@
package com.teterialosjuanjos.tfg.sync_service.integration.prestashop.dto;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* Minimal representation of a PrestaShop customer.
@ -12,7 +13,9 @@ public record PrestashopCustomerDto(
Integer id,
String firstname,
String lastname,
String email
String email,
@JsonProperty("default_group") String defaultGroup,
@JsonProperty("id_default_address") String idDefaultAddress
) {
/** Envelope for {@code GET /api/customers/{id}} */

View File

@ -166,7 +166,11 @@ public class OrderSyncService {
? psCustomer.email()
: "ps_customer_%s@noemail.local".formatted(psOrder.idCustomer());
return dolibarrClient.getOrCreateThirdparty(email, name);
String address = null;
String city = null;
String zip = null;
return dolibarrClient.getOrCreateThirdparty(email, name, address, city, zip);
}
/**