Class: GHI::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/ghi/client.rb

Defined Under Namespace

Classes: Error, Response

Constant Summary collapse

CONTENT_TYPE =
'application/vnd.github.beta+json'
USER_AGENT =
'ghi/%s (%s; +%s)' % [
  GHI::Commands::Version::VERSION,
  RUBY_DESCRIPTION,
  'https://github.com/stephencelis/ghi'
]
METHODS =
{
  :head   => Net::HTTP::Head,
  :get    => Net::HTTP::Get,
  :post   => Net::HTTP::Post,
  :put    => Net::HTTP::Put,
  :patch  => Net::HTTP::Patch,
  :delete => Net::HTTP::Delete
}
DEFAULT_HOST =
'api.github.com'
HOST =
GHI.config('github.host') || DEFAULT_HOST
PORT =
443

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username = nil, password = nil) ⇒ Client

Returns a new instance of Client.



67
68
69
# File 'lib/ghi/client.rb', line 67

def initialize username = nil, password = nil
  @username, @password = username, password
end

Instance Attribute Details

#passwordObject (readonly)

Returns the value of attribute password.



66
67
68
# File 'lib/ghi/client.rb', line 66

def password
  @password
end

#usernameObject (readonly)

Returns the value of attribute username.



66
67
68
# File 'lib/ghi/client.rb', line 66

def username
  @username
end

Instance Method Details

#delete(path, options = {}) ⇒ Object



91
92
93
# File 'lib/ghi/client.rb', line 91

def delete path, options = {}
  request :delete, path, options
end

#get(path, params = {}, options = {}) ⇒ Object



75
76
77
# File 'lib/ghi/client.rb', line 75

def get path, params = {}, options = {}
  request :get, path, options.merge(:params => params)
end

#head(path, options = {}) ⇒ Object



71
72
73
# File 'lib/ghi/client.rb', line 71

def head path, options = {}
  request :head, path, options
end

#patch(path, body = nil, options = {}) ⇒ Object



87
88
89
# File 'lib/ghi/client.rb', line 87

def patch path, body = nil, options = {}
  request :patch, path, options.merge(:body => body)
end

#post(path, body = nil, options = {}) ⇒ Object



79
80
81
# File 'lib/ghi/client.rb', line 79

def post path, body = nil, options = {}
  request :post, path, options.merge(:body => body)
end

#put(path, body = nil, options = {}) ⇒ Object



83
84
85
# File 'lib/ghi/client.rb', line 83

def put path, body = nil, options = {}
  request :put, path, options.merge(:body => body)
end