0

In the ruby-asana documentation almost every method needs a client? What is a client? Almost every method requires one.

I am trying this and getting an undefined method 'get'

I am trying:

client = Asana::Client
puts Asana::Tag.find_all(client)

I get:

C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/asana-0.5.0/lib/asana/resources/tag.rb:91:in `find_all': undefined method `get' for Asana::Client:Class (NoMethodError)
Did you mean?  gets
               gem
        from test.rb:13:in `<main>'
Eric Snyder
  • 1,816
  • 3
  • 22
  • 46

1 Answers1

1

The Client is an object that is configured to speak to the Asana API - you can think of it as your gateway to the API. It needs authentication to work correctly, so you need to "create" a client with Asana::Client.new - Asana::Client is merely the class, but you need an instance. (Some of this will be a bit confusing until you learn more about ruby and object-oriented programming.)

If you check out the README you'll find examples of how to create a client for various different configurations. For now, following examples and tweaking them to your use case may be your best choice.

Note that once you have a client, you can actually use it to make calls like:

client.tags.find_by_workspace(workspace: id_of_workspace)

Check out the CLI example which shows how you would get all the tags for all the workspaces a client has access to.

agnoster
  • 3,744
  • 2
  • 21
  • 29