diff options
author | Tiago Botelho <tiagonbotelho@hotmail.com> | 2016-12-27 15:44:24 +0300 |
---|---|---|
committer | Tiago Botelho <tiagonbotelho@hotmail.com> | 2017-01-22 03:02:29 +0300 |
commit | cd51af1a991eaa5e16e3c6b94c89d90e20a5641f (patch) | |
tree | 487d4facff51567ab73121aed9f3fec29d7aad8f /lib | |
parent | 4b7ec44b91e0571d209c790d54947ba1756dac0e (diff) |
adds events to services api deserialization
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/services.rb | 49 |
1 files changed, 46 insertions, 3 deletions
diff --git a/lib/api/services.rb b/lib/api/services.rb index 3a9dfbb237c..907f80db438 100644 --- a/lib/api/services.rb +++ b/lib/api/services.rb @@ -145,7 +145,7 @@ module API name: :room, type: String, desc: 'Campfire room' - }, + } ], 'custom-issue-tracker' => [ { @@ -534,7 +534,36 @@ module API desc: 'The password of the user' } ] - }.freeze + } + + service_classes = [ + AsanaService, + AssemblaService, + BambooService, + BugzillaService, + BuildkiteService, + BuildsEmailService, + CampfireService, + CustomIssueTrackerService, + DroneCiService, + EmailsOnPushService, + ExternalWikiService, + FlowdockService, + GemnasiumService, + HipchatService, + IrkerService, + JiraService, + KubernetesService, + MattermostSlashCommandsService, + SlackSlashCommandsService, + PipelinesEmailService, + PivotaltrackerService, + PushoverService, + RedmineService, + SlackService, + MattermostService, + TeamcityService, + ].freeze trigger_services = { 'mattermost-slash-commands' => [ @@ -568,6 +597,20 @@ module API services.each do |service_slug, settings| desc "Set #{service_slug} service for project" params do + service_classes.each do |service| + event_names = service.try(:event_names) || [] + event_names.each do |event_name| + services[service.to_param.gsub("_", "-")] << { + required: false, + name: event_name.to_sym, + type: String, + desc: ServicesHelper.instance_method(:service_event_description) + .bind(self).call(event_name) + } + end + end + services.freeze + settings.each do |setting| if setting[:required] requires setting[:name], type: setting[:type], desc: setting[:desc] @@ -581,7 +624,7 @@ module API service_params = declared_params(include_missing: false).merge(active: true) if service.update_attributes(service_params) - true + present service, with: Entities::ProjectService, include_passwords: current_user.is_admin? else render_api_error!('400 Bad Request', 400) end |