Sha256: 38c958e1187c0fd4ab92bdf25c1c51e41d1b7bcf73e801145ec52bb639fa08ca

Contents?: true

Size: 1.46 KB

Versions: 21

Compression:

Stored size: 1.46 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(params={})
      normalize! params
      response = get_request("/user/emails", 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)
      params = args.extract_options!
      normalize! params
      params['data'] = args if args
      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)
      params = args.extract_options!
      normalize! params
      params['data'] = args if args
      delete_request("/user/emails", params)
    end

  end # Users::Emails
end # Github

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
github_api-0.9.0 lib/github_api/users/emails.rb
github_api-0.8.11 lib/github_api/users/emails.rb
github_api-0.8.10 lib/github_api/users/emails.rb
github_api-0.8.9 lib/github_api/users/emails.rb
github_api-0.8.8 lib/github_api/users/emails.rb
github_api-0.8.7 lib/github_api/users/emails.rb
github_api-0.8.6 lib/github_api/users/emails.rb
github_api-0.8.5 lib/github_api/users/emails.rb
github_api-0.8.4 lib/github_api/users/emails.rb
github_api-0.8.3 lib/github_api/users/emails.rb
github_api-0.8.2 lib/github_api/users/emails.rb
github_api-0.8.1 lib/github_api/users/emails.rb
github_api-0.8.0 lib/github_api/users/emails.rb
github_api-0.7.2 lib/github_api/users/emails.rb
github_api-0.7.1 lib/github_api/users/emails.rb
github_api-0.7.0 lib/github_api/users/emails.rb
github_api-0.6.5 lib/github_api/users/emails.rb
github_api-0.6.4 lib/github_api/users/emails.rb
github_api-0.6.3 lib/github_api/users/emails.rb
github_api-0.6.2 lib/github_api/users/emails.rb