Class: Quickbase::Http
- Inherits:
-
Object
- Object
- Quickbase::Http
- Includes:
- HTTParty
- Defined in:
- lib/classes/http.rb
Instance Attribute Summary (collapse)
-
- (Object) qb_params
Returns the value of attribute qb_params.
Instance Method Summary (collapse)
-
- (Http) initialize(config)
constructor
A new instance of Http.
- - (Object) post(quickbase_action, params = [])
Constructor Details
- (Http) initialize(config)
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.find_first("//ticket").content qb_params[:apptoken] = config[:apptoken] qb_params[:dbid] = config[:dbid] end |
Instance Attribute Details
- (Object) qb_params
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
- (Object) post(quickbase_action, params = [])
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 = LibXML::XML::Document.string(self.class.post("/db/#{qb_params[:dbid]}", :body => clean_xml_string).to_xml) error_handler(response) response end |