Sha256: 173974e777bdb915d6866ea7ae1a995f7d73a2c0517a1e5d154e184b3d7c23d3

Contents?: true

Size: 1.79 KB

Versions: 6

Compression:

Stored size: 1.79 KB

Contents

class Gitlab::Client
  # Third party services connected to a project.
  # @see https://docs.gitlab.com/ce/api/services.html
  module Services
    # Create/Edit service
    # Full service params documentation: https://github.com/gitlabhq/gitlabhq/blob/master/doc/api/services.md
    #
    # @example
    #   Gitlab.change_service(42, :redmine, { new_issue_url: 'https://example.com/projects/test_project/issues/new',
    #                                         project_url: 'https://example.com/projects/test_project/issues',
    #                                         issues_url: 'https://example.com/issues/:id' })
    #
    # @param  [Integer, String] project The ID or name of a project.
    # @param  [String] service A service code name.
    # @param  [Hash] params A service parameters.
    # @return [Boolean]
    def change_service(project, service, params)
      put("/projects/#{url_encode project}/services/#{correct_service_name(service)}", body: params)
    end

    # Delete service
    #
    # @example
    #   Gitlab.delete_service(42, :redmine)
    #
    # @param  [Integer, String] project The ID or name of a project.
    # @param  [String] service A service code name.
    # @return [Boolean]
    def delete_service(project, service)
      delete("/projects/#{url_encode project}/services/#{correct_service_name(service)}")
    end

    # Get service
    #
    # @example
    #   Gitlab.service(42, :redmine)
    #
    # @param  [Integer, String] project The ID or name of a project.
    # @param  [String] service A service code name.
    # @return [Gitlab::ObjectifiedHash]
    def service(project, service)
      get("/projects/#{url_encode project}/services/#{correct_service_name(service)}")
    end

    private
    def correct_service_name(service)
      service.to_s.gsub('_', '-')
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
gitlab-4.5.0 lib/gitlab/client/services.rb
gitlab-4.4.0 lib/gitlab/client/services.rb
gitlab-4.3.0 lib/gitlab/client/services.rb
gitlab-4.2.0 lib/gitlab/client/services.rb
gitlab-4.1.0 lib/gitlab/client/services.rb
gitlab-4.0.0 lib/gitlab/client/services.rb