I'm have a check_delivery
method which uses Sidekiq to call the EasyPost api gem.
def check_delivery
if tracking_number.present?
EasypostWorker.perform_async(tracking_number)
end
end
class EasypostWorker
include Sidekiq::Worker
def perform(tracking_number)
EasyPost.api_key = Rails.application.secrets.easypost_api_key
tracker = EasyPost::Tracker.create(tracking_code: tracking_number)
tracker.status
end
end
However this returns the 24 random char Sidekiq job id instead of the tracker status (ie, "out_for_delivery", "delivered", etc.)
What am I doing wrong?
The check_delivery method was calling the EasypostWorker, which returned the job id.
Apparently Sidekiq Workers don't return results like regular ruby classes and methods.
So I added a
status
attribute to my model and updated the attribute inside the Worker.