lob/lob-ruby

Can't retrieve letters if they have tracking events

Closed this issue · 2 comments

Hi! i'm having trouble retrieving letters using the Lob::LettersApi#get method.

Steps to reproduce. Like in the docs:

Lob.configure do |config|
  config.username = 'YOUR USERNAME'
  config.password = 'YOUR PASSWORD'
end

api_instance = Lob::LettersApi.new
ltr_id = 'ltr_id_example' # Id of a letter with at least one tracking event

begin
  result = api_instance.get(ltr_id)
  p result
rescue Lob::ApiError => e
  puts "Error when calling LettersApi->get: #{e}"
end

Result:

Traceback (most recent call last):
./lib/ruby/gems/2.7.0/gems/lob-6.0.2/lib/openapi_client/models/letter.rb:542:in `tracking_events=': invalid value for "tracking_events", number of items must be less than or equal to 0. (ArgumentError)

I've tried to use the configuration option client_side_validation but the result was the same.

I'm using lob gem version 6.0.2 on ruby 2.7.7.

Thanks!

There's this workaround until an official patch:

# initializers/lob_letter.rb

module Lob
  class Letter
    def tracking_events=(tracking_events)
      @tracking_events = tracking_events
    end
  end
end

FYI that in our codebase, we use sorbet to check (both statically and at runtime) that tracking_events is an array of Lob::TrackingEventNormal. I omitted the sorbet signatures. You can easily add runtime checking directly.

Great thanks!