Sha256: f0d0f8e73e40f77274ea5f07341f29561a8e821c6bf121e4e909441b47e4ecf5

Contents?: true

Size: 1.56 KB

Versions: 16

Compression:

Stored size: 1.56 KB

Contents

# encoding: utf-8

module Github
  class Client::Repos::Downloads < API

    REQUIRED_PARAMS = %w[ name size ].freeze

    VALID_DOWNLOAD_PARAM_NAMES = %w[
      name
      size
      description
      content_type
    ].freeze

    # List downloads for a repository
    #
    # @example
    #   github = Github.new
    #   github.repos.downloads.list 'user-name', 'repo-name'
    #   github.repos.downloads.list 'user-name', 'repo-name' { |downl| ... }
    #
    # @api public
    def list(*args)
      arguments(args, required: [:user, :repo])

      response = get_request("/repos/#{arguments.user}/#{arguments.repo}/downloads", arguments.params)
      return response unless block_given?
      response.each { |el| yield el }
    end
    alias :all :list

    # Get a single download
    #
    # @example
    #   github = Github.new
    #   github.repos.downloads.get 'user-name', 'repo-name', 'download-id'
    #
    # @api public
    def get(*args)
      arguments(args, required: [:user, :repo, :id])

      get_request("/repos/#{arguments.user}/#{arguments.repo}/downloads/#{arguments.id}", arguments.params)
    end
    alias :find :get

    # Delete download from a repository
    #
    # @example
    #   github = Github.new
    #   github.repos.downloads.delete 'user-name', 'repo-name', 'download-id'
    #
    # @api public
    def delete(*args)
      arguments(args, required: [:user, :repo, :id])

      delete_request("/repos/#{arguments.user}/#{arguments.repo}/downloads/#{arguments.id}", arguments.params)
    end
    alias :remove :delete
  end # Repos::Downloads
end # Github

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
github_api-0.17.0 lib/github_api/client/repos/downloads.rb
github_api-0.16.0 lib/github_api/client/repos/downloads.rb
github_api-0.15.0 lib/github_api/client/repos/downloads.rb
github_api-0.14.5 lib/github_api/client/repos/downloads.rb
github_api-0.14.4 lib/github_api/client/repos/downloads.rb
github_api-0.14.3 lib/github_api/client/repos/downloads.rb
github_api-0.14.2 lib/github_api/client/repos/downloads.rb
github_api-0.14.1 lib/github_api/client/repos/downloads.rb
github_api-0.14.0 lib/github_api/client/repos/downloads.rb
github_api-0.13.1 lib/github_api/client/repos/downloads.rb
github_api-0.13.0 lib/github_api/client/repos/downloads.rb
github_api-0.12.4 lib/github_api/client/repos/downloads.rb
github_api-0.12.3 lib/github_api/client/repos/downloads.rb
github_api-0.12.2 lib/github_api/client/repos/downloads.rb
github_api-0.12.1 lib/github_api/client/repos/downloads.rb
github_api-0.12.0 lib/github_api/client/repos/downloads.rb