lob-ruby icon indicating copy to clipboard operation
lob-ruby copied to clipboard

Undefined method `=~' for [:ReturnEnvelope, :Boolean]:Array

Open acimadamore opened this issue 2 years ago • 6 comments

I'm receiving the error in the title when sending a Letter. It seems that the problem is with attributes that are mapped to Open API type that is an Ruby Array.

In this error in particular return_envelope is mapped to Array[:ReturnEnvelope, :Boolean]: https://github.com/lob/lob-ruby/blob/2591d23a0993a373121e8c7e03d09bc3db260563/lib/openapi_client/models/letter.rb#L190

The second if in Letter#build_from_hash breaks because a =~ is sent to the array instance: https://github.com/lob/lob-ruby/blob/2591d23a0993a373121e8c7e03d09bc3db260563/lib/openapi_client/models/letter.rb#L624

Maybe the third if should precede the second one and add a check if type responds_to(:=~)? This problem should be present in all the implementations of build_form_hash of other model classes.

Thanks!

acimadamore avatar Jul 28 '23 18:07 acimadamore

Hey, I hit this issue too: https://github.com/lob/lob-ruby/pull/216, see their reply there.

arich avatar Oct 12 '23 15:10 arich

I'm hitting this same issue with gem version 6.0.9 after upgrading to Ruby 3.2.0. Is Lob doing anything about this? Am I expected to patch the code myself and rebuild the gem?

palu3492 avatar May 03 '24 18:05 palu3492

That's a shame, I was hoping the newer versions fixed it. You can use my fork over here. I haven't updated it to the latest, it's on 6.0.5. https://github.com/hellobrightline/lob-ruby

gem "lob", github: "hellobrightline/lob-ruby"

arich avatar May 07 '24 15:05 arich

@arich Thanks. I ended up forking it as well and patching it with your code suggestion. That fixed the issue. I will hold out hope that Lob figures this out so I can use the official gem.

palu3492 avatar May 07 '24 17:05 palu3492

Sounds good, I'm not promising I'll maintain this forever so best to use your own fork!

arich avatar May 07 '24 18:05 arich