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 14 15 |
# File 'lib/unresponsys/client.rb', line 5 def initialize( = {}) raise Unresponsys::ArgumentError unless [:username] && [:password] raise Unresponsys::ArgumentError unless [nil, 2, 5].include?([:interact]) @username = [:username] @password = [:password] @interact = .fetch(:interact, 2) @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
33 34 35 36 37 38 39 |
# File 'lib/unresponsys/client.rb', line 33 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
41 42 43 |
# File 'lib/unresponsys/client.rb', line 41 def folders @folders ||= Folders.new(self) end |
#get(path, options = {}, &block) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/unresponsys/client.rb', line 17 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
45 46 47 |
# File 'lib/unresponsys/client.rb', line 45 def lists @lists ||= Lists.new(self) end |
#post(path, options = {}, &block) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/unresponsys/client.rb', line 25 def post(path, = {}, &block) path = "#{@base_uri}#{path}" = @options.merge() = .merge(@log_opts) if @debug response = HTTParty.post(path, , &block) handle_error(response) end |