get_data(); foreach ( (array) $fulfillments as $fulfillment ) { $shipments = $fulfillment->shipments ?? null; if ( empty( $shipments->data ) || ! is_array( $shipments->data ) ) { continue; } // The platform inlines rates, label costs and the label download URL on shipments — merchant-only data. $shipments->data = array_map( function ( $shipment ) { $slim = []; foreach ( $this->customer_shipment_fields as $field ) { $slim[ $field ] = $shipment->$field ?? null; } return (object) $slim; }, $shipments->data ); $fulfillment->shipments = $shipments; } $response->set_data( $fulfillments ); return $response; } }