Class: Integrations::SquashTm

Inherits:
Integration show all
Includes:
HasWebHook
Defined in:
app/models/integrations/squash_tm.rb

Constant Summary

Constants included from Base::Integration

Base::Integration::BASE_ATTRIBUTES, Base::Integration::BASE_CLASSES, Base::Integration::DEV_INTEGRATION_NAMES, Base::Integration::ENCRYPTED_PROPERTIES_MAX_SIZE, Base::Integration::INSTANCE_LEVEL_ONLY_INTEGRATION_NAMES, Base::Integration::INTEGRATION_NAMES, Base::Integration::PROJECT_AND_GROUP_LEVEL_ONLY_INTEGRATION_NAMES, Base::Integration::PROJECT_LEVEL_ONLY_INTEGRATION_NAMES, Base::Integration::SECTION_TYPE_CONFIGURATION, Base::Integration::SECTION_TYPE_CONNECTION, Base::Integration::SECTION_TYPE_TRIGGER, Base::Integration::SNOWPLOW_EVENT_ACTION, Base::Integration::SNOWPLOW_EVENT_LABEL, Base::Integration::UnknownType

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

Constants included from HasCheckConstraints

HasCheckConstraints::NOT_NULL_CHECK_PATTERN

Constants included from ResetOnColumnErrors

ResetOnColumnErrors::MAX_RESET_PERIOD

Class Method Summary collapse

Instance Method Summary collapse

Methods included from HasWebHook

#execute_web_hook!, #hook_ssl_verification, #update_web_hook!

Methods included from Base::Integration

#activate!, #activate_disabled_reason, #activated?, #after_build_from_integration, #api_field_names, #async_execute, #attributes, #attribution_notice, #category, #chat?, #ci?, #configurable_events, #deactivate!, #default_test_event, #description, #dup, #editable?, #event_channel_names, #event_names, #fields, #form_fields, #group_level?, #help, #inheritable?, #initialize_properties, #instance_level?, #json_fields, #manual_activation?, #operating?, #organization_id_from_parent, #parent, #project_level?, #reencrypt_properties, #reset_updated_properties, #secret_fields, #sections, #supported_events, #supports_data_fields?, #testable?, #title, #to_database_hash, #to_param, #toggle!, #updated_properties, #validate_encrypted_properties_size_limit

Methods included from Gitlab::Utils::Override

#extended, extensions, #included, #method_added, #override, #prepended, #queue_verification, verify!

Methods inherited from ApplicationRecord

===, cached_column_list, #create_or_load_association, current_transaction, declarative_enum, default_select_columns, delete_all_returning, #deleted_from_database?, id_in, id_not_in, iid_in, nullable_column?, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order

Methods included from Organizations::Sharding

#sharding_organization

Methods included from ResetOnColumnErrors

#reset_on_union_error, #reset_on_unknown_attribute_error

Methods included from Gitlab::SensitiveSerializableHash

#serializable_hash

Class Method Details

.default_test_eventObject



50
51
52
# File 'app/models/integrations/squash_tm.rb', line 50

def self.default_test_event
  'issue'
end

.descriptionObject



31
32
33
# File 'app/models/integrations/squash_tm.rb', line 31

def self.description
  s_("SquashTmIntegration|Update Squash TM requirements when GitLab issues are modified.")
end

.helpObject



35
36
37
38
39
40
# File 'app/models/integrations/squash_tm.rb', line 35

def self.help
  build_help_page_url(
    'user/project/integrations/squash_tm.md',
    s_("SquashTmIntegration|Update Squash TM requirements when GitLab issues are modified.")
  )
end

.supported_eventsObject



42
43
44
# File 'app/models/integrations/squash_tm.rb', line 42

def self.supported_events
  %w[issue confidential_issue]
end

.titleObject



27
28
29
# File 'app/models/integrations/squash_tm.rb', line 27

def self.title
  'Squash TM'
end

.to_paramObject



46
47
48
# File 'app/models/integrations/squash_tm.rb', line 46

def self.to_param
  'squash_tm'
end

Instance Method Details

#execute(data) ⇒ Object



54
55
56
57
58
# File 'app/models/integrations/squash_tm.rb', line 54

def execute(data)
  return unless supported_events.include?(data[:object_kind])

  execute_web_hook!(data, "#{data[:object_kind]} Hook")
end

#hook_urlObject



69
70
71
# File 'app/models/integrations/squash_tm.rb', line 69

def hook_url
  format("#{url}%s", ('?token={token}' unless token.blank?))
end

#test(data) ⇒ Object



60
61
62
63
64
65
66
# File 'app/models/integrations/squash_tm.rb', line 60

def test(data)
  result = execute_web_hook!(data, "Test Configuration Hook")

  { success: result.payload[:http_status] == 200, result: result.message }
rescue StandardError => error
  { success: false, result: error.message }
end

#url_variablesObject



73
74
75
# File 'app/models/integrations/squash_tm.rb', line 73

def url_variables
  { 'token' => token }.compact
end