Class: IntacctRB::Contact
- Inherits:
-
Base
show all
- Defined in:
- lib/intacctrb/contact.rb
Instance Attribute Summary
Attributes inherited from Base
#current_user, #data, #intacct_action, #object, #response, #sent_xml
Instance Method Summary
collapse
Methods inherited from Base
#initialize, #intacct_id
Instance Method Details
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
# File 'lib/intacctrb/contact.rb', line 103
def contact_xml(xml, is_update = false)
xml.contact {
xml.recordno object.intacct_id if object.intacct_id
xml.contactname object.name unless (is_update || object.intacct_id.nil?)
xml.printas object.name
}
end
|
3
4
5
6
7
8
9
10
11
12
13
|
# File 'lib/intacctrb/contact.rb', line 3
def create
send_xml('create') do |xml|
xml.function(controlid: "1") {
xml.send("create") {
contact_xml(xml)
}
}
end
successful?
end
|
91
92
93
94
95
96
97
98
99
100
101
|
# File 'lib/intacctrb/contact.rb', line 91
def delete
return false unless object.intacct_id.present?
@response = send_xml('delete') do |xml|
xml.function(controlid: "1") {
xml.delete_contact(contactid: intacct_id)
}
end
successful?
end
|
#get(options = {}) ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/intacctrb/contact.rb', line 15
def get(options = {})
options[:fields] = [
:contactid,
:contactname
] if options[:fields].nil?
send_xml('get') do |xml|
xml.function(controlid: "f4") {
xml.read {
xml.object 'contact'
xml.keys object.try(:intacct_id) || options[:intacct_id]
xml.fields '*'
}
}
end
if successful?
@data = OpenStruct.new({
id: response.at("//contact/RECORDNO").content,
name: response.at("//contact/PERSONALINFO/CONTACTNAME").content
})
end
successful?
end
|
#get_list(*fields) ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/intacctrb/contact.rb', line 43
def get_list *fields
fields = [
:customerid,
:name,
:termname
] if fields.empty?
send_xml('get_list') do |xml|
xml.function(controlid: "f4") {
xml.get_list(object: "contact", maxitems: "10", showprivate:"false") {
}
}
end
puts response
end
|
#update(updated_contact = false) ⇒ Object
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/intacctrb/contact.rb', line 76
def update updated_contact = false
@object = updated_contact if updated_contact
return false unless object.intacct_id.present?
send_xml('update') do |xml|
xml.function(controlid: "1") {
xml.update {
contact_xml(xml, true)
}
}
end
successful?
end
|