Class: SimpleHttpClient
- Inherits:
-
Object
- Object
- SimpleHttpClient
- Defined in:
- lib/simple_http_client.rb
Constant Summary collapse
- CONTENT_TYPE =
{ 'Content-Type' => 'application/json' }
- ACCEPT =
{ 'Accept' => 'application/json' }
Instance Method Summary collapse
- #delete(path, header = {}) ⇒ Object
- #get(path, header = {}) ⇒ Object
-
#initialize(base_url) ⇒ SimpleHttpClient
constructor
A new instance of SimpleHttpClient.
- #post(path, body, header = {}) ⇒ Object
- #put(path, body, header = {}) ⇒ Object
Constructor Details
#initialize(base_url) ⇒ SimpleHttpClient
Returns a new instance of SimpleHttpClient.
9 10 11 |
# File 'lib/simple_http_client.rb', line 9 def initialize(base_url) @uri = URI.parse(base_url) end |
Instance Method Details
#delete(path, header = {}) ⇒ Object
18 19 20 21 |
# File 'lib/simple_http_client.rb', line 18 def delete(path, header = {}) request = Net::HTTP::Delete.new("/#{path}") non_body_request(request, header) end |
#get(path, header = {}) ⇒ Object
13 14 15 16 |
# File 'lib/simple_http_client.rb', line 13 def get(path, header = {}) request = Net::HTTP::Get.new("/#{path}") non_body_request(request, header) end |
#post(path, body, header = {}) ⇒ Object
23 24 25 26 |
# File 'lib/simple_http_client.rb', line 23 def post(path, body, header = {}) request = Net::HTTP::Post.new(path) body_request(request, body, header) end |
#put(path, body, header = {}) ⇒ Object
28 29 30 31 |
# File 'lib/simple_http_client.rb', line 28 def put(path, body, header = {}) request = Net::HTTP::Put.new(path) body_request(request, body, header) end |