Class: Kanbanery::Client
- Inherits:
-
Object
- Object
- Kanbanery::Client
- Defined in:
- lib/ranbanery.rb
Constant Summary collapse
- BASE_URL =
'https://%s.kanbanery.com/api/v1'
Instance Attribute Summary collapse
-
#key ⇒ Object
Returns the value of attribute key.
-
#workspace ⇒ Object
Returns the value of attribute workspace.
Instance Method Summary collapse
- #columns(project_id = nil) ⇒ Object
- #comments(task_id = nil) ⇒ Object
-
#initialize(workspace, key) ⇒ Client
constructor
A new instance of Client.
- #projects ⇒ Object
- #resource(name, options = {}) ⇒ Object
- #subtasks(task_id = nil) ⇒ Object
- #tasks(project_id = nil) ⇒ Object
- #users(project_id = nil) ⇒ Object
Constructor Details
#initialize(workspace, key) ⇒ Client
Returns a new instance of Client.
15 16 17 18 |
# File 'lib/ranbanery.rb', line 15 def initialize(workspace, key) self.workspace = workspace self.key = key end |
Instance Attribute Details
#key ⇒ Object
Returns the value of attribute key.
11 12 13 |
# File 'lib/ranbanery.rb', line 11 def key @key end |
#workspace ⇒ Object
Returns the value of attribute workspace.
11 12 13 |
# File 'lib/ranbanery.rb', line 11 def workspace @workspace end |
Instance Method Details
#columns(project_id = nil) ⇒ Object
40 41 42 |
# File 'lib/ranbanery.rb', line 40 def columns(project_id=nil) resource(:column, prefix: project_id ? "/projects/#{project_id}" : nil) end |
#comments(task_id = nil) ⇒ Object
52 53 54 |
# File 'lib/ranbanery.rb', line 52 def comments(task_id=nil) resource(:comment, prefix: task_id ? "/tasks/#{task_id}" : nil) end |
#projects ⇒ Object
32 33 34 |
# File 'lib/ranbanery.rb', line 32 def projects resource(:project) end |
#resource(name, options = {}) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ranbanery.rb', line 20 def resource(name, ={}) the_workspace = self.workspace the_key = self.key klass = "Kanbanery::#{name.to_s.classify}".constantize Class.new(klass) do |c| def self.name; superclass.name; end c.element_name = name.to_s c.site = "#{BASE_URL % the_workspace}#{options[:prefix]}" c.headers['X-Kanbanery-ApiToken'] = the_key end end |
#subtasks(task_id = nil) ⇒ Object
48 49 50 |
# File 'lib/ranbanery.rb', line 48 def subtasks(task_id=nil) resource(:subtask, prefix: task_id ? "/tasks/#{task_id}" : nil) end |
#tasks(project_id = nil) ⇒ Object
44 45 46 |
# File 'lib/ranbanery.rb', line 44 def tasks(project_id=nil) resource(:task, prefix: project_id ? "/projects/#{project_id}" : nil) end |
#users(project_id = nil) ⇒ Object
36 37 38 |
# File 'lib/ranbanery.rb', line 36 def users(project_id=nil) resource(:user, prefix: project_id ? "/projects/#{project_id}" : nil) end |