Class: GHI::Client
- Inherits:
-
Object
- Object
- GHI::Client
- Defined in:
- lib/ghi/client.rb
Defined Under Namespace
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
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #delete(path, options = {}) ⇒ Object
- #get(path, params = {}, options = {}) ⇒ Object
- #head(path, options = {}) ⇒ Object
-
#initialize(username = nil, password = nil) ⇒ Client
constructor
A new instance of Client.
- #patch(path, body = nil, options = {}) ⇒ Object
- #post(path, body = nil, options = {}) ⇒ Object
- #put(path, body = nil, options = {}) ⇒ Object
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
#password ⇒ Object (readonly)
Returns the value of attribute password.
66 67 68 |
# File 'lib/ghi/client.rb', line 66 def password @password end |
#username ⇒ Object (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, = {} request :delete, path, end |
#get(path, params = {}, options = {}) ⇒ Object
75 76 77 |
# File 'lib/ghi/client.rb', line 75 def get path, params = {}, = {} request :get, path, .merge(:params => params) end |
#head(path, options = {}) ⇒ Object
71 72 73 |
# File 'lib/ghi/client.rb', line 71 def head path, = {} request :head, path, end |
#patch(path, body = nil, options = {}) ⇒ Object
87 88 89 |
# File 'lib/ghi/client.rb', line 87 def patch path, body = nil, = {} request :patch, path, .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, = {} request :post, path, .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, = {} request :put, path, .merge(:body => body) end |