Module: Poms::Api::Client
Overview
The Client module isolates all HTTP interactions, regardless of the driver module to implement the actual operations. Use the Client module to build signed requests and execute them.
Constant Summary
Drivers::NetHttp::NET_HTTP_ERRORS
Class Method Summary
collapse
execute
Class Method Details
.get(uri, credentials, headers = {}) ⇒ Object
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/poms/api/client.rb', line 18
def get(uri, credentials, = {})
handle_response(
execute(
Auth.sign(
prepare_get(uri, ),
credentials
)
)
)
end
|
.handle_response(response) ⇒ Object
40
41
42
43
44
45
46
47
|
# File 'lib/poms/api/client.rb', line 40
def handle_response(response)
case response.code
when 400..499 then raise Errors::HttpMissingError, response.code
when 500..599 then raise Errors::HttpServerError, response.code
else
response
end
end
|
.post(uri, body, credentials, headers = {}) ⇒ Object
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/poms/api/client.rb', line 29
def post(uri, body, credentials, = {})
handle_response(
execute(
Auth.sign(
prepare_post(uri, body, ),
credentials
)
)
)
end
|
.prepare_get(uri, headers = {}) ⇒ Object
49
50
51
|
# File 'lib/poms/api/client.rb', line 49
def prepare_get(uri, = {})
Request.get(uri, nil, )
end
|
.prepare_post(uri, body, headers = {}) ⇒ Object
53
54
55
|
# File 'lib/poms/api/client.rb', line 53
def prepare_post(uri, body, = {})
Request.post(uri, body, )
end
|