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

View File

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

View File

@ -166,7 +166,11 @@ public class OrderSyncService {
? psCustomer.email() ? psCustomer.email()
: "ps_customer_%s@noemail.local".formatted(psOrder.idCustomer()); : "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);
} }
/** /**