email_vision 0.2.4 → 0.2.5
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/Readme.md +21 -2
- data/VERSION +1 -1
- data/email_vision.gemspec +3 -3
- data/lib/email_vision.rb +2 -1
- data/spec/email_vision_spec.rb +25 -3
- metadata +9 -9
data/Readme.md
CHANGED
@@ -19,7 +19,26 @@ Usage
|
|
19
19
|
emv.rejoin 'me@host.com'
|
20
20
|
|
21
21
|
# create, create_or_update, update, change_email return a job-id
|
22
|
-
|
22
|
+
# it can be used to wait for the job or fetch its status
|
23
|
+
job_id = emv.update :email => 'me@host.com', :foo => 1
|
24
|
+
puts "Status is #{emv.job_status job_id}"
|
25
|
+
emv.wait_for_job_to_finish job_id # raises when job failed
|
26
|
+
|
27
|
+
|
28
|
+
# :dateunjoin cannot be set via update, use a separate rejoin / unjoin request
|
29
|
+
class User < ActiveRecord::Base
|
30
|
+
after_save :update_email_vision
|
31
|
+
|
32
|
+
def update_email_vision
|
33
|
+
case receive_newsletter_change
|
34
|
+
when [false, true]
|
35
|
+
emv.rejoin(email)
|
36
|
+
emv.update(...data for emailv vision...)
|
37
|
+
when [true, false]
|
38
|
+
emv.unjoin(email)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
23
42
|
|
24
43
|
Docs
|
25
44
|
====
|
@@ -29,4 +48,4 @@ Author
|
|
29
48
|
======
|
30
49
|
[Michael Grosser](http://grosser.it)<br/>
|
31
50
|
michael@grosser.it<br/>
|
32
|
-
Hereby placed under public domain, do what you want, just do not hold me accountable...
|
51
|
+
Hereby placed under public domain, do what you want, just do not hold me accountable...
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.5
|
data/email_vision.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{email_vision}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Michael Grosser"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-06-09}
|
13
13
|
s.email = %q{michael@grosser.it}
|
14
14
|
s.files = [
|
15
15
|
"Gemfile",
|
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
|
|
24
24
|
]
|
25
25
|
s.homepage = %q{http://github.com/grosser/email_vision}
|
26
26
|
s.require_paths = ["lib"]
|
27
|
-
s.rubygems_version = %q{1.
|
27
|
+
s.rubygems_version = %q{1.6.2}
|
28
28
|
s.summary = %q{Ruby SOAP Api Client for EmailVision / CampaignCommander}
|
29
29
|
s.test_files = [
|
30
30
|
"spec/email_vision_spec.rb"
|
data/lib/email_vision.rb
CHANGED
@@ -17,6 +17,7 @@ class EmailVision
|
|
17
17
|
|
18
18
|
def find(email_or_id)
|
19
19
|
result = execute_by_email_or_id(:get_member, email_or_id)
|
20
|
+
result = result.first if result.is_a?(Array) # may return multiple users if they have the same email -> return first
|
20
21
|
return unless result.is_a?(Hash)
|
21
22
|
result = convert_to_hash(result[:attributes][:entry], :key, :value)
|
22
23
|
result.reject{|k,v| v.nil? }
|
@@ -157,4 +158,4 @@ class EmailVision
|
|
157
158
|
def api_namespaced(method)
|
158
159
|
"api:#{method.to_s.gsub(/_./){|x| x.slice(1,1).upcase }}"
|
159
160
|
end
|
160
|
-
end
|
161
|
+
end
|
data/spec/email_vision_spec.rb
CHANGED
@@ -31,6 +31,10 @@ describe "EmailVision" do
|
|
31
31
|
email.should == changeable_user[:email]
|
32
32
|
end
|
33
33
|
|
34
|
+
def steady_fields(hash)
|
35
|
+
hash.reject{|k,v| [:datejoin, :dateunjoin, :custom26].include?(k) }
|
36
|
+
end
|
37
|
+
|
34
38
|
let(:config){YAML.load(File.read('spec/account.yml'))}
|
35
39
|
let(:client){EmailVision.new(config)}
|
36
40
|
let(:findable_user) do
|
@@ -60,12 +64,18 @@ describe "EmailVision" do
|
|
60
64
|
describe :find do
|
61
65
|
it "can find by email" do
|
62
66
|
response = client.find(findable_user[:email])
|
63
|
-
response.should == findable_user
|
67
|
+
steady_fields(response).should == steady_fields(findable_user)
|
64
68
|
end
|
65
69
|
|
66
70
|
it "can find by id" do
|
67
71
|
response = client.find(findable_user[:member_id])
|
68
|
-
response.should == findable_user
|
72
|
+
steady_fields(response).should == steady_fields(findable_user)
|
73
|
+
end
|
74
|
+
|
75
|
+
it "can find first users of multiple that have the same email" do
|
76
|
+
client.should_receive(:execute_by_email_or_id).and_return [{:attributes=>{:entry=>[{:key=>"xx",:value=>'yyy'}]}},{:attributes=>{:entry=>[{:key=>"xx",:value=>'zzz'}]}}]
|
77
|
+
response = client.find('foo@bar.com')
|
78
|
+
steady_fields(response).should == {:xx => 'yyy'}
|
69
79
|
end
|
70
80
|
|
71
81
|
it "is nil when nothing was found" do
|
@@ -139,6 +149,18 @@ describe "EmailVision" do
|
|
139
149
|
data = client.find(changeable_user[:email])
|
140
150
|
data[:dateofbirth].strftime('%s').to_i.should == 1272664800
|
141
151
|
end
|
152
|
+
|
153
|
+
it "can remove dateunjoin" do
|
154
|
+
pending
|
155
|
+
wait_for_job_to_finish do
|
156
|
+
client.unjoin(changeable_user[:email])
|
157
|
+
end
|
158
|
+
wait_for_job_to_finish do
|
159
|
+
client.update(:email => changeable_user[:email], :dateunjoin => 'NULL')
|
160
|
+
end
|
161
|
+
data = client.find(changeable_user[:email])
|
162
|
+
data[:dateunjoin].should == nil
|
163
|
+
end
|
142
164
|
|
143
165
|
it "returns a job id" do
|
144
166
|
job_id = client.update(:email => changeable_user[:email], :firstname => random_value)
|
@@ -213,4 +235,4 @@ describe "EmailVision" do
|
|
213
235
|
Time.parse(date.to_s).should be_within(40).of(Time.now)
|
214
236
|
end
|
215
237
|
end
|
216
|
-
end
|
238
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: email_vision
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 5
|
10
|
+
version: 0.2.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Michael Grosser
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-06-09 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -30,10 +30,10 @@ dependencies:
|
|
30
30
|
- 8
|
31
31
|
- 2
|
32
32
|
version: 0.8.2
|
33
|
-
prerelease: false
|
34
|
-
version_requirements: *id001
|
35
33
|
type: :runtime
|
36
34
|
name: savon
|
35
|
+
version_requirements: *id001
|
36
|
+
prerelease: false
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
segments:
|
45
45
|
- 0
|
46
46
|
version: "0"
|
47
|
-
prerelease: false
|
48
|
-
version_requirements: *id002
|
49
47
|
type: :runtime
|
50
48
|
name: savon
|
49
|
+
version_requirements: *id002
|
50
|
+
prerelease: false
|
51
51
|
description:
|
52
52
|
email: michael@grosser.it
|
53
53
|
executables: []
|
@@ -96,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
96
|
requirements: []
|
97
97
|
|
98
98
|
rubyforge_project:
|
99
|
-
rubygems_version: 1.
|
99
|
+
rubygems_version: 1.6.2
|
100
100
|
signing_key:
|
101
101
|
specification_version: 3
|
102
102
|
summary: Ruby SOAP Api Client for EmailVision / CampaignCommander
|