Class: Desk::Connection
- Inherits:
-
Object
- Object
- Desk::Connection
- Defined in:
- lib/desk/connection.rb
Instance Method Summary collapse
- #delete(*opts) ⇒ Object
- #get(*opts) ⇒ Object
-
#initialize(opts = {}) ⇒ Connection
constructor
A new instance of Connection.
- #patch(*opts) ⇒ Object
- #post(*opts) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Connection
Returns a new instance of Connection.
7 8 9 10 11 12 13 14 15 |
# File 'lib/desk/connection.rb', line 7 def initialize(opts={}) @site = opts[:site] connection use_basic_auth(opts) if opts[:email] && opts[:password] use_oauth(opts) if opts[:consumer_key] && opts[:consumer_secret] && opts[:token] && opts[:token_secret] end |
Instance Method Details
#delete(*opts) ⇒ Object
29 30 31 32 33 |
# File 'lib/desk/connection.rb', line 29 def delete(*opts) result = @connection.delete(*opts) result.status == 204 end |
#get(*opts) ⇒ Object
17 18 19 |
# File 'lib/desk/connection.rb', line 17 def get(*opts) @connection.get(*stringify_arrays(*opts)).body end |
#patch(*opts) ⇒ Object
25 26 27 |
# File 'lib/desk/connection.rb', line 25 def patch(*opts) @connection.patch(*opts).body end |
#post(*opts) ⇒ Object
21 22 23 |
# File 'lib/desk/connection.rb', line 21 def post(*opts) @connection.post(*opts).body end |