Class: Assembla::Client
- Inherits:
-
Object
- Object
- Assembla::Client
- Defined in:
- lib/assemblabla.rb
Constant Summary collapse
- BASE_URL =
'https://api.assembla.com/v1/'
Instance Attribute Summary collapse
-
#key ⇒ Object
Returns the value of attribute key.
-
#secret ⇒ Object
Returns the value of attribute secret.
Instance Method Summary collapse
-
#initialize(key, secret) ⇒ Client
constructor
A new instance of Client.
- #resource(name, options = {}) ⇒ Object
- #spaces ⇒ Object
- #tickets(space_id) ⇒ Object
Constructor Details
#initialize(key, secret) ⇒ Client
Returns a new instance of Client.
13 14 15 16 |
# File 'lib/assemblabla.rb', line 13 def initialize(key, secret) self.key = key self.secret = secret end |
Instance Attribute Details
#key ⇒ Object
Returns the value of attribute key.
9 10 11 |
# File 'lib/assemblabla.rb', line 9 def key @key end |
#secret ⇒ Object
Returns the value of attribute secret.
9 10 11 |
# File 'lib/assemblabla.rb', line 9 def secret @secret end |
Instance Method Details
#resource(name, options = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/assemblabla.rb', line 18 def resource(name, ={}) the_key = self.key the_secret = self.secret klass = "Assembla::#{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}#{[:prefix]}" c.headers['X-Api-Key'] = the_key c.headers['X-Api-Secret'] = the_secret end end |
#spaces ⇒ Object
31 32 33 |
# File 'lib/assemblabla.rb', line 31 def spaces resource(:space) end |
#tickets(space_id) ⇒ Object
35 36 37 |
# File 'lib/assemblabla.rb', line 35 def tickets(space_id) resource(:ticket, prefix: "spaces/#{space_id}/") end |