Class: Quickbase::Api
- Inherits:
-
Object
- Object
- Quickbase::Api
- Defined in:
- lib/classes/api.rb
Instance Attribute Summary (collapse)
-
- (Object) connection
Returns the value of attribute connection.
Instance Method Summary (collapse)
-
- (Object) add_record(fields)
Documentation at www.quickbase.com/api-guide/add_record.html.
-
- (Object) delete_record(rid)
Documentation at www.quickbase.com/api-guide/delete_record.html.
-
- (Object) do_query(params)
Documentation at www.quickbase.com/api-guide/do_query.html.
-
- (Object) edit_record(rid, fields)
Documentation at www.quickbase.com/api-guide/edit_record.html.
-
- (Api) initialize(connection)
constructor
A new instance of Api.
Constructor Details
- (Api) initialize(connection)
A new instance of Api
5 6 7 |
# File 'lib/classes/api.rb', line 5 def initialize(connection) instance_variable_set "@connection", connection end |
Instance Attribute Details
- (Object) connection
Returns the value of attribute connection
3 4 5 |
# File 'lib/classes/api.rb', line 3 def connection @connection end |
Instance Method Details
- (Object) add_record(fields)
Documentation at www.quickbase.com/api-guide/add_record.html
26 27 28 29 |
# File 'lib/classes/api.rb', line 26 def add_record(fields) fields = Quickbase::Helper.generate_fields(fields) connection.http.post("API_AddRecord", fields) end |
- (Object) delete_record(rid)
Documentation at www.quickbase.com/api-guide/delete_record.html
39 40 41 42 |
# File 'lib/classes/api.rb', line 39 def delete_record(rid) = Quickbase::Helper.hash_to_xml({:rid => rid.to_s}) connection.http.post("API_DeleteRecord", ) end |
- (Object) do_query(params)
Documentation at www.quickbase.com/api-guide/do_query.html
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/classes/api.rb', line 10 def do_query(params) params.merge!({:fmt => "structured"}) clist = params[:clist].to_s.split(".") response = connection.http.post("API_DoQuery", Quickbase::Helper.hash_to_xml(params)) array_of_records = response.find("//record[@type='array']/record") records = array_of_records.empty? ? response.find("//record") : array_of_records return [] if records.empty? records.map{|record| array_of_fields = record.find("f[@type='array']/f") fields = array_of_fields.empty? ? record.find("f") : array_of_fields Hash[fields.to_enum(:each_with_index).collect{|field,index| Hash[clist[index],field.content] }.map(&:flatten)] } end |
- (Object) edit_record(rid, fields)
Documentation at www.quickbase.com/api-guide/edit_record.html
32 33 34 35 36 |
# File 'lib/classes/api.rb', line 32 def edit_record(rid, fields) = Quickbase::Helper.generate_fields(fields) << Quickbase::Helper.hash_to_xml({:rid => rid.to_s}) connection.http.post("API_EditRecord", ) end |