Class: UEUser
Instance Method Summary collapse
-
#add_connection(connection_name, service_scheme, service_access_token) ⇒ UEConnection
Adds a connection to the current user.
-
#initialize(uri_or_key, secret = nil) ⇒ UEUser
constructor
URI: user://e9759590-54ef-4cd3-a01c-cb2241ddd812:1aee1a25-e0c4-4036-a8fd-4d41adc8611b@ COMB: key,secret Constructor.
-
#list_connections ⇒ Connection
List connections for current user.
-
#remove_connection(connection_name) ⇒ Boolean
Removes a connection from a user.
-
#test_connection(service_uri) ⇒ Boolean
Tests a connection to a connector.
-
#uri ⇒ Object
Getters.
- #user_key ⇒ Object
- #user_secret ⇒ Object
Constructor Details
#initialize(uri_or_key, secret = nil) ⇒ UEUser
URI: user://e9759590-54ef-4cd3-a01c-cb2241ddd812:1aee1a25-e0c4-4036-a8fd-4d41adc8611b@ COMB: key,secret Constructor
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/models/UEUser.rb', line 11 def initialize(uri_or_key, secret=nil) if secret then # key,secret format @user_key, @user_secret = [uri_or_key, secret] @uri = "user://#{@user_key}:#{@user_secret}@" else # uri format @uri = uri_or_key @user_key, @user_secret = uri_or_key.match(/user:\/\/(.+):(.+)@/).captures end end |
Instance Method Details
#add_connection(connection_name, service_scheme, service_access_token) ⇒ UEConnection
Adds a connection to the current user
/
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/models/UEUser.rb', line 46 def add_connection(connection_name, service_scheme, service_access_token) response = UERequest.fetch "connection/add",{ user: @user_key, pass: @user_secret, form: { uri: "#{service_scheme}://#{service_access_token}@#{service_scheme}.com", name: connection_name } } (response[:status] == 200) || response end |
#list_connections ⇒ Connection
List connections for current user
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/models/UEUser.rb', line 65 def list_connections() response = UERequest.fetch "connection/list",{ user: @user_key, pass: @user_secret, } if !response[:connections] return [] end connections = [] response[:connections].each do |cname,v| connections.push(UEConnection.new cname, response[:connections][cname.to_sym][:uri], self) end connections end |
#remove_connection(connection_name) ⇒ Boolean
Removes a connection from a user
92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/models/UEUser.rb', line 92 def remove_connection(connection_name) response = UERequest.fetch "connection/remove",{ user: @user_key, pass: @user_secret, form:{ name: connection_name } } response[:status] == 200 end |
#test_connection(service_uri) ⇒ Boolean
Tests a connection to a connector
113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/models/UEUser.rb', line 113 def test_connection(service_uri) response = UERequest.fetch "connection/test",{ user: @user_key, pass: @user_secret, form:{ uri: service_uri } } response[:Status][:""][:status] == 200 end |
#user_key ⇒ Object
29 30 31 |
# File 'lib/models/UEUser.rb', line 29 def user_key @user_key end |
#user_secret ⇒ Object
33 34 35 |
# File 'lib/models/UEUser.rb', line 33 def user_secret @user_secret end |