Class: MethodCrm::Client
- Inherits:
-
Object
- Object
- MethodCrm::Client
- Defined in:
- lib/method_crm.rb
Instance Method Summary collapse
- #field_list(table, options = {}) ⇒ Object
- #get_record(table, options = {}) ⇒ Object
- #get_records(table, options = {}) ⇒ Object
-
#initialize(company, username, password) ⇒ Client
constructor
A new instance of Client.
- #table_list(options = {}) ⇒ Object
Constructor Details
#initialize(company, username, password) ⇒ Client
Returns a new instance of Client.
10 11 12 |
# File 'lib/method_crm.rb', line 10 def initialize(company, username, password) @auth = {strCompanyAccount: company, strLogin: username, strPassword: password, strSessionID: nil} end |
Instance Method Details
#field_list(table, options = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/method_crm.rb', line 24 def field_list(table, ={}) results = perform_opperation('FieldList', {'strTable' => table}) case [:output].to_s when 'detailed' results else results.map { |table| table[:field_name] } end end |
#get_record(table, options = {}) ⇒ Object
40 41 42 43 44 |
# File 'lib/method_crm.rb', line 40 def get_record(table, ={}) records = get_records(table, ) raise MethodCrmClientError, 'Query returned more than one record' if records.length > 1 records.first end |
#get_records(table, options = {}) ⇒ Object
34 35 36 37 38 |
# File 'lib/method_crm.rb', line 34 def get_records(table, ={}) [:fields] ||= field_list(table).join(',') data = @auth.merge({strTable: table, strFields: [:fields], strWhereClause: [:where], strGroupByClause: nil, strHaving: nil, strOrderBy: nil}) perform_opperation('Select_XML', data) end |
#table_list(options = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/method_crm.rb', line 14 def table_list(={}) results = perform_opperation('TableList') case [:output].to_s when 'detailed' results else results.map { |table| table[:table_name] } end end |