email_vision 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -41,12 +41,11 @@ end
41
41
 
42
42
  begin
43
43
  require 'jeweler'
44
- project_name = 'email_vision'
45
44
  Jeweler::Tasks.new do |gem|
46
- gem.name = project_name
45
+ gem.name = 'email_vision'
47
46
  gem.summary = "Ruby SOAP Api Client for EmailVision / CampaignCommander"
48
47
  gem.email = "michael@grosser.it"
49
- gem.homepage = "http://github.com/grosser/#{project_name}"
48
+ gem.homepage = "http://github.com/grosser/#{gem.name}"
50
49
  gem.authors = ["Michael Grosser"]
51
50
  gem.add_dependency 'savon'
52
51
  end
data/Readme.md CHANGED
@@ -21,8 +21,12 @@ Usage
21
21
  # create, create_or_update, update, change_email return a job-id
22
22
  emv.job_status job_id
23
23
 
24
+ Docs
25
+ ====
26
+ - [EmailVision api](https://docs.google.com/viewer?a=v&pid=explorer&chrome=true&srcid=1FLFs3Jautozs6-ZNcT34oSXJbH6K7szw1wD8cU5i9jpEWjA4p64StquqYa6P&hl=de&authkey=CO383_EP)
27
+
24
28
  Author
25
29
  ======
26
- [Michael Grosser](http://grosser.it)
27
- michael@grosser.it
30
+ [Michael Grosser](http://grosser.it)<br/>
31
+ michael@grosser.it<br/>
28
32
  Hereby placed under public domain, do what you want, just do not hold me accountable...
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.3
1
+ 0.2.4
@@ -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.3"
8
+ s.version = "0.2.4"
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-01-21}
12
+ s.date = %q{2011-02-17}
13
13
  s.email = %q{michael@grosser.it}
14
14
  s.files = [
15
15
  "Gemfile",
@@ -2,6 +2,7 @@ require 'savon'
2
2
 
3
3
  class EmailVision
4
4
  WSDL = "http://emvapi.emv3.com/apimember/services/MemberService?wsdl"
5
+ NAMESPACE = 'http://api.service.apimember.emailvision.com/'
5
6
  SESSION_TIMEOUT = 10*60
6
7
  VERSION = File.read( File.join(File.dirname(__FILE__),'..','VERSION') ).strip
7
8
  attr_accessor :options
@@ -85,14 +86,12 @@ class EmailVision
85
86
  end
86
87
 
87
88
  def connect!
88
- response = client.request :open_api_connection do |r|
89
- r.body = {
90
- :login => options[:login],
91
- :pwd => options[:password],
92
- :key => options[:key]
93
- }
94
- end
95
- @token = response.to_hash[:open_api_connection_response][:return]
89
+ @token = request_without_protection(:open_api_connection,
90
+ :login => options[:login],
91
+ :pwd => options[:password],
92
+ :key => options[:key],
93
+ :soap_client => client
94
+ )
96
95
  @token_requested = Time.now.to_i
97
96
  end
98
97
 
@@ -120,8 +119,7 @@ class EmailVision
120
119
  end
121
120
 
122
121
  def execute(method, options={})
123
- response = connection.request(method){|r| r.body = options.merge(:token => @token) }
124
- response.to_hash["#{method}_response".to_sym][:return]
122
+ request_without_protection(method, options.merge(:token => true))
125
123
  rescue Object => e
126
124
  if e.respond_to?(:http) and e.http.respond_to?(:body)
127
125
  retries ||= -1
@@ -139,10 +137,24 @@ class EmailVision
139
137
  raise e
140
138
  end
141
139
 
140
+ def request_without_protection(method, options)
141
+ client = options.delete(:soap_client) || connection
142
+ response = client.request(api_namespaced(method)) do |r|
143
+ r.namespaces['xmlns:api'] = NAMESPACE
144
+ options[:token] = @token if options[:token] # token first is generated via connection method
145
+ r.body = options
146
+ end
147
+ response.to_hash["#{method}_response".to_sym][:return]
148
+ end
149
+
142
150
  def convert_to_hash(entries, key, value)
143
151
  entries.inject({}) do |hash, part|
144
152
  hash[to_ruby_style(part[key])] = part[value]
145
153
  hash
146
154
  end
147
155
  end
156
+
157
+ def api_namespaced(method)
158
+ "api:#{method.to_s.gsub(/_./){|x| x.slice(1,1).upcase }}"
159
+ end
148
160
  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: 17
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 3
10
- version: 0.2.3
9
+ - 4
10
+ version: 0.2.4
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-01-21 00:00:00 +01:00
18
+ date: 2011-02-17 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency