Class: Elevate::HTTP::HTTPClient
- Inherits:
-
Object
- Object
- Elevate::HTTP::HTTPClient
- Defined in:
- lib/elevate/http/http_client.rb
Instance Method Summary collapse
- #delete(path, &block) ⇒ Object
- #get(path, query = {}, &block) ⇒ Object
-
#initialize(base_url) ⇒ HTTPClient
constructor
A new instance of HTTPClient.
- #post(path, body, &block) ⇒ Object
- #put(path, body, &block) ⇒ Object
- #set_credentials(username, password) ⇒ Object
Constructor Details
#initialize(base_url) ⇒ HTTPClient
Returns a new instance of HTTPClient.
4 5 6 7 |
# File 'lib/elevate/http/http_client.rb', line 4 def initialize(base_url) @base_url = NSURL.URLWithString(base_url) @credentials = nil end |
Instance Method Details
#delete(path, &block) ⇒ Object
21 22 23 |
# File 'lib/elevate/http/http_client.rb', line 21 def delete(path, &block) issue(:delete, path, nil, &block) end |
#get(path, query = {}, &block) ⇒ Object
9 10 11 |
# File 'lib/elevate/http/http_client.rb', line 9 def get(path, query={}, &block) issue(:get, path, nil, query: query, &block) end |
#post(path, body, &block) ⇒ Object
13 14 15 |
# File 'lib/elevate/http/http_client.rb', line 13 def post(path, body, &block) issue(:post, path, body, &block) end |
#put(path, body, &block) ⇒ Object
17 18 19 |
# File 'lib/elevate/http/http_client.rb', line 17 def put(path, body, &block) issue(:put, path, body, &block) end |
#set_credentials(username, password) ⇒ Object
25 26 27 |
# File 'lib/elevate/http/http_client.rb', line 25 def set_credentials(username, password) @credentials = { username: username, password: password } end |