list.rb:11:in `[]': no implicit conversion of String into Integer (TypeError)
alexandre-mbm opened this issue · 11 comments
error:
$ ./program.rb
/home/alexandre/.gem/ruby/2.3.0/gems/wunderlist-api-1.0.5/lib/wunderlist/list.rb:11:in `[]': no implicit conversion of String into Integer (TypeError)
from /home/alexandre/.gem/ruby/2.3.0/gems/wunderlist-api-1.0.5/lib/wunderlist/list.rb:11:in `initialize'
...
..
.
program.rb:
#!/usr/bin/ruby
require 'wunderlist'
$wl = Wunderlist::API.new({
:access_token => 'SECRET',
:client_id => 'SECRET'
})
tasks = $wl.tasks
You have to pass list_names_or_ids to this method.
Ex. tasks = $wl.tasks('your_list_name_or_id')
Please refer to https://github.com/sh8/wunderlist-api/blob/master/lib/wunderlist/api.rb#L72
For:
list = $wl.tasks '149037921'
Result:
/home/alexandre/.gem/ruby/2.3.0/gems/wunderlist-api-1.0.5/lib/wunderlist/list.rb:11:in `[]': no implicit conversion of String into Integer (TypeError)
from /home/alexandre/.gem/ruby/2.3.0/gems/wunderlist-api-1.0.5/lib/wunderlist/list.rb:11:in `initialize'
from /home/alexandre/.gem/ruby/2.3.0/gems/wunderlist-api-1.0.5/lib/wunderlist/api.rb:52:in `new'
from /home/alexandre/.gem/ruby/2.3.0/gems/wunderlist-api-1.0.5/lib/wunderlist/api.rb:52:in `block in lists'
from /home/alexandre/.gem/ruby/2.3.0/gems/wunderlist-api-1.0.5/lib/wunderlist/api.rb:51:in `each'
from /home/alexandre/.gem/ruby/2.3.0/gems/wunderlist-api-1.0.5/lib/wunderlist/api.rb:51:in `lists'
from /home/alexandre/.gem/ruby/2.3.0/gems/wunderlist-api-1.0.5/lib/wunderlist/api.rb:202:in `get_list_ids'
from /home/alexandre/.gem/ruby/2.3.0/gems/wunderlist-api-1.0.5/lib/wunderlist/api.rb:73:in `tasks'
from ctest.rb:10:in `<main>'
Thanks for your quick reply😄
I forgot to release latest version to RubyGems.
I now release latest version (v1.1.0).
Please install it, and then you can get tasks via your command.
For:
tasks = $wl.tasks ['149037921']
Result:
/home/alexandre/.gem/ruby/2.3.0/gems/wunderlist-api-1.1.0/lib/wunderlist/list.rb:11:in `[]': no implicit conversion of String into Integer (TypeError)
from /home/alexandre/.gem/ruby/2.3.0/gems/wunderlist-api-1.1.0/lib/wunderlist/list.rb:11:in `initialize'
from /home/alexandre/.gem/ruby/2.3.0/gems/wunderlist-api-1.1.0/lib/wunderlist/api.rb:52:in `new'
from /home/alexandre/.gem/ruby/2.3.0/gems/wunderlist-api-1.1.0/lib/wunderlist/api.rb:52:in `block in lists'
from /home/alexandre/.gem/ruby/2.3.0/gems/wunderlist-api-1.1.0/lib/wunderlist/api.rb:51:in `each'
from /home/alexandre/.gem/ruby/2.3.0/gems/wunderlist-api-1.1.0/lib/wunderlist/api.rb:51:in `lists'
from /home/alexandre/.gem/ruby/2.3.0/gems/wunderlist-api-1.1.0/lib/wunderlist/api.rb:205:in `get_list_ids'
from /home/alexandre/.gem/ruby/2.3.0/gems/wunderlist-api-1.1.0/lib/wunderlist/api.rb:73:in `tasks'
from ctest.rb:10:in `<main>'
list = $wl.tasks([149037921])
<- Use Fixnum
Now we update this gem to 1.1.2.
You can get tasks like this.
# Both are the same
list = $wl.tasks([149037921])
list = $wl.tasks(149037921)
/home/alexandre/.gem/ruby/2.3.0/gems/wunderlist-api-1.1.2/lib/wunderlist/list.rb:11:in `[]': no implicit conversion of String into Integer (TypeError)
from /home/alexandre/.gem/ruby/2.3.0/gems/wunderlist-api-1.1.2/lib/wunderlist/list.rb:11:in `initialize'
from /home/alexandre/.gem/ruby/2.3.0/gems/wunderlist-api-1.1.2/lib/wunderlist/api.rb:52:in `new'
from /home/alexandre/.gem/ruby/2.3.0/gems/wunderlist-api-1.1.2/lib/wunderlist/api.rb:52:in `block in lists'
from /home/alexandre/.gem/ruby/2.3.0/gems/wunderlist-api-1.1.2/lib/wunderlist/api.rb:51:in `each'
from /home/alexandre/.gem/ruby/2.3.0/gems/wunderlist-api-1.1.2/lib/wunderlist/api.rb:51:in `lists'
from /home/alexandre/.gem/ruby/2.3.0/gems/wunderlist-api-1.1.2/lib/wunderlist/api.rb:207:in `get_list_ids'
from /home/alexandre/.gem/ruby/2.3.0/gems/wunderlist-api-1.1.2/lib/wunderlist/api.rb:73:in `tasks'
from ctest.rb:10:in `<main>'
$ ruby --version
ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-linux]
Probably, you set wrong list id.😓
I should refine these confusing error messages ...
Get the same error....
Update: Made the mistake to use CLIENT SECRET as access token!!! Fixed it and it works! :)