Class: GitWand::GitHub::API::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/git_wand/github/api/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#tokenObject (readonly)

Returns the value of attribute token.



11
12
13
# File 'lib/git_wand/github/api/client.rb', line 11

def token
  @token
end

#usernameObject (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_infoObject



18
19
20
21
22
23
24
# File 'lib/git_wand/github/api/client.rb', line 18

def 
  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