Class: Readiness::SupportSuperFormProcessor::EditMacro
- Defined in:
- lib/support_readiness/support_super_form_processor/edit_macro.rb
Overview
Defines the class EditMacro within the module Zendesk.
Class Method Summary collapse
-
.comment ⇒ Object
Sets the global variable comment.
- .create_macro_file_if_needed ⇒ Object
-
.description ⇒ Object
Sets the global variable description.
-
.instance ⇒ Object
Sets the global variable instance.
- .issue_assignees ⇒ Object
-
.message(file_path) ⇒ Object
Return the string for the issue body.
-
.name ⇒ Object
Sets the global variable name.
-
.process!(gitlab_client, gitlab_admin_client) ⇒ Object
Process a Edit Macro request.
-
.project ⇒ Object
Sets the global variable project.
-
.requester ⇒ Object
Sets the global variable requester.
-
.requester_email ⇒ Object
Sets the global variable requester_email.
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
.comment ⇒ Object
Sets the global variable comment
91 92 93 |
# File 'lib/support_readiness/support_super_form_processor/edit_macro.rb', line 91 def self.comment @comment ||= ENV.fetch('EDIT_MACRO_COMMENT') end |
.create_macro_file_if_needed ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/support_readiness/support_super_form_processor/edit_macro.rb', line 31 def self.create_macro_file_if_needed return nil if comment == 'none' macro_project_id = if instance == 'Zendesk Global' 53382456 else 53561363 end macro_project = Readiness::GitLab::Projects.find!(@gitlab_client, macro_project_id) path = "active/#{name.split('::').join('/')}.md" file = Readiness::GitLab::Repositories.file(@gitlab_client, macro_project, path, 'master') unless file.key? 'file_name' commit_params = { branch: 'master', commit_message: 'Creating placeholder file for macro', actions: [ { file_path: path, content: 'PLACEHOLDER', action: 'create' } ] } Readiness::GitLab::Repositories.create_commit!(@gitlab_client, macro_project, commit_params) end path end |
.description ⇒ Object
Sets the global variable description
118 119 120 |
# File 'lib/support_readiness/support_super_form_processor/edit_macro.rb', line 118 def self.description @tag ||= ENV.fetch('EDIT_MACRO_DESCRIPTION') end |
.instance ⇒ Object
Sets the global variable instance
100 101 102 |
# File 'lib/support_readiness/support_super_form_processor/edit_macro.rb', line 100 def self.instance @instance ||= ENV.fetch('EDIT_MACRO_INSTANCE') end |
.issue_assignees ⇒ Object
122 123 124 125 126 |
# File 'lib/support_readiness/support_super_form_processor/edit_macro.rb', line 122 def self.issue_assignees return '@jcolyer @secole' if instance == 'Zendesk US Government' '@jcolyer @nabeel.bilgrami @avilla4 @dtragjasi @secole @rverschoor' end |
.message(file_path) ⇒ Object
Return the string for the issue body
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/support_readiness/support_super_form_processor/edit_macro.rb', line 133 def self.(file_path) <<~STRING ## Edit an existing macro Greetings @#{requester.username} ! This is a request to edit an existing macro within a Zendesk instance. The details are as follows: - Name of Macro: #{name} - Zendesk Instance: #{instance} - Type of comment: #{comment} - Managed content file: #{file_path.nil? ? 'N/A' : file_path} - Description of changes: ``` #{description} ``` /label ~"Stage::Development" ~zendesk ~"Customer::Support" ~p4 ~administrative /assign #{issue_assignees} STRING end |
.name ⇒ Object
Sets the global variable name
109 110 111 |
# File 'lib/support_readiness/support_super_form_processor/edit_macro.rb', line 109 def self.name @name ||= ENV.fetch('EDIT_MACRO_CURRENT_NAME') end |
.process!(gitlab_client, gitlab_admin_client) ⇒ Object
Process a Edit Macro request
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/support_readiness/support_super_form_processor/edit_macro.rb', line 18 def self.process!(gitlab_client, gitlab_admin_client) @gitlab_client = gitlab_client @gitlab_admin_client = gitlab_admin_client requester file_path = create_macro_file_if_needed issue = Readiness::GitLab::Issues.new issue.title = 'Edit an existing macro' issue.description = (file_path) 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
82 83 84 |
# File 'lib/support_readiness/support_super_form_processor/edit_macro.rb', line 82 def self.project @project ||= Readiness::GitLab::Projects.find!(@gitlab_client, 68534119) end |
.requester ⇒ Object
Sets the global variable requester
64 65 66 |
# File 'lib/support_readiness/support_super_form_processor/edit_macro.rb', line 64 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
73 74 75 |
# File 'lib/support_readiness/support_super_form_processor/edit_macro.rb', line 73 def self.requester_email @requester_email ||= ENV.fetch('REQUESTER_EMAIL') end |