Sha256: 1f93c84ede76d781270e0e45b8abbf310563fdb2f2f4037c60cce1e99cabcebd

Contents?: true

Size: 1.59 KB

Versions: 6

Compression:

Stored size: 1.59 KB

Contents

# encoding: utf-8

require_relative '../../api'

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

6 entries across 6 versions & 3 rubygems

Version Path
github_api2-1.0.1 lib/github_api2/client/repos/downloads.rb
github_api2-1.0.0 lib/github_api2/client/repos/downloads.rb
github_api-0.19.0 lib/github_api/client/repos/downloads.rb
lingfennan-github_api-0.18.2 lib/github_api/client/repos/downloads.rb
github_api-0.18.2 lib/github_api/client/repos/downloads.rb
github_api-0.18.1 lib/github_api/client/repos/downloads.rb