synapse_pay 0.0.1 → 0.0.3

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: 3812258b427d907502b4a954d75fc130272a8797
4
- data.tar.gz: c051b7c387ec68046eb67f061122ee91e19c1a7a
3
+ metadata.gz: 720ddc79c7f6962344d1d7161215180ca279b00a
4
+ data.tar.gz: e128b0f4f50b452d5fbb464f95d99e0119f234c8
5
5
  SHA512:
6
- metadata.gz: c0c701d80d45d27d479e260286c57c3eb2c561d105ffe7ca6b9aa539607c4fb5483430bd08b92932f15b4377185080f307c8ed380db5014a9ef66ef28ef04887
7
- data.tar.gz: 04431e4e07ede206e4cab686118ee4a1a6bba4ad45f4b6e10dad3eac41883bcca6d6a41d25524139b01c07a588274a5f6fc716265eb416623883d8efacfd6745
6
+ metadata.gz: 92dd72493f70f32f9d72a01772014ff1e090c14ae09ac54e5e11002f74e54c2d1f27fbdd60d69707fd82b4bfd2a12b8e153dfe0614ffbbe84a568400e878769a
7
+ data.tar.gz: 8ecc3d272b3c84b763bd5050d60878a80773a3e15dd311a3a803d1569f0c68a74990a9744aa55d498aa2e32cc1d03cdf511e47e60ed9dc69cc1ca2b4c1640ade
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
- # SynapsePay Ruby Bindings ![Travis CI Status](https://travis-ci.org/synapse_pay/synapse_pay-ruby.svg?branch=master) [![Code Climate](https://codeclimate.com/github/synapse_pay/synapse_pay-ruby/badges/gpa.svg)](https://codeclimate.com/github/synapse_pay/synapse_pay-ruby)
1
+ # SynapsePay Ruby Bindings [![Code Climate](https://codeclimate.com/github/synapsepayments/synapse_pay-ruby/badges/gpa.svg)](https://codeclimate.com/github/synapsepayments/synapse_pay-ruby)
2
2
 
3
+ [![API Library via Apibits.com](http://apibits.com/assets/images/apibits-badge.png)](http://apibits.com)
3
4
 
4
5
  ## Installation
5
6
 
@@ -14,12 +15,18 @@ If you want to build & install the gem from source:
14
15
 
15
16
  ```bash
16
17
  gem build synapse_pay.gemspec
17
- gem install synapse_pay-0.0.1.gem
18
+ gem install synapse_pay-0.0.3.gem
18
19
  ```
19
20
 
21
+ ## Documentation
20
22
 
23
+ Documentation is available at [http://api.synapsepay.com/v2.0](http://api.synapsepay.com/v2.0).
21
24
 
22
25
 
26
+ ## Samples
27
+
28
+ See [samples.md](https://github.com/synapsepayments/synapse_pay-ruby/blob/master/samples.md) for sample usage in ruby.
29
+
23
30
 
24
31
  ## Requirements
25
32
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.3
@@ -33,6 +33,10 @@ module SynapsePay
33
33
  raise @error
34
34
  end
35
35
 
36
+ if(!response_json[:success])
37
+ @error = APIError.new(response_json, self)
38
+ raise @error
39
+ end
36
40
  response_json
37
41
  end
38
42
 
@@ -41,17 +45,14 @@ module SynapsePay
41
45
  end
42
46
 
43
47
  def response_json
48
+ return @json if @json
44
49
  begin
45
- json = Util.symbolize_keys(JSON.parse(@response_body))
50
+ @json = Util.symbolize_keys(JSON.parse(@response_body))
46
51
  rescue JSON::ParserError
47
52
  @error = APIError.new("Unable to parse the server response as JSON.", self)
48
53
  raise @error
49
54
  end
50
- if(!json[:success])
51
- @error = APIError.new(json, self)
52
- raise @error
53
- end
54
- json
55
+ @json
55
56
  end
56
57
 
57
58
  def compose_error(error)
@@ -85,11 +86,11 @@ module SynapsePay
85
86
  def error_with_response(error)
86
87
  case @response_code
87
88
  when 400, 404
88
- return APIError.new("Invalid request. Please check the URL and parameters.", self)
89
+ return APIError.new(@response_body || "Invalid request. Please check the URL and parameters.", self)
89
90
  when 401
90
- return AuthenticationError.new("Authentication failed. Please check your API key and verify that it is correct.", self)
91
+ return AuthenticationError.new(@response_body || "Authentication failed.", self)
91
92
  else
92
- return APIError.new("An error occured while making the API call.", self)
93
+ return APIError.new(@response_body || "An error occured while making the API call.", self)
93
94
  end
94
95
  end
95
96
 
@@ -45,7 +45,7 @@ module SynapsePay
45
45
  end
46
46
  params = nil
47
47
  else
48
- if headers["Content-Type"] == "application/json"
48
+ if headers["Content-Type"] == "application/json" || headers[:"Content-Type"] == "application/json"
49
49
  params = JSON.generate(params)
50
50
  else
51
51
  headers["Content-Type"] = "application/x-www-form-urlencoded"
@@ -57,33 +57,41 @@ module SynapsePay
57
57
  @banks ||= BankEndpoint.new(self)
58
58
  end
59
59
 
60
- def orders
61
- @orders ||= OrderEndpoint.new(self)
60
+ def bank_mfa_devices
61
+ @bank_mfa_devices ||= BankMfaDeviceEndpoint.new(self)
62
62
  end
63
63
 
64
- def deposits
65
- @deposits ||= DepositEndpoint.new(self)
64
+ def bank_mfa_questions
65
+ @bank_mfa_questions ||= BankMfaQuestionsEndpoint.new(self)
66
66
  end
67
67
 
68
- def withdrawals
69
- @withdrawals ||= WithdrawalEndpoint.new(self)
68
+ def bank_statuses
69
+ @bank_statuses ||= BankStatusEndpoint.new(self)
70
70
  end
71
71
 
72
72
  def cards
73
73
  @cards ||= CardEndpoint.new(self)
74
74
  end
75
75
 
76
+ def deposits
77
+ @deposits ||= DepositEndpoint.new(self)
78
+ end
79
+
76
80
  def mass_pays
77
81
  @mass_pays ||= MassPayEndpoint.new(self)
78
82
  end
79
83
 
80
- def bank_statuses
81
- @bank_statuses ||= BankStatusEndpoint.new(self)
84
+ def orders
85
+ @orders ||= OrderEndpoint.new(self)
82
86
  end
83
87
 
84
88
  def wires
85
89
  @wires ||= WireEndpoint.new(self)
86
90
  end
87
91
 
92
+ def withdrawals
93
+ @withdrawals ||= WithdrawalEndpoint.new(self)
94
+ end
95
+
88
96
  end
89
97
  end
@@ -25,22 +25,22 @@ module SynapsePay
25
25
  end
26
26
  end
27
27
 
28
- def remove(bank_id, params={}, headers={})
28
+ def refresh(id, params={}, headers={})
29
29
  params = ParamsBuilder.merge({
30
- :bank_id => bank_id,
30
+ :id => id,
31
31
  }, params)
32
- method = APIMethod.new(:post, "/bank/delete", params, headers, self)
32
+ method = APIMethod.new(:post, "/bank/refresh", params, headers, self)
33
33
  json = @client.execute(method)
34
- json
34
+ APIList.new(:Bank, json[:banks], method, @client)
35
35
  end
36
36
 
37
- def retrieve(id, params={}, headers={})
37
+ def remove(bank_id, params={}, headers={})
38
38
  params = ParamsBuilder.merge({
39
- :id => id,
39
+ :bank_id => bank_id,
40
40
  }, params)
41
- method = APIMethod.new(:post, "/bank/refresh", params, headers, self)
41
+ method = APIMethod.new(:post, "/bank/delete", params, headers, self)
42
42
  json = @client.execute(method)
43
- APIList.new(:Bank, json[:banks], method, @client)
43
+ json
44
44
  end
45
45
 
46
46
  end
@@ -1,5 +1,16 @@
1
1
  module SynapsePay
2
2
  class BankMfaDeviceEndpoint < APIEndpoint
3
+
4
+ def answer(access_token, bank, mfa, params={}, headers={})
5
+ params = ParamsBuilder.merge({
6
+ :access_token => access_token,
7
+ :bank => bank,
8
+ :mfa => mfa,
9
+ }, params)
10
+ method = APIMethod.new(:post, "/bank/mfa", params, headers, self)
11
+ json = @client.execute(method)
12
+ APIList.new(:Bank, json[:banks], method, @client)
13
+ end
3
14
 
4
15
  end
5
16
  end
@@ -1,5 +1,16 @@
1
1
  module SynapsePay
2
2
  class BankMfaQuestionsEndpoint < APIEndpoint
3
+
4
+ def answer(access_token, bank, mfa, params={}, headers={})
5
+ params = ParamsBuilder.merge({
6
+ :access_token => access_token,
7
+ :bank => bank,
8
+ :mfa => mfa,
9
+ }, params)
10
+ method = APIMethod.new(:post, "/bank/mfa", params, headers, self)
11
+ json = @client.execute(method)
12
+ APIList.new(:Bank, json[:banks], method, @client)
13
+ end
3
14
 
4
15
  end
5
16
  end
@@ -17,7 +17,10 @@ module SynapsePay
17
17
 
18
18
  def json
19
19
  begin
20
- @api_method.response_json if @api_method
20
+ if @api_method
21
+ hash = @api_method.response_json
22
+ return APIObject.construct(hash)
23
+ end
21
24
  rescue APIError
22
25
  nil
23
26
  end
@@ -1,19 +1,22 @@
1
1
  module SynapsePay
2
2
  class Bank < APIResource
3
- attr_accessor :is_active
4
- attr_accessor :nickname
5
- attr_accessor :resource_uri
3
+ attr_accessor :account_class
4
+ attr_accessor :account_number_string
5
+ attr_accessor :account_type
6
+ attr_accessor :address
7
+ attr_accessor :balance
8
+ attr_accessor :bank_name
6
9
  attr_accessor :date
10
+ attr_accessor :email
7
11
  attr_accessor :id
8
- attr_accessor :account_type
9
12
  attr_accessor :is_buyer_default
10
- attr_accessor :is_verified
13
+ attr_accessor :is_seller_default
14
+ attr_accessor :mfa_verifed
11
15
  attr_accessor :name_on_account
16
+ attr_accessor :nickname
17
+ attr_accessor :phone_number
18
+ attr_accessor :resource_uri
12
19
  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
20
 
18
21
  def remove(params={}, headers={})
19
22
  params = ParamsBuilder.merge({
@@ -27,20 +30,23 @@ module SynapsePay
27
30
  # Everything below here is used behind the scenes.
28
31
  APIResource.register_api_subclass(self, "bank")
29
32
  @api_attributes = {
30
- :is_active => {},
31
- :nickname => {},
32
- :resource_uri => {},
33
+ :account_class => {},
34
+ :account_number_string => {},
35
+ :account_type => {},
36
+ :address => {},
37
+ :balance => {},
38
+ :bank_name => {},
33
39
  :date => {},
40
+ :email => {},
34
41
  :id => {},
35
- :account_type => {},
36
42
  :is_buyer_default => {},
37
- :is_verified => {},
43
+ :is_seller_default => {},
44
+ :mfa_verifed => {},
38
45
  :name_on_account => {},
46
+ :nickname => {},
47
+ :phone_number => {},
48
+ :resource_uri => {},
39
49
  :routing_number_string => {},
40
- :account_class => {},
41
- :is_seller_default => {},
42
- :account_number_string => {},
43
- :bank_name => {},
44
50
  }
45
51
  end
46
52
  end
@@ -1,10 +1,10 @@
1
1
  module SynapsePay
2
2
  class BankMfaDevice < APIResource
3
- attr_accessor :type
4
3
  attr_accessor :access_token
5
4
  attr_accessor :cookies
6
5
  attr_accessor :form_extra
7
6
  attr_accessor :mfa
7
+ attr_accessor :type
8
8
 
9
9
  def answer(bank, mfa, params={}, headers={})
10
10
  params = ParamsBuilder.merge({
@@ -22,11 +22,11 @@ module SynapsePay
22
22
  # Everything below here is used behind the scenes.
23
23
  APIResource.register_api_subclass(self, "bank_mfa_device")
24
24
  @api_attributes = {
25
- :type => {},
26
25
  :access_token => {},
27
26
  :cookies => {},
28
27
  :form_extra => {},
29
28
  :mfa => {},
29
+ :type => {},
30
30
  }
31
31
  end
32
32
  end
@@ -1,21 +1,21 @@
1
1
  module SynapsePay
2
2
  class BankStatus < APIResource
3
+ attr_accessor :bank_name
3
4
  attr_accessor :date
4
5
  attr_accessor :id
5
6
  attr_accessor :logo
6
7
  attr_accessor :resource_uri
7
8
  attr_accessor :status
8
- attr_accessor :bank_name
9
9
 
10
10
  # Everything below here is used behind the scenes.
11
11
  APIResource.register_api_subclass(self, "bank_status")
12
12
  @api_attributes = {
13
+ :bank_name => {},
13
14
  :date => {},
14
15
  :id => {},
15
16
  :logo => {},
16
17
  :resource_uri => {},
17
18
  :status => {},
18
- :bank_name => {},
19
19
  }
20
20
  end
21
21
  end
@@ -1,12 +1,12 @@
1
1
  module SynapsePay
2
2
  class Card < APIResource
3
- attr_accessor :routing_number_string
4
3
  attr_accessor :account_class
5
4
  attr_accessor :account_number_string
6
5
  attr_accessor :account_type
7
6
  attr_accessor :id
8
7
  attr_accessor :name_on_account
9
8
  attr_accessor :resource_uri
9
+ attr_accessor :routing_number_string
10
10
 
11
11
  def update(params={}, headers={})
12
12
  params = ParamsBuilder.merge({
@@ -20,13 +20,13 @@ module SynapsePay
20
20
  # Everything below here is used behind the scenes.
21
21
  APIResource.register_api_subclass(self, "card")
22
22
  @api_attributes = {
23
- :routing_number_string => {},
24
23
  :account_class => {},
25
24
  :account_number_string => {},
26
25
  :account_type => {},
27
26
  :id => {},
28
27
  :name_on_account => {},
29
28
  :resource_uri => {},
29
+ :routing_number_string => {},
30
30
  }
31
31
  end
32
32
  end
@@ -1,5 +1,6 @@
1
1
  module SynapsePay
2
2
  class Deposit < APIResource
3
+ attr_accessor :amount
3
4
  attr_accessor :bank
4
5
  attr_accessor :date_created
5
6
  attr_accessor :id
@@ -7,11 +8,11 @@ module SynapsePay
7
8
  attr_accessor :status
8
9
  attr_accessor :status_url
9
10
  attr_accessor :user_id
10
- attr_accessor :amount
11
11
 
12
12
  # Everything below here is used behind the scenes.
13
13
  APIResource.register_api_subclass(self, "deposit")
14
14
  @api_attributes = {
15
+ :amount => {},
15
16
  :bank => {},
16
17
  :date_created => {},
17
18
  :id => {},
@@ -19,7 +20,6 @@ module SynapsePay
19
20
  :status => {},
20
21
  :status_url => {},
21
22
  :user_id => {},
22
- :amount => {},
23
23
  }
24
24
  end
25
25
  end
@@ -1,15 +1,15 @@
1
1
  module SynapsePay
2
2
  class MassPay < APIResource
3
- attr_accessor :resource_uri
4
3
  attr_accessor :account_number_string
4
+ attr_accessor :amount
5
+ attr_accessor :date
5
6
  attr_accessor :fee
7
+ attr_accessor :id
6
8
  attr_accessor :name_on_account
9
+ attr_accessor :resource_uri
7
10
  attr_accessor :routing_number_string
8
11
  attr_accessor :status
9
12
  attr_accessor :trans_type
10
- attr_accessor :amount
11
- attr_accessor :date
12
- attr_accessor :id
13
13
 
14
14
  def cancel(params={}, headers={})
15
15
  params = ParamsBuilder.merge({
@@ -23,16 +23,16 @@ module SynapsePay
23
23
  # Everything below here is used behind the scenes.
24
24
  APIResource.register_api_subclass(self, "mass_pay")
25
25
  @api_attributes = {
26
- :resource_uri => {},
27
26
  :account_number_string => {},
27
+ :amount => {},
28
+ :date => {},
28
29
  :fee => {},
30
+ :id => {},
29
31
  :name_on_account => {},
32
+ :resource_uri => {},
30
33
  :routing_number_string => {},
31
34
  :status => {},
32
35
  :trans_type => {},
33
- :amount => {},
34
- :date => {},
35
- :id => {},
36
36
  }
37
37
  end
38
38
  end
@@ -1,23 +1,23 @@
1
1
  module SynapsePay
2
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
3
+ attr_accessor :account_type
11
4
  attr_accessor :amount
12
5
  attr_accessor :date
13
- attr_accessor :supp_id
6
+ attr_accessor :date_settled
7
+ attr_accessor :discount
8
+ attr_accessor :facilitator_fee
9
+ attr_accessor :fee
10
+ attr_accessor :id
14
11
  attr_accessor :is_buyer
15
12
  attr_accessor :note
16
- attr_accessor :account_type
17
- attr_accessor :discount
13
+ attr_accessor :resource_uri
14
+ attr_accessor :seller
18
15
  attr_accessor :status
19
- attr_accessor :date_settled
20
- attr_accessor :facilitator_fee
16
+ attr_accessor :status_url
17
+ attr_accessor :supp_id
18
+ attr_accessor :ticket_number
19
+ attr_accessor :tip
20
+ attr_accessor :total
21
21
 
22
22
  def update(params={}, headers={})
23
23
  params = ParamsBuilder.merge({
@@ -40,24 +40,24 @@ module SynapsePay
40
40
  # Everything below here is used behind the scenes.
41
41
  APIResource.register_api_subclass(self, "order")
42
42
  @api_attributes = {
43
- :status_url => {},
44
- :tip => {},
45
- :id => {},
46
- :seller => {},
47
- :fee => {},
48
- :resource_uri => {},
49
- :ticket_number => {},
50
- :total => {},
43
+ :account_type => {},
51
44
  :amount => {},
52
45
  :date => {},
53
- :supp_id => {},
46
+ :date_settled => {},
47
+ :discount => {},
48
+ :facilitator_fee => {},
49
+ :fee => {},
50
+ :id => {},
54
51
  :is_buyer => {},
55
52
  :note => {},
56
- :account_type => {},
57
- :discount => {},
53
+ :resource_uri => {},
54
+ :seller => {},
58
55
  :status => {},
59
- :date_settled => {},
60
- :facilitator_fee => {},
56
+ :status_url => {},
57
+ :supp_id => {},
58
+ :ticket_number => {},
59
+ :tip => {},
60
+ :total => {},
61
61
  }
62
62
  end
63
63
  end
@@ -1,22 +1,22 @@
1
1
  module SynapsePay
2
2
  class User < APIResource
3
- attr_accessor :email
4
- attr_accessor :phone_number
5
- attr_accessor :visit_count
6
- attr_accessor :visit_message
3
+ attr_accessor :accept_bank_payments
7
4
  attr_accessor :accept_gratuity
8
- attr_accessor :fullname
9
- attr_accessor :is_trusted
10
- attr_accessor :resource_uri
11
5
  attr_accessor :avatar
12
- attr_accessor :has_avatar
13
- attr_accessor :referral_code
14
- attr_accessor :username
15
- attr_accessor :accept_bank_payments
16
6
  attr_accessor :balance
7
+ attr_accessor :email
8
+ attr_accessor :fullname
9
+ attr_accessor :has_avatar
10
+ attr_accessor :is_trusted
11
+ attr_accessor :phone_number
17
12
  attr_accessor :promo_text
13
+ attr_accessor :referral_code
14
+ attr_accessor :resource_uri
18
15
  attr_accessor :seller_details
19
16
  attr_accessor :user_id
17
+ attr_accessor :username
18
+ attr_accessor :visit_count
19
+ attr_accessor :visit_message
20
20
 
21
21
  def self.create(params={}, headers={})
22
22
  method = APIMethod.new(:post, "/user/create", params, headers, self)
@@ -58,23 +58,23 @@ module SynapsePay
58
58
  # Everything below here is used behind the scenes.
59
59
  APIResource.register_api_subclass(self, "user")
60
60
  @api_attributes = {
61
- :email => {},
62
- :phone_number => {},
63
- :visit_count => {},
64
- :visit_message => {},
61
+ :accept_bank_payments => {},
65
62
  :accept_gratuity => {},
66
- :fullname => {},
67
- :is_trusted => {},
68
- :resource_uri => {},
69
63
  :avatar => {},
70
- :has_avatar => {},
71
- :referral_code => {},
72
- :username => {},
73
- :accept_bank_payments => {},
74
64
  :balance => {},
65
+ :email => {},
66
+ :fullname => {},
67
+ :has_avatar => {},
68
+ :is_trusted => {},
69
+ :phone_number => {},
75
70
  :promo_text => {},
71
+ :referral_code => {},
72
+ :resource_uri => {},
76
73
  :seller_details => {},
77
74
  :user_id => {},
75
+ :username => {},
76
+ :visit_count => {},
77
+ :visit_message => {},
78
78
  }
79
79
  end
80
80
  end
@@ -1,31 +1,31 @@
1
1
  module SynapsePay
2
2
  class Wire < APIResource
3
- attr_accessor :resource_uri
4
- attr_accessor :status
3
+ attr_accessor :account_number_string
5
4
  attr_accessor :amount
6
5
  attr_accessor :date
6
+ attr_accessor :fee
7
+ attr_accessor :id
7
8
  attr_accessor :memo
8
9
  attr_accessor :reference_id
10
+ attr_accessor :resource_uri
9
11
  attr_accessor :routing_number_string
12
+ attr_accessor :status
10
13
  attr_accessor :status_url
11
- attr_accessor :account_number_string
12
- attr_accessor :fee
13
- attr_accessor :id
14
14
 
15
15
  # Everything below here is used behind the scenes.
16
16
  APIResource.register_api_subclass(self, "wire")
17
17
  @api_attributes = {
18
- :resource_uri => {},
19
- :status => {},
18
+ :account_number_string => {},
20
19
  :amount => {},
21
20
  :date => {},
21
+ :fee => {},
22
+ :id => {},
22
23
  :memo => {},
23
24
  :reference_id => {},
25
+ :resource_uri => {},
24
26
  :routing_number_string => {},
27
+ :status => {},
25
28
  :status_url => {},
26
- :account_number_string => {},
27
- :fee => {},
28
- :id => {},
29
29
  }
30
30
  end
31
31
  end
@@ -1,29 +1,29 @@
1
1
  module SynapsePay
2
2
  class Withdrawal < APIResource
3
+ attr_accessor :amount
4
+ attr_accessor :bank
5
+ attr_accessor :date_created
3
6
  attr_accessor :fee
7
+ attr_accessor :id
8
+ attr_accessor :instant_credit
4
9
  attr_accessor :resource_uri
5
10
  attr_accessor :status
6
11
  attr_accessor :status_url
7
12
  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
13
 
14
14
  # Everything below here is used behind the scenes.
15
15
  APIResource.register_api_subclass(self, "withdrawal")
16
16
  @api_attributes = {
17
+ :amount => {},
18
+ :bank => {},
19
+ :date_created => {},
17
20
  :fee => {},
21
+ :id => {},
22
+ :instant_credit => {},
18
23
  :resource_uri => {},
19
24
  :status => {},
20
25
  :status_url => {},
21
26
  :user_id => {},
22
- :date_created => {},
23
- :bank => {},
24
- :id => {},
25
- :instant_credit => {},
26
- :amount => {},
27
27
  }
28
28
  end
29
29
  end