Class: Quickbase::HTTP
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.
6 7 8 9 10 11 12 13 |
# File 'lib/classes/http.rb', line 6 def initialize(config) self.class.base_uri "https://#{config[:org]}.quickbase.com" instance_variable_set "@qb_params", {:dbid => "main"} response = post("API_Authenticate", Quickbase::Helper.hash_to_xml(config)) qb_params[:ticket] = response.xpath("//ticket").first.content qb_params[:apptoken] = config[:apptoken] qb_params[:dbid] = config[:dbid] end |
Instance Attribute Details
#qb_params ⇒ Object
Returns the value of attribute qb_params.
4 5 6 |
# File 'lib/classes/http.rb', line 4 def qb_params @qb_params end |
Instance Method Details
#post(quickbase_action, params = []) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/classes/http.rb', line 15 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 |