Class: WCC::API::RestClient::TyphoeusAdapter
- Inherits:
-
Object
- Object
- WCC::API::RestClient::TyphoeusAdapter
- Defined in:
- lib/wcc/api/rest_client/typhoeus_adapter.rb
Defined Under Namespace
Classes: Response
Instance Method Summary collapse
- #delete(url, query = {}, headers = {}) ⇒ Object
- #get(url, params = {}, headers = {}) {|req| ... } ⇒ Object
- #post(url, body, headers = {}) ⇒ Object
- #put(url, body, headers = {}) ⇒ Object
Instance Method Details
#delete(url, query = {}, headers = {}) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/wcc/api/rest_client/typhoeus_adapter.rb', line 40 def delete(url, query = {}, headers = {}) Response.new( Typhoeus.delete( url, headers: headers ) ) end |
#get(url, params = {}, headers = {}) {|req| ... } ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/wcc/api/rest_client/typhoeus_adapter.rb', line 8 def get(url, params = {}, headers = {}) req = OpenStruct.new(params: params, headers: headers) yield req if block_given? Response.new( Typhoeus.get( url, params: req.params, headers: req.headers ) ) end |
#post(url, body, headers = {}) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/wcc/api/rest_client/typhoeus_adapter.rb', line 20 def post(url, body, headers = {}) Response.new( Typhoeus.post( url, body: body.is_a?(String) ? body : body.to_json, headers: headers ) ) end |
#put(url, body, headers = {}) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/wcc/api/rest_client/typhoeus_adapter.rb', line 30 def put(url, body, headers = {}) Response.new( Typhoeus.put( url, body: body.is_a?(String) ? body : body.to_json, headers: headers ) ) end |