synapse_pay_rest 3.3.1 → 3.4.0

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: 503d134992f78bafbfe89fd3ebbe6430fe35ca87
4
- data.tar.gz: a23d139910156322ff423ed7dc01d0e2d23d5f81
3
+ metadata.gz: 2d39843aa3c581493f96b2cd055bccf32cec1ebe
4
+ data.tar.gz: 4ae3a0cd80c4282eeaf9db0715e9e7296a689c8e
5
5
  SHA512:
6
- metadata.gz: 2a55b51ce0018030f2dc71a238751132ec436a99365ae6e68a0362f8c2787fcf4f12142534bdf921c339a377e03986e7f003afa08cb740bba9619e20157006a1
7
- data.tar.gz: 00642c06e8e320fd101b7db256c3833949b3b293ca25bddd42386e722083fa35ebeecb33bd0b6e1d8d3293b3f80f7720004becb51f8a4470412cff3e5570abe7
6
+ metadata.gz: edb542dea9180a45b5a11e86e26a7e86eeea9d0369170bbdc629598a40a5304a759db8d1b38541fc73c86627c315869fcd9d374acfa23fb259b71afd5fab17ad
7
+ data.tar.gz: 764b6483c776ca8164277751fd013b864a36eebf25425a7faebaf58c3ab365f32eeaa323e0a0cc9ea61266926547d4e69bf69cb1d54fb3f6c7b48a91860c37d2
data/README.md CHANGED
@@ -28,7 +28,7 @@ $ gem install synapse_pay_rest
28
28
 
29
29
  - [Samples demonstrating common operations](samples.md)
30
30
  - [synapse_pay_rest gem docs](http://www.rubydoc.info/github/synapsepay/SynapsePayRest-Ruby)
31
- - [API docs](http://docs.synapsepay.com/v3.1)
31
+ - [API docs](http://docs.synapsefi.com/v3.1)
32
32
 
33
33
  ## Contributing
34
34
 
@@ -10,6 +10,8 @@ require 'synapse_pay_rest/api/transactions'
10
10
  require 'synapse_pay_rest/api/subscriptions'
11
11
  require 'synapse_pay_rest/api/institutions'
12
12
  require 'synapse_pay_rest/api/client'
13
+ require 'synapse_pay_rest/api/atms'
14
+ require 'synapse_pay_rest/api/crypto_quotes'
13
15
 
14
16
  # general library classes
15
17
  require 'synapse_pay_rest/error'
@@ -58,6 +60,9 @@ require 'synapse_pay_rest/models/node/clearing_us_node.rb'
58
60
  require 'synapse_pay_rest/models/node/ib_deposit_us_node.rb'
59
61
  require 'synapse_pay_rest/models/node/ib_subaccount_us_node.rb'
60
62
  require 'synapse_pay_rest/models/node/interchange_us_node.rb'
63
+ require 'synapse_pay_rest/models/node/card_us_node.rb'
64
+ require 'synapse_pay_rest/models/node/subcard_us_node.rb'
65
+ require 'synapse_pay_rest/models/node/crypto_us_node.rb'
61
66
 
62
67
  # iou
63
68
  require 'synapse_pay_rest/models/node/iou_node.rb'
@@ -79,6 +84,9 @@ require 'synapse_pay_rest/models/institution/institution'
79
84
 
80
85
  require 'synapse_pay_rest/models/client/issue_public_key'
81
86
 
87
+ require 'synapse_pay_rest/models/atm/atm'
88
+
89
+ require 'synapse_pay_rest/models/crypto_quote/crypto_quote'
82
90
 
83
91
 
84
92
  # Namespace for all SynapsePayRest classes and modules
@@ -0,0 +1,35 @@
1
+ module SynapsePayRest
2
+ # Wrapper class for /client endpoint
3
+ class Atms
4
+ VALID_QUERY_PARAMS = [:page, :per_page, :radius, :zip, :lat, :lon].freeze
5
+
6
+ # @!attribute [rw] client
7
+ # @return [SynapsePayRest::HTTPClient]
8
+ attr_accessor :client
9
+
10
+ # @param client [SynapsePayRest::HTTPClient]
11
+ def initialize(client)
12
+ @client = client
13
+ end
14
+
15
+ # Sends a GET request to /nodes endpoint to locate atms, and returns the
16
+ # response.
17
+ #
18
+ # @param scope [String]
19
+ #
20
+ # @raise [SynapsePayRest::Error] may return subclasses of error based on
21
+ # HTTP response from API
22
+ #
23
+ # @return [Hash] API responsea
24
+ def locate(**options)
25
+ params = VALID_QUERY_PARAMS.map do |p|
26
+ options[p] ? "#{p}=#{options[p]}" : nil
27
+ end.compact
28
+
29
+ path = "/nodes/atms?"
30
+ path += params.join('&') if params.any?
31
+ client.get(path)
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,30 @@
1
+ module SynapsePayRest
2
+ # Wrapper class for /client endpoint
3
+ class CryptoQuotes
4
+
5
+ # @!attribute [rw] client
6
+ # @return [SynapsePayRest::HTTPClient]
7
+ attr_accessor :client
8
+
9
+ # @param client [SynapsePayRest::HTTPClient]
10
+ def initialize(client)
11
+ @client = client
12
+ end
13
+
14
+ # Sends a GET request to /crypto-quotes endpoint to get btc exchange rate and returns the
15
+ # response.
16
+ #
17
+ # @param scope [String]
18
+ #
19
+ # @raise [SynapsePayRest::Error] may return subclasses of error based on
20
+ # HTTP response from API
21
+ #
22
+ # @return [Hash] API response
23
+ def get()
24
+ path = '/nodes/crypto-quotes'
25
+ client.get(path)
26
+ end
27
+ private
28
+
29
+ end
30
+ end
@@ -1,7 +1,5 @@
1
1
  module SynapsePayRest
2
2
  # Wrapper class for /institutions endpoints
3
- #
4
- #
5
3
  class Institutions
6
4
 
7
5
  # @!attribute [rw] client
@@ -13,7 +11,7 @@ module SynapsePayRest
13
11
  @client = client
14
12
  end
15
13
 
16
- # Sends a GET request to /v3.1/institutions endpoint. Queries a specific subscription_id
14
+ # Sends a GET request to /v3.1/institutions endpoint.
17
15
  #
18
16
  #
19
17
  # @raise [SynapsePayRest::Error] may return subclasses of error based on
@@ -94,6 +94,38 @@ module SynapsePayRest
94
94
  client.patch(path, {})
95
95
  end
96
96
 
97
+ # Sends a PATCH request to /nodes endpoint to reissue debit card-us node, and returns the
98
+ # response.
99
+ #
100
+ # @param user_id [String]
101
+ # @param node_id [String]
102
+ #
103
+ # @raise [SynapsePayRest::Error] may return subclasses of error based on
104
+ # HTTP response from API
105
+ #
106
+ # @return [Hash] API response
107
+ def reissue_card(user_id:, node_id:)
108
+ path = node_path(user_id: user_id, node_id: node_id)
109
+ path += '?reissue_card=YES'
110
+ client.patch(path, {})
111
+ end
112
+
113
+ # Sends a PATCH request to /nodes endpoint to reorder debit card-us node, and returns the
114
+ # response.
115
+ #
116
+ # @param user_id [String]
117
+ # @param node_id [String]
118
+ #
119
+ # @raise [SynapsePayRest::Error] may return subclasses of error based on
120
+ # HTTP response from API
121
+ #
122
+ # @return [Hash] API response
123
+ def reorder_card(user_id:, node_id:)
124
+ path = node_path(user_id: user_id, node_id: node_id)
125
+ path += '?reorder_card=YES'
126
+ client.patch(path, {})
127
+ end
128
+
97
129
  # Sends a DELETE request to /node endpoint to remove a node, and returns the response.
98
130
  #
99
131
  # @param user_id [String]
@@ -14,7 +14,7 @@ module SynapsePayRest
14
14
  # @!attribute [rw] subscriptions
15
15
  # @return [SynapsePayRest::Subscriptions]
16
16
  attr_accessor :http_client, :users, :nodes, :subnets, :transactions, :subscriptions, :institutions,
17
- :client_endpoint
17
+ :client_endpoint, :atms, :crypto_quotes
18
18
 
19
19
  # Alias for #transactions (legacy name)
20
20
  alias_method :trans, :transactions
@@ -49,6 +49,8 @@ module SynapsePayRest
49
49
  @subscriptions = Subscriptions.new @http_client
50
50
  @institutions = Institutions.new @http_client
51
51
  @client_endpoint = ClientEndpoint.new @http_client
52
+ @atms = Atms.new @http_client
53
+ @crypto_quotes = CryptoQuotes.new @http_client
52
54
  end
53
55
 
54
56
 
@@ -56,5 +58,10 @@ module SynapsePayRest
56
58
  def issue_public_key(scope: "OAUTH|POST,USERS|POST,USERS|GET,USER|GET,USER|PATCH,SUBSCRIPTIONS|GET,SUBSCRIPTIONS|POST,SUBSCRIPTION|GET,SUBSCRIPTION|PATCH,CLIENT|REPORTS,CLIENT|CONTROLS")
57
59
  PublicKey.issue(client: self, scope: scope)
58
60
  end
61
+
62
+ def get_crypto_quotes()
63
+ CryptoQuote.get(client: self)
64
+ end
65
+
59
66
  end
60
67
  end
@@ -0,0 +1,81 @@
1
+ module SynapsePayRest
2
+ # Represents a public key record and holds methods for getting public key instances
3
+ # from API calls. This is built on top of the SynapsePayRest::Client class and
4
+ # is intended to make it easier to use the API without knowing payload formats
5
+ # or knowledge of REST.
6
+ class Atm
7
+ attr_reader :client, :address_city, :address_country, :address_postal_code, :address_state, :address_street,
8
+ :latitude, :longitude, :id, :isAvailable24Hours, :isDepositAvailable, :isHandicappedAccessible, :isOffPremise,
9
+ :isSeasonal, :languageType, :locationDescription, :logoName, :name, :distance
10
+
11
+ class << self
12
+ # Creates a client public key from a response hash.
13
+ # @note Shouldn't need to call this directly.
14
+ def from_response(client, response)
15
+ args = {
16
+ client: client,
17
+ address_city: response['atmLocation']['address']['city'],
18
+ address_country: response['atmLocation']['address']['country'],
19
+ address_postal_code: response['atmLocation']['address']['postalCode'],
20
+ address_state: response['atmLocation']['address']['state'],
21
+ address_street: response['atmLocation']['address']['street'],
22
+ latitude: response['atmLocation']['coordinates']['latitude'],
23
+ longitude: response['atmLocation']['coordinates']['longitude'],
24
+ id: response['atmLocation']['id'],
25
+ isAvailable24Hours: response['atmLocation']['isAvailable24Hours'],
26
+ isDepositAvailable: response['atmLocation']['isDepositAvailable'],
27
+ isHandicappedAccessible: response['atmLocation']['isHandicappedAccessible'],
28
+ isOffPremise: response['atmLocation']['isOffPremise'],
29
+ isSeasonal: response['atmLocation']['isSeasonal'],
30
+ languageType: response['atmLocation']['languageType'],
31
+ locationDescription: response['atmLocation']['locationDescription'],
32
+ logoName: response['atmLocation']['logoName'],
33
+ name: response['atmLocation']['name'],
34
+ distance: response['distance']
35
+ }
36
+ self.new(args)
37
+ end
38
+
39
+ # Locate ATMs near zip code
40
+ # @param client [SynapsePayRest::Client]
41
+ # @param zip [String]
42
+ #
43
+ # @raise [SynapsePayRest::Error]
44
+ #
45
+ # @return [SynapsePayRest::Atm] new instance corresponding to same API record
46
+ def locate(client:, zip: nil, page: nil, per_page: nil, radius: nil, lat: nil, lon: nil)
47
+ raise ArgumentError, 'client must be a SynapsePayRest::Client' unless client.is_a?(Client)
48
+ [page, per_page].each do |arg|
49
+ if arg && (!arg.is_a?(Integer) || arg < 1)
50
+ raise ArgumentError, "#{arg} must be nil or an Integer >= 1"
51
+ end
52
+ end
53
+
54
+ [zip, radius, lat, lon].each do |arg|
55
+ if arg && !arg.is_a?(String)
56
+ raise ArgumentError, "#{arg}must be a String"
57
+ end
58
+ end
59
+
60
+ response = client.atms.locate(zip: zip, page: page, per_page: per_page, radius: radius, lat: lat, lon: lon)
61
+ multiple_from_response(client, response['atms'])
62
+ end
63
+
64
+
65
+ # Calls from_response on each member of a response collection.
66
+ def multiple_from_response(client, response)
67
+ return [] if response.empty?
68
+ response.map { |atm_data| from_response(client.dup, atm_data)}
69
+ end
70
+ end
71
+
72
+
73
+ # @note Do not call directly. Use other class method
74
+ # to instantiate via API action.
75
+ def initialize(**options)
76
+ options.each { |key, value| instance_variable_set("@#{key}", value) }
77
+ end
78
+
79
+
80
+ end
81
+ end
@@ -0,0 +1,40 @@
1
+ module SynapsePayRest
2
+ # Represents a public key record and holds methods for getting crypto quote
3
+ # from API calls. This is built on top of the SynapsePayRest::Client class and
4
+ # is intended to make it easier to use the API without knowing payload formats
5
+ # or knowledge of REST.
6
+ class CryptoQuote
7
+ attr_reader :client, :btcusd, :ethusd, :usdbtc, :usdeth
8
+
9
+ class << self
10
+
11
+ # Creates a crypto quote from a response hash.
12
+ #
13
+ # @note Shouldn't need to call this directly.
14
+ def from_response(client, response)
15
+ args = {
16
+ client: client,
17
+ btcusd: response['BTCUSD'],
18
+ ethusd: response['ETHUSD'],
19
+ usdbtc: response['USDBTC'],
20
+ usdeth: response['USDETH']
21
+ }
22
+ self.new(args)
23
+ end
24
+
25
+ def get(client:)
26
+ raise ArgumentError, 'client must be a SynapsePayRest::Client' unless client.is_a?(Client)
27
+ response = client.crypto_quotes.get()
28
+ self.from_response(client, response)
29
+ end
30
+
31
+ end
32
+
33
+ # @note Do not call directly. Use other class method
34
+ # to instantiate via API action.
35
+ def initialize(**options)
36
+ options.each { |key, value| instance_variable_set("@#{key}", value) }
37
+ end
38
+
39
+ end
40
+ end
@@ -4,22 +4,17 @@ module SynapsePayRest
4
4
  # is intended to make it easier to use the API without knowing payload formats
5
5
  # or knowledge of REST.
6
6
  #
7
- # @todo use mixins to remove duplication between Node and BaseNode.
8
7
  class Institution
9
- attr_reader :id, :is_active, :scope, :url
8
+ attr_reader :client, :bank_code, :bank_name, :features, :forgotten_password, :is_active, :logo, :tx_history_months
10
9
 
11
10
  class << self
12
- def all(client:)
13
- raise ArgumentError, 'client must be a SynapsePayRest::Client' unless client.is_a?(Client)
14
- response = client.institutions.get()
15
- multiple_from_response(response['banks'])
16
- end
17
11
 
18
12
  # Creates an Institution from a response hash.
19
13
  #
20
14
  # @note Shouldn't need to call this directly.
21
- def from_response(response)
15
+ def from_response(client, response)
22
16
  args = {
17
+ client: client,
23
18
  bank_code: response['bank_code'],
24
19
  bank_name: response['bank_name'],
25
20
  features: response['features'],
@@ -31,14 +26,25 @@ module SynapsePayRest
31
26
  self.new(args)
32
27
  end
33
28
 
29
+ def all(client:)
30
+ raise ArgumentError, 'client must be a SynapsePayRest::Client' unless client.is_a?(Client)
31
+ response = client.institutions.get()
32
+ multiple_from_response(client, response['banks'])
33
+ end
34
+
34
35
  # Calls from_response on each member of a response collection.
35
- def multiple_from_response(response)
36
+ def multiple_from_response(client, response)
36
37
  return [] if response.empty?
37
- response.map { |institution_data| from_response(institution_data)}
38
+ response.map { |institution_data| from_response(client.dup, institution_data)}
38
39
  end
39
40
 
40
- private
41
+ end
41
42
 
43
+ # @note Do not call directly. Use other class method
44
+ # to instantiate via API action.
45
+ def initialize(**options)
46
+ options.each { |key, value| instance_variable_set("@#{key}", value) }
42
47
  end
48
+
43
49
  end
44
50
  end
@@ -23,7 +23,9 @@ module SynapsePayRest
23
23
  :email_match, :name_match, :phonenumber_match, :address_street,
24
24
  :address_city, :address_subdivision, :address_country_code,
25
25
  :address_postal_code, :payee_address, :payee_name, :other, :network,
26
- :document_id, :card_type
26
+ :document_id, :interchange_type, :card_hash, :is_international, :allow_foreign_transactions,
27
+ :atm_withdrawal_limit, :max_pin_attempts, :pos_withdrawal_limit, :security_alerts,
28
+ :card_type, :access_token, :portfolio_BTC, :portfolio_ETH, :card_style_id
27
29
 
28
30
  class << self
29
31
  # Creates a new node in the API associated to the provided user and
@@ -97,7 +99,10 @@ module SynapsePayRest
97
99
  payee_name: response['info']['payee_name'],
98
100
  document_id: response['info']['document_id'],
99
101
  network: response['info']['network'],
100
- card_type: response['info']['type'],
102
+ interchange_type: response['info']['type'],
103
+ card_type: response['info']['card_type'],
104
+ card_hash: response['info']['card_hash'],
105
+ is_international: response['info']['is_international'],
101
106
  user_info: nil,
102
107
  transactions: nil,
103
108
  timeline: nil,
@@ -144,6 +149,9 @@ module SynapsePayRest
144
149
 
145
150
  transaction_analysis = response['extra']['other']['transaction_analysis']
146
151
  args[:transaction_analysis] = transaction_analysis
152
+
153
+ access_token = response['extra']['other']['access_token']
154
+ args[:access_token] = access_token
147
155
  end
148
156
 
149
157
  if response['timeline']
@@ -160,6 +168,21 @@ module SynapsePayRest
160
168
  args[:address_postal_code] = payee_address['address_postal_code']
161
169
  end
162
170
 
171
+ if response['info']['preferences']
172
+ preferences = response['info']['preferences']
173
+ args[:allow_foreign_transactions] = preferences['allow_foreign_transactions']
174
+ args[:atm_withdrawal_limit] = preferences['atm_withdrawal_limit']
175
+ args[:max_pin_attempts] = preferences['max_pin_attempts']
176
+ args[:pos_withdrawal_limit] = preferences['pos_withdrawal_limit']
177
+ args[:security_alerts] = preferences['security_alerts']
178
+ end
179
+
180
+ if response['info']['portfolio']
181
+ preferences = response['info']['portfolio']
182
+ args[:portfolio_BTC] = preferences['BTC']
183
+ args[:portfolio_ETH] = preferences['ETH']
184
+ end
185
+
163
186
  self.new(**args)
164
187
  end
165
188
 
@@ -228,6 +251,12 @@ module SynapsePayRest
228
251
  if options[:document_id]
229
252
  payload['info']['document_id'] = options[:document_id]
230
253
  end
254
+ if options[:card_type]
255
+ payload['info']['card_type'] = options[:card_type]
256
+ end
257
+ if options[:card_style_id]
258
+ payload['card_style_id'] = options[:card_style_id]
259
+ end
231
260
 
232
261
  balance_fields = [:currency]
233
262
  balance_fields.each do |field|
@@ -0,0 +1,92 @@
1
+ module SynapsePayRest
2
+
3
+ class CardUsNode < BaseNode
4
+ class << self
5
+ private
6
+
7
+ def payload_for_create(nickname:, document_id:, card_type:, **options)
8
+ args = {
9
+ type: 'CARD-US',
10
+ nickname: nickname,
11
+ document_id: document_id,
12
+ card_type: card_type,
13
+ }.merge(options)
14
+ super(args)
15
+ end
16
+
17
+ end
18
+
19
+ def update_preferences(**options)
20
+ if options.empty?
21
+ raise ArgumentError, 'must provide some key-value pairs to update'
22
+ end
23
+ payload = payload_for_preferences(options)
24
+ response = user.client.nodes.patch(user_id: user.id, node_id: id, payload: payload)
25
+ self.class.from_response(user, response)
26
+ end
27
+
28
+ def update_allowed(allowed:)
29
+ if allowed.empty?
30
+ raise ArgumentError, 'must provide some key-value pairs to update'
31
+ end
32
+ payload = { 'allowed': allowed }
33
+ response = user.client.nodes.patch(user_id: user.id, node_id: id, payload: payload)
34
+ self.class.from_response(user, response)
35
+ end
36
+
37
+ # Reissues Debit Card on a node
38
+ # Use Reissue if you wish to change the card number associated with the debit card.
39
+ # This is meant to be used in instances where the user wishes to change their existing card
40
+ # number (due to fraud or any other reason).
41
+ #
42
+ # @raise [SynapsePayRest::Error] if wrong guess or HTTP error
43
+ #
44
+ # @return [SynapsePayRest::CardUsNode]
45
+ def reissue_card()
46
+ response = user.client.nodes.reissue_card(user_id: user.id, node_id: id)
47
+ self.class.from_response(user, response)
48
+ end
49
+
50
+ # Reorders Debit Card on a node
51
+ # Use Reorder if the user wishes to keep the same card number but want to order a new plastic.
52
+ #Can be used in scenarios where the user's card was destroyed.
53
+ #
54
+ # @raise [SynapsePayRest::Error] if wrong guess or HTTP error
55
+ #
56
+ # @return [SynapsePayRest::CardUsNode]
57
+ def reorder_card()
58
+ response = user.client.nodes.reorder_card(user_id: user.id, node_id: id)
59
+ self.class.from_response(user, response)
60
+ end
61
+
62
+ private
63
+
64
+ def payload_for_preferences(**options)
65
+ payload = {
66
+ 'preferences' => {}
67
+ }
68
+ if options[:allow_foreign_transactions]
69
+ payload['preferences']['allow_foreign_transactions'] = options[:allow_foreign_transactions]
70
+ end
71
+
72
+ if options[:atm_withdrawal_limit]
73
+ payload['preferences']['atm_withdrawal_limit'] = options[:atm_withdrawal_limit]
74
+ end
75
+
76
+ if options[:max_pin_attempts]
77
+ payload['preferences']['max_pin_attempts'] = options[:max_pin_attempts]
78
+ end
79
+
80
+ if options[:pos_withdrawal_limit]
81
+ payload['preferences']['pos_withdrawal_limit'] = options[:pos_withdrawal_limit]
82
+ end
83
+
84
+ if options[:security_alerts]
85
+ payload['preferences']['security_alerts'] = options[:security_alerts]
86
+ end
87
+
88
+ payload
89
+ end
90
+
91
+ end
92
+ end
@@ -0,0 +1,16 @@
1
+ module SynapsePayRest
2
+ # A BTC node allowing any user to hold funds in BTC.
3
+ class CryptoUsNode < BaseNode
4
+ class << self
5
+ private
6
+
7
+ def payload_for_create(nickname:, **options)
8
+ args = {
9
+ type: 'CRYPTO-US',
10
+ nickname: nickname
11
+ }.merge(options)
12
+ super(args)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -23,7 +23,10 @@ module SynapsePayRest
23
23
  'CLEARING-US' => ClearingUsNode,
24
24
  'IB-DEPOSIT-US' => IbDepositUsNode,
25
25
  'IB-SUBACCOUNT-US' => IbSubaccountUsNode,
26
- 'INTERCHANGE-US' => InterchangeUsNode
26
+ 'INTERCHANGE-US' => InterchangeUsNode,
27
+ 'CARD-US' => CardUsNode,
28
+ 'SUBCARD-US' => SubcardUsNode,
29
+ 'CRYPTO-US' => CryptoUsNode
27
30
  }.freeze
28
31
 
29
32
  class << self
@@ -0,0 +1,65 @@
1
+ module SynapsePayRest
2
+
3
+ class SubcardUsNode < BaseNode
4
+ class << self
5
+ private
6
+
7
+ def payload_for_create(nickname:, document_id:, card_type:, **options)
8
+ args = {
9
+ type: 'SUBCARD-US',
10
+ nickname: nickname,
11
+ document_id: document_id,
12
+ card_type: card_type,
13
+ }.merge(options)
14
+ super(args)
15
+ end
16
+ end
17
+
18
+ def update_preferences(**options)
19
+ if options.empty?
20
+ raise ArgumentError, 'must provide some key-value pairs to update'
21
+ end
22
+ payload = payload_for_preferences(options)
23
+ response = user.client.nodes.patch(user_id: user.id, node_id: id, payload: payload)
24
+ self.class.from_response(user, response)
25
+ end
26
+
27
+ def update_allowed(allowed:)
28
+ if allowed.empty?
29
+ raise ArgumentError, 'must provide some key-value pairs to update'
30
+ end
31
+ payload = { 'allowed': allowed }
32
+ response = user.client.nodes.patch(user_id: user.id, node_id: id, payload: payload)
33
+ self.class.from_response(user, response)
34
+ end
35
+
36
+ private
37
+
38
+ def payload_for_preferences(**options)
39
+ payload = {
40
+ 'preferences' => {}
41
+ }
42
+ if options[:allow_foreign_transactions]
43
+ payload['preferences']['allow_foreign_transactions'] = options[:allow_foreign_transactions]
44
+ end
45
+
46
+ if options[:atm_withdrawal_limit]
47
+ payload['preferences']['atm_withdrawal_limit'] = options[:atm_withdrawal_limit]
48
+ end
49
+
50
+ if options[:max_pin_attempts]
51
+ payload['preferences']['max_pin_attempts'] = options[:max_pin_attempts]
52
+ end
53
+
54
+ if options[:pos_withdrawal_limit]
55
+ payload['preferences']['pos_withdrawal_limit'] = options[:pos_withdrawal_limit]
56
+ end
57
+
58
+ if options[:security_alerts]
59
+ payload['preferences']['security_alerts'] = options[:security_alerts]
60
+ end
61
+
62
+ payload
63
+ end
64
+ end
65
+ end
@@ -12,7 +12,7 @@ module SynapsePayRest
12
12
  attr_reader :node, :id, :amount, :currency, :client_id, :client_name, :created_on,
13
13
  :ip, :latlon, :note, :process_on, :supp_id, :webhook, :fees,
14
14
  :recent_status, :timeline, :from, :to, :to_type, :to_id,
15
- :fee_amount, :fee_note, :fee_to_id
15
+ :fee_amount, :fee_note, :fee_to_id , :asset, :same_day
16
16
 
17
17
  class << self
18
18
  # Creates a new transaction in the API belonging to the provided node and
@@ -130,6 +130,7 @@ module SynapsePayRest
130
130
  latlon: response['extra']['latlon'],
131
131
  note: response['extra']['note'],
132
132
  process_on: response['extra']['process_on'],
133
+ same_day: response['extra']['same_day'],
133
134
  supp_id: response['extra']['supp_id'],
134
135
  webhook: response['extra']['webhook'],
135
136
  fees: response['fees'],
@@ -166,6 +167,8 @@ module SynapsePayRest
166
167
  }
167
168
  }
168
169
  # optional payload fields
170
+ payload['extra']['asset'] = options[:asset] if options[:asset]
171
+ payload['extra']['same_day'] = options[:same_day] if options[:same_day]
169
172
  payload['extra']['supp_id'] = options[:supp_id] if options[:supp_id]
170
173
  payload['extra']['note'] = options[:note] if options[:note]
171
174
  payload['extra']['process_on'] = options[:process_in] if options[:process_in]
@@ -727,7 +727,7 @@ module SynapsePayRest
727
727
  # Creates a INTERCHANGE-US node.
728
728
  #
729
729
  # @param nickname [String] nickname for the node
730
- # @param supp_id [String] (optional)
730
+ # @param document_id [String] Document ID of user's base document that the card is associated with
731
731
  # @param gateway_restricted [Boolean] (optional)
732
732
  #
733
733
  # @raise [SynapsePayRest::Error]
@@ -737,6 +737,45 @@ module SynapsePayRest
737
737
  InterchangeUsNode.create(user: self, **options)
738
738
  end
739
739
 
740
+ # Creates a CARD-US node.
741
+ #
742
+ # @param nickname [String] nickname for the node
743
+ # @param document_id [String] Document ID of user's base document that the card is associated with
744
+ # @param card_type[String] PHYSICAL or VIRTUAL
745
+ #
746
+ # @raise [SynapsePayRest::Error]
747
+ #
748
+ # @return [SynapsePayRest::CardUsNode]
749
+ def create_card_us_node(**options)
750
+ CardUsNode.create(user: self, **options)
751
+ end
752
+
753
+ # Creates a SUBCARD-US node.
754
+ #
755
+ # @param nickname [String] nickname for the node
756
+ # @param document_id [String] Document ID of user's base document that the card is associated with
757
+ # @param card_type[String] PHYSICAL or VIRTUAL
758
+ #
759
+ # @raise [SynapsePayRest::Error]
760
+ #
761
+ # @return [SynapsePayRest::SubcardUsNode]
762
+ def create_subcard_us_node(**options)
763
+ SubcardUsNode.create(user: self, **options)
764
+ end
765
+
766
+ # Creates a BTC-US node.
767
+ #
768
+ # @param nickname [String] nickname for the node
769
+ # @param supp_id [String] (optional)
770
+ # @param gateway_restricted [Boolean] (optional)
771
+ #
772
+ # @raise [SynapsePayRest::Error]
773
+ #
774
+ # @return [SynapsePayRest::BtcUsNode]
775
+ def create_crypto_us_node(**options)
776
+ CryptoUsNode.create(user: self, **options)
777
+ end
778
+
740
779
  # Checks if two User instances have same id (different instances of same record).
741
780
  def ==(other)
742
781
  other.instance_of?(self.class) && !id.nil? && id == other.id
@@ -1,4 +1,4 @@
1
1
  module SynapsePayRest
2
2
  # Gem version
3
- VERSION = '3.3.1'.freeze
3
+ VERSION = '3.4.0'.freeze
4
4
  end
data/samples.md CHANGED
@@ -1125,6 +1125,51 @@ node = user.create_interchange_us_node(node_info)
1125
1125
  # => #<SynapsePayRest::InterchangeUsNode>
1126
1126
  ```
1127
1127
 
1128
+ #### Create CARD-US Node
1129
+
1130
+ ```ruby
1131
+ id = base_document.id
1132
+
1133
+ node_info = {
1134
+ nickname: 'Debit Card',
1135
+ document_id: id,
1136
+ card_type: 'PHYSICAL',
1137
+ card_style_id: '550' #optional -- only pass this in if there are multiple styles
1138
+ }
1139
+
1140
+ card_node = user.create_card_us_node(node_info)
1141
+ # => #<SynapsePayRest::CardUsNode>
1142
+ ```
1143
+
1144
+ #### Reorder CARD-US Node
1145
+
1146
+ ```ruby
1147
+ node = card_node.reorder_card
1148
+ # => #<SynapsePayRest::CardUsNode>
1149
+ ```
1150
+
1151
+ #### Reissue CARD-US Node
1152
+
1153
+ ```ruby
1154
+ node = card_node.reissue_card
1155
+ # => #<SynapsePayRest::CardUsNode>
1156
+ ```
1157
+
1158
+ #### Update CARD-US Preferences
1159
+
1160
+ ```ruby
1161
+ card_prefs = {
1162
+ allow_foreign_transactions: true,
1163
+ atm_withdrawal_limit: 6000,
1164
+ max_pin_attempts: 4,
1165
+ pos_withdrawal_limit: 100,
1166
+ security_alerts: false
1167
+ }
1168
+
1169
+ node = node.update_preferences(card_prefs)
1170
+ # => #<SynapsePayRest::CardUsNode>
1171
+ ```
1172
+
1128
1173
  #### Deactivate a Node
1129
1174
 
1130
1175
  This deactivates the node. It does not automatically cancel any transactions already underway.
@@ -1292,9 +1337,73 @@ public_key = client.issue_public_key(scope: ‘CLIENT|CONTROLS’)
1292
1337
  # => #<SynapsePayRest::Public_key>
1293
1338
  ```
1294
1339
 
1295
- ##### b) Subnet#all
1340
+ ##### b) PublicKey#issue
1296
1341
 
1297
1342
  ```ruby
1298
1343
  public_key = SynapsePayRest::PublicKey.issue(client: client, scope: ‘CLIENT|CONTROLS')
1299
1344
  # => #<SynapsePayRest::Public_key>
1300
1345
  ```
1346
+
1347
+ ## Crypto Quote Method
1348
+
1349
+ #### Get Crypto Quote From Client
1350
+
1351
+ ##### a) Client#get_crypto_quotes
1352
+
1353
+ ```ruby
1354
+ crypto_quotes = client.get_crypto_quotes
1355
+ # => #<SynapsePayRest::CryptoQuote>
1356
+ ```
1357
+
1358
+ ##### b) CryptoQuote#get
1359
+
1360
+ ```ruby
1361
+ crypto_quote = SynapsePayRest::CryptoQuote.get(client: client)
1362
+ # => #<SynapsePayRest::CryptoQuote>
1363
+ ```
1364
+
1365
+ ## Institution Method
1366
+
1367
+ #### Get Institutions
1368
+
1369
+ ##### a) Institutions#all
1370
+
1371
+ ```ruby
1372
+ institutions = SynapsePayRest::Institution.all(client: client)
1373
+ # => [#<SynapsePayRest::Institution>, #<SynapsePayRest::Institution>, ...]
1374
+ ```
1375
+
1376
+ ## Locate ATM Method
1377
+
1378
+ #### Locate nearby ATMs with lat/lon or zipcode
1379
+
1380
+ ##### a) ATM#locate
1381
+
1382
+ ```ruby
1383
+ atm_info = {
1384
+ client: client,
1385
+ lat: '37.764832',
1386
+ lon: '-122.419304',
1387
+ radius: '5',
1388
+ page: 1,
1389
+ per_page: 10
1390
+ }
1391
+
1392
+ atms = SynapsePayRest::Atm.locate(atm_info)
1393
+ # => [#<SynapsePayRest::Atm>, #<SynapsePayRest::Atm>, ...]
1394
+ ```
1395
+
1396
+ ##### b) ATM#locate
1397
+
1398
+ ```ruby
1399
+ atm_args = {
1400
+ client: client,
1401
+ zip: '95131',
1402
+ radius: '10',
1403
+ page: 1,
1404
+ per_page: 10
1405
+ }
1406
+
1407
+ atms = SynapsePayRest::Atm.locate(atm_args)
1408
+ # => [#<SynapsePayRest::Atm>, #<SynapsePayRest::Atm>, ...]
1409
+ ```
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: synapse_pay_rest
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.1
4
+ version: 3.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Broderick
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2018-02-12 00:00:00.000000000 Z
12
+ date: 2018-08-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
@@ -151,7 +151,9 @@ files:
151
151
  - Rakefile
152
152
  - bin/console
153
153
  - lib/synapse_pay_rest.rb
154
+ - lib/synapse_pay_rest/api/atms.rb
154
155
  - lib/synapse_pay_rest/api/client.rb
156
+ - lib/synapse_pay_rest/api/crypto_quotes.rb
155
157
  - lib/synapse_pay_rest/api/institutions.rb
156
158
  - lib/synapse_pay_rest/api/nodes.rb
157
159
  - lib/synapse_pay_rest/api/subnets.rb
@@ -161,12 +163,16 @@ files:
161
163
  - lib/synapse_pay_rest/client.rb
162
164
  - lib/synapse_pay_rest/error.rb
163
165
  - lib/synapse_pay_rest/http_client.rb
166
+ - lib/synapse_pay_rest/models/atm/atm.rb
164
167
  - lib/synapse_pay_rest/models/client/issue_public_key.rb
168
+ - lib/synapse_pay_rest/models/crypto_quote/crypto_quote.rb
165
169
  - lib/synapse_pay_rest/models/institution/institution.rb
166
170
  - lib/synapse_pay_rest/models/node/ach_us_node.rb
167
171
  - lib/synapse_pay_rest/models/node/base_node.rb
172
+ - lib/synapse_pay_rest/models/node/card_us_node.rb
168
173
  - lib/synapse_pay_rest/models/node/check_us_node.rb
169
174
  - lib/synapse_pay_rest/models/node/clearing_us_node.rb
175
+ - lib/synapse_pay_rest/models/node/crypto_us_node.rb
170
176
  - lib/synapse_pay_rest/models/node/deposit_us_node.rb
171
177
  - lib/synapse_pay_rest/models/node/eft_ind_node.rb
172
178
  - lib/synapse_pay_rest/models/node/eft_np_node.rb
@@ -177,6 +183,7 @@ files:
177
183
  - lib/synapse_pay_rest/models/node/node.rb
178
184
  - lib/synapse_pay_rest/models/node/reserve_us_node.rb
179
185
  - lib/synapse_pay_rest/models/node/subaccount_us_node.rb
186
+ - lib/synapse_pay_rest/models/node/subcard_us_node.rb
180
187
  - lib/synapse_pay_rest/models/node/synapse_ind_node.rb
181
188
  - lib/synapse_pay_rest/models/node/synapse_np_node.rb
182
189
  - lib/synapse_pay_rest/models/node/synapse_us_node.rb