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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6787ab652932cc6ebd94296498ca1a536323ae30
4
- data.tar.gz: ddeec478a8fac58e0fedbdb4bbd719499bf5bd59
3
+ metadata.gz: 2c5679a78a0f7bc2a210c2894d709bb20bd73331
4
+ data.tar.gz: a2171b887b3ec17c3ca3892d2da9e215e45d18c1
5
5
  SHA512:
6
- metadata.gz: 40dd6e6c24d34ff06d08634beaaa86f105427e49613a522d148f5cf38173a649d344b1e77efcfbdf37baf4d82655addf2b18655fd33207565bb9628cf786eb64
7
- data.tar.gz: 7d677f11652727c21f6c7dadc63dd1b7052388fcd1efd1d84ac13eb048bc60a578442e050063629992128f376ae43484c495820fba0c4b7814b3aa8e37a277e2
6
+ metadata.gz: b9eb2e3e50717f26d42a862cf25e1a4897e9cae2980f69a1f33f0d9ca6585167630aec771ba03425c21710d13b250dbf688a3170f7fbc1eb67b8ca0d4396c260
7
+ data.tar.gz: 992729e551eed93037fae0749370d38c9432cf762034b4b07db13be1012cc492decdfb89127760e17a881eaf081f6e025e8e96b0442173d22437d7b9cd3b8b70
@@ -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
@@ -1,3 +1,3 @@
1
1
  module FinApps
2
- VERSION = '0.1.6.pre'
2
+ VERSION = '0.1.7.pre'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: finapps
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6.pre
4
+ version: 0.1.7.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erich Quintero