Class: UcbRailsUser::UserUcPathService::UcPathClient
- Inherits:
-
Object
- Object
- UcbRailsUser::UserUcPathService::UcPathClient
- Defined in:
- app/models/ucb_rails_user/user_uc_path_service.rb
Instance Attribute Summary collapse
-
#app_id ⇒ Object
readonly
Returns the value of attribute app_id.
-
#app_key ⇒ Object
readonly
Returns the value of attribute app_key.
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
Instance Method Summary collapse
- #fetch_employee_data(ldap_uid) ⇒ Object
-
#initialize ⇒ UcPathClient
constructor
A new instance of UcPathClient.
Constructor Details
#initialize ⇒ UcPathClient
Returns a new instance of UcPathClient.
54 55 56 57 58 59 60 |
# File 'app/models/ucb_rails_user/user_uc_path_service.rb', line 54 def initialize credentials = Rails.application.credentials.ucpath || Rails.application.credentials.hcm @app_id = credentials&.fetch(:app_id) @app_key = credentials&.fetch(:app_key) @endpoint = credentials&.fetch(:endpoint) end |
Instance Attribute Details
#app_id ⇒ Object (readonly)
Returns the value of attribute app_id.
52 53 54 |
# File 'app/models/ucb_rails_user/user_uc_path_service.rb', line 52 def app_id @app_id end |
#app_key ⇒ Object (readonly)
Returns the value of attribute app_key.
52 53 54 |
# File 'app/models/ucb_rails_user/user_uc_path_service.rb', line 52 def app_key @app_key end |
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
52 53 54 |
# File 'app/models/ucb_rails_user/user_uc_path_service.rb', line 52 def endpoint @endpoint end |
Instance Method Details
#fetch_employee_data(ldap_uid) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'app/models/ucb_rails_user/user_uc_path_service.rb', line 62 def fetch_employee_data(ldap_uid) if [app_id, app_key, endpoint].any?(&:blank?) Rails.logger.warn return nil end response = Faraday.get("#{endpoint}/employees/#{ldap_uid}") do |req| req.params["id-type"] = "campus-uid" req.headers["Accept"] = "application/json" req.headers["app_id"] = app_id req.headers["app_key"] = app_key end parse_response(response)&.first end |