为什么升级后从Etsy Ruby API V3访问列表属性时会出现NoMethodError?

yc0p9oo0  于 2023-05-22  发布在  Ruby
关注(0)|答案(1)|浏览(156)

升级到Etsy Ruby API V3后出错
访问列表属性时,简单的Listing查找失败。
我相信这个错误是在进行一般升级时出现的,Etsy库从V2移动到V3
在附加的代码中,访问

listing.id
% cat test.rb
#!/usr/bin/env ruby

require 'etsy'

# Define authentication parameters. You should update these with the
# authentication details for your own shop and private application.

API_KEY='api_key'
API_SECRET='secret'
ACCESS_TOKEN='access_token'
ACCESS_SECRET='access_secret'
LISTING_ID=616662871

# Configure the Shop API with our authentication credentials.
Etsy.protocol = "https"
Etsy.api_key = API_KEY
Etsy.api_secret = API_SECRET

Etsy.environment = :production
Etsy.silent_errors = false

user=Etsy.myself(ACCESS_TOKEN, ACCESS_SECRET)

listing = Etsy::Listing.find(LISTING_ID)

puts listing.to_s
puts "listing.id="
puts listing.id.to_s
puts "exit"

% ./test.rb
#<Etsy::Listing:0x000000010fe5a7a8>
listing.id=
/Users/martin/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/etsy-0.3.4/lib     /etsy/model.rb:8:in `block in attribute': undefined method `[]' for true:TrueClass (NoMethodError)

          @result[options.fetch(:from, name).to_s]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    from ./test.rb:28:in `<main>'
% 

Was expecting:
#<Etsy::Listing:0x000000010fe5a7a8>
listing.id=nnnnnnnn
exit

相关问题