bronto 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/bronto/contact.rb +22 -0
- data/lib/bronto/version.rb +1 -1
- metadata +1 -1
data/lib/bronto/contact.rb
CHANGED
@@ -20,6 +20,28 @@ module Bronto
|
|
20
20
|
Array.wrap(resp[:return]).map { |hash| new(hash) }
|
21
21
|
end
|
22
22
|
|
23
|
+
def self.save(*objs)
|
24
|
+
objs = objs.flatten
|
25
|
+
|
26
|
+
resp = request(:add_or_update) do
|
27
|
+
soap.body = {
|
28
|
+
plural_class_name => objs.map(&:to_hash)
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
objs.each { |o| o.errors.clear }
|
33
|
+
|
34
|
+
Array.wrap(resp[:return][:results]).each_with_index do |result, i|
|
35
|
+
if result[:is_new] and !result[:is_error]
|
36
|
+
objs[i].id = result[:id]
|
37
|
+
elsif result[:is_error]
|
38
|
+
objs[i].errors.add(result[:error_code], result[:error_string])
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
objs
|
43
|
+
end
|
44
|
+
|
23
45
|
def initialize(options = {})
|
24
46
|
self.fields = {}
|
25
47
|
fields = options.delete(:fields)
|
data/lib/bronto/version.rb
CHANGED