Sha256: 3d4bc385a93897b2a58877530c1e893ddd8feb68af267009e0d87c076f6ee135

Contents?: true

Size: 1.55 KB

Versions: 4

Compression:

Stored size: 1.55 KB

Contents

# encoding: utf-8

module Github
  class Users
    module Emails

      # List email addresses for the authenticated user
      #
      # = Examples
      #  @github = Github.new :oauth_token => '...'
      #  @github.users.emails
      #  @github.users.emails { |email| ... }
      #
      def emails(params={})
        _normalize_params_keys(params)
        response = get("/user/emails", params)
        return response unless block_given?
        response.each { |el| yield el }
      end

      # 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.add_email "octocat@github.com", "support@github.com"
      #
      def add_email(*args)
        params = _extract_parameters(args)
        _normalize_params_keys(params)
        params['data'] = [args].flatten if args
        post("/user/emails", params)
      end

      # 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.delete_email "octocat@github.com", "support@github.com"
      #
      def delete_email(*args)
        params = _extract_parameters(args)
        _normalize_params_keys(params)
        params['data'] = [args].flatten
        delete("/user/emails", params)
      end

    end # Emails
  end # Users
end # Github

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
github_api-0.4.11 lib/github_api/users/emails.rb
github_api-0.4.10 lib/github_api/users/emails.rb
github_api-0.4.9 lib/github_api/users/emails.rb
github_api-0.4.8 lib/github_api/users/emails.rb