Sha256: d8e03957a089bfa750f99e39be210f47d61e0b527fa3ed23ed4c02cce0818e51
Contents?: true
Size: 1.18 KB
Versions: 5
Compression:
Stored size: 1.18 KB
Contents
module Netscaler class Adapter def session return @session end def session=(value) @session = value end :protected def prepare_payload(data) if data.is_a?(String) post_data = "object=#{data}" else post_data = "object=#{data.to_json}" end return post_data end def prepare_options(args) options = { :cookies=>{} } unless @session.nil? options[:cookies]['NITRO_AUTH_TOKEN'] = @session end options[:accept] = :json options[:params] = args[:params] if args.has_key?(:params) return options end def check_error(payload) if payload['errorcode'] != 0 raise Exception, "ErrorCode #{payload['errorcode']} -> #{payload['message']}" end end def process_result(result, response) #status_code = result.code.to_i if result.header['content-type'] =~ /application\/json/ payload = JSON.parse(response) check_error(payload) return payload else raise Exception, 'Shit is broke' end end def get_uri(part) url = 'nitro/v1/' return url + part end end end
Version data entries
5 entries across 5 versions & 1 rubygems