Sha256: c2d9eb522d24423e48214419e83c167de233882a694838ef4d5dcae1188fbb55

Contents?: true

Size: 1.53 KB

Versions: 14

Compression:

Stored size: 1.53 KB

Contents

# encoding: utf-8
require 'cgi'

module Github
  class Users::Emails < API

    # List email addresses for the authenticated user
    #
    # = Examples
    #  github = Github.new :oauth_token => '...'
    #  github.users.emails.list
    #  github.users.emails.list { |email| ... }
    #
    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
    #
    # = Inputs
    # You can include a single email address or an array of addresses
    #
    # = Examples
    #  github = Github.new :oauth_token => '...'
    #  github.users.emails.add "octocat@github.com", "support@github.com"
    #
    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
    #
    # = Inputs
    # You can include a single email address or an array of addresses
    #
    # = Examples
    #  github = Github.new :oauth_token => '...'
    #  github.users.emails.delete "octocat@github.com", "support@github.com"
    #
    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

14 entries across 14 versions & 1 rubygems

Version Path
github_api-0.11.3 lib/github_api/users/emails.rb
github_api-0.11.2 lib/github_api/users/emails.rb
github_api-0.11.1 lib/github_api/users/emails.rb
github_api-0.11.0 lib/github_api/users/emails.rb
github_api-0.10.2 lib/github_api/users/emails.rb
github_api-0.10.1 lib/github_api/users/emails.rb
github_api-0.10.0 lib/github_api/users/emails.rb
github_api-0.9.7 lib/github_api/users/emails.rb
github_api-0.9.6 lib/github_api/users/emails.rb
github_api-0.9.5 lib/github_api/users/emails.rb
github_api-0.9.4 lib/github_api/users/emails.rb
github_api-0.9.3 lib/github_api/users/emails.rb
github_api-0.9.2 lib/github_api/users/emails.rb
github_api-0.9.1 lib/github_api/users/emails.rb