Skip to content

Children objects unproperly serialised as json string. Unusable SDK ? #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
CaptainFalcon92 opened this issue Mar 22, 2025 · 0 comments

Comments

@CaptainFalcon92
Copy link

Children objects are being included as string during Shippo\API\Models\Components\ShipmentCreateRequestserialization.

What i did in a nutshell :

  $shipmentCreateRequest = new ShipmentCreateRequest();
  //...
  $shipmentCreateRequest->addressFrom = new AddressCreateRequest();
  //...
  $shipmentCreateRequest->addressTo = new AddressCreateRequest();
  //...
  $parcel = new Parcel();
  //...
  $shipmentCreateRequest->parcels = [$parcel];
  
  $response = $this->shippo->shipments->create($shipmentCreateRequest);

Error i got :

{"detail":"HydratedObjectsByIdsRequest Address ID {\"name\":\"from me\",\"company\":\"from company\",\"street1\":\"from add\",\"city\":\"from city\",\"state\":\"from state\",\"zip\":\"from zip\",\"country\":\"FR\",\"email\":\"contact@from.me\"} is not a valid UUID"}

after a json decode here is the result :

dump:

^ array:6 [
  "metadata" => "Customer ID 123456"
  "shipment_date" => "2025-03-24T21:05:38+00:00"
  "address_from" => "{"name":"from me","company":"from company","street1":"from addr","city":"from city","state":"from state","zip":"from zip","country":"FR","email":"contact@from.me"}"
  "address_to" => "{"name":"john doe","street1":"johndoe street","city":"johndoe city","state":"","zip":"01203","country":"NO","phone":"+33701020304","email":"doesnotexists@example.com","is_residential":true,"metadata":"domvalue"}"
  "async" => false
  "parcels" => array:1 [
    0 => "{"mass_unit":"g","weight":"200","distance_unit":"mm","height":"80","length":"200","width":"150"}"
  ]
]

Property address_from, address_to and parcels are still strings. There is an undesired level of quote/escaping applied to the object. Request cannot be performed. I can only assume this happen on the whole sdk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant