Class: RubyCleverdome::Client
- Inherits:
-
Object
- Object
- RubyCleverdome::Client
- Defined in:
- lib/ruby-cleverdome.rb
Instance Method Summary collapse
- #add_document_tag(session_id, doc_guid, tag_text) ⇒ Object
- #auth(provider, uid, private_key_file, certificate_file) ⇒ Object
- #get_document_tags(session_id, doc_guid) ⇒ Object
- #get_document_template(session_id, doc_guid) ⇒ Object
- #get_document_type(session_id, doc_guid) ⇒ Object
- #get_template_types(session_id, app_id, template_id) ⇒ Object
- #get_templates(session_id, app_id) ⇒ Object
-
#initialize(sso_endpoint, widgets_path) ⇒ Client
constructor
A new instance of Client.
- #remove_document_tag(session_id, doc_guid, tag_id) ⇒ Object
- #set_document_template_type(session_id, doc_guid, template_id, type_id) ⇒ Object
- #upload_file(session_id, app_id, file_path) ⇒ Object
- #upload_file_binary(session_id, app_id, filename, binary_data) ⇒ Object
- #widgets_call(method, locals) ⇒ Object
Constructor Details
#initialize(sso_endpoint, widgets_path) ⇒ Client
Returns a new instance of Client.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ruby-cleverdome.rb', line 11 def initialize(sso_endpoint, ) = @sso_client = Savon.client( endpoint: sso_endpoint, namespace: 'urn:up-us:sso-service:service:v1', #proxy: 'http://127.0.0.1:8888', # log_level: :debug ) = Savon.client( wsdl: + '?wsdl', #proxy: 'http://127.0.0.1:8888', element_form_default: :unqualified, # log_level: :debug ) end |
Instance Method Details
#add_document_tag(session_id, doc_guid, tag_text) ⇒ Object
180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/ruby-cleverdome.rb', line 180 def add_document_tag(session_id, doc_guid, tag_text) resp_doc = ( :add_document_tag, { 'sessionID' => session_id, 'documentGuid' => doc_guid, 'tagName' => tag_text }).doc check_body(resp_doc) end |
#auth(provider, uid, private_key_file, certificate_file) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/ruby-cleverdome.rb', line 28 def auth(provider, uid, private_key_file, certificate_file) req = create_request(provider, uid) req = sign_request(req, private_key_file, certificate_file) resp = saml_call(req) resp_doc = Nokogiri::XML::Document.parse(resp) resp_doc.remove_namespaces! check_resp(resp_doc) session_id = resp_doc.xpath('//Assertion//AttributeStatement//Attribute[@Name="SessionID"]//AttributeValue')[0].content session_id end |
#get_document_tags(session_id, doc_guid) ⇒ Object
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/ruby-cleverdome.rb', line 162 def (session_id, doc_guid) resp_doc = ( :get_document_tags, { 'sessionID' => session_id, 'documentGuid' => doc_guid }).doc check_body(resp_doc) hash = resp_doc.xpath('//ReturnValue')[0] .element_children.each_with_object(Hash.new) do |e, h| h[Integer(e.at('ID').content)] = e.at('Name').content end hash end |
#get_document_template(session_id, doc_guid) ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/ruby-cleverdome.rb', line 104 def get_document_template(session_id, doc_guid) resp_doc = ( :get_document_template, { 'sessionID' => session_id, 'documentGuid' => doc_guid }).doc check_body(resp_doc) return [Integer(resp_doc.xpath('//ReturnValue/ID')[0].content), resp_doc.xpath('//ReturnValue/Name')[0].content] end |
#get_document_type(session_id, doc_guid) ⇒ Object
136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/ruby-cleverdome.rb', line 136 def get_document_type(session_id, doc_guid) resp_doc = ( :get_document_type, { 'sessionID' => session_id, 'documentGuid' => doc_guid }).doc check_body(resp_doc) return [Integer(resp_doc.xpath('//ReturnValue/ID')[0].content), resp_doc.xpath('//ReturnValue/Name')[0].content] end |
#get_template_types(session_id, app_id, template_id) ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/ruby-cleverdome.rb', line 117 def get_template_types(session_id, app_id, template_id) resp_doc = ( :get_document_types, { 'sessionID' => session_id, 'templateID' => template_id, 'applicationID' => app_id }).doc check_body(resp_doc) hash = resp_doc.xpath('//ReturnValue')[0] .element_children.each_with_object(Hash.new) do |e, h| h[Integer(e.at('ID').content)] = e.at('Name').content end hash end |
#get_templates(session_id, app_id) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/ruby-cleverdome.rb', line 86 def get_templates(session_id, app_id) resp_doc = ( :get_document_templates, { 'sessionID' => session_id, 'applicationID' => app_id }).doc check_body(resp_doc) hash = resp_doc.xpath('//ReturnValue')[0] .element_children.each_with_object(Hash.new) do |e, h| h[Integer(e.at('ID').content)] = e.at('Name').content end hash end |
#remove_document_tag(session_id, doc_guid, tag_id) ⇒ Object
192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/ruby-cleverdome.rb', line 192 def remove_document_tag(session_id, doc_guid, tag_id) resp_doc = ( :remove_document_tag, { 'sessionID' => session_id, 'documentGuid' => doc_guid, 'tagID' => tag_id }).doc check_body(resp_doc) end |
#set_document_template_type(session_id, doc_guid, template_id, type_id) ⇒ Object
149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/ruby-cleverdome.rb', line 149 def set_document_template_type(session_id, doc_guid, template_id, type_id) resp_doc = ( :set_document_template, { 'sessionID' => session_id, 'documentGuid' => doc_guid, 'templateID' => template_id, 'documentTypeID' => type_id }).doc check_body(resp_doc) end |
#upload_file(session_id, app_id, file_path) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/ruby-cleverdome.rb', line 50 def upload_file(session_id, app_id, file_path) data, headers = Multipart::Post.prepare_query( "sessionID" => session_id, "file" => File.open(file_path, 'rb'), 'applicationID' => app_id ) response = .call( :upload_file, :attributes => { 'xmlns' => 'http://tempuri.org/' }, message: { inputStream: Base64.encode64(data) }) response.body[:upload_file_response][:upload_file_result] end |
#upload_file_binary(session_id, app_id, filename, binary_data) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/ruby-cleverdome.rb', line 68 def upload_file_binary(session_id, app_id, filename, binary_data) data, headers = Multipart::Post.prepare_query( "sessionID" => session_id, "file" => { 'filename' => filename, 'data' => binary_data }, 'applicationID' => app_id ) response = .call( :upload_file, :attributes => { 'xmlns' => 'http://tempuri.org/' }, message: { inputStream: Base64.encode64(data) }) response.body[:upload_file_response][:upload_file_result] end |
#widgets_call(method, locals) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/ruby-cleverdome.rb', line 42 def (method, locals) response = .call( method, :attributes => { 'xmlns' => 'http://tempuri.org/' }, message: locals ) end |