Class: MmJsonClient::HttpClient::Client
- Inherits:
-
Object
- Object
- MmJsonClient::HttpClient::Client
- Defined in:
- lib/mm_json_client/http_client/client.rb
Overview
A helper class to handle lower level HTTP calls for the API.
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(url, endpoint, options = {}) ⇒ Client
constructor
A new instance of Client.
- #post(data) ⇒ Object
Constructor Details
#initialize(url, endpoint, options = {}) ⇒ Client
Returns a new instance of Client.
9 10 11 12 13 |
# File 'lib/mm_json_client/http_client/client.rb', line 9 def initialize(url, endpoint, = {}) @url = url @endpoint = endpoint @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/mm_json_client/http_client/client.rb', line 7 def @options end |
Instance Method Details
#post(data) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/mm_json_client/http_client/client.rb', line 15 def post(data) new_http(URI(@url)).start do |http| req = Net::HTTP::Post.new(@endpoint) req.body = data configure_content_type(req) http.request(req) end end |