synapse_pay 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +4 -0
  3. data/.travis.yml +16 -0
  4. data/Gemfile +8 -0
  5. data/LICENSE +21 -0
  6. data/README.md +54 -0
  7. data/Rakefile +8 -0
  8. data/VERSION +1 -0
  9. data/bin/synapse_pay-console +7 -0
  10. data/gemfiles/default-with-activesupport.gemfile +10 -0
  11. data/gemfiles/json.gemfile +12 -0
  12. data/gemfiles/yajl.gemfile +12 -0
  13. data/lib/synapse_pay.rb +78 -0
  14. data/lib/synapse_pay/apibits/api_client.rb +29 -0
  15. data/lib/synapse_pay/apibits/api_endpoint.rb +9 -0
  16. data/lib/synapse_pay/apibits/api_list.rb +88 -0
  17. data/lib/synapse_pay/apibits/api_method.rb +97 -0
  18. data/lib/synapse_pay/apibits/api_object.rb +52 -0
  19. data/lib/synapse_pay/apibits/api_resource.rb +127 -0
  20. data/lib/synapse_pay/apibits/headers_builder.rb +47 -0
  21. data/lib/synapse_pay/apibits/params_builder.rb +30 -0
  22. data/lib/synapse_pay/apibits/path_builder.rb +38 -0
  23. data/lib/synapse_pay/apibits/requester.rb +104 -0
  24. data/lib/synapse_pay/apibits/util.rb +51 -0
  25. data/lib/synapse_pay/client.rb +89 -0
  26. data/lib/synapse_pay/endpoints/bank_endpoint.rb +47 -0
  27. data/lib/synapse_pay/endpoints/bank_mfa_device_endpoint.rb +5 -0
  28. data/lib/synapse_pay/endpoints/bank_mfa_questions_endpoint.rb +5 -0
  29. data/lib/synapse_pay/endpoints/bank_status_endpoint.rb +11 -0
  30. data/lib/synapse_pay/endpoints/card_endpoint.rb +26 -0
  31. data/lib/synapse_pay/endpoints/deposit_endpoint.rb +23 -0
  32. data/lib/synapse_pay/endpoints/mass_pay_endpoint.rb +26 -0
  33. data/lib/synapse_pay/endpoints/order_endpoint.rb +44 -0
  34. data/lib/synapse_pay/endpoints/user_endpoint.rb +26 -0
  35. data/lib/synapse_pay/endpoints/wire_endpoint.rb +29 -0
  36. data/lib/synapse_pay/endpoints/withdrawal_endpoint.rb +17 -0
  37. data/lib/synapse_pay/errors/api_connection_error.rb +4 -0
  38. data/lib/synapse_pay/errors/api_error.rb +32 -0
  39. data/lib/synapse_pay/errors/authentication_error.rb +4 -0
  40. data/lib/synapse_pay/errors/synapse_pay_error.rb +13 -0
  41. data/lib/synapse_pay/nested_list.rb +32 -0
  42. data/lib/synapse_pay/resources/bank.rb +46 -0
  43. data/lib/synapse_pay/resources/bank_mfa_device.rb +32 -0
  44. data/lib/synapse_pay/resources/bank_mfa_questions.rb +28 -0
  45. data/lib/synapse_pay/resources/bank_status.rb +21 -0
  46. data/lib/synapse_pay/resources/card.rb +32 -0
  47. data/lib/synapse_pay/resources/deposit.rb +25 -0
  48. data/lib/synapse_pay/resources/mass_pay.rb +38 -0
  49. data/lib/synapse_pay/resources/order.rb +63 -0
  50. data/lib/synapse_pay/resources/user.rb +80 -0
  51. data/lib/synapse_pay/resources/wire.rb +31 -0
  52. data/lib/synapse_pay/resources/withdrawal.rb +29 -0
  53. data/lib/synapse_pay/version.rb +3 -0
  54. data/synapse_pay.gemspec +29 -0
  55. data/test/synapse_pay/api_list_test.rb +23 -0
  56. data/test/synapse_pay/api_method_test.rb +89 -0
  57. data/test/synapse_pay/headers_builder_test.rb +39 -0
  58. data/test/synapse_pay/params_builder_test.rb +57 -0
  59. data/test/synapse_pay/path_builder_test.rb +50 -0
  60. data/test/synapse_pay/requester_test.rb +86 -0
  61. data/test/synapse_pay/util_test.rb +51 -0
  62. data/test/test_data.rb +72 -0
  63. data/test/test_helper.rb +41 -0
  64. metadata +220 -0
@@ -0,0 +1,46 @@
1
+ module SynapsePay
2
+ class Bank < APIResource
3
+ attr_accessor :is_active
4
+ attr_accessor :nickname
5
+ attr_accessor :resource_uri
6
+ attr_accessor :date
7
+ attr_accessor :id
8
+ attr_accessor :account_type
9
+ attr_accessor :is_buyer_default
10
+ attr_accessor :is_verified
11
+ attr_accessor :name_on_account
12
+ attr_accessor :routing_number_string
13
+ attr_accessor :account_class
14
+ attr_accessor :is_seller_default
15
+ attr_accessor :account_number_string
16
+ attr_accessor :bank_name
17
+
18
+ def remove(params={}, headers={})
19
+ params = ParamsBuilder.merge({
20
+ :bank_id => id,
21
+ }, params)
22
+ method = APIMethod.new(:post, "/bank/delete", params, headers, self)
23
+ json = @client.execute(method)
24
+ json
25
+ end
26
+
27
+ # Everything below here is used behind the scenes.
28
+ APIResource.register_api_subclass(self, "bank")
29
+ @api_attributes = {
30
+ :is_active => {},
31
+ :nickname => {},
32
+ :resource_uri => {},
33
+ :date => {},
34
+ :id => {},
35
+ :account_type => {},
36
+ :is_buyer_default => {},
37
+ :is_verified => {},
38
+ :name_on_account => {},
39
+ :routing_number_string => {},
40
+ :account_class => {},
41
+ :is_seller_default => {},
42
+ :account_number_string => {},
43
+ :bank_name => {},
44
+ }
45
+ end
46
+ end
@@ -0,0 +1,32 @@
1
+ module SynapsePay
2
+ class BankMfaDevice < APIResource
3
+ attr_accessor :type
4
+ attr_accessor :access_token
5
+ attr_accessor :cookies
6
+ attr_accessor :form_extra
7
+ attr_accessor :mfa
8
+
9
+ def answer(bank, mfa, params={}, headers={})
10
+ params = ParamsBuilder.merge({
11
+ :bank => bank,
12
+ :mfa => mfa,
13
+ }, params)
14
+ params = ParamsBuilder.merge({
15
+ :access_token => access_token,
16
+ }, params)
17
+ method = APIMethod.new(:post, "/bank/mfa", params, headers, self)
18
+ json = @client.execute(method)
19
+ APIList.new(:Bank, json[:banks], method, @client)
20
+ end
21
+
22
+ # Everything below here is used behind the scenes.
23
+ APIResource.register_api_subclass(self, "bank_mfa_device")
24
+ @api_attributes = {
25
+ :type => {},
26
+ :access_token => {},
27
+ :cookies => {},
28
+ :form_extra => {},
29
+ :mfa => {},
30
+ }
31
+ end
32
+ end
@@ -0,0 +1,28 @@
1
+ module SynapsePay
2
+ class BankMfaQuestions < APIResource
3
+ attr_accessor :access_token
4
+ attr_accessor :mfa
5
+ attr_accessor :type
6
+
7
+ def answer(bank, mfa, params={}, headers={})
8
+ params = ParamsBuilder.merge({
9
+ :bank => bank,
10
+ :mfa => mfa,
11
+ }, params)
12
+ params = ParamsBuilder.merge({
13
+ :access_token => access_token,
14
+ }, params)
15
+ method = APIMethod.new(:post, "/bank/mfa", params, headers, self)
16
+ json = @client.execute(method)
17
+ APIList.new(:Bank, json[:banks], method, @client)
18
+ end
19
+
20
+ # Everything below here is used behind the scenes.
21
+ APIResource.register_api_subclass(self, "bank_mfa_questions")
22
+ @api_attributes = {
23
+ :access_token => {},
24
+ :mfa => {},
25
+ :type => {},
26
+ }
27
+ end
28
+ end
@@ -0,0 +1,21 @@
1
+ module SynapsePay
2
+ class BankStatus < APIResource
3
+ attr_accessor :date
4
+ attr_accessor :id
5
+ attr_accessor :logo
6
+ attr_accessor :resource_uri
7
+ attr_accessor :status
8
+ attr_accessor :bank_name
9
+
10
+ # Everything below here is used behind the scenes.
11
+ APIResource.register_api_subclass(self, "bank_status")
12
+ @api_attributes = {
13
+ :date => {},
14
+ :id => {},
15
+ :logo => {},
16
+ :resource_uri => {},
17
+ :status => {},
18
+ :bank_name => {},
19
+ }
20
+ end
21
+ end
@@ -0,0 +1,32 @@
1
+ module SynapsePay
2
+ class Card < APIResource
3
+ attr_accessor :routing_number_string
4
+ attr_accessor :account_class
5
+ attr_accessor :account_number_string
6
+ attr_accessor :account_type
7
+ attr_accessor :id
8
+ attr_accessor :name_on_account
9
+ attr_accessor :resource_uri
10
+
11
+ def update(params={}, headers={})
12
+ params = ParamsBuilder.merge({
13
+ :id => id,
14
+ }, params)
15
+ method = APIMethod.new(:post, "/card/edit", params, headers, self)
16
+ json = @client.execute(method)
17
+ self.refresh_from(json[:card], method)
18
+ end
19
+
20
+ # Everything below here is used behind the scenes.
21
+ APIResource.register_api_subclass(self, "card")
22
+ @api_attributes = {
23
+ :routing_number_string => {},
24
+ :account_class => {},
25
+ :account_number_string => {},
26
+ :account_type => {},
27
+ :id => {},
28
+ :name_on_account => {},
29
+ :resource_uri => {},
30
+ }
31
+ end
32
+ end
@@ -0,0 +1,25 @@
1
+ module SynapsePay
2
+ class Deposit < APIResource
3
+ attr_accessor :bank
4
+ attr_accessor :date_created
5
+ attr_accessor :id
6
+ attr_accessor :resource_uri
7
+ attr_accessor :status
8
+ attr_accessor :status_url
9
+ attr_accessor :user_id
10
+ attr_accessor :amount
11
+
12
+ # Everything below here is used behind the scenes.
13
+ APIResource.register_api_subclass(self, "deposit")
14
+ @api_attributes = {
15
+ :bank => {},
16
+ :date_created => {},
17
+ :id => {},
18
+ :resource_uri => {},
19
+ :status => {},
20
+ :status_url => {},
21
+ :user_id => {},
22
+ :amount => {},
23
+ }
24
+ end
25
+ end
@@ -0,0 +1,38 @@
1
+ module SynapsePay
2
+ class MassPay < APIResource
3
+ attr_accessor :resource_uri
4
+ attr_accessor :account_number_string
5
+ attr_accessor :fee
6
+ attr_accessor :name_on_account
7
+ attr_accessor :routing_number_string
8
+ attr_accessor :status
9
+ attr_accessor :trans_type
10
+ attr_accessor :amount
11
+ attr_accessor :date
12
+ attr_accessor :id
13
+
14
+ def cancel(params={}, headers={})
15
+ params = ParamsBuilder.merge({
16
+ :id => id,
17
+ }, params)
18
+ method = APIMethod.new(:post, "/masspay/cancel", params, headers, self)
19
+ json = @client.execute(method)
20
+ APIList.new(:MassPay, json[:mass_pays], method, @client)
21
+ end
22
+
23
+ # Everything below here is used behind the scenes.
24
+ APIResource.register_api_subclass(self, "mass_pay")
25
+ @api_attributes = {
26
+ :resource_uri => {},
27
+ :account_number_string => {},
28
+ :fee => {},
29
+ :name_on_account => {},
30
+ :routing_number_string => {},
31
+ :status => {},
32
+ :trans_type => {},
33
+ :amount => {},
34
+ :date => {},
35
+ :id => {},
36
+ }
37
+ end
38
+ end
@@ -0,0 +1,63 @@
1
+ module SynapsePay
2
+ class Order < APIResource
3
+ attr_accessor :status_url
4
+ attr_accessor :tip
5
+ attr_accessor :id
6
+ attr_accessor :seller
7
+ attr_accessor :fee
8
+ attr_accessor :resource_uri
9
+ attr_accessor :ticket_number
10
+ attr_accessor :total
11
+ attr_accessor :amount
12
+ attr_accessor :date
13
+ attr_accessor :supp_id
14
+ attr_accessor :is_buyer
15
+ attr_accessor :note
16
+ attr_accessor :account_type
17
+ attr_accessor :discount
18
+ attr_accessor :status
19
+ attr_accessor :date_settled
20
+ attr_accessor :facilitator_fee
21
+
22
+ def update(params={}, headers={})
23
+ params = ParamsBuilder.merge({
24
+ :order_id => id,
25
+ }, params)
26
+ method = APIMethod.new(:post, "/order/update", params, headers, self)
27
+ json = @client.execute(method)
28
+ self.refresh_from(json[:order], method)
29
+ end
30
+
31
+ def void(params={}, headers={})
32
+ params = ParamsBuilder.merge({
33
+ :order_id => id,
34
+ }, params)
35
+ method = APIMethod.new(:post, "/order/void", params, headers, self)
36
+ json = @client.execute(method)
37
+ self.refresh_from(json[:order], method)
38
+ end
39
+
40
+ # Everything below here is used behind the scenes.
41
+ APIResource.register_api_subclass(self, "order")
42
+ @api_attributes = {
43
+ :status_url => {},
44
+ :tip => {},
45
+ :id => {},
46
+ :seller => {},
47
+ :fee => {},
48
+ :resource_uri => {},
49
+ :ticket_number => {},
50
+ :total => {},
51
+ :amount => {},
52
+ :date => {},
53
+ :supp_id => {},
54
+ :is_buyer => {},
55
+ :note => {},
56
+ :account_type => {},
57
+ :discount => {},
58
+ :status => {},
59
+ :date_settled => {},
60
+ :facilitator_fee => {},
61
+ }
62
+ end
63
+ end
@@ -0,0 +1,80 @@
1
+ module SynapsePay
2
+ class User < APIResource
3
+ attr_accessor :email
4
+ attr_accessor :phone_number
5
+ attr_accessor :visit_count
6
+ attr_accessor :visit_message
7
+ attr_accessor :accept_gratuity
8
+ attr_accessor :fullname
9
+ attr_accessor :is_trusted
10
+ attr_accessor :resource_uri
11
+ attr_accessor :avatar
12
+ attr_accessor :has_avatar
13
+ attr_accessor :referral_code
14
+ attr_accessor :username
15
+ attr_accessor :accept_bank_payments
16
+ attr_accessor :balance
17
+ attr_accessor :promo_text
18
+ attr_accessor :seller_details
19
+ attr_accessor :user_id
20
+
21
+ def self.create(params={}, headers={})
22
+ method = APIMethod.new(:post, "/user/create", params, headers, self)
23
+ json = method.execute
24
+ Client.new().refresh_from(json)
25
+ end
26
+
27
+ def self.login(username, password, params={}, headers={})
28
+ params = ParamsBuilder.merge({
29
+ :username => username,
30
+ :password => password,
31
+ }, params)
32
+ method = APIMethod.new(:post, "/user/login", params, headers, self)
33
+ json = method.execute
34
+ Client.new().refresh_from(json)
35
+ end
36
+
37
+ def self.refresh_access(refresh_token, params={}, headers={})
38
+ params = ParamsBuilder.merge({
39
+ :refresh_token => refresh_token,
40
+ }, params)
41
+ method = APIMethod.new(:post, "/user/refresh", params, headers, self)
42
+ json = method.execute
43
+ Client.new().refresh_from(json)
44
+ end
45
+
46
+ def refresh(params={}, headers={})
47
+ method = APIMethod.new(:post, "/user/show", params, headers, self)
48
+ json = @client.execute(method)
49
+ self.refresh_from(json[:user], method)
50
+ end
51
+
52
+ def update(params={}, headers={})
53
+ method = APIMethod.new(:post, "/user/edit", params, headers, self)
54
+ json = @client.execute(method)
55
+ self.refresh_from(json[:user], method)
56
+ end
57
+
58
+ # Everything below here is used behind the scenes.
59
+ APIResource.register_api_subclass(self, "user")
60
+ @api_attributes = {
61
+ :email => {},
62
+ :phone_number => {},
63
+ :visit_count => {},
64
+ :visit_message => {},
65
+ :accept_gratuity => {},
66
+ :fullname => {},
67
+ :is_trusted => {},
68
+ :resource_uri => {},
69
+ :avatar => {},
70
+ :has_avatar => {},
71
+ :referral_code => {},
72
+ :username => {},
73
+ :accept_bank_payments => {},
74
+ :balance => {},
75
+ :promo_text => {},
76
+ :seller_details => {},
77
+ :user_id => {},
78
+ }
79
+ end
80
+ end
@@ -0,0 +1,31 @@
1
+ module SynapsePay
2
+ class Wire < APIResource
3
+ attr_accessor :resource_uri
4
+ attr_accessor :status
5
+ attr_accessor :amount
6
+ attr_accessor :date
7
+ attr_accessor :memo
8
+ attr_accessor :reference_id
9
+ attr_accessor :routing_number_string
10
+ attr_accessor :status_url
11
+ attr_accessor :account_number_string
12
+ attr_accessor :fee
13
+ attr_accessor :id
14
+
15
+ # Everything below here is used behind the scenes.
16
+ APIResource.register_api_subclass(self, "wire")
17
+ @api_attributes = {
18
+ :resource_uri => {},
19
+ :status => {},
20
+ :amount => {},
21
+ :date => {},
22
+ :memo => {},
23
+ :reference_id => {},
24
+ :routing_number_string => {},
25
+ :status_url => {},
26
+ :account_number_string => {},
27
+ :fee => {},
28
+ :id => {},
29
+ }
30
+ end
31
+ end
@@ -0,0 +1,29 @@
1
+ module SynapsePay
2
+ class Withdrawal < APIResource
3
+ attr_accessor :fee
4
+ attr_accessor :resource_uri
5
+ attr_accessor :status
6
+ attr_accessor :status_url
7
+ attr_accessor :user_id
8
+ attr_accessor :date_created
9
+ attr_accessor :bank
10
+ attr_accessor :id
11
+ attr_accessor :instant_credit
12
+ attr_accessor :amount
13
+
14
+ # Everything below here is used behind the scenes.
15
+ APIResource.register_api_subclass(self, "withdrawal")
16
+ @api_attributes = {
17
+ :fee => {},
18
+ :resource_uri => {},
19
+ :status => {},
20
+ :status_url => {},
21
+ :user_id => {},
22
+ :date_created => {},
23
+ :bank => {},
24
+ :id => {},
25
+ :instant_credit => {},
26
+ :amount => {},
27
+ }
28
+ end
29
+ end
@@ -0,0 +1,3 @@
1
+ module SynapsePay
2
+ VERSION = File.open(File.expand_path("../../../VERSION", __FILE__)).read()
3
+ end