Class: Github::Orgs

Inherits:
API
  • Object
show all
Defined in:
lib/github_api/orgs.rb

Defined Under Namespace

Classes: Members, Teams

Constant Summary

VALID_ORG_PARAM_NAMES =
%w[
  billing_email
  company
  email
  location
  name
].freeze

Constants included from Request

Request::HTTP_METHODS, Request::METHODS_WITH_BODIES

Constants included from Connection

Connection::ALLOWED_OPTIONS

Constants included from Constants

Constants::ACCEPT, Constants::ACCEPTED_OAUTH_SCOPES, Constants::ACCEPT_CHARSET, Constants::CACHE_CONTROL, Constants::CONTENT_LENGTH, Constants::CONTENT_TYPE, Constants::DATE, Constants::ETAG, Constants::HEADER_LAST, Constants::HEADER_LINK, Constants::HEADER_NEXT, Constants::LOCATION, Constants::META_FIRST, Constants::META_LAST, Constants::META_NEXT, Constants::META_PREV, Constants::META_REL, Constants::OAUTH_SCOPES, Constants::PARAM_PAGE, Constants::PARAM_PER_PAGE, Constants::PARAM_START_PAGE, Constants::RATELIMIT_LIMIT, Constants::RATELIMIT_REMAINING, Constants::SERVER, Constants::USER_AGENT

Constants included from MimeType

MimeType::MEDIA_LOOKUP

Instance Attribute Summary

Attributes inherited from API

#current_options

Attributes included from Authorization

#scopes

Instance Method Summary (collapse)

Methods inherited from API

#api_methods_in, #append_arguments, #arguments, extract_class_name, inherited, #initialize, #method_missing, namespace, #process_basic_auth, #set, #setup, #with, #yield_or_eval

Methods included from ClassMethods

#configuration, #require_all

Methods included from RateLimit

#ratelimit, #ratelimit_remaining

Methods included from Request

#delete_request, #get_request, #patch_request, #post_request, #put_request, #request

Methods included from Connection

#caching?, #clear_cache, #connection, #default_middleware, #default_options, #stack

Methods included from MimeType

#lookup_media, #parse

Methods included from Authorization

#auth_code, #authenticated?, #authentication, #authorize_url, #basic_authed?, #client, #get_token

Constructor Details

This class inherits a constructor from Github::API

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Github::API

Instance Method Details

- (Object) edit(*args)

Edit organization

Parameters

:billing_email - Optional string - Billing email address. This address is not publicized. :company - Optional string :email - Optional string :location - Optional string :name - Optional string

Examples

github = Github.new oauth_token: '...'
github.orgs.edit 'github',
  "billing_email": "support@github.com",
  "blog": "https://github.com/blog",
  "company": "GitHub",
  "email": "support@github.com",
  "location": "San Francisco",
  "name": "github"


81
82
83
84
85
86
87
# File 'lib/github_api/orgs.rb', line 81

def edit(*args)
  arguments(args, :required => [:org_name]) do
    sift VALID_ORG_PARAM_NAMES
  end

  patch_request("/orgs/#{org_name}", arguments.params)
end

- (Object) get(*args) Also known as: find

Get properties for a single organization

Examples

github = Github.new
github.orgs.get 'github'


55
56
57
58
59
# File 'lib/github_api/orgs.rb', line 55

def get(*args)
  arguments(args, :required => [:org_name])

  get_request("/orgs/#{org_name}", arguments.params)
end

- (Object) list(*args) Also known as: all

List all public organizations for a user.

Examples

github = Github.new
github.orgs.list user: 'user-name'

List public and private organizations for the authenticated user.

github = Github.new oauth_token: '..'
github.orgs.list


35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/github_api/orgs.rb', line 35

def list(*args)
  params = arguments(args).params

  response = if (user_name = params.delete("user"))
    get_request("/users/#{user_name}/orgs", params)
  else
    # For the authenticated user
    get_request("/user/orgs", params)
  end
  return response unless block_given?
  response.each { |el| yield el }
end