Module: SOF::MCM
- Defined in:
- lib/sof/mcm.rb,
lib/sof/mcm/client.rb,
lib/sof/mcm/request.rb,
lib/sof/mcm/version.rb,
lib/sof/mcm/test_helper.rb
Defined Under Namespace
Modules: TestHelper Classes: Client, Error, Get, Put, Request
Constant Summary collapse
- VERSION =
"0.1.1"
Class Method Summary collapse
-
.assign(edipi, application:, env: ENV, **kwargs) ⇒ Object
Assigns a user to an application.
-
.client(env = ENV) ⇒ MCM::Client
Returns a MCM::Client instance.
Class Method Details
.assign(edipi, application:, env: ENV, **kwargs) ⇒ Object
Assigns a user to an application
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/sof/mcm.rb', line 26 def assign(edipi, application:, env: ENV, **kwargs) comment = kwargs.fetch(:comment, "Assigning user") config = kwargs.except(:comment) client = client(env, **config) body = client.applications.body parsed_body = JSON.parse(body) results = parsed_body.fetch("results") application_data = results.find { |app| app["id"] == application } || {} application_uid = application_data["uid"] if application_uid client.assign(edipi, application_uid:, comment:) else raise Error, "Unable to find application UID for #{application}" end rescue JSON::ParserError raise Error, "Unable to parse JSON response from MCM:\n#{body}" rescue KeyError raise Error, "Missing 'results' key in response from MCM:\n#{body}" end |
.client(env = ENV) ⇒ MCM::Client
Returns a MCM::Client instance
17 18 19 |
# File 'lib/sof/mcm.rb', line 17 def client(env = ENV, **) Client.new(env, **) end |