Module: MangoApi::HttpClient
- Defined in:
- lib/mangopay/api/http_client.rb
Overview
Handles HTTP communication.
Constant Summary collapse
- LOG =
MangoPay::LogProvider.provide(self)
Class Method Summary collapse
-
.api_headers ⇒ Object
Provides a hash containing necessary headers for API calls.
-
.get(uri, filter_request = nil) ⇒ Hash
Launches a self-configuring GET request, with headers required by the API.
-
.get_raw(uri, &block) ⇒ Hash
Launches a fully customizable GET request.
-
.post(uri, entity, id_key = nil) ⇒ Hash
Launches a self-configuring POST request, with headers required by the API.
-
.post_raw(uri, &block) ⇒ Hash
Launches a fully customizable POST request.
-
.put(uri, entity = nil) ⇒ Hash
Launches a self-configuring PUT request, with headers required by the API.
-
.put_raw(uri, &block) ⇒ Hash
Launches a fully customizable PUT request.
Class Method Details
.api_headers ⇒ Object
Provides a hash containing necessary headers for API calls.
94 95 96 97 |
# File 'lib/mangopay/api/http_client.rb', line 94 def api_headers initialize_headers unless @default_headers @default_headers end |
.get(uri, filter_request = nil) ⇒ Hash
Launches a self-configuring GET request, with headers required by the API. Applies filters if provided.
74 75 76 77 78 79 |
# File 'lib/mangopay/api/http_client.rb', line 74 def get(uri, filter_request = nil) request proc { |ury, &block| get_raw(ury, &block) }, uri, nil, filter_request end |
.get_raw(uri, &block) ⇒ Hash
Launches a fully customizable GET request. Expects to be given a block to which it yields the request object before execution to be configured.
87 88 89 90 91 |
# File 'lib/mangopay/api/http_client.rb', line 87 def get_raw(uri, &block) request_raw Net::HTTP::Get, uri, &block end |
.post(uri, entity, id_key = nil) ⇒ Hash
Launches a self-configuring POST request, with headers required by the API.
22 23 24 25 26 27 28 |
# File 'lib/mangopay/api/http_client.rb', line 22 def post(uri, entity, id_key = nil) request proc { |ury, &block| post_raw(ury, &block) }, uri, entity, nil, id_key end |
.post_raw(uri, &block) ⇒ Hash
Launches a fully customizable POST request. Expects to be given a block to which it yields the request object before execution to be configured.
36 37 38 39 40 |
# File 'lib/mangopay/api/http_client.rb', line 36 def post_raw(uri, &block) request_raw Net::HTTP::Post, uri, &block end |
.put(uri, entity = nil) ⇒ Hash
Launches a self-configuring PUT request, with headers required by the API.
49 50 51 52 53 |
# File 'lib/mangopay/api/http_client.rb', line 49 def put(uri, entity = nil) request proc { |ury, &block| put_raw(ury, &block) }, uri, entity end |
.put_raw(uri, &block) ⇒ Hash
Launches a fully customizable PUT request. Expects to be given a block to which it yields the request object before execution to be configured.
61 62 63 64 65 |
# File 'lib/mangopay/api/http_client.rb', line 61 def put_raw(uri, &block) request_raw Net::HTTP::Put, uri, &block end |