Class: GitWand::GitHub::API::Client
- Inherits:
-
Object
- Object
- GitWand::GitHub::API::Client
- Defined in:
- lib/git_wand/github/api/client.rb
Instance Attribute Summary collapse
-
#token ⇒ Object
readonly
Returns the value of attribute token.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #create_repository(name:, private: false) ⇒ Object
- #current_user_info ⇒ Object
- #delete_repository(name:) ⇒ Object
-
#initialize(username:, token:) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(username:, token:) ⇒ Client
Returns a new instance of Client.
13 14 15 16 |
# File 'lib/git_wand/github/api/client.rb', line 13 def initialize(username:, token:) @username = username @token = token end |
Instance Attribute Details
#token ⇒ Object (readonly)
Returns the value of attribute token.
11 12 13 |
# File 'lib/git_wand/github/api/client.rb', line 11 def token @token end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
11 12 13 |
# File 'lib/git_wand/github/api/client.rb', line 11 def username @username end |
Instance Method Details
#create_repository(name:, private: false) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/git_wand/github/api/client.rb', line 26 def create_repository(name:, private: false) parameters = { name: name, private: private } response = post(resource: "user/repos", parameters: parameters) result = Result.new result.success = response[:status][:code] == "201" result.body = response[:body] result end |
#current_user_info ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/git_wand/github/api/client.rb', line 18 def current_user_info response = get(resource: "user") result = Result.new result.success = response[:status][:code] == "200" result.body = response[:body] result end |
#delete_repository(name:) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/git_wand/github/api/client.rb', line 38 def delete_repository(name:) response = delete(resource: "repos/#{username}/#{name}") result = Result.new result.success = response[:status][:code] == "204" result.body = response[:body] result end |