Class: Quickbase::HTTP
Direct Known Subclasses
Instance Attribute Summary collapse
-
#qb_params ⇒ Object
Returns the value of attribute qb_params.
Instance Method Summary collapse
-
#initialize(config) ⇒ HTTP
constructor
A new instance of HTTP.
- #post(quickbase_action, params = []) ⇒ Object
Constructor Details
#initialize(config) ⇒ HTTP
Returns a new instance of HTTP.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/classes/http.rb', line 7 def initialize(config) self.class.base_uri "https://#{config[:org]}.quickbase.com" instance_variable_set "@qb_params", {:dbid => "main"} http_proxy = config[:http_proxy] || ENV['http_proxy'] setup_proxy(http_proxy) if http_proxy qb_params[:ticket] = auth_ticket config qb_params[:apptoken] = config[:apptoken] qb_params[:dbid] = config[:dbid] end |
Instance Attribute Details
#qb_params ⇒ Object
Returns the value of attribute qb_params.
5 6 7 |
# File 'lib/classes/http.rb', line 5 def qb_params @qb_params end |
Instance Method Details
#post(quickbase_action, params = []) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/classes/http.rb', line 19 def post(quickbase_action, params = []) params = params.concat(Quickbase::Helper.hash_to_xml(qb_params)) clean_xml_string = Quickbase::Helper.generate_xml(params).to_s self.class.headers({"Content-Length" => clean_xml_string.length.to_s}) self.class.headers({"Content-Type" => "application/xml"}) self.class.headers({"QUICKBASE-ACTION" => quickbase_action}) response = Nokogiri::XML([self.class.post("/db/#{qb_params[:dbid]}", :body => clean_xml_string)].to_xml) error_handler(response) response end |