Class: Readiness::SupportSuperFormProcessor::USGovSetOrgASE
- Defined in:
- lib/support_readiness/support_super_form_processor/usgov_set_org_ase.rb
Overview
Defines the class USGovSetOrgASE within the module Zendesk.
Class Method Summary collapse
-
.agent ⇒ Object
Sets the global variable agent.
-
.agent_id ⇒ Object
Sets the global variable agent_id.
-
.agent_info ⇒ Object
Returns the value to set the organization field to.
-
.agent_valid? ⇒ Boolean
Determines if the agent to use is valid.
-
.approved_requester? ⇒ Boolean
Determines if the requester is authorized to make the request.
-
.approved_requester_list ⇒ Object
Sets the global variable approved_requester_list.
- .bad_requester ⇒ Object
- .bad_requester_message ⇒ Object
-
.determine_approved_requesters ⇒ Object
Determines the list of approved requesters.
- .invalid_agent ⇒ Object
-
.invalid_user_message ⇒ Object
Returns the issue description for an invalid user.
-
.message ⇒ Object
Returns the issue description.
-
.org ⇒ Object
Sets the global variable org.
- .org_does_not_exist ⇒ Object
-
.org_does_not_exist_message ⇒ Object
Returns the issue description.
-
.org_id ⇒ Object
Sets the global variable org_id.
-
.process!(gitlab_client, gitlab_admin_client, zendesk_client, redis_client) ⇒ Object
Process setting an ASE on a US Government organization.
-
.project ⇒ Object
Sets the global variable project.
-
.requester ⇒ Object
Sets the global variable requester.
-
.requester_email ⇒ Object
Sets the global variable requester_email.
-
.team ⇒ Object
Sets the global variable team.
Methods inherited from Client
auth_error, bad_request_error, convert_actions, convert_conditions, convert_standard_names_to_ids, convert_ticket_form_agent_conditions, convert_ticket_form_brands, convert_ticket_form_end_user_conditions, convert_ticket_form_names_to_ids, convert_view_names_to_ids, convert_view_restrictions, covert_ticket_form_field_ids, create_package!, erb_renderer, handle_request_error, not_found_error, not_processible_error, put_into_archive, recursively_deflate_directory, timestamp_filename, to_clean_json, to_clean_json_with_key, to_hash, to_nearly_clean_json, to_nearly_clean_json_with_key, to_param_string, write_entries
Class Method Details
.agent ⇒ Object
Sets the global variable agent
187 188 189 |
# File 'lib/support_readiness/support_super_form_processor/usgov_set_org_ase.rb', line 187 def self.agent @agent ||= Readiness::Zendesk::Users.find(@zendesk_client, agent_id) end |
.agent_id ⇒ Object
Sets the global variable agent_id
196 197 198 |
# File 'lib/support_readiness/support_super_form_processor/usgov_set_org_ase.rb', line 196 def self.agent_id @agent_id ||= ENV.fetch('ZENDESK_AGENT_ID') end |
.agent_info ⇒ Object
Returns the value to set the organization field to
122 123 124 125 126 |
# File 'lib/support_readiness/support_super_form_processor/usgov_set_org_ase.rb', line 122 def self.agent_info return '' if agent_id == 'None' agent.id.to_s end |
.agent_valid? ⇒ Boolean
Determines if the agent to use is valid
107 108 109 110 111 112 113 114 115 |
# File 'lib/support_readiness/support_super_form_processor/usgov_set_org_ase.rb', line 107 def self.agent_valid? return true if agent_id == 'None' return false if agent.is_a? Hash return false if agent.role == 'end-user' return false if agent.suspended return false if [360008074111, 360009109092].include? agent.custom_role_id true end |
.approved_requester? ⇒ Boolean
Determines if the requester is authorized to make the request
73 74 75 76 77 |
# File 'lib/support_readiness/support_super_form_processor/usgov_set_org_ase.rb', line 73 def self.approved_requester? return true if approved_requester_list.map { |t| t['email'] }.include? requester_email false end |
.approved_requester_list ⇒ Object
Sets the global variable approved_requester_list
84 85 86 |
# File 'lib/support_readiness/support_super_form_processor/usgov_set_org_ase.rb', line 84 def self.approved_requester_list @approved_requester_list ||= determine_approved_requesters end |
.bad_requester ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/support_readiness/support_super_form_processor/usgov_set_org_ase.rb', line 41 def self.bad_requester issue = Readiness::GitLab::Issues.new issue.title = 'Invalid Request - Not approved to make this request' issue.description = create = Readiness::GitLab::Issues.create!(@gitlab_client, project, issue) puts "Issue created: #{create.web_url}" exit 0 end |
.bad_requester_message ⇒ Object
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
# File 'lib/support_readiness/support_super_form_processor/usgov_set_org_ase.rb', line 250 def self. <<~STRING ## Invalid Request - Not approved to make this request Greetings @#{requester.username} ! We received a request from you recently to set an ASE on a Zendesk US Goverment organization, however this type of request can only be made by specifc approved persons. Please contact one fo the following via [#support_leadership](https://gitlab.enterprise.slack.com/archives/C01F9S37AKT) to discuss this request: #{approved_requester_list.map { |a| "- #{a['email']}" }.join("\n")} /label ~"AutomatedRequests::Invalid Permissions" ~"Stage::Blocked" ~administrative ~p4 ~zendesk ~"Customer::Support" /iteration [cadence:"Customer Support Operations"] --current /assign @#{requester.username} STRING end |
.determine_approved_requesters ⇒ Object
Determines the list of approved requesters
93 94 95 96 97 98 99 100 |
# File 'lib/support_readiness/support_super_form_processor/usgov_set_org_ase.rb', line 93 def self.determine_approved_requesters members = [] directors = team.select { |t| t['title'] =~ /Director/ } members += directors.select { |t| t['region'] =~ /AMER/ } managers = team.select { |t| t['title'] =~ /Manager/ } members += managers.select { |t| t['zendesk']['us-federal']['role'] == 'Support Managers' } members end |
.invalid_agent ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/support_readiness/support_super_form_processor/usgov_set_org_ase.rb', line 59 def self.invalid_agent issue = Readiness::GitLab::Issues.new issue.title = 'Invalid Request - Invalid agent provided' issue.description = create = Readiness::GitLab::Issues.create!(@gitlab_client, project, issue) puts "Issue created: #{create.web_url}" exit 0 end |
.invalid_user_message ⇒ Object
Returns the issue description for an invalid user
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
# File 'lib/support_readiness/support_super_form_processor/usgov_set_org_ase.rb', line 275 def self. <<~STRING ## Set an Assigned Support Engineer for a Zendesk US Goverment organization - #{org.id} Greetings @#{requester.username} ! We were unable to set the ASE on the Zendesk US Goverment organization at this time, as we were encountered one of the following issues with the Zendesk US Government agent with the ID of #{agent_id}: - The agent does not exist - The agent does not have write permissions on tickets - The agent is suspended - The agent is an end-user Please review the Zendesk agent you were wanting to use once more and file a new submission. If you need assistance in locating the agent's ID, please ask in the Slack channel [#support_operations](https://gitlab.slack.com/archives/C018ZGZAMPD) /label ~"AutomatedRequests::Set Org ASE" ~"Stage::Blocked" ~administrative ~p4 ~zendesk ~"Customer::Support" /iteration [cadence:"Customer Support Operations"] --current /assign @#{requester.username} STRING end |
.message ⇒ Object
Returns the issue description
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
# File 'lib/support_readiness/support_super_form_processor/usgov_set_org_ase.rb', line 205 def self. <<~STRING ## Set an Assigned Support Engineer for a Zendesk US Goverment organization - #{org.id} Greetings @#{requester.username} ! We have set the Assigned Support Engineer of the Zendesk US Goverment organization to that of #{agent_id} at this time. If that is not the ID of the agent you were intending to use, please review the Zendesk agent you were wanting to use once more and file a new submission. If you need assistance in locating the agent's ID, please ask in the Slack channel [#support_operations](https://gitlab.slack.com/archives/C018ZGZAMPD) /label ~"AutomatedRequests::Set Org ASE" ~"Stage::Completed" ~administrative ~p4 ~zendesk ~"Customer::Support" /iteration [cadence:"Customer Support Operations"] --current /assign @#{requester.username} STRING end |
.org ⇒ Object
Sets the global variable org
169 170 171 |
# File 'lib/support_readiness/support_super_form_processor/usgov_set_org_ase.rb', line 169 def self.org @org ||= Readiness::Zendesk::Organizations.find(@zendesk_client, org_id) end |
.org_does_not_exist ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/support_readiness/support_super_form_processor/usgov_set_org_ase.rb', line 50 def self.org_does_not_exist issue = Readiness::GitLab::Issues.new issue.title = 'Invalid Request - Organization Not Found' issue.description = create = Readiness::GitLab::Issues.create!(@gitlab_client, project, issue) puts "Issue created: #{create.web_url}" exit 0 end |
.org_does_not_exist_message ⇒ Object
Returns the issue description
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 |
# File 'lib/support_readiness/support_super_form_processor/usgov_set_org_ase.rb', line 230 def self. <<~STRING ## Invalid Request Organization Not Found Greetings @#{requester.username} ! We received a request from you recently, however the organization ID given #{org_id} is not a valid Zendesk US Goverment Organization ID. As such, we are not able to proceed. Please review the Zendesk US Goverment organization you were wanting to use once more and file a new submission. If you need assistance in locating the organization's ID, please ask in the Slack channel [#support_operations](https://gitlab.slack.com/archives/C018ZGZAMPD) /label ~"AutomatedRequests::Invalid Organization" ~"Stage::Blocked" ~administrative ~p4 ~zendesk ~"Customer::Support" /iteration [cadence:"Customer Support Operations"] --current /assign @#{requester.username} STRING end |
.org_id ⇒ Object
Sets the global variable org_id
178 179 180 |
# File 'lib/support_readiness/support_super_form_processor/usgov_set_org_ase.rb', line 178 def self.org_id @org_id ||= ENV.fetch('ORG_ID') end |
.process!(gitlab_client, gitlab_admin_client, zendesk_client, redis_client) ⇒ Object
Process setting an ASE on a US Government organization
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/support_readiness/support_super_form_processor/usgov_set_org_ase.rb', line 18 def self.process!(gitlab_client, gitlab_admin_client, zendesk_client, redis_client) @gitlab_client = gitlab_client @gitlab_admin_client = gitlab_admin_client @zendesk_client = zendesk_client @redis_client = redis_client requester bad_requester unless approved_requester? org_does_not_exist if org.is_a? Hash invalid_agent unless agent_valid? new_org = Readiness::Zendesk::Organizations.new new_org.id = org.id new_org.organization_fields = { "assigned_se" => agent_info } Readiness::Zendesk::Organizations.update!(@zendesk_client, new_org) issue = Readiness::GitLab::Issues.new issue.title = "Set an Assigned Support Engineer for a Zendesk US Goverment organization - #{org.id}" issue.description = create = Readiness::GitLab::Issues.create!(@gitlab_client, project, issue) puts "Issue created: #{create.web_url}" exit 0 end |
.project ⇒ Object
Sets the global variable project
160 161 162 |
# File 'lib/support_readiness/support_super_form_processor/usgov_set_org_ase.rb', line 160 def self.project @project ||= Readiness::GitLab::Projects.find!(@gitlab_client, 68534119) end |
.requester ⇒ Object
Sets the global variable requester
142 143 144 |
# File 'lib/support_readiness/support_super_form_processor/usgov_set_org_ase.rb', line 142 def self.requester @requester ||= Readiness::SupportSuperFormProcessor::Shared.gitlab_user_check(@gitlab_admin_client, requester_email) end |
.requester_email ⇒ Object
Sets the global variable requester_email
151 152 153 |
# File 'lib/support_readiness/support_super_form_processor/usgov_set_org_ase.rb', line 151 def self.requester_email @requester_email ||= ENV.fetch('REQUESTER_EMAIL') end |