EasyPost::Address, can they even be updated?
Closed this issue · 2 comments
iamvery commented
I'm working with a use case where I'm attempting to create and verify an EasyPost::Address
and then a little later add a name
and company
to the record in order to create a shipment. This will not work because once the Address
record is created, the updated name
and company
attributes do not persist which leads to a missing information error during shipment creation.
I then came upon save
and though this would be the answer to my persistence issue. I'm seeing an error when attempting to save the address record. Is this not an appropriate workflow? Is there a Right Way™ to update an existing record?
1.9.3p448 :004 > a = EasyPost::Address.create(street1: '1989 College Ave', zip: '30317')
=> #<EasyPost::Address: id=adr_qzMOzkRy> JSON: {"id":"adr_qzMOzkRy","object":"Address","created_at":"2013-10-07T15:38:02Z","updated_at":"2013-10-07T15:38:02Z","name":null,"company":null,"street1":"1989 College Ave","street2":null,"city":null,"state":null,"zip":"30317","country":"US","phone":null,"email":null,"mode":"test"}
1.9.3p448 :005 > a.name = 'BNR'
=> "BNR"
1.9.3p448 :006 > a.save
EasyPost::Error: (Status 404) Invalid response from API, unable to decode.
from /Users/jay/.rvm/gems/ruby-1.9.3-p448@tappy/gems/easypost-2.0.9/lib/easypost.rb:101:in `rescue in rescue in request'
from /Users/jay/.rvm/gems/ruby-1.9.3-p448@tappy/gems/easypost-2.0.9/lib/easypost.rb:98:in `rescue in request'
from /Users/jay/.rvm/gems/ruby-1.9.3-p448@tappy/gems/easypost-2.0.9/lib/easypost.rb:94:in `request'
from /Users/jay/.rvm/gems/ruby-1.9.3-p448@tappy/gems/easypost-2.0.9/lib/easypost/resource.rb:61:in `save'
from (irb):6
from /Users/jay/.rvm/gems/ruby-1.9.3-p448@tappy/gems/railties-3.2.13/lib/rails/commands/console.rb:47:in `start'
from /Users/jay/.rvm/gems/ruby-1.9.3-p448@tappy/gems/railties-3.2.13/lib/rails/commands/console.rb:8:in `start'
from /Users/jay/.rvm/gems/ruby-1.9.3-p448@tappy/gems/railties-3.2.13/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Thanks for the help and great API! 😄