Class: Unresponsys::Client
Defined Under Namespace
Instance Method Summary collapse
- #delete(path, options = {}, &block) ⇒ Object
- #folders ⇒ Object
- #get(path, options = {}, &block) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #lists ⇒ Object
- #post(path, options = {}, &block) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
5 6 7 8 9 10 11 12 13 |
# File 'lib/unresponsys/client.rb', line 5 def initialize( = {}) raise Unresponsys::ArgumentError unless [:username] && [:password] @username = [:username] @password = [:password] @debug = [:debug] @logger = Logger.new(STDOUT) if @debug @log_opts = { logger: @logger, log_level: :debug, log_format: :curl } authenticate end |
Instance Method Details
#delete(path, options = {}, &block) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/unresponsys/client.rb', line 31 def delete(path, = {}, &block) path = "#{@base_uri}#{path}" = @options.merge() = .merge(@log_opts) if @debug response = HTTParty.delete(path, , &block) handle_error(response) end |
#folders ⇒ Object
39 40 41 |
# File 'lib/unresponsys/client.rb', line 39 def folders @folders ||= Folders.new(self) end |
#get(path, options = {}, &block) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/unresponsys/client.rb', line 15 def get(path, = {}, &block) path = "#{@base_uri}#{path}" = @options.merge() = .merge(@log_opts) if @debug response = HTTParty.get(path, , &block) handle_error(response) end |
#lists ⇒ Object
43 44 45 |
# File 'lib/unresponsys/client.rb', line 43 def lists @lists ||= Lists.new(self) end |
#post(path, options = {}, &block) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/unresponsys/client.rb', line 23 def post(path, = {}, &block) path = "#{@base_uri}#{path}" = @options.merge() = .merge(@log_opts) if @debug response = HTTParty.post(path, , &block) handle_error(response) end |