bronto 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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)
@@ -1,3 +1,3 @@
1
1
  module Bronto
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bronto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: