finicity 0.1.1 → 0.1.2

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: 7b098f2e47f9c53c1f98d3a78f144b88aa3c1de2
4
- data.tar.gz: da0f3715ebe1058bc3aca43e8b23826dfc55c4e3
3
+ metadata.gz: 3bdd449e8495e55c19dba35b84698f9ecdd3881d
4
+ data.tar.gz: a2d7276438ddb21b0401e5c55cd29763a10975bf
5
5
  SHA512:
6
- metadata.gz: 3932de91e2a85786bf99a602ac765bfb6e07a816cf66fd2a094f20725442626b95c9378ca3cace828d45efd7e82ee20d9d2637abc0eb1d3d4e9915525d722e44
7
- data.tar.gz: a648e639ccda88f0d3fab206438b08c468cdf975023343a31a27011a9bfac6f82f4ebd126f064001dee40775b847eab82442fac8b2d79d3ee7e0c8729bd8ebdc
6
+ metadata.gz: 826f60559ea6e003196b151d3a0502482d2af3676f76fe3c237adc3f4456f24ed631d35f37439ef852509d272ae315de32a69db85cea0da9f0e1a30b9d430c01
7
+ data.tar.gz: 9eebfd4a6f96d929b7981aef2a197c984c18038ec8c680f9495123823820cb446954ce590addc035611d8b7604dc72384108ae4f61ebe1defa9c944183f5dd35
@@ -84,6 +84,20 @@ module Finicity
84
84
  end
85
85
  end
86
86
 
87
+ def delete_account(customer_id, account_id)
88
+ request = ::Finicity::V1::Request::DeleteAccount.new(token, customer_id, account_id)
89
+ request.log_request
90
+ response = request.delete_account
91
+ log_response(response)
92
+
93
+ if response.ok?
94
+ # No data to parse, so return a hash for consistent return type
95
+ return {}
96
+ else
97
+ raise_generic_error!(response)
98
+ end
99
+ end
100
+
87
101
  def delete_customer(customer_id)
88
102
  request = ::Finicity::V1::Request::DeleteCustomer.new(token, customer_id)
89
103
  response = request.delete_customer
@@ -324,6 +338,21 @@ module Finicity
324
338
  end
325
339
  end
326
340
 
341
+ # The login_credentials parameter is an array of hashes with the keys :id, :name, :value
342
+ def update_credentials(customer_id, account_id, login_credentials)
343
+ request = ::Finicity::V1::Request::UpdateCredentials.new(token, customer_id, account_id, login_credentials)
344
+ request.log_request
345
+ response = request.update_credentials
346
+ log_response(response)
347
+
348
+ if response.ok?
349
+ # No data to parse, so return a hash for consistent return type
350
+ return {}
351
+ else
352
+ raise_generic_error!(response)
353
+ end
354
+ end
355
+
327
356
  private
328
357
 
329
358
  def log_response(response)
@@ -1,6 +1,7 @@
1
1
  require 'finicity/v1/request/activate_accounts'
2
2
  require 'finicity/v1/request/activate_accounts_with_mfa'
3
3
  require 'finicity/v1/request/add_customer'
4
+ require 'finicity/v1/request/delete_account'
4
5
  require 'finicity/v1/request/delete_customer'
5
6
  require 'finicity/v1/request/discover_accounts'
6
7
  require 'finicity/v1/request/discover_accounts_with_mfa'
@@ -14,6 +15,7 @@ require 'finicity/v1/request/get_transactions'
14
15
  require 'finicity/v1/request/interactive_refresh_account'
15
16
  require 'finicity/v1/request/interactive_refresh_account_with_mfa'
16
17
  require 'finicity/v1/request/refresh_accounts'
18
+ require 'finicity/v1/request/update_credentials'
17
19
 
18
20
  require 'finicity/v1/response/accounts'
19
21
  require 'finicity/v1/response/customers'
@@ -0,0 +1,47 @@
1
+ module Finicity::V1
2
+ module Request
3
+ class DeleteAccount
4
+ include ::Finicity::Logger
5
+ extend ::HTTPClient::IncludeClient
6
+ include_http_client do |client|
7
+ client.cookie_manager = nil
8
+ end
9
+
10
+ ##
11
+ # Attributes
12
+ #
13
+ attr_accessor :account_id, :customer_id, :token
14
+
15
+ ##
16
+ # Instance Methods
17
+ #
18
+ def initialize(token, customer_id, account_id)
19
+ @account_id = account_id
20
+ @customer_id = customer_id
21
+ @token = token
22
+ end
23
+
24
+ def delete_account
25
+ http_client.delete(url, nil, headers)
26
+ end
27
+
28
+ def headers
29
+ {
30
+ 'Finicity-App-Key' => ::Finicity.config.app_key,
31
+ 'Finicity-App-Token' => token
32
+ }
33
+ end
34
+
35
+ def url
36
+ ::URI.join(
37
+ ::Finicity.config.base_url,
38
+ 'v1/',
39
+ 'customers/',
40
+ "#{customer_id}/",
41
+ 'accounts/',
42
+ "#{account_id}"
43
+ )
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,65 @@
1
+ module Finicity::V1
2
+ module Request
3
+ class UpdateCredentials
4
+ include ::Finicity::Logger
5
+ extend ::HTTPClient::IncludeClient
6
+ include_http_client do |client|
7
+ client.cookie_manager = nil
8
+ end
9
+
10
+ ##
11
+ # Attributes
12
+ #
13
+ attr_accessor :account_id, :customer_id, :login_credentials, :token
14
+
15
+ ##
16
+ # Instance Methods
17
+ #
18
+ def initialize(token, customer_id, account_id, login_credentials)
19
+ @account_id = account_id
20
+ @customer_id = customer_id
21
+ @login_credentials = login_credentials
22
+ @token = token
23
+ end
24
+
25
+ def body
26
+ builder = ::Nokogiri::XML::Builder.new do |xml|
27
+ xml.loginForm {
28
+ login_credentials.each do |login_credential|
29
+ xml.loginField {
30
+ xml.id(login_credential[:id])
31
+ xml.value(login_credential[:value])
32
+ }
33
+ end
34
+ }
35
+ end
36
+
37
+ builder.to_xml
38
+ end
39
+
40
+ def update_credentials
41
+ http_client.put(url, body, headers)
42
+ end
43
+
44
+ def headers
45
+ {
46
+ 'Finicity-App-Key' => ::Finicity.config.app_key,
47
+ 'Finicity-App-Token' => token,
48
+ 'Content-Type' => 'application/xml'
49
+ }
50
+ end
51
+
52
+ def url
53
+ ::URI.join(
54
+ ::Finicity.config.base_url,
55
+ 'v1/',
56
+ 'customers/',
57
+ "#{customer_id}/",
58
+ 'accounts/',
59
+ "#{account_id}/",
60
+ 'loginForm'
61
+ )
62
+ end
63
+ end
64
+ end
65
+ end
@@ -1,3 +1,3 @@
1
1
  module Finicity
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -143,6 +143,27 @@ describe ::Finicity::Client do
143
143
  end
144
144
  end
145
145
 
146
+ describe "#delete_account" do
147
+ context "when the response is successful" do
148
+ it "returns the parsed response" do
149
+ allow_any_instance_of(::Finicity::V1::Request::DeleteAccount).to(
150
+ receive(:delete_account).and_return(response)
151
+ )
152
+ response = subject.delete_account(1, 2)
153
+ response.should eq({})
154
+ end
155
+ end
156
+
157
+ context "when the response is an error" do
158
+ it "fails" do
159
+ allow_any_instance_of(::Finicity::V1::Request::DeleteAccount).to(
160
+ receive(:delete_account).and_return(error)
161
+ )
162
+ expect { subject.delete_account(1, 2) }.to raise_error(::Finicity::GenericError)
163
+ end
164
+ end
165
+ end
166
+
146
167
  describe "#delete_customer" do
147
168
  context "when the response is successful" do
148
169
  it "returns the parsed response" do
@@ -535,4 +556,25 @@ describe ::Finicity::Client do
535
556
  end
536
557
  end
537
558
  end
559
+
560
+ describe "#update_credentials" do
561
+ context "when the response is successful" do
562
+ it "returns the parsed response" do
563
+ allow_any_instance_of(::Finicity::V1::Request::UpdateCredentials).to(
564
+ receive(:update_credentials).and_return(response)
565
+ )
566
+ response = subject.update_credentials(1, 2, [])
567
+ response.should eq({})
568
+ end
569
+ end
570
+
571
+ context "when the response is an error" do
572
+ it "fails" do
573
+ allow_any_instance_of(::Finicity::V1::Request::UpdateCredentials).to(
574
+ receive(:update_credentials).and_return(error)
575
+ )
576
+ expect { subject.update_credentials(1, 2, []) }.to raise_error(::Finicity::GenericError)
577
+ end
578
+ end
579
+ end
538
580
  end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe ::Finicity::V1::Request::DeleteAccount do
4
+ subject { described_class.new("token-123", 1, 2) }
5
+
6
+ describe "#headers" do
7
+ it "has correct headers" do
8
+ subject.headers.should have_key('Finicity-App-Key')
9
+ subject.headers.should have_key('Finicity-App-Token')
10
+ end
11
+ end
12
+
13
+ describe "#url" do
14
+ it "has a correct url" do
15
+ subject.url.to_s.should include('customers/1/accounts/2')
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ describe ::Finicity::V1::Request::UpdateCredentials do
4
+ let(:login_credential) {
5
+ {
6
+ :id => '1',
7
+ :name => 'username',
8
+ :value => 'test_user'
9
+ }
10
+ }
11
+ let(:login_credentials) { [login_credential] }
12
+
13
+ subject { described_class.new("token-123", 1, 2, login_credentials) }
14
+
15
+ describe "#headers" do
16
+ it "has correct headers" do
17
+ subject.headers.should have_key('Finicity-App-Key')
18
+ subject.headers.should have_key('Finicity-App-Token')
19
+ subject.headers.should have_key('Content-Type')
20
+ end
21
+ end
22
+
23
+ describe "#body" do
24
+ it "forms the correct id" do
25
+ subject.body.should include("<id>1</id>")
26
+ end
27
+
28
+ it "forms the correct value" do
29
+ subject.body.should include("<value>test_user</value>")
30
+ end
31
+ end
32
+
33
+ describe "#url" do
34
+ it "has a correct url" do
35
+ subject.url.to_s.should include('customers/1/accounts/2/loginForm')
36
+ end
37
+ end
38
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: finicity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Moneydesktop
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-09 00:00:00.000000000 Z
11
+ date: 2014-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient
@@ -160,6 +160,7 @@ files:
160
160
  - lib/finicity/v1/request/activate_accounts.rb
161
161
  - lib/finicity/v1/request/activate_accounts_with_mfa.rb
162
162
  - lib/finicity/v1/request/add_customer.rb
163
+ - lib/finicity/v1/request/delete_account.rb
163
164
  - lib/finicity/v1/request/delete_customer.rb
164
165
  - lib/finicity/v1/request/discover_accounts.rb
165
166
  - lib/finicity/v1/request/discover_accounts_with_mfa.rb
@@ -173,6 +174,7 @@ files:
173
174
  - lib/finicity/v1/request/interactive_refresh_account.rb
174
175
  - lib/finicity/v1/request/interactive_refresh_account_with_mfa.rb
175
176
  - lib/finicity/v1/request/refresh_accounts.rb
177
+ - lib/finicity/v1/request/update_credentials.rb
176
178
  - lib/finicity/v1/response/accounts.rb
177
179
  - lib/finicity/v1/response/customers.rb
178
180
  - lib/finicity/v1/response/error.rb
@@ -188,6 +190,7 @@ files:
188
190
  - spec/finicity/v1/request/activate_accounts_spec.rb
189
191
  - spec/finicity/v1/request/activate_accounts_with_mfa_spec.rb
190
192
  - spec/finicity/v1/request/add_customer_spec.rb
193
+ - spec/finicity/v1/request/delete_account_spec.rb
191
194
  - spec/finicity/v1/request/delete_customer_spec.rb
192
195
  - spec/finicity/v1/request/discover_accounts_spec.rb
193
196
  - spec/finicity/v1/request/discover_accounts_with_mfa_spec.rb
@@ -201,6 +204,7 @@ files:
201
204
  - spec/finicity/v1/request/interactive_refresh_account_spec.rb
202
205
  - spec/finicity/v1/request/interactive_refresh_account_with_mfa_spec.rb
203
206
  - spec/finicity/v1/request/refresh_accounts_spec.rb
207
+ - spec/finicity/v1/request/update_credentials_spec.rb
204
208
  - spec/finicity/v1/response/accounts_spec.rb
205
209
  - spec/finicity/v1/response/customers_spec.rb
206
210
  - spec/finicity/v1/response/error_spec.rb
@@ -240,6 +244,7 @@ test_files:
240
244
  - spec/finicity/v1/request/activate_accounts_spec.rb
241
245
  - spec/finicity/v1/request/activate_accounts_with_mfa_spec.rb
242
246
  - spec/finicity/v1/request/add_customer_spec.rb
247
+ - spec/finicity/v1/request/delete_account_spec.rb
243
248
  - spec/finicity/v1/request/delete_customer_spec.rb
244
249
  - spec/finicity/v1/request/discover_accounts_spec.rb
245
250
  - spec/finicity/v1/request/discover_accounts_with_mfa_spec.rb
@@ -253,6 +258,7 @@ test_files:
253
258
  - spec/finicity/v1/request/interactive_refresh_account_spec.rb
254
259
  - spec/finicity/v1/request/interactive_refresh_account_with_mfa_spec.rb
255
260
  - spec/finicity/v1/request/refresh_accounts_spec.rb
261
+ - spec/finicity/v1/request/update_credentials_spec.rb
256
262
  - spec/finicity/v1/response/accounts_spec.rb
257
263
  - spec/finicity/v1/response/customers_spec.rb
258
264
  - spec/finicity/v1/response/error_spec.rb