Class: RubyCleverdome::Client
- Inherits:
-
Object
- Object
- RubyCleverdome::Client
- Defined in:
- lib/ruby-cleverdome.rb
Instance Method Summary collapse
- #auth(provider, uid, private_key_file, certificate_file) ⇒ Object
-
#initialize(sso_endpoint, widgets_path) ⇒ Client
constructor
A new instance of Client.
- #upload_file(session_id, app_id, file_path) ⇒ Object
- #widgets_call(method, locals) ⇒ Object
Constructor Details
#initialize(sso_endpoint, widgets_path) ⇒ 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
#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 |
#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), '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: { sessionID: 'EE282ABB-7BC3-42D3-BE98-9F8CE4217A12' } .merge(locals) ) end |