Sha256: 8302d07c5de7e7dbb4f5ef01268c041241b4dd483955cb4c1c84e1df9cdcf06f

Contents?: true

Size: 1.65 KB

Versions: 16

Compression:

Stored size: 1.65 KB

Contents

# encoding: utf-8
require 'cgi'

module Github
  class Client::Users::Emails < API

    # List email addresses for the authenticated user
    #
    # @example
    #  github = Github.new oauth_token: '...'
    #  github.users.emails.list
    #  github.users.emails.list { |email| ... }
    #
    # @return [Hash]
    #
    # @api public
    def list(*args)
      arguments(args)
      response = get_request("/user/emails", arguments.params)
      return response unless block_given?
      response.each { |el| yield el }
    end
    alias :all :list

    # Add email address(es) for the authenticated user
    #
    # @param [Array[String]] emails
    #   You can include a single email address or an array of addresses
    #
    # @example
    #  github = Github.new oauth_token: '...'
    #  github.users.emails.add "octocat@github.com", "support@github.com"
    #
    # @api public
    def add(*args)
      arguments(args)
      params = arguments.params
      params['data'] = arguments.remaining unless arguments.remaining.empty?

      post_request("/user/emails", params)
    end
    alias :<< :add

    # Delete email address(es) for the authenticated user
    #
    # @param [Array[String]] emails
    #   You can include a single email address or an array of addresses
    #
    # @example
    #  github = Github.new oauth_token: '...'
    #  github.users.emails.delete "octocat@github.com", "support@github.com"
    #
    # @api public
    def delete(*args)
      arguments(args)
      params = arguments.params
      params['data'] = arguments.remaining unless arguments.remaining.empty?

      delete_request("/user/emails", params)
    end
  end # Users::Emails
end # Github

Version data entries

16 entries across 16 versions & 1 rubygems

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