Skip to content

Tracking data is not formatted as expected - webhook vs api #12

Description

@Insood

Hello,

I'm running into a weird issue -- there is a difference in the shape of the response if I get tracking information from the API or via webhook. I am using version 11.

When using the webhook, the body of our callback method looks like this:

      aftership_webhook_body = Oj.load(request.body.read)&.dig('msg')
      tracking_data = AftershipAPI::Model::GetTrackingByIdResponse.new(aftership_webhook_body)

Here the courier_estimated_delivery_date is a Hash:

(byebug) tracking_data.class
AftershipAPI::Model::GetTrackingByIdRespons

(byebug) tracking_data.courier_estimated_delivery_date
{"estimated_delivery_date"=>"2025-08-08T20:37:22-04:00", "estimated_delivery_date_min"=>nil, "estimated_delivery_date_max"=>nil}

(byebug) tracking_data.courier_estimated_delivery_date.class
Hash

if I use the same the data from the API:

tracking_data = Tracking.get_tracking_by_id(id: "xyz1234")

(byebug) tracking_data.class
AftershipAPI::Model::GetTrackingByIdResponse

(byebug) tracking_data.courier_estimated_delivery_date
#<AftershipAPI::Model::CourierEstimatedDeliveryDateGetTrackingByIdResponse:0x0000ffff61b1c400 @estimated_delivery_date="2025-08-08T19:53:06-04:00", @estimated_delivery_date_min=nil, @estimated_delivery_date_max=nil>

(byebug) tracking_data.courier_estimated_delivery_date.class
AftershipAPI::Model::CourierEstimatedDeliveryDateGetTrackingByIdResponse

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions