finapps 0.1.10.pre → 0.1.11.pre

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f9bb9c1f912e72afc9a3b0b8c72e1f8285df32a7
4
- data.tar.gz: 7047152f6c890bd120dc1e0cd1ef4ce76f393e09
3
+ metadata.gz: 53f9ba3a47f60be7a1331b950167d75dfc035840
4
+ data.tar.gz: ecb81f293534522901e6227f5d2a9133c7b8b858
5
5
  SHA512:
6
- metadata.gz: 1739253c2b1d1c9420ceb99c486ea5d30f64763552d221fc41c015649a7a45c6b219d36159ef4906294044f73258c23e196cf3e2f3e205c2c7ef6c76f271897e
7
- data.tar.gz: 445c302fe03d7727540fbd58e7bab99d4b6e3a5408adfe2a91ae5233f66d910f38808c59a77f9520aa1ab3ec35ba51b0c81431d6b4073ee10f66f52980c3ec77
6
+ metadata.gz: 1fa4e903b29d153006651bea2983304af2bac2e1bda130ea5e7f914be21a809c0791905288b97c0136487c345aa5dbc22e9c5c64194d3eb8262ad548e3fa86c4
7
+ data.tar.gz: 9cfb4694e3b0e44b3358f85f9d3938155053872b1f44e0ae1fc0fc66611f1a050761e5cb9d0630496c5cdd19a9ecb19402afa18fdf96838da3c422875f8fb64d
@@ -52,17 +52,22 @@ module FinApps
52
52
 
53
53
  case method
54
54
  when :get
55
- result, error_messages = get(path) { proc if block_given? }
55
+ response = get(path)
56
56
  when :post
57
- result, error_messages = post(path, params) { proc if block_given? }
57
+ response = post(path, params)
58
58
  when :put
59
- result, error_messages = put(path, params) { proc if block_given? }
59
+ response = put(path, params)
60
60
  when :delete
61
- result, error_messages = delete(path, params) { proc if block_given? }
61
+ response = delete(path, params)
62
62
  else
63
63
  raise StandardError "Method not supported: #{method}."
64
64
  end
65
65
 
66
+ if response.present? && block_given?
67
+ result = proc.call(response)
68
+ logger.debug "##{__method__.to_s} => parsed result: #{result.pretty_inspect}" if result.present?
69
+ end
70
+
66
71
  rescue FinApps::REST::Error => error
67
72
  error_messages = error.error_messages
68
73
  rescue Faraday::ParsingError => error
@@ -79,29 +84,41 @@ module FinApps
79
84
  return result, error_messages
80
85
  end
81
86
 
87
+ # @param [String] user_identifier
88
+ # @param [String] user_token
89
+ def user_credentials!(user_identifier, user_token)
90
+ logger.debug "##{__method__.to_s} => Started"
91
+
92
+ {:user_identifier => user_identifier, :user_token => user_token}.validate_required_strings!
93
+ logger.debug "##{__method__.to_s} => Credentials passed validation. Attempting to set user credentials on current connection."
94
+
95
+
96
+ @config[:user_identifier] = user_identifier
97
+ @config[:user_token] = user_token
98
+ @connection = set_up_connection(@company_credentials, @config)
99
+
100
+ logger.debug "##{__method__.to_s} => Completed"
101
+ end
102
+
103
+ private
104
+
82
105
  # Performs an HTTP GET request. You shouldn't need to use this method directly,
83
106
  # but it can be useful for debugging. Returns a hash obtained from parsing
84
107
  # the JSON object in the response body.
85
108
  #
86
109
  # @param [String] path
87
- # @param [Proc] proc
88
110
  # @return [Hash,Array<String>]
89
- def get(path, &proc)
111
+ def get(path)
90
112
  logger.debug "##{__method__.to_s} => Started"
91
113
  raise MissingArgumentsError.new 'Missing argument: path.' if path.blank?
92
- result, error_messages = nil, nil
93
114
 
94
115
  logger.debug "##{__method__.to_s} => GET path:#{path}"
95
116
  response = @connection.get do |req|
96
117
  req.url path
97
118
  end
98
- if response.present? && block_given?
99
- result = proc.call(response)
100
- logger.debug "##{__method__.to_s} => parsed result: #{result.pretty_inspect}" if result.present?
101
- end
102
119
 
103
120
  logger.debug "##{__method__.to_s} => Completed"
104
- return result, error_messages
121
+ response
105
122
  end
106
123
 
107
124
  # Performs an HTTP POST request. You shouldn't need to use this method directly,
@@ -110,25 +127,19 @@ module FinApps
110
127
  #
111
128
  # @param [String] path
112
129
  # @param [Hash] params
113
- # @param [Proc] proc
114
130
  # @return [Hash,Array<String>]
115
- def post(path, params = {}, &proc)
131
+ def post(path, params = {})
116
132
  logger.debug "##{__method__.to_s} => Started"
117
133
  raise MissingArgumentsError.new 'Missing argument: path.' if path.blank?
118
- result, error_messages = nil, nil
119
134
 
120
135
  logger.debug "##{__method__.to_s} => POST path:#{path} params:#{skip_sensitive_data(params)}"
121
136
  response = @connection.post do |req|
122
137
  req.url path
123
138
  req.body = params
124
139
  end
125
- if response.present? && block_given?
126
- result = proc.call(response)
127
- logger.debug "##{__method__.to_s} => parsed result: #{result.pretty_inspect}" if result.present?
128
- end
129
140
 
130
141
  logger.debug "##{__method__.to_s} => Completed"
131
- return result, error_messages
142
+ response
132
143
  end
133
144
 
134
145
  # Performs an HTTP DELETE request. You shouldn't need to use this method directly,
@@ -137,50 +148,21 @@ module FinApps
137
148
  #
138
149
  # @param [String] path
139
150
  # @param [Hash] params
140
- # @param [Proc] proc
141
151
  # @return [Hash,Array<String>]
142
- def delete(path, params = {}, &proc)
152
+ def delete(path, params = {})
143
153
  logger.debug "##{__method__.to_s} => Started"
144
154
  raise MissingArgumentsError.new 'Missing argument: path.' if path.blank?
145
- response, result, error_messages = nil, nil, nil
146
-
147
- begin
148
- logger.debug "##{__method__.to_s} => DELETE path:#{path} params:#{skip_sensitive_data(params)}"
149
- response = @connection.delete do |req|
150
- req.url path
151
- req.body = params
152
- end
153
- if response.present? && block_given?
154
- result = proc.call(response)
155
- logger.debug "##{__method__.to_s} => parsed result: #{result.pretty_inspect}" if result.present?
156
- end
157
155
 
158
- rescue FinApps::REST::Error => error
159
- error_messages = error.error_messages
160
- logger.debug "##{__method__.to_s} => Failed, error_messages: #{error_messages.pretty_inspect}" if error_messages.present?
156
+ logger.debug "##{__method__.to_s} => DELETE path:#{path} params:#{skip_sensitive_data(params)}"
157
+ response = @connection.delete do |req|
158
+ req.url path
159
+ req.body = params
161
160
  end
162
161
 
163
162
  logger.debug "##{__method__.to_s} => Completed"
164
- return result, error_messages
163
+ response
165
164
  end
166
165
 
167
- # @param [String] user_identifier
168
- # @param [String] user_token
169
- def user_credentials!(user_identifier, user_token)
170
- logger.debug "##{__method__.to_s} => Started"
171
-
172
- {:user_identifier => user_identifier, :user_token => user_token}.validate_required_strings!
173
- logger.debug "##{__method__.to_s} => Credentials passed validation. Attempting to set user credentials on current connection."
174
-
175
-
176
- @config[:user_identifier] = user_identifier
177
- @config[:user_token] = user_token
178
- @connection = set_up_connection(@company_credentials, @config)
179
-
180
- logger.debug "##{__method__.to_s} => Completed"
181
- end
182
-
183
- private
184
166
 
185
167
  def set_up_resources
186
168
  @users ||= FinApps::REST::Users.new self
@@ -1,3 +1,3 @@
1
1
  module FinApps
2
- VERSION = '0.1.10.pre'
2
+ VERSION = '0.1.11.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.10.pre
4
+ version: 0.1.11.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erich Quintero