synapsis 0.0.7 → 0.0.8

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: 14bcbb633ac4588d0c5c2aec128086bc1a76ec6a
4
- data.tar.gz: 161ed76607fc6fe4a5336e23423f1e2d3f894d8f
3
+ metadata.gz: ecde15b08bf18590a20a13795e91010562449565
4
+ data.tar.gz: 5e496bb5ca4b58af878323805c01c0da1248d548
5
5
  SHA512:
6
- metadata.gz: 51b3daec18b29486ea45dd9b66b90cf73e6b88ec644ff8872eec042af25efc21b63558ce1c50ea3ffcce64d14bbf021faaa925fad6d7c2496d75738784df4d60
7
- data.tar.gz: 55c997216c62ec91e687c59bcd651e6aca46e9d080e094a2a45706a160b481f64f76491bdb1fc6888562ee4dbacd9a61b551866708a5ec36a67fd32a46d73599
6
+ metadata.gz: a47452de08e2b1432cf57b05101c8aeefee2ee0a81ea06c715c55af993dbb075269b216e51d0c16a5d06cd16f730ff3a26072d4940324049b86a085b97bb256f
7
+ data.tar.gz: c9f6b96d45eecbd844e2f65be73067b071beed149ca43626082c93e89a0812aacffb321b0ba9b08909cd868b6f154f45d503588c0c091727adf5ca64b6f6bb10
@@ -1,10 +1,6 @@
1
1
  module Synapsis::APIOperations::Create
2
2
  def create_request(params)
3
- Synapsis.connection.post do |req|
4
- req.headers['Content-Type'] = 'application/json'
5
- req.url create_url
6
- req.body = JSON.generate(params)
7
- end
3
+ request(:post, create_url, params)
8
4
  end
9
5
 
10
6
  def create_url
@@ -1,10 +1,6 @@
1
1
  module Synapsis::APIOperations::Edit
2
2
  def edit_request(params)
3
- Synapsis.connection.post do |req|
4
- req.headers['Content-Type'] = 'application/json'
5
- req.url edit_url
6
- req.body = JSON.generate(params)
7
- end
3
+ request(:post, edit_url, params)
8
4
  end
9
5
 
10
6
  def edit_url
@@ -1,10 +1,11 @@
1
1
  module Synapsis::APIOperations::View
2
+ def view(params)
3
+ response = view_request(params)
4
+ return_response(response)
5
+ end
6
+
2
7
  def view_request(params)
3
- Synapsis.connection.post do |req|
4
- req.headers['Content-Type'] = 'application/json'
5
- req.url view_url
6
- req.body = JSON.generate(params)
7
- end
8
+ request(:post, view_url, params)
8
9
  end
9
10
 
10
11
  def view_url
@@ -1,4 +1,12 @@
1
1
  class Synapsis::APIResource
2
+ def self.request(method = :post, url, params)
3
+ Synapsis.connection.send(method) do |req|
4
+ req.headers['Content-Type'] = 'application/json'
5
+ req.url url
6
+ req.body = JSON.generate(params)
7
+ end
8
+ end
9
+
2
10
  def self.class_name
3
11
  name.partition('::').last.downcase
4
12
  end
@@ -13,7 +21,7 @@ class Synapsis::APIResource
13
21
  if response.success?
14
22
  return parsed_response
15
23
  else
16
- raise Synapsis::Error, parsed_response['reason']
24
+ raise Synapsis::Error, parsed_response['reason'] || parsed_response['error_message']
17
25
  end
18
26
  end
19
27
 
data/lib/synapsis/bank.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  class Synapsis::Bank < Synapsis::APIResource
2
2
  include Synapsis::Utilities
3
3
  extend Synapsis::APIOperations::Create
4
+ extend Synapsis::APIOperations::View
4
5
 
5
6
  module AccountClass
6
7
  PERSONAL = 1
@@ -37,13 +38,9 @@ class Synapsis::Bank < Synapsis::APIResource
37
38
  return_response(added_bank)
38
39
  end
39
40
 
40
- def self.link(params)
41
- partially_linked_bank = Synapsis.connection.post do |req|
42
- req.headers['Content-Type'] = 'application/json'
43
- req.url "#{API_V2_PATH}bank/login/?is_dev=yes"
44
- req.body = JSON.generate(params)
45
- end
46
41
 
42
+ def self.link(params)
43
+ partially_linked_bank = request(:post, bank_link_url, params)
47
44
  parsed_partially_linked_bank = parse_as_synapse_resource(partially_linked_bank)
48
45
 
49
46
  if parsed_partially_linked_bank.success
@@ -53,15 +50,10 @@ class Synapsis::Bank < Synapsis::APIResource
53
50
 
54
51
  @access_token = parsed_partially_linked_bank.response.access_token
55
52
 
56
- new_bank = Synapsis.connection.post do |req|
57
- req.headers['Content-Type'] = 'application/json'
58
- req.url "#{API_V2_PATH}bank/mfa/?is_dev=yes"
59
- req.body = JSON.generate(params.merge(access_token: @access_token))
60
- end
61
-
53
+ new_bank = request(:post, bank_mfa_url, params.merge(access_token: @access_token))
62
54
  parsed_new_bank = parse_as_synapse_resource(new_bank)
63
55
 
64
- if parsed_new_bank.banks
56
+ if parsed_new_bank.banks # SynapseAPI will return an array of the banks if the MFA process was successful
65
57
  return parsed_new_bank
66
58
  else
67
59
  raise Synapsis::Error, 'Wrong MFA answer.'
@@ -71,28 +63,32 @@ class Synapsis::Bank < Synapsis::APIResource
71
63
  end
72
64
  end
73
65
 
74
- def self.view_linked_banks(params)
75
- self.new(params).view_linked_banks
66
+ def self.view_linked_banks(oauth_token)
67
+ response = view_request(oauth_consumer_key: oauth_token)
68
+ return_response(response)
76
69
  end
77
70
 
78
71
  def self.remove(bank_id, oauth_consumer_key)
79
- response = Synapsis.connection.post do |req|
80
- req.headers['Content-Type'] = 'application/json'
81
- req.url "#{API_V2_PATH}bank/delete/"
82
- req.body = JSON.generate(
83
- bank_id: bank_id,
84
- oauth_consumer_key: oauth_consumer_key
85
- )
86
- end
72
+ params = {
73
+ bank_id: bank_id,
74
+ oauth_consumer_key: oauth_consumer_key
75
+ }
87
76
 
77
+ response = request(:post, bank_delete_url, params)
88
78
  return_response(response)
89
79
  end
90
80
 
91
- def view_linked_banks
92
- Synapsis.connection.post do |req|
93
- req.headers['Content-Type'] = 'application/json'
94
- req.url "#{API_V2_PATH}bank/show/"
95
- req.body = build_json_from_variable_hash
96
- end
81
+ private
82
+
83
+ def self.bank_link_url
84
+ "#{API_V2_PATH}bank/login/?is_dev=yes"
85
+ end
86
+
87
+ def self.bank_mfa_url
88
+ "#{API_V2_PATH}bank/mfa/?is_dev=yes"
89
+ end
90
+
91
+ def self.bank_delete_url
92
+ "#{API_V2_PATH}bank/delete/"
97
93
  end
98
94
  end
@@ -0,0 +1,10 @@
1
+ class Synapsis::Card < Synapsis::APIResource
2
+ extend Synapsis::APIOperations::Create
3
+ extend Synapsis::APIOperations::View
4
+
5
+ def self.add(params)
6
+ response = create_request(params)
7
+ return_response(response)
8
+ end
9
+ end
10
+
@@ -0,0 +1,31 @@
1
+ class Synapsis::MassPay < Synapsis::APIResource
2
+ extend Synapsis::APIOperations::Create
3
+ extend Synapsis::APIOperations::View
4
+
5
+ COST_PER_MASS_PAY = 0.1
6
+
7
+ def self.cost_per_mass_pay
8
+ COST_PER_MASS_PAY
9
+ end
10
+
11
+ def self.add(mass_pays:, oauth_consumer_key:)
12
+ params = {
13
+ mass_pays: mass_pays,
14
+ oauth_consumer_key: oauth_consumer_key
15
+ }
16
+
17
+ response = create_request(params)
18
+ return_response(response)
19
+ end
20
+
21
+ def self.show(mass_pay_id: {}, oauth_consumer_key:)
22
+ params = {
23
+ id: mass_pay_id,
24
+ oauth_consumer_key: oauth_consumer_key
25
+ }
26
+
27
+ response = view_request(params)
28
+ return_response(response)
29
+ end
30
+ end
31
+
@@ -7,6 +7,11 @@ class Synapsis::Order < Synapsis::APIResource
7
7
  return_response(response)
8
8
  end
9
9
 
10
+ def self.poll(order_id:)
11
+ response = request(:post, poll_url, order_id: order_id)
12
+ return_response(response)
13
+ end
14
+
10
15
  def self.synapse_fee(transaction_amount)
11
16
  if transaction_amount > 10
12
17
  0.25
@@ -14,5 +19,11 @@ class Synapsis::Order < Synapsis::APIResource
14
19
  0.1
15
20
  end
16
21
  end
22
+
23
+ private
24
+
25
+ def self.poll_url
26
+ "#{API_V2_PATH}order/poll"
27
+ end
17
28
  end
18
29
 
data/lib/synapsis/user.rb CHANGED
@@ -15,8 +15,11 @@ class Synapsis::User < Synapsis::APIResource
15
15
  end
16
16
 
17
17
  def self.view(oauth_token)
18
- response = view_request('oauth_consumer_key' => oauth_token)
19
- return_response(response)
18
+ show('oauth_consumer_key' => oauth_token)
19
+ end
20
+
21
+ def self.view_linked_banks(oauth_token)
22
+ Synapsis::Bank.view_linked_banks(oauth_token)
20
23
  end
21
24
 
22
25
  private
@@ -1,3 +1,3 @@
1
1
  module Synapsis
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -6,13 +6,11 @@ class Synapsis::Withdrawal < Synapsis::APIResource
6
6
  # Note: If you do not supply the bank_id, Synapse will attempt to withdraw from the primary bank.
7
7
  def self.create(params)
8
8
  response = create_request(params)
9
-
10
9
  return_response(response)
11
10
  end
12
11
 
13
12
  def self.view(params)
14
13
  response = view_request(params)
15
-
16
14
  return_response(response)
17
15
  end
18
16
 
data/lib/synapsis.rb CHANGED
@@ -20,6 +20,8 @@ require "synapsis/bank"
20
20
  require "synapsis/withdrawal"
21
21
  require "synapsis/deposit"
22
22
  require "synapsis/order"
23
+ require "synapsis/card"
24
+ require "synapsis/mass_pay"
23
25
  require "synapsis/error"
24
26
 
25
27
  API_V2_PATH = 'api/v2/'
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Synapsis::Card do
4
+ let!(:users_consumer_key) { 'dcd234d9d9fb55ad9711c4c41e254868ef3768d4' }
5
+ describe '.add' do
6
+ context 'happy path' do
7
+ it 'returns the created Card object' do
8
+ card_params = {
9
+ legal_name: 'Test Person',
10
+ account_number: '1111111112',
11
+ routing_number: '121000358',
12
+ amount: 1,
13
+ trans_type: 0,
14
+ account_class: 1,
15
+ account_type: 1,
16
+ oauth_consumer_key: users_consumer_key
17
+ }
18
+
19
+ added_card_response = Synapsis::Card.add(card_params)
20
+
21
+ expect(added_card_response).to respond_to(:card)
22
+ expect(added_card_response.card).to respond_to(:id)
23
+ expect(added_card_response).to respond_to(:success)
24
+ end
25
+ end
26
+ end
27
+
28
+ context '.show' do
29
+ context 'without id parameter' do
30
+ context 'happy path' do
31
+ it 'shows all of the user\'s cards' do
32
+ card_params = {
33
+ oauth_consumer_key: users_consumer_key
34
+ }
35
+
36
+ shown_card_response = Synapsis::Card.show(card_params)
37
+
38
+ expect(shown_card_response).to respond_to(:cards)
39
+ expect(shown_card_response.obj_count).to be > 1
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -12,10 +12,16 @@ RSpec.describe Synapsis::Deposit do
12
12
  it 'constructs the correct deposit object' do
13
13
  deposit_response = Synapsis::Deposit.create(deposit_params)
14
14
 
15
+ FIRST_LEVEL_PARAMS = ['deposit', 'reason', 'success']
16
+
15
17
  DEPOSIT_SPECIFIC_PARAMS = ['amount', 'bank', 'date_created', 'id', 'resource_uri', 'status', 'status_url', 'user_id']
16
18
 
17
- (DEPOSIT_SPECIFIC_PARAMS - ['status_url']).each do |x|
18
- expect(deposit_response.deposit.send(x.to_s.gsub('@', ''))).not_to be_nil
19
+ FIRST_LEVEL_PARAMS.each do |param|
20
+ expect(deposit_response).to respond_to(param)
21
+ end
22
+
23
+ DEPOSIT_SPECIFIC_PARAMS.each do |param|
24
+ expect(deposit_response.deposit).to respond_to(param)
19
25
  end
20
26
  end
21
27
  end
@@ -0,0 +1,129 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Synapsis::MassPay do
4
+ let!(:users_consumer_key) { 'dcd234d9d9fb55ad9711c4c41e254868ef3768d4' }
5
+ describe '.add' do
6
+ # These tests might fail if the guy runs out of money
7
+ context 'happy path' do
8
+ let!(:delta) { 0.001 }
9
+ let!(:mass_pay_hash) {{
10
+ legal_name: 'Test Person',
11
+ account_number: '1111111112',
12
+ routing_number: '121000358',
13
+ amount: 1,
14
+ trans_type: 0,
15
+ account_class: 1,
16
+ account_type: 1
17
+ }}
18
+ let!(:mass_pay_hash2) {{
19
+ legal_name: 'Test Person2',
20
+ account_number: '1111111112',
21
+ routing_number: '121000359',
22
+ amount: 1,
23
+ trans_type: 0,
24
+ account_class: 1,
25
+ account_type: 1
26
+ }}
27
+
28
+ it 'returns an array of MassPay objects' do
29
+ mass_pay_response = Synapsis::MassPay.add(
30
+ mass_pays: [mass_pay_hash, mass_pay_hash2],
31
+ oauth_consumer_key: users_consumer_key)
32
+
33
+ expect(mass_pay_response).to respond_to(:mass_pays)
34
+ expect(mass_pay_response.mass_pays.count).to eq 2
35
+ expect(mass_pay_response).to respond_to(:success)
36
+ end
37
+
38
+ it 'deducts the user\'s account by the total amount plus 0.1 per mass pay' do
39
+ users_balance = Synapsis::User.view(users_consumer_key).user.balance
40
+
41
+ Synapsis::MassPay.add(
42
+ mass_pays: [mass_pay_hash, mass_pay_hash2],
43
+ oauth_consumer_key: users_consumer_key)
44
+
45
+ users_balance_after = Synapsis::User.view(users_consumer_key).user.balance
46
+ expect(users_balance_after).to be_within(delta).of(users_balance - mass_pay_hash[:amount] - mass_pay_hash2[:amount] - (2 * Synapsis::MassPay.cost_per_mass_pay))
47
+ end
48
+ end
49
+ end
50
+
51
+ describe '.add (via cards)' do
52
+ # These tests might fail if the guy runs out of money
53
+ context 'happy path' do
54
+ let!(:delta) { 0.001 }
55
+ let!(:mass_pay_hash) {{
56
+ amount: 1,
57
+ card_id: 359,
58
+ trans_type: 0
59
+ }}
60
+ let!(:mass_pay_hash2) {{
61
+ amount: 1,
62
+ card_id: 360,
63
+ trans_type: 0
64
+ }}
65
+
66
+ it 'returns an array of MassPay objects' do
67
+ mass_pay_response = Synapsis::MassPay.add(
68
+ mass_pays: [mass_pay_hash, mass_pay_hash2],
69
+ oauth_consumer_key: users_consumer_key)
70
+
71
+ expect(mass_pay_response).to respond_to(:mass_pays)
72
+ expect(mass_pay_response.mass_pays.count).to eq 2
73
+ expect(mass_pay_response).to respond_to(:success)
74
+ end
75
+
76
+ it 'deducts the user\'s account by the total amount plus 0.1 per mass pay' do
77
+ users_balance = Synapsis::User.view(users_consumer_key).user.balance
78
+
79
+ Synapsis::MassPay.add(
80
+ mass_pays: [mass_pay_hash, mass_pay_hash2],
81
+ oauth_consumer_key: users_consumer_key)
82
+
83
+ users_balance_after = Synapsis::User.view(users_consumer_key).user.balance
84
+ expect(users_balance_after).to be_within(delta).of(users_balance - mass_pay_hash[:amount] - mass_pay_hash2[:amount] - (2 * Synapsis::MassPay.cost_per_mass_pay))
85
+ end
86
+ end
87
+ end
88
+
89
+ describe '.show' do
90
+ context 'with mass_pay_id argument' do
91
+ context 'happy path' do
92
+ it 'returns a MassPay object' do
93
+ view_params = {
94
+ mass_pay_id: 721,
95
+ oauth_consumer_key: users_consumer_key
96
+ }
97
+
98
+ mass_pay_response = Synapsis::MassPay.show(view_params)
99
+
100
+ [:success, :mass_pays, :obj_count]. each do |param|
101
+ expect(mass_pay_response).to respond_to(param)
102
+ end
103
+ expect(mass_pay_response.obj_count).to eq 1
104
+ end
105
+ end
106
+
107
+ context 'bad_parameters' do
108
+ it 'raises an error' do
109
+ # Authentication isn't owned by the user
110
+ expect { Synapsis::MassPay.show(mass_pay_id: 721, oauth_consumer_key: 'WRONG KEY') }.to raise_error(Synapsis::Error).with_message('Error in OAuth Authentication.')
111
+
112
+ # Bad ID
113
+ expect { Synapsis::MassPay.show(mass_pay_id: 'a', oauth_consumer_key: users_consumer_key) }.to raise_error(Synapsis::Error).with_message('Sorry, this request could not be processed. Please try again later.')
114
+
115
+ # If mass_pay_id isn't owned by the user, then return all the mass_pays of the user
116
+ expect(Synapsis::MassPay.show(mass_pay_id: 200, oauth_consumer_key: users_consumer_key)).to respond_to(:obj_count)
117
+ end
118
+ end
119
+ end
120
+
121
+ context 'without mass_pay_id argument' do
122
+ it 'returns all the user\'s mass_pays' do
123
+ mass_pay_response = Synapsis::MassPay.show(oauth_consumer_key: users_consumer_key)
124
+
125
+ expect(mass_pay_response.obj_count).to be > 1
126
+ end
127
+ end
128
+ end
129
+ end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  RSpec.describe Synapsis::Order do
4
- context '#add' do
4
+ context '.add' do
5
5
  let!(:delta) { 0.001 }
6
6
  let!(:buyer_consumer_key) { '3bdb5790692d06983d8cb0feb40365886631e52d' }
7
7
  let!(:seller_consumer_key) { '325ea5c0c3a7927280c54ed3ad310c02b45129d8' }
@@ -13,12 +13,19 @@ RSpec.describe Synapsis::Order do
13
13
 
14
14
  context 'happy path' do
15
15
  it 'constructs the correct Order object' do
16
- order = Synapsis::Order.add(order_params)
16
+ order_response = Synapsis::Order.add(order_params)
17
17
 
18
- ORDER_PARAMS = ['account_type', 'amount', 'date', 'date_settled', 'discount', 'facilitator_fee', 'fee', 'id', 'is_buyer', 'note', 'resource_uri', 'seller', 'status', 'status_uri', 'ticket_number', 'tip', 'total']
18
+ FIRST_LEVEL_PARAMS = ['balance_verified', 'order', 'success']
19
19
 
20
- (ORDER_PARAMS - ['status_uri']).each do |x|
21
- expect(order.order.send(x)).not_to be_nil
20
+ ORDER_PARAMS = ['account_type', 'amount', 'date', 'date_settled', 'discount', 'facilitator_fee', 'fee', 'id', 'is_buyer', 'note', 'resource_uri', 'seller', 'status', 'status_url', 'ticket_number', 'tip', 'total']
21
+
22
+
23
+ FIRST_LEVEL_PARAMS.each do |param|
24
+ expect(order_response).to respond_to(param)
25
+ end
26
+
27
+ ORDER_PARAMS.each do |x|
28
+ expect(order_response.order).to respond_to(x)
22
29
  end
23
30
  end
24
31
 
@@ -26,20 +33,20 @@ RSpec.describe Synapsis::Order do
26
33
  buyer_account_balance = Synapsis::User.view(buyer_consumer_key).user.balance
27
34
  seller_account_balance = Synapsis::User.view(seller_consumer_key).user.balance
28
35
 
29
- order = Synapsis::Order.add(order_params)
36
+ order_response = Synapsis::Order.add(order_params)
30
37
 
31
38
  new_buyer_account_balance = Synapsis::User.view(buyer_consumer_key).user.balance
32
39
  new_seller_account_balance = Synapsis::User.view(seller_consumer_key).user.balance
33
40
 
34
41
  expect(new_buyer_account_balance).to be_within(delta).of(buyer_account_balance - order_params[:amount])
35
- expect(new_seller_account_balance).to be_within(seller_account_balance + order_params[:amount] - Synapsis::Order.synapse_fee(order_params[:amount]))
42
+ expect(new_seller_account_balance).to be_within(delta).of(seller_account_balance + order_params[:amount] - Synapsis::Order.synapse_fee(order_params[:amount]))
36
43
  end
37
44
 
38
- it 'subtracts the money from the consumer\'s account and adds to the seller\'s account, with a charge of ' do
45
+ it 'subtracts the money from the consumer\'s account and adds to the seller\'s account, with a charge of 0.25 if amount is greater than $10' do
39
46
  buyer_account_balance = Synapsis::User.view(buyer_consumer_key).user.balance
40
47
  seller_account_balance = Synapsis::User.view(seller_consumer_key).user.balance
41
48
 
42
- order = Synapsis::Order.add(order_params.merge(amount: 10.1))
49
+ order_response = Synapsis::Order.add(order_params.merge(amount: 10.1))
43
50
 
44
51
  new_buyer_account_balance = Synapsis::User.view(buyer_consumer_key).user.balance
45
52
  new_seller_account_balance = Synapsis::User.view(seller_consumer_key).user.balance
@@ -49,7 +56,7 @@ RSpec.describe Synapsis::Order do
49
56
  end
50
57
  end
51
58
 
52
- context 'no amount specified' do
59
+ context 'errors' do
53
60
  it 'raises a Synapsis::Error' do
54
61
  expect{ Synapsis::Order.add(order_params.merge(oauth_consumer_key: 'WRONG!')) }.to raise_error(Synapsis::Error).with_message('Error in OAuth Authentication.')
55
62
  expect{ Synapsis::Order.add(order_params.merge(amount: 0)) }.to raise_error(Synapsis::Error).with_message('Missing amount')
@@ -57,4 +64,21 @@ RSpec.describe Synapsis::Order do
57
64
  end
58
65
  end
59
66
  end
67
+
68
+ context '.poll' do
69
+ context 'happy path' do
70
+ it 'retrieves the order' do
71
+ order_id = 1398
72
+ polled_order_response = Synapsis::Order.poll(order_id: 1398)
73
+
74
+ FIRST_LEVEL_PARAMS = ['order', 'success']
75
+
76
+ FIRST_LEVEL_PARAMS.each do |param|
77
+ expect(polled_order_response).to respond_to(param)
78
+ end
79
+
80
+ expect(polled_order_response.order.status).not_to be_nil
81
+ end
82
+ end
83
+ end
60
84
  end
@@ -80,4 +80,24 @@ RSpec.describe Synapsis::User do
80
80
  end
81
81
  end
82
82
  end
83
+
84
+ describe '.view_linked_banks' do
85
+ context 'happy path' do
86
+ it 'shows the user\'s balance and linked banks' do
87
+ token = 'da2e45d5665551667ba6e08292407b56daa6ea43'
88
+ synapse_response = Synapsis::User.view_linked_banks(token)
89
+
90
+ expect(synapse_response).to respond_to(:balance)
91
+ expect(synapse_response).to respond_to(:banks)
92
+ end
93
+ end
94
+
95
+ context 'authentication error' do
96
+ it 'raises an Error' do
97
+ oauth_token = 'WRONG!!!'
98
+
99
+ expect { Synapsis::User.view_linked_banks(oauth_token) }.to raise_error(Synapsis::Error).with_message('Error in OAuth Authentication.')
100
+ end
101
+ end
102
+ end
83
103
  end
@@ -12,10 +12,16 @@ RSpec.describe Synapsis::Withdrawal do
12
12
  it 'constructs the correct Withdrawal object' do
13
13
  withdrawal_response = Synapsis::Withdrawal.create(withdrawal_params)
14
14
 
15
+ FIRST_LEVEL_PARAMS = ['balance', 'is_mfa', 'reason', 'success', 'withdrawal']
16
+
15
17
  WITHDRAWAL_SPECIFIC_PARAMS = ['amount', 'bank', 'date_created', 'fee', 'id', 'instant_credit', 'resource_uri', 'status', 'status_url', 'user_id']
16
18
 
17
- (WITHDRAWAL_SPECIFIC_PARAMS - ['status_url']).each do |x|
18
- expect(withdrawal_response.withdrawal.send(x.to_s.gsub('@', ''))).not_to be_nil
19
+ FIRST_LEVEL_PARAMS.each do |param|
20
+ expect(withdrawal_response).to respond_to(param)
21
+ end
22
+
23
+ WITHDRAWAL_SPECIFIC_PARAMS.each do |param|
24
+ expect(withdrawal_response.withdrawal).to respond_to(param)
19
25
  end
20
26
  end
21
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: synapsis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daryll Santos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-12 00:00:00.000000000 Z
11
+ date: 2015-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -115,8 +115,10 @@ files:
115
115
  - lib/synapsis/api_resource.rb
116
116
  - lib/synapsis/authentication.rb
117
117
  - lib/synapsis/bank.rb
118
+ - lib/synapsis/card.rb
118
119
  - lib/synapsis/deposit.rb
119
120
  - lib/synapsis/error.rb
121
+ - lib/synapsis/mass_pay.rb
120
122
  - lib/synapsis/order.rb
121
123
  - lib/synapsis/user.rb
122
124
  - lib/synapsis/utilities.rb
@@ -129,7 +131,9 @@ files:
129
131
  - spec/synapsis/authentication_spec.rb
130
132
  - spec/synapsis/bank_link_spec.rb
131
133
  - spec/synapsis/bank_spec.rb
134
+ - spec/synapsis/card_spec.rb
132
135
  - spec/synapsis/deposit_spec.rb
136
+ - spec/synapsis/mass_pay_spec.rb
133
137
  - spec/synapsis/order_spec.rb
134
138
  - spec/synapsis/user_spec.rb
135
139
  - spec/synapsis/withdrawal_spec.rb
@@ -166,7 +170,9 @@ test_files:
166
170
  - spec/synapsis/authentication_spec.rb
167
171
  - spec/synapsis/bank_link_spec.rb
168
172
  - spec/synapsis/bank_spec.rb
173
+ - spec/synapsis/card_spec.rb
169
174
  - spec/synapsis/deposit_spec.rb
175
+ - spec/synapsis/mass_pay_spec.rb
170
176
  - spec/synapsis/order_spec.rb
171
177
  - spec/synapsis/user_spec.rb
172
178
  - spec/synapsis/withdrawal_spec.rb