Class: Bluevia::Directory
- Inherits:
-
BaseClient
- Object
- BaseClient
- Bluevia::Directory
- Defined in:
- lib/bluevia/directory.rb
Overview
This class is in charge of access Bluevia Directory API
Constant Summary collapse
- USER_PROFILE =
@@valid_methods[0]
- USER_ACCESS_INFO =
@@valid_methods[1]
- USER_TERMINAL_INFO =
@@valid_methods[2]
- BASEPATH_API =
Base Path for Directory API
"/Directory"
- @@valid_methods =
Valid methods included in the API
%W[Profile AccessInfo TerminalInfo]
Constants inherited from BaseClient
BaseClient::BASEPATH, BaseClient::BASEPATH_COMMERCIAL, BaseClient::BASEPATH_SANDBOX, BaseClient::BASEURI, BaseClient::DEFAULT_PARAMS, BaseClient::PROXY
Instance Attribute Summary
Attributes inherited from BaseClient
Instance Method Summary collapse
-
#get_user_info(user, type = nil) ⇒ Object
This method is in charge of retrieving user information [user] User identifier, a valid access token [type] information to be retrieved.
-
#initialize(params = nil) ⇒ Directory
constructor
A new instance of Directory.
Methods inherited from BaseClient
#DELETE, #GET, #POST, #[]=, #authorized_client, create_rest_client, #get_basepath, #get_headers, #include_params, #set_http_client, #set_path, #set_timeout
Methods included from BlueviaLogger
#create_logger, #log_level=, #logger, #logger=
Constructor Details
#initialize(params = nil) ⇒ Directory
Returns a new instance of Directory.
26 27 28 |
# File 'lib/bluevia/directory.rb', line 26 def initialize(params = nil) super(params) end |
Instance Method Details
#get_user_info(user, type = nil) ⇒ Object
This method is in charge of retrieving user information
- user
-
User identifier, a valid access token
- type
-
information to be retrieved. Can be one or more @@valid_methods.
Raises RuntimeError if any error occurred while invoking the request
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/bluevia/directory.rb', line 37 def get_user_info(user, type = nil) Utils.check_attribute user, "User cannot be null" unless type.nil? if (type.instance_of?(Array)) if type.length == 1 if @@valid_methods.to_a.include?(type[0]) _type = "/" + type[0] else raise SyntaxError, "Type not allowed. #{@@valid_methods} only." end else _type = "" data_sets = type.join(',') end elsif (type.instance_of?(String)) if @@valid_methods.to_a.include?(type) _type = "/User" + type else raise SyntaxError, "Type not allowed. #{@@valid_methods} only." end else raise SyntaxError, "Invalid type" end else _type = "" end # Include the alias prefix in URL identifier = CGI::escape("alias:#{user}") params = Hash.new unless data_sets.nil? params[:dataSets] = data_sets end # returns the response body GET("#{get_basepath}/#{identifier}/UserInfo#{_type}", params, nil) end |