Class: Github::Client
- Inherits:
-
Object
- Object
- Github::Client
- Defined in:
- lib/github/client.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ access_token: nil, user: {} }
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#access_token ⇒ Object
returns user access_token.
-
#email(options = {}) ⇒ Object
getter for email.
-
#html_url(options = {}) ⇒ Object
getter for user page url.
-
#initialize(options = {}) ⇒ Client
constructor
stores user access_token to make authenticated requests.
-
#login(options = {}) ⇒ Object
getter for login.
-
#name(options = {}) ⇒ Object
getter for name.
-
#repos(options = {}) ⇒ Object
fetches user’s repositories and wraps them in RepoResponseWrapper.
-
#repos_url(options = {}) ⇒ Object
getter for url to get repositories from API.
-
#user(options = {}) ⇒ Object
fetches user information from github API using access_token to identify user.
Constructor Details
#initialize(options = {}) ⇒ Client
stores user access_token to make authenticated requests
14 15 16 17 |
# File 'lib/github/client.rb', line 14 def initialize(={}) () check_token end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
11 12 13 |
# File 'lib/github/client.rb', line 11 def @options end |
Instance Method Details
#access_token ⇒ Object
returns user access_token
20 21 22 |
# File 'lib/github/client.rb', line 20 def access_token @options[:access_token] end |
#email(options = {}) ⇒ Object
getter for email
57 58 59 60 61 62 63 |
# File 'lib/github/client.rb', line 57 def email(={}) if .empty? user["email"] else user()["email"] end end |
#html_url(options = {}) ⇒ Object
getter for user page url
66 67 68 69 70 71 72 |
# File 'lib/github/client.rb', line 66 def html_url(={}) if .empty? user["html_url"] else user()["html_url"] end end |
#login(options = {}) ⇒ Object
getter for login
48 49 50 51 52 53 54 |
# File 'lib/github/client.rb', line 48 def login(={}) if .empty? user["login"] else [:login] end end |
#name(options = {}) ⇒ Object
getter for name
39 40 41 42 43 44 45 |
# File 'lib/github/client.rb', line 39 def name(={}) if .empty? user["name"] else user()["name"] end end |
#repos(options = {}) ⇒ Object
fetches user’s repositories and wraps them in RepoResponseWrapper
84 85 86 |
# File 'lib/github/client.rb', line 84 def repos(={}) Github::ReposResponseWrapper.new(request(repos_url(), access_token), access_token) end |
#repos_url(options = {}) ⇒ Object
getter for url to get repositories from API
75 76 77 78 79 80 81 |
# File 'lib/github/client.rb', line 75 def repos_url(={}) if .empty? user['repos_url'] else user()['repos_url'] end end |
#user(options = {}) ⇒ Object
fetches user information from github API using access_token to identify user
26 27 28 29 30 31 32 |
# File 'lib/github/client.rb', line 26 def user(={}) if .empty? get_user('user') if .empty? else get_user("users/#{[:login]}") end end |