Method: IntacctRB::Customer#get

Defined in:
lib/intacctrb/customer.rb

#get(*fields) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/intacctrb/customer.rb', line 18

def get *fields
  #return false unless object.intacct_system_id.present?

  fields = [
    :customerid,
    :name,
    :termname
  ] if fields.empty?

  send_xml('get') do |xml|
    xml.function(controlid: "f4") {
      xml.get(object: "customer", key: "intacct_system_id") {
        xml.fields {
          fields.each do |field|
            xml.field field.to_s
          end
        }
      }
    }
  end

  if successful?
    @data = OpenStruct.new({
      id: response.at("//customer//customerid").content,
      name: response.at("//customer//name").content,
      termname: response.at("//customer//termname").content
    })
  end

  successful?
end