Class: Readiness::SupportSuperFormProcessor::GlobalSetOrgASE
- Defined in:
- lib/support_readiness/support_super_form_processor/global_set_org_ase.rb
Overview
Defines the class GlobalSetOrgASE 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 Global 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
185 186 187 |
# File 'lib/support_readiness/support_super_form_processor/global_set_org_ase.rb', line 185 def self.agent @agent ||= Readiness::Zendesk::Users.find(@zendesk_client, agent_id) end |
.agent_id ⇒ Object
Sets the global variable agent_id
194 195 196 |
# File 'lib/support_readiness/support_super_form_processor/global_set_org_ase.rb', line 194 def self.agent_id @agent_id ||= ENV.fetch('ZENDESK_AGENT_ID') end |
.agent_info ⇒ Object
Returns the value to set the organization field to
120 121 122 123 124 |
# File 'lib/support_readiness/support_super_form_processor/global_set_org_ase.rb', line 120 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
105 106 107 108 109 110 111 112 113 |
# File 'lib/support_readiness/support_super_form_processor/global_set_org_ase.rb', line 105 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 [360004984553, 12510471332508].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/global_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/global_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/global_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
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 |
# File 'lib/support_readiness/support_super_form_processor/global_set_org_ase.rb', line 248 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 Global 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 |
# File 'lib/support_readiness/support_super_form_processor/global_set_org_ase.rb', line 93 def self.determine_approved_requesters members = [] members += team.select { |t| t['title'] =~ /Director/ } members += team.select { |t| t['title'] =~ /Manager/ } members end |
.invalid_agent ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/support_readiness/support_super_form_processor/global_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
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 |
# File 'lib/support_readiness/support_super_form_processor/global_set_org_ase.rb', line 273 def self. <<~STRING ## Set an Assigned Support Engineer for a Zendesk Global organization - #{org.id} Greetings @#{requester.username} ! We were unable to set the ASE on the Zendesk Global organization at this time, as we were encountered one of the following issues with the Zendesk Global 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
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/support_readiness/support_super_form_processor/global_set_org_ase.rb', line 203 def self. <<~STRING ## Set an Assigned Support Engineer for a Zendesk Global organization - #{org.id} Greetings @#{requester.username} ! We have set the Assigned Support Engineer of the Zendesk Global 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
167 168 169 |
# File 'lib/support_readiness/support_super_form_processor/global_set_org_ase.rb', line 167 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/global_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
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
# File 'lib/support_readiness/support_super_form_processor/global_set_org_ase.rb', line 228 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 Global Organization ID. As such, we are not able to proceed. Please review the Zendesk Global 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
176 177 178 |
# File 'lib/support_readiness/support_super_form_processor/global_set_org_ase.rb', line 176 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 Global 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/global_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 Global 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
158 159 160 |
# File 'lib/support_readiness/support_super_form_processor/global_set_org_ase.rb', line 158 def self.project @project ||= Readiness::GitLab::Projects.find!(@gitlab_client, 68534119) end |
.requester ⇒ Object
Sets the global variable requester
140 141 142 |
# File 'lib/support_readiness/support_super_form_processor/global_set_org_ase.rb', line 140 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
149 150 151 |
# File 'lib/support_readiness/support_super_form_processor/global_set_org_ase.rb', line 149 def self.requester_email @requester_email ||= ENV.fetch('REQUESTER_EMAIL') end |