【问题标题】:Coinbase API 4.2.1 Account Request Method, Missing parameter: `type`Coinbase API 4.2.1 帐户请求方法,缺少参数:`type`
【发布时间】:2019-09-25 21:13:23
【问题描述】:

我正在使用他们拥有的红宝石: https://github.com/coinbase/coinbase-ruby/tree/4.2.1

这是我成功使用我的 api 密钥获取我的主帐户但随后尝试使用它请求付款后遇到的错误:

account.request(to: 'example@example.com', amount: '0.00001', currency: 'BTC')
Traceback (most recent call last):
       10: from /usr/share/rvm/rubies/ruby-2.6.4/bin/irb:23:in `<main>'
        9: from /usr/share/rvm/rubies/ruby-2.6.4/bin/irb:23:in `load'
        8: from /usr/share/rvm/rubies/ruby-2.6.4/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in `<top (required)>'
        7: from (irb):13
        6: from (irb):13:in `rescue in irb_binding'
        5: from /home/doom/.rvm/gems/ruby-2.6.4/gems/coinbase-4.2.1/lib/coinbase/wallet/models/account.rb:79:in `request'
        4: from /home/doom/.rvm/gems/ruby-2.6.4/gems/coinbase-4.2.1/lib/coinbase/wallet/api_client.rb:302:in `request'
        3: from /home/doom/.rvm/gems/ruby-2.6.4/gems/coinbase-4.2.1/lib/coinbase/wallet/api_client.rb:687:in `post'
        2: from /home/doom/.rvm/gems/ruby-2.6.4/gems/coinbase-4.2.1/lib/coinbase/wallet/adapters/net_http.rb:36:in `http_verb'
        1: from /home/doom/.rvm/gems/ruby-2.6.4/gems/coinbase-4.2.1/lib/coinbase/wallet/api_errors.rb:28:in `check_response_status'
Coinbase::Wallet::ParamRequiredError (Missing parameter: `type`)

我已经通过了 byebug,当我通过 gems/coinbase-4.2.1/lib/coinbase/wallet/api_client.rb:302:inrequest'` 方法时:

  def request(account_id, params = {})
    [ :to, :amount, :currency ].each do |param|
      raise APIError, "Missing parameter: #{param}" unless params.include? param
    end
    params['type'] = 'request'

    out = nil
    post("/v2/accounts/#{account_id}/transactions", params) do |resp|
      out = Request.new(self, resp.data)
      yield(out, resp) if block_given?
    end
    out
  end

我的请求中添加了“类型”参数。所以我不确定这个错误来自哪里以及我能做些什么来继续前进。任何见解将不胜感激。

编辑: 用 byebug 注销我的日志:

byebug; account.request(to: 'example@example.com', amount: '0.00001', currency: 'BTC')

[74, 83] in /home/doom/.rvm/gems/ruby-2.6.4/gems/coinbase-4.2.1/lib/coinbase/wallet/models/account.rb
   74:           yield(data, resp) if block_given?
   75:         end
   76:       end
   77: 
   78:       def request(params = {})
=> 79:         @client.request(self['id'], params) do |data, resp|
   80:           yield(data, resp) if block_given?
   81:         end
   82:       end
   83: 
(byebug) step

[291, 300] in /home/doom/.rvm/gems/ruby-2.6.4/gems/coinbase-4.2.1/lib/coinbase/wallet/api_client.rb
   291:         end
   292:         out
   293:       end
   294: 
   295:       def request(account_id, params = {})
=> 296:         [ :to, :amount, :currency ].each do |param|
   297:           raise APIError, "Missing parameter: #{param}" unless params.include? param
   298:         end
   299:         params['type'] = 'request'
   300: 
(byebug) eval params
{:to=>"example@example.com", :amount=>"0.00001", :currency=>"BTC"}
(byebug) step

[292, 301] in /home/doom/.rvm/gems/ruby-2.6.4/gems/coinbase-4.2.1/lib/coinbase/wallet/api_client.rb
   292:         out
   293:       end
   294: 
   295:       def request(account_id, params = {})
   296:         [ :to, :amount, :currency ].each do |param|
=> 297:           raise APIError, "Missing parameter: #{param}" unless params.include? param
   298:         end
   299:         params['type'] = 'request'
   300: 
   301:         out = nil
(byebug) 

[292, 301] in /home/doom/.rvm/gems/ruby-2.6.4/gems/coinbase-4.2.1/lib/coinbase/wallet/api_client.rb
   292:         out
   293:       end
   294: 
   295:       def request(account_id, params = {})
   296:         [ :to, :amount, :currency ].each do |param|
=> 297:           raise APIError, "Missing parameter: #{param}" unless params.include? param
   298:         end
   299:         params['type'] = 'request'
   300: 
   301:         out = nil
(byebug) 

[292, 301] in /home/doom/.rvm/gems/ruby-2.6.4/gems/coinbase-4.2.1/lib/coinbase/wallet/api_client.rb
   292:         out
   293:       end
   294: 
   295:       def request(account_id, params = {})
   296:         [ :to, :amount, :currency ].each do |param|
=> 297:           raise APIError, "Missing parameter: #{param}" unless params.include? param
   298:         end
   299:         params['type'] = 'request'
   300: 
   301:         out = nil
(byebug) 

[294, 303] in /home/doom/.rvm/gems/ruby-2.6.4/gems/coinbase-4.2.1/lib/coinbase/wallet/api_client.rb
   294: 
   295:       def request(account_id, params = {})
   296:         [ :to, :amount, :currency ].each do |param|
   297:           raise APIError, "Missing parameter: #{param}" unless params.include? param
   298:         end
=> 299:         params['type'] = 'request'
   300: 
   301:         out = nil
   302:         post("/v2/accounts/#{account_id}/transactions", params) do |resp|
   303:           out = Request.new(self, resp.data)
(byebug) 

[296, 305] in /home/doom/.rvm/gems/ruby-2.6.4/gems/coinbase-4.2.1/lib/coinbase/wallet/api_client.rb
   296:         [ :to, :amount, :currency ].each do |param|
   297:           raise APIError, "Missing parameter: #{param}" unless params.include? param
   298:         end
   299:         params['type'] = 'request'
   300: 
=> 301:         post("/v2/accounts/#{account_id}/transactions", params) do |resp|
   303:           out = Request.new(self, resp.data)
   304:           yield(out, resp) if block_given?
   305:         end
(byebug) eval params
{:to=>"example@example.com", :amount=>"0.00001", :currency=>"BTC", "type"=>"request"}   out = nil
   302:         post("/v2/accounts/#{account_id}/transactions", params) do |resp|
   303:           out = Request.new(self, resp.data)
   304:           yield(out, resp) if block_given?
   305:         end
(byebug) eval params
{:to=>"example@example.com", :amount=>"0.00001", :currency=>"BTC", "type"=>"request"}

【问题讨论】:

  • 您找到解决方案了吗?
  • 没有,只是决定不使用。

标签: ruby coinbase-api


【解决方案1】:

他们实际上已经弃用了这个 gem。

https://github.com/coinbase/coinbase-ruby/issues/124

【讨论】:

    猜你喜欢
    • 2019-12-25
    • 1970-01-01
    • 2015-01-31
    • 1970-01-01
    • 1970-01-01
    • 2021-12-16
    • 1970-01-01
    • 2018-08-07
    • 2021-04-28
    相关资源
    最近更新 更多