synapse_client 0.1.1 → 0.1.2
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/README.md +6 -5
- data/lib/synapse_client.rb +1 -0
- data/lib/synapse_client/customer.rb +1 -1
- data/lib/synapse_client/mass_pay.rb +35 -0
- data/lib/synapse_client/version.rb +1 -1
- data/spec/synapse_client_mass_pay_spec.rb +56 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4636a88b781418553e2e97de39a7edd3e76f833
|
4
|
+
data.tar.gz: 8db58c259fd1d4c6c552f0788e53f26d6f94053f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d157a8213f38001d4f06a907196877b479777b31f45819547d0af5444b3003a0fe1dee5e4c431cc688420132027b10879d7e25616bf460e8fb0081e173e8b6b4
|
7
|
+
data.tar.gz: 82389bfbe4f943911732ce7d1bce1009f6a96a24ec1a69ed9cbed0ef9c88687a654f09bbfd3133dec1ff0e8027d453e7a40e25481840525cfc094aba05a226f4
|
data/README.md
CHANGED
@@ -44,10 +44,11 @@ _See the specs for the most up to date usage demo._
|
|
44
44
|
|
45
45
|
```ruby
|
46
46
|
SynapseClient::Customer.create({
|
47
|
-
:email
|
48
|
-
:fullname
|
49
|
-
:phonenumber
|
50
|
-
:ip_address
|
47
|
+
:email => "foo@example.com",
|
48
|
+
:fullname => "Foo Bar,
|
49
|
+
:phonenumber => "5555555555",
|
50
|
+
:ip_address => "8.8.8.8",
|
51
|
+
:force_create => true
|
51
52
|
})
|
52
53
|
```
|
53
54
|
|
@@ -110,8 +111,8 @@ _See the specs for the most up to date usage demo._
|
|
110
111
|
## TODO (in order of priority)
|
111
112
|
|
112
113
|
* Better synapse error handling
|
114
|
+
* Test for errors
|
113
115
|
* HTTP Error handling
|
114
|
-
* Logging
|
115
116
|
* MassPay
|
116
117
|
* Refresh access tokens
|
117
118
|
* Security Questions
|
data/lib/synapse_client.rb
CHANGED
@@ -7,6 +7,7 @@ require "synapse_client/api_operations/response"
|
|
7
7
|
require "synapse_client/api_operations/list"
|
8
8
|
require "synapse_client/bank_account"
|
9
9
|
require "synapse_client/error"
|
10
|
+
require "synapse_client/mass_pay"
|
10
11
|
require "synapse_client/merchant"
|
11
12
|
require "synapse_client/mfa"
|
12
13
|
require "synapse_client/order"
|
@@ -93,7 +93,7 @@ module SynapseClient
|
|
93
93
|
else
|
94
94
|
Order.create(params.merge({
|
95
95
|
:access_token => @access_token,
|
96
|
-
:seller_id => SynapseClient.merchant_synapse_id,
|
96
|
+
:seller_id => params[:seller_id] || SynapseClient.merchant_synapse_id,
|
97
97
|
:bank_pay => "yes" # see README.md
|
98
98
|
}))
|
99
99
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
|
2
|
+
module SynapseClient
|
3
|
+
class MassPay < APIResource
|
4
|
+
|
5
|
+
attr_reader :amount
|
6
|
+
attr_reader :trans_type
|
7
|
+
attr_reader :source_bank_id
|
8
|
+
attr_reader :dest_bank_id
|
9
|
+
|
10
|
+
|
11
|
+
def initialize(options = {})
|
12
|
+
options = Map.new(options)
|
13
|
+
|
14
|
+
update_attributes(options)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.create(params={})
|
18
|
+
response = SynapseClient.request(:post, url + "add", params)
|
19
|
+
|
20
|
+
return response unless response.successful?
|
21
|
+
response.data.mass_pays.map do |mp|
|
22
|
+
MassPay.new(mp)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
def update_attributes(options)
|
28
|
+
@amount = options[:amount]
|
29
|
+
@trans_type = options[:trans_type]
|
30
|
+
@source_bank_id = options[:source_bank_id].to_i
|
31
|
+
@dest_bank_id = options[:dest_bank_id].to_i
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SynapseClient::MassPay do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@customer_a = get_dummy_customer
|
7
|
+
@bank_account_a = @customer_a.add_bank_account(dummy_add_bank_account_info)
|
8
|
+
|
9
|
+
@customer_b = get_dummy_customer
|
10
|
+
@bank_account_b = @customer_b.add_bank_account(dummy_add_bank_account_info)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "adding a bunch of deposits to users" do
|
14
|
+
it "should successfully return multiple mass pays" do
|
15
|
+
|
16
|
+
params = {
|
17
|
+
:access_token => @customer_a.access_token,
|
18
|
+
:mass_pays => [{
|
19
|
+
:amount => 20.to_s,
|
20
|
+
:trans_type => 0.to_s,
|
21
|
+
:source_bank_id => @bank_account_a.id.to_s,
|
22
|
+
:dest_bank_id => @bank_account_b.id.to_s
|
23
|
+
},{
|
24
|
+
:amount => 10.to_s,
|
25
|
+
:trans_type => 0.to_s,
|
26
|
+
:source_bank_id => @bank_account_a.id.to_s,
|
27
|
+
:dest_bank_id => @bank_account_b.id.to_s
|
28
|
+
}]
|
29
|
+
}
|
30
|
+
|
31
|
+
masspays = SynapseClient::MassPay.create(params)
|
32
|
+
|
33
|
+
if !masspays.instance_of?(Array)
|
34
|
+
puts "*** Error message: #{ masspays.error_msg }"
|
35
|
+
end
|
36
|
+
|
37
|
+
expect(masspays).to be_an Array
|
38
|
+
|
39
|
+
masspays.each do |mp|
|
40
|
+
expect(mp.amount).to be_a Float
|
41
|
+
expect(mp.trans_type).to be_a Fixnum
|
42
|
+
expect(mp.source_bank_id).to be_a Fixnum
|
43
|
+
expect(mp.dest_bank_id).to be_a Fixnum
|
44
|
+
|
45
|
+
expect(mp.amount).to eq(20).or eq(10)
|
46
|
+
expect(mp.trans_type).to eq(0)
|
47
|
+
expect(mp.source_bank_id).to eq(@bank_account_a.id)
|
48
|
+
expect(mp.dest_bank_id).to eq(@bank_account_b.id)
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: synapse_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Matthias
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -208,6 +208,7 @@ files:
|
|
208
208
|
- lib/synapse_client/bank_account.rb
|
209
209
|
- lib/synapse_client/customer.rb
|
210
210
|
- lib/synapse_client/error.rb
|
211
|
+
- lib/synapse_client/mass_pay.rb
|
211
212
|
- lib/synapse_client/merchant.rb
|
212
213
|
- lib/synapse_client/mfa.rb
|
213
214
|
- lib/synapse_client/order.rb
|
@@ -218,6 +219,7 @@ files:
|
|
218
219
|
- spec/spec_helper.rb
|
219
220
|
- spec/synapse_client_bank_account_spec.rb
|
220
221
|
- spec/synapse_client_customer_spec.rb
|
222
|
+
- spec/synapse_client_mass_pay_spec.rb
|
221
223
|
- spec/synapse_client_order_spec.rb
|
222
224
|
- spec/synapse_client_spec.rb
|
223
225
|
- synapse_client.gemspec
|
@@ -249,5 +251,6 @@ test_files:
|
|
249
251
|
- spec/spec_helper.rb
|
250
252
|
- spec/synapse_client_bank_account_spec.rb
|
251
253
|
- spec/synapse_client_customer_spec.rb
|
254
|
+
- spec/synapse_client_mass_pay_spec.rb
|
252
255
|
- spec/synapse_client_order_spec.rb
|
253
256
|
- spec/synapse_client_spec.rb
|