eroi 0.1.3 → 0.1.4

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
data/eroi.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{eroi}
8
- s.version = "0.1.3"
8
+ s.version = "0.1.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["CardPlayer"]
12
- s.date = %q{2009-12-04}
12
+ s.date = %q{2009-12-07}
13
13
  s.description = %q{API interface to eROI.}
14
14
  s.email = %q{techteam@cardplayer.com}
15
15
  s.extra_rdoc_files = [
data/lib/eroi/client.rb CHANGED
@@ -27,6 +27,13 @@ module EROI
27
27
 
28
28
  alias :update_contact :add_contact
29
29
 
30
+ def add_contacts(records)
31
+ records = records.collect { |r| build_contact_record(r) }
32
+ Request::Post.send(self, records)
33
+ end
34
+
35
+ alias :update_contacts :add_contacts
36
+
30
37
  def change_contact_email(current_email, new_email)
31
38
  Request::Post.send(self, build_contact_record(
32
39
  :email => current_email,
@@ -43,6 +43,22 @@ class TestClient < Test::Unit::TestCase
43
43
  end
44
44
  end
45
45
 
46
+ context "when adding contacts" do
47
+ should "respond with a success" do
48
+ response = @client.add_contacts(
49
+ [{ :email => 'longbob@longbob.com',
50
+ :firstname => 'Longbob',
51
+ :lastname => 'Longson',
52
+ :mailing_lists => 'TestList' },
53
+ { :email => 'shortbob@shortbob.com',
54
+ :firstname => 'Shortbob',
55
+ :lastname => 'Shortson',
56
+ :mainling_lists => 'TestList' }])
57
+
58
+ assert_equal true, response.success?
59
+ end
60
+ end
61
+
46
62
  context "when changing a contact's email" do
47
63
  should "respond with a success" do
48
64
  response = @client.change_contact_email(
@@ -66,6 +82,23 @@ class TestClient < Test::Unit::TestCase
66
82
  end
67
83
  end
68
84
 
85
+ context "when updating contacts" do
86
+ should "respond with a success" do
87
+ response = @client.update_contacts(
88
+ [{ :email => 'longbob@longbob.com',
89
+ :firstname => 'Shortbob',
90
+ :lastname => 'Shortson',
91
+ :mailing_lists => 'TestList' },
92
+ { :email => 'shortbob@shortbob.com',
93
+ :firstname => 'Longbob',
94
+ :lastname => 'Longson',
95
+ :mainling_lists => 'TestList' }])
96
+
97
+ assert_equal true, response.success?
98
+ assert_equal 1, response.number_of_records
99
+ end
100
+ end
101
+
69
102
  context "when removing a contact" do
70
103
  should "respond with a success" do
71
104
  response = @client.remove_contact('longbob@longbob.com')
@@ -47,6 +47,28 @@ class TestClient < Test::Unit::TestCase
47
47
  end
48
48
  end
49
49
 
50
+ context "when adding contacts" do
51
+ teardown do
52
+ @client.remove_contact('longbob@longbob.com')
53
+ @client.remove_contact('shortbob@shortbob.com')
54
+ end
55
+
56
+ should "respond with a success" do
57
+ response = @client.add_contacts(
58
+ [{ :email => 'longbob@longbob.com',
59
+ :firstname => 'Longbob',
60
+ :lastname => 'Longson',
61
+ :mailing_lists => 'TestList' },
62
+ { :email => 'shortbob@shortbob.com',
63
+ :firstname => 'Shortbob',
64
+ :lastname => 'Shortson',
65
+ :mainling_lists => 'TestList' }])
66
+
67
+ assert_equal true, response.success?
68
+ assert_equal 2, response.number_of_records
69
+ end
70
+ end
71
+
50
72
  context "when changing a contact's email" do
51
73
  teardown do
52
74
  @client.remove_contact('longbob@longbob.com')
@@ -91,6 +113,40 @@ class TestClient < Test::Unit::TestCase
91
113
  end
92
114
  end
93
115
 
116
+ context "when updating contacts" do
117
+ teardown do
118
+ @client.remove_contact('longbob@longbob.com')
119
+ @client.remove_contact('shortbob@shortbob.com')
120
+ end
121
+
122
+ should "respond with a success" do
123
+ @client.add_contact(
124
+ :email => 'longbob@longbob.com',
125
+ :firstname => 'Longbob',
126
+ :lastname => 'Longson',
127
+ :mailing_lists => 'MainList')
128
+
129
+ @client.add_contact(
130
+ :email => 'shortbob@shortbob.com',
131
+ :firstname => 'Shortbob',
132
+ :lastname => 'Shortson',
133
+ :mailing_lists => 'MainList')
134
+
135
+ response = @client.update_contacts(
136
+ [{ :email => 'longbob@longbob.com',
137
+ :firstname => 'Shortbob',
138
+ :lastname => 'Shortson',
139
+ :mailing_lists => 'TestList' },
140
+ { :email => 'shortbob@shortbob.com',
141
+ :firstname => 'Longbob',
142
+ :lastname => 'Longson',
143
+ :mainling_lists => 'TestList' }])
144
+
145
+ assert_equal true, response.success?
146
+ assert_equal 2, response.number_of_records
147
+ end
148
+ end
149
+
94
150
  context "when removing a contact" do
95
151
  should "respond with a success" do
96
152
  response = @client.remove_contact('longbob@longbob.com')
@@ -107,7 +163,7 @@ class TestClient < Test::Unit::TestCase
107
163
 
108
164
  should "respond with a success" do
109
165
  @client.add_contact(
110
- :email => 'longbob@longbob.com'
166
+ :email => 'longbob@longbob.com',
111
167
  :firstname => 'Longbob',
112
168
  :lastname => 'Longson',
113
169
  :mailing_lists => 'MainList')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eroi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - CardPlayer
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-04 00:00:00 -08:00
12
+ date: 2009-12-07 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies: []
15
15