Class: Ghee::API::Users::Proxy
- Inherits:
-
ResourceProxy
- Object
- ResourceProxy
- Ghee::API::Users::Proxy
- Includes:
- CUD
- Defined in:
- lib/ghee/api/keys.rb,
lib/ghee/api/users.rb,
lib/ghee/api/emails.rb,
lib/ghee/api/watchers.rb,
lib/ghee/api/followers.rb
Overview
Users::Proxy inherits from Ghee::Proxy and enables defining methods on the proxy object
Instance Attribute Summary
Attributes inherited from ResourceProxy
#connection, #current_page, #pagination, #params, #path_prefix, #total
Instance Method Summary collapse
- #emails ⇒ Object
- #follow(user) ⇒ Object
- #follow!(user) ⇒ Object
- #followers ⇒ Object
- #following ⇒ Object
- #following?(user) ⇒ Boolean
-
#gists(params = {}) ⇒ Object
Gists for a user.
- #keys(id = nil) ⇒ Object
-
#memberships(params = {state: "active"}, &block) ⇒ Object
Returns a Memberships Proxy.
-
#orgs(org = nil, params = {}) ⇒ Object
Returns list of the provided users organizations or an organization by name.
-
#repos(name = nil, params = {}) ⇒ Object
Repos for a user.
- #watch(user, repo) ⇒ Object
- #watch!(user, repo) ⇒ Object
- #watched ⇒ Object
- #watching?(user, repo) ⇒ Boolean
Methods included from CUD
Methods inherited from ResourceProxy
accept_header, #all, #all_parallel, #build_prefix, #initialize, #method_missing, #paginate, #raw, #subject
Constructor Details
This class inherits a constructor from Ghee::ResourceProxy
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Ghee::ResourceProxy
Instance Method Details
#emails ⇒ Object
24 25 26 |
# File 'lib/ghee/api/emails.rb', line 24 def emails Ghee::API::Users::Emails::Proxy.new connection, "#{path_prefix}/emails" end |
#follow(user) ⇒ Object
19 20 21 |
# File 'lib/ghee/api/followers.rb', line 19 def follow(user) connection.put("#{path_prefix}/following/#{user}").status == 204 end |
#follow!(user) ⇒ Object
22 23 24 |
# File 'lib/ghee/api/followers.rb', line 22 def follow!(user) connection.delete("#{path_prefix}/following/#{user}").status == 204 end |
#followers ⇒ Object
10 11 12 |
# File 'lib/ghee/api/followers.rb', line 10 def followers connection.get("#{path_prefix}/followers").body end |
#following ⇒ Object
13 14 15 |
# File 'lib/ghee/api/followers.rb', line 13 def following connection.get("#{path_prefix}/following").body end |
#following?(user) ⇒ Boolean
16 17 18 |
# File 'lib/ghee/api/followers.rb', line 16 def following?(user) connection.get("#{path_prefix}/following/#{user}").status == 204 end |
#gists(params = {}) ⇒ Object
Gists for a user
Returns json
60 61 62 |
# File 'lib/ghee/api/users.rb', line 60 def gists(params={}) Ghee::API::Gists::Proxy.new(connection,"#{path_prefix}/gists", params) end |
#keys(id = nil) ⇒ Object
46 47 48 49 |
# File 'lib/ghee/api/keys.rb', line 46 def keys(id=nil) prefix = id ? "#{path_prefix}/keys/#{id}" : "#{path_prefix}/keys" Ghee::API::Users::Keys::Proxy.new connection, prefix end |
#memberships(params = {state: "active"}, &block) ⇒ Object
Returns a Memberships Proxy
88 89 90 91 |
# File 'lib/ghee/api/users.rb', line 88 def memberships(params={state: "active"}, &block) prefix = "#{path_prefix}/memberships/orgs" Ghee::API::Users::Memberships::Proxy.new(connection, prefix, params, &block) end |
#orgs(org = nil, params = {}) ⇒ Object
Returns list of the provided users organizations or an organization by name
org - String name of the organization (optional)
Returns json
81 82 83 84 85 |
# File 'lib/ghee/api/users.rb', line 81 def orgs(org=nil, params={}) params = org if org.is_a?Hash prefix = org.is_a?(String) ? "./orgs/#{org}" : "#{path_prefix}/orgs" Ghee::API::Orgs::Proxy.new(connection, prefix, params) end |
#repos(name = nil, params = {}) ⇒ Object
Repos for a user
Returns json
68 69 70 71 72 |
# File 'lib/ghee/api/users.rb', line 68 def repos(name=nil, params={}) params = name if name.is_a?Hash prefix = name.is_a?(String) ? "./repos/#{self["login"]}/#{name}" : "#{path_prefix}/repos" Ghee::API::Repos::Proxy.new(connection,prefix, params) end |
#watch(user, repo) ⇒ Object
31 32 33 |
# File 'lib/ghee/api/watchers.rb', line 31 def watch(user, repo) connection.put("#{path_prefix}/watched/#{user}/#{repo}").status == 204 end |
#watch!(user, repo) ⇒ Object
34 35 36 |
# File 'lib/ghee/api/watchers.rb', line 34 def watch!(user, repo) connection.delete("#{path_prefix}/watched/#{user}/#{repo}").status == 204 end |
#watched ⇒ Object
25 26 27 |
# File 'lib/ghee/api/watchers.rb', line 25 def watched connection.get("#{path_prefix}/watched").body end |
#watching?(user, repo) ⇒ Boolean
28 29 30 |
# File 'lib/ghee/api/watchers.rb', line 28 def watching?(user,repo) connection.get("#{path_prefix}/watched/#{user}/#{repo}").status == 204 end |