emailvision 2.1.10 → 2.1.11
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/emailvision/api.rb +22 -22
- metadata +1 -1
data/lib/emailvision/api.rb
CHANGED
@@ -79,30 +79,30 @@ module Emailvision
|
|
79
79
|
# == Sanitize parameters ==
|
80
80
|
parameters = Emailvision::Tools.sanitize_parameters(parameters)
|
81
81
|
|
82
|
-
# == Build uri ==
|
83
|
-
uri = base_uri + method
|
84
|
-
if parameters[:uri]
|
85
|
-
uri += token ? "/#{token}/" : '/'
|
86
|
-
uri += (parameters[:uri].respond_to?(:join) ? parameters[:uri] : [parameters[:uri]]).compact.join '/'
|
87
|
-
parameters.delete :uri
|
88
|
-
elsif parameters[:body]
|
89
|
-
uri += token ? "/#{token}/" : '/'
|
90
|
-
else
|
91
|
-
parameters[:token] = token
|
92
|
-
end
|
93
|
-
|
94
|
-
# == Build body ==
|
95
|
-
# 1. Extract body from parameters
|
96
|
-
body = parameters[:body] || {}
|
97
|
-
parameters.delete :body
|
98
|
-
# 2. Camelize all keys
|
99
|
-
body = Emailvision::Tools.r_camelize body
|
100
|
-
# 3. Convert to xml
|
101
|
-
body_xml = Emailvision::Tools.to_xml_as_is body
|
102
|
-
|
103
|
-
# == Send request ==
|
104
82
|
retries = 2
|
105
83
|
begin
|
84
|
+
# == Build uri ==
|
85
|
+
uri = base_uri + method
|
86
|
+
if parameters[:uri]
|
87
|
+
uri += token ? "/#{token}/" : '/'
|
88
|
+
uri += (parameters[:uri].respond_to?(:join) ? parameters[:uri] : [parameters[:uri]]).compact.join '/'
|
89
|
+
parameters.delete :uri
|
90
|
+
elsif parameters[:body]
|
91
|
+
uri += token ? "/#{token}/" : '/'
|
92
|
+
else
|
93
|
+
parameters[:token] = token
|
94
|
+
end
|
95
|
+
|
96
|
+
# == Build body ==
|
97
|
+
# 1. Extract body from parameters
|
98
|
+
body = parameters[:body] || {}
|
99
|
+
parameters.delete :body
|
100
|
+
# 2. Camelize all keys
|
101
|
+
body = Emailvision::Tools.r_camelize body
|
102
|
+
# 3. Convert to xml
|
103
|
+
body_xml = Emailvision::Tools.to_xml_as_is body
|
104
|
+
|
105
|
+
# == Send request ==
|
106
106
|
logger.send "#{uri} with query : #{parameters} and body : #{body}"
|
107
107
|
response = self.class.send http_verb, uri, :query => parameters, :body => body_xml, :timeout => 30
|
108
108
|
|