ruby-cleverdome 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ruby-cleverdome.rb +89 -4
- metadata +1 -1
data/lib/ruby-cleverdome.rb
CHANGED
@@ -14,12 +14,12 @@ module RubyCleverdome
|
|
14
14
|
@sso_client = Savon.client(
|
15
15
|
endpoint: sso_endpoint,
|
16
16
|
namespace: 'urn:up-us:sso-service:service:v1',
|
17
|
-
proxy: 'http://127.0.0.1:8888',
|
17
|
+
# proxy: 'http://127.0.0.1:8888',
|
18
18
|
# log_level: :debug
|
19
19
|
)
|
20
20
|
@widgets_client = Savon.client(
|
21
21
|
wsdl: widgets_path + '?wsdl',
|
22
|
-
proxy: 'http://127.0.0.1:8888',
|
22
|
+
# proxy: 'http://127.0.0.1:8888',
|
23
23
|
element_form_default: :unqualified,
|
24
24
|
# log_level: :debug
|
25
25
|
)
|
@@ -43,7 +43,7 @@ module RubyCleverdome
|
|
43
43
|
response = @widgets_client.call(
|
44
44
|
method,
|
45
45
|
:attributes => { 'xmlns' => 'http://tempuri.org/' },
|
46
|
-
message:
|
46
|
+
message: locals
|
47
47
|
)
|
48
48
|
end
|
49
49
|
|
@@ -65,6 +65,82 @@ module RubyCleverdome
|
|
65
65
|
response.body[:upload_file_response][:upload_file_result]
|
66
66
|
end
|
67
67
|
|
68
|
+
def get_templates(session_id, app_id)
|
69
|
+
resp_doc = widgets_call(
|
70
|
+
:get_document_templates,
|
71
|
+
{
|
72
|
+
'sessionID' => session_id,
|
73
|
+
'applicationID' => app_id
|
74
|
+
}).doc
|
75
|
+
|
76
|
+
check_body(resp_doc)
|
77
|
+
|
78
|
+
hash = resp_doc.xpath('//ReturnValue')[0]
|
79
|
+
.element_children.each_with_object(Hash.new) do |e, h|
|
80
|
+
h[Integer(e.at('ID').content)] = e.at('Name').content
|
81
|
+
end
|
82
|
+
|
83
|
+
hash
|
84
|
+
end
|
85
|
+
|
86
|
+
def get_document_template(session_id, doc_guid)
|
87
|
+
resp_doc = widgets_call(
|
88
|
+
:get_document_template,
|
89
|
+
{
|
90
|
+
'sessionID' => session_id,
|
91
|
+
'documentGuid' => doc_guid
|
92
|
+
}).doc
|
93
|
+
|
94
|
+
check_body(resp_doc)
|
95
|
+
|
96
|
+
return [Integer(resp_doc.xpath('//ReturnValue/ID')[0].content), resp_doc.xpath('//ReturnValue/Name')[0].content]
|
97
|
+
end
|
98
|
+
|
99
|
+
def get_template_types(session_id, app_id, template_id)
|
100
|
+
resp_doc = widgets_call(
|
101
|
+
:get_document_types,
|
102
|
+
{
|
103
|
+
'sessionID' => session_id,
|
104
|
+
'templateID' => template_id,
|
105
|
+
'applicationID' => app_id
|
106
|
+
}).doc
|
107
|
+
|
108
|
+
check_body(resp_doc)
|
109
|
+
|
110
|
+
hash = resp_doc.xpath('//ReturnValue')[0]
|
111
|
+
.element_children.each_with_object(Hash.new) do |e, h|
|
112
|
+
h[Integer(e.at('ID').content)] = e.at('Name').content
|
113
|
+
end
|
114
|
+
|
115
|
+
hash
|
116
|
+
end
|
117
|
+
|
118
|
+
def get_document_type(session_id, doc_guid)
|
119
|
+
resp_doc = widgets_call(
|
120
|
+
:get_document_type,
|
121
|
+
{
|
122
|
+
'sessionID' => session_id,
|
123
|
+
'documentGuid' => doc_guid
|
124
|
+
}).doc
|
125
|
+
|
126
|
+
check_body(resp_doc)
|
127
|
+
|
128
|
+
return [Integer(resp_doc.xpath('//ReturnValue/ID')[0].content), resp_doc.xpath('//ReturnValue/Name')[0].content]
|
129
|
+
end
|
130
|
+
|
131
|
+
def set_document_template_type(session_id, doc_guid, template_id, type_id)
|
132
|
+
resp_doc = widgets_call(
|
133
|
+
:set_document_template,
|
134
|
+
{
|
135
|
+
'sessionID' => session_id,
|
136
|
+
'documentGuid' => doc_guid,
|
137
|
+
'templateID' => template_id,
|
138
|
+
'documentTypeID' => type_id
|
139
|
+
}).doc
|
140
|
+
|
141
|
+
check_body(resp_doc)
|
142
|
+
end
|
143
|
+
|
68
144
|
def create_request(provider, uid)
|
69
145
|
builder = Nokogiri::XML::Builder.new do |xml|
|
70
146
|
xml['s'].Envelope('xmlns:s' => 'http://schemas.xmlsoap.org/soap/envelope/') {
|
@@ -143,6 +219,15 @@ module RubyCleverdome
|
|
143
219
|
end
|
144
220
|
end
|
145
221
|
|
146
|
-
|
222
|
+
def check_body(resp)
|
223
|
+
resp.remove_namespaces!
|
224
|
+
status = resp.xpath('//Result')[0].content
|
225
|
+
|
226
|
+
if status.casecmp('success') != 0
|
227
|
+
raise resp.xpath('//Message')[0].content
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
private :create_request, :sign_request, :saml_call, :check_resp, :check_body
|
147
232
|
end
|
148
233
|
end
|