finapps 0.1.6.pre → 0.1.7.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/finapps/rest/client.rb +44 -1
- data/lib/finapps/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c5679a78a0f7bc2a210c2894d709bb20bd73331
|
4
|
+
data.tar.gz: a2171b887b3ec17c3ca3892d2da9e215e45d18c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9eb2e3e50717f26d42a862cf25e1a4897e9cae2980f69a1f33f0d9ca6585167630aec771ba03425c21710d13b250dbf688a3170f7fbc1eb67b8ca0d4396c260
|
7
|
+
data.tar.gz: 992729e551eed93037fae0749370d38c9432cf762034b4b07db13be1012cc492decdfb89127760e17a881eaf081f6e025e8e96b0442173d22437d7b9cd3b8b70
|
data/lib/finapps/rest/client.rb
CHANGED
@@ -34,6 +34,50 @@ module FinApps
|
|
34
34
|
logger.debug "##{__method__.to_s} => Completed"
|
35
35
|
end
|
36
36
|
|
37
|
+
# Performs HTTP GET, POST, UPDATE and DELETE requests.
|
38
|
+
# You shouldn't need to use this method directly,
|
39
|
+
# but it can be useful for debugging. Returns a hash obtained from parsing
|
40
|
+
# the JSON object in the response body.
|
41
|
+
#
|
42
|
+
# @param [String] path
|
43
|
+
# @param [String] method
|
44
|
+
# @param [Proc] proc
|
45
|
+
# @return [Hash,Array<String>]
|
46
|
+
def send(path, method, params = {}, &proc)
|
47
|
+
logger.debug "##{__method__.to_s} => Started"
|
48
|
+
result, error_messages = nil, nil
|
49
|
+
|
50
|
+
begin
|
51
|
+
|
52
|
+
case method
|
53
|
+
when :get
|
54
|
+
result, error_messages = get(path) { proc if block_given? }
|
55
|
+
when :post
|
56
|
+
result, error_messages = post(path, params) { proc if block_given? }
|
57
|
+
when :put
|
58
|
+
result, error_messages = put(path, params) { proc if block_given? }
|
59
|
+
when :delete
|
60
|
+
result, error_messages = delete(path, params) { proc if block_given? }
|
61
|
+
else
|
62
|
+
raise StandardError "Method not supported: #{method}."
|
63
|
+
end
|
64
|
+
|
65
|
+
rescue FinApps::REST::Error => error
|
66
|
+
error_messages = error.error_messages
|
67
|
+
rescue Faraday::ParsingError => error
|
68
|
+
error_messages = ['Unable to parse the server response.']
|
69
|
+
logger.debug "##{__method__.to_s} => Faraday::ParsingError, #{error.to_s}"
|
70
|
+
rescue Exception => error
|
71
|
+
error_messages = ['Unexpected error.']
|
72
|
+
logger.debug "##{__method__.to_s} => Exception, #{error.to_s}"
|
73
|
+
ensure
|
74
|
+
logger.debug "##{__method__.to_s} => Failed, error_messages: #{error_messages.pretty_inspect}" if error_messages.present?
|
75
|
+
end
|
76
|
+
|
77
|
+
logger.debug "##{__method__.to_s} => Completed"
|
78
|
+
return result, error_messages
|
79
|
+
end
|
80
|
+
|
37
81
|
# Performs an HTTP GET request. You shouldn't need to use this method directly,
|
38
82
|
# but it can be useful for debugging. Returns a hash obtained from parsing
|
39
83
|
# the JSON object in the response body.
|
@@ -54,7 +98,6 @@ module FinApps
|
|
54
98
|
if response.present? && block_given?
|
55
99
|
result = proc.call(response)
|
56
100
|
logger.debug "##{__method__.to_s} => parsed result: #{result.pretty_inspect}" if result.present?
|
57
|
-
|
58
101
|
end
|
59
102
|
rescue FinApps::REST::Error => error
|
60
103
|
error_messages = error.error_messages
|
data/lib/finapps/version.rb
CHANGED