synapse_pay_rest 3.4.1 → 3.4.2

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 +5 -5
  2. data/.env.sample +2 -1
  3. data/.gitignore +0 -0
  4. data/Gemfile +0 -0
  5. data/LICENSE +0 -0
  6. data/README.md +0 -0
  7. data/Rakefile +0 -0
  8. data/lib/synapse_pay_rest.rb +3 -0
  9. data/lib/synapse_pay_rest/api/atms.rb +0 -0
  10. data/lib/synapse_pay_rest/api/client.rb +0 -0
  11. data/lib/synapse_pay_rest/api/crypto_quotes.rb +0 -0
  12. data/lib/synapse_pay_rest/api/institutions.rb +0 -0
  13. data/lib/synapse_pay_rest/api/nodes.rb +0 -0
  14. data/lib/synapse_pay_rest/api/statements.rb +41 -0
  15. data/lib/synapse_pay_rest/api/subnets.rb +0 -0
  16. data/lib/synapse_pay_rest/api/subscriptions.rb +0 -0
  17. data/lib/synapse_pay_rest/api/transactions.rb +0 -0
  18. data/lib/synapse_pay_rest/api/users.rb +0 -0
  19. data/lib/synapse_pay_rest/client.rb +2 -1
  20. data/lib/synapse_pay_rest/error.rb +0 -0
  21. data/lib/synapse_pay_rest/http_client.rb +0 -0
  22. data/lib/synapse_pay_rest/models/atm/atm.rb +0 -0
  23. data/lib/synapse_pay_rest/models/client/issue_public_key.rb +0 -0
  24. data/lib/synapse_pay_rest/models/crypto_quote/crypto_quote.rb +0 -0
  25. data/lib/synapse_pay_rest/models/institution/institution.rb +0 -0
  26. data/lib/synapse_pay_rest/models/node/ach_us_node.rb +0 -0
  27. data/lib/synapse_pay_rest/models/node/base_node.rb +0 -0
  28. data/lib/synapse_pay_rest/models/node/card_us_node.rb +0 -0
  29. data/lib/synapse_pay_rest/models/node/check_us_node.rb +0 -0
  30. data/lib/synapse_pay_rest/models/node/clearing_us_node.rb +0 -0
  31. data/lib/synapse_pay_rest/models/node/crypto_us_node.rb +0 -0
  32. data/lib/synapse_pay_rest/models/node/deposit_us_node.rb +0 -0
  33. data/lib/synapse_pay_rest/models/node/eft_ind_node.rb +0 -0
  34. data/lib/synapse_pay_rest/models/node/eft_np_node.rb +0 -0
  35. data/lib/synapse_pay_rest/models/node/ib_deposit_us_node.rb +0 -0
  36. data/lib/synapse_pay_rest/models/node/ib_subaccount_us_node.rb +0 -0
  37. data/lib/synapse_pay_rest/models/node/interchange_us_node.rb +0 -0
  38. data/lib/synapse_pay_rest/models/node/iou_node.rb +0 -0
  39. data/lib/synapse_pay_rest/models/node/node.rb +0 -0
  40. data/lib/synapse_pay_rest/models/node/reserve_us_node.rb +0 -0
  41. data/lib/synapse_pay_rest/models/node/subaccount_us_node.rb +0 -0
  42. data/lib/synapse_pay_rest/models/node/subcard_us_node.rb +0 -0
  43. data/lib/synapse_pay_rest/models/node/synapse_ind_node.rb +0 -0
  44. data/lib/synapse_pay_rest/models/node/synapse_np_node.rb +0 -0
  45. data/lib/synapse_pay_rest/models/node/synapse_us_node.rb +0 -0
  46. data/lib/synapse_pay_rest/models/node/triumph_subaccount_us_node.rb +0 -0
  47. data/lib/synapse_pay_rest/models/node/unverified_node.rb +0 -0
  48. data/lib/synapse_pay_rest/models/node/wire_int_node.rb +0 -0
  49. data/lib/synapse_pay_rest/models/node/wire_us_node.rb +0 -0
  50. data/lib/synapse_pay_rest/models/statement/statement.rb +80 -0
  51. data/lib/synapse_pay_rest/models/subnet/subnet.rb +0 -0
  52. data/lib/synapse_pay_rest/models/subscription/subscription.rb +0 -0
  53. data/lib/synapse_pay_rest/models/transaction/transaction.rb +0 -0
  54. data/lib/synapse_pay_rest/models/user/base_document.rb +0 -0
  55. data/lib/synapse_pay_rest/models/user/document.rb +0 -0
  56. data/lib/synapse_pay_rest/models/user/physical_document.rb +0 -0
  57. data/lib/synapse_pay_rest/models/user/question.rb +0 -0
  58. data/lib/synapse_pay_rest/models/user/social_document.rb +0 -0
  59. data/lib/synapse_pay_rest/models/user/user.rb +0 -0
  60. data/lib/synapse_pay_rest/models/user/virtual_document.rb +0 -0
  61. data/lib/synapse_pay_rest/version.rb +1 -1
  62. data/samples.md +26 -0
  63. data/synapse_pay_rest.gemspec +0 -0
  64. metadata +5 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 92076f52668f8985f892f4d4c2e7747032331cce
4
- data.tar.gz: 565e475469416d09ddb3ec13c054a31a5e248f73
2
+ SHA256:
3
+ metadata.gz: 5c739268324bccef13ac3b3cfdcf97c6de821b0acfd30ec0ab8df1a7b7d4466a
4
+ data.tar.gz: 8b19a633a2da3cf57040b3d765a5b71e12231b30fa008b44eef0a94ec649b801
5
5
  SHA512:
6
- metadata.gz: 8d02e29de00d3232f5826704528bddb6e00f8ed7abdca5bccf9fd8ef69a89aa659e5707fe376f656f2ac78e1b6ae766428d6987e3fdb5e4a9d5ba98d1561700b
7
- data.tar.gz: f0962e044936a8e633a78bc2cfc307efe6a885ae42b1b75e2d490c8045546436655a5f82e7505f03e3e5ec924371c6db1dbfb7fb3c5443839d565bbaf7966cc8
6
+ metadata.gz: e3f12fd2df17e7b2f6b0c2f805497dd30ce031299af3eadc1ed38ee8ef0fd1819791d5c1d2673200cfd5adc9e50ee271339978f1c7d704f3160e99a7e0a16f4e
7
+ data.tar.gz: 243fa3411c03815f237cf606d4882ac34bf993897d5ce71815873b85af43fa8c842eb392a5c0661b4e30683b87afd76f7c067d86239284209715d3e4093f9ac6
@@ -5,4 +5,5 @@
5
5
 
6
6
  # For running tests
7
7
  TEST_CLIENT_ID=your_sandbox_client_id
8
- TEST_CLIENT_SECRET=your_sandbox_client_secret
8
+ TEST_CLIENT_SECRET=your_sandbox_client_secret
9
+
data/.gitignore CHANGED
File without changes
data/Gemfile CHANGED
File without changes
data/LICENSE CHANGED
File without changes
data/README.md CHANGED
File without changes
data/Rakefile CHANGED
File without changes
@@ -12,6 +12,7 @@ require 'synapse_pay_rest/api/institutions'
12
12
  require 'synapse_pay_rest/api/client'
13
13
  require 'synapse_pay_rest/api/atms'
14
14
  require 'synapse_pay_rest/api/crypto_quotes'
15
+ require 'synapse_pay_rest/api/statements'
15
16
 
16
17
  # general library classes
17
18
  require 'synapse_pay_rest/error'
@@ -88,6 +89,8 @@ require 'synapse_pay_rest/models/atm/atm'
88
89
 
89
90
  require 'synapse_pay_rest/models/crypto_quote/crypto_quote'
90
91
 
92
+ require 'synapse_pay_rest/models/statement/statement'
93
+
91
94
 
92
95
  # Namespace for all SynapsePayRest classes and modules
93
96
  module SynapsePayRest
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,41 @@
1
+ module SynapsePayRest
2
+ # Wrapper class for /client endpoint
3
+ class Statements
4
+
5
+ # Valid optional args for #get
6
+ # @todo Should refactor this to HTTPClient
7
+ VALID_QUERY_PARAMS = [:page, :per_page].freeze
8
+
9
+ # @!attribute [rw] client
10
+ # @return [SynapsePayRest::HTTPClient]
11
+ attr_accessor :client
12
+
13
+ # @param client [SynapsePayRest::HTTPClient]
14
+ def initialize(client)
15
+ @client = client
16
+ end
17
+
18
+ # Sends a GET request /node or /user statments endpoint to retrieve statements, and returns the
19
+ # response.
20
+ #
21
+ # @param user_id [String]
22
+ # @param node_id [String] optional
23
+ #
24
+ # @raise [SynapsePayRest::Error] may return subclasses of error based on
25
+ # HTTP response from API
26
+ #
27
+ # @return [Hash] API response
28
+ def get(user_id:, node_id: nil, **options)
29
+ params = VALID_QUERY_PARAMS.map do |p|
30
+ options[p] ? "#{p}=#{options[p]}" : nil
31
+ end.compact
32
+
33
+ path = "/users/#{user_id}"
34
+ path += "/nodes/#{node_id}" if node_id
35
+ path += "/statements"
36
+ path += '?' + params.join('&') if params.any?
37
+ client.get(path)
38
+ end
39
+
40
+ end
41
+ end
File without changes
File without changes
File without changes
File without changes
@@ -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, :atms, :crypto_quotes
17
+ :client_endpoint, :atms, :crypto_quotes, :statements
18
18
 
19
19
  # Alias for #transactions (legacy name)
20
20
  alias_method :trans, :transactions
@@ -51,6 +51,7 @@ module SynapsePayRest
51
51
  @client_endpoint = ClientEndpoint.new @http_client
52
52
  @atms = Atms.new @http_client
53
53
  @crypto_quotes = CryptoQuotes.new @http_client
54
+ @statements = Statements.new @http_client
54
55
  end
55
56
 
56
57
 
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,80 @@
1
+ module SynapsePayRest
2
+ # Represents a statement record and holds methods for getting statements
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 Statement
7
+ attr_reader :client, :id, :date_end, :date_start, :csv_url, :pdf_url, :user, :node
8
+
9
+ class << self
10
+ # Creates a statements instance from a response hash.
11
+ # @note Shouldn't need to call this directly.
12
+ def from_response(client, response)
13
+ args = {
14
+ client: client,
15
+ id: response['_id'],
16
+ date_end: response['date_end'],
17
+ date_start: response['date_start'],
18
+ csv_url: response['urls']['csv'],
19
+ pdf_url: response['urls']['pdf']
20
+ }
21
+ self.new(args)
22
+ end
23
+
24
+ # Gets statement by node or user.
25
+ # @param client [SynapsePayRest::Client]
26
+ # @param user [SynapsePayRest::User]
27
+ #
28
+ # @raise [SynapsePayRest::Error]
29
+ #
30
+ # @return [SynapsePayRest::Statement] new instance corresponding to same API record
31
+ def by_user(client:, user:, page: nil, per_page: nil)
32
+ raise ArgumentError, 'client must be a SynapsePayRest::Client' unless client.is_a?(Client)
33
+ raise ArgumentError, 'id must be a SynapsePayRest::User' unless user.is_a?(User)
34
+
35
+ [page, per_page].each do |arg|
36
+ if arg && (!arg.is_a?(Integer) || arg < 1)
37
+ raise ArgumentError, "#{arg} must be nil or an Integer >= 1"
38
+ end
39
+ end
40
+
41
+ response = client.statements.get(user_id: user.id, page: page, per_page: per_page)
42
+ multiple_from_response(client, response['statements'])
43
+ end
44
+
45
+ # Gets statement by node or user.
46
+ # @param client [SynapsePayRest::Client]
47
+ # @param user [SynapsePayRest::Node]
48
+ #
49
+ # @raise [SynapsePayRest::Error]
50
+ #
51
+ # @return [SynapsePayRest::Statement] new instance corresponding to same API record
52
+ def by_node(client:, node:, page: nil, per_page: nil)
53
+ raise ArgumentError, 'client must be a SynapsePayRest::Client' unless client.is_a?(Client)
54
+ raise ArgumentError, 'node must be a SynapsePayRest::Node' unless node.is_a?(BaseNode)
55
+
56
+ [page, per_page].each do |arg|
57
+ if arg && (!arg.is_a?(Integer) || arg < 1)
58
+ raise ArgumentError, "#{arg} must be nil or an Integer >= 1"
59
+ end
60
+ end
61
+
62
+ response = client.statements.get(user_id: node.user.id, node_id: node.id, page: page, per_page: per_page)
63
+ multiple_from_response(client, response['statements'])
64
+ end
65
+
66
+ def multiple_from_response(client, response)
67
+ return [] if response.empty?
68
+ response.map { |statement_data| from_response(client, statement_data) }
69
+ end
70
+
71
+ end
72
+
73
+ # @note Do not call directly. Use Statement.get or 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
+ end
80
+ end
File without changes
@@ -1,4 +1,4 @@
1
1
  module SynapsePayRest
2
2
  # Gem version
3
- VERSION = '3.4.1'.freeze
3
+ VERSION = '3.4.2'.freeze
4
4
  end
data/samples.md CHANGED
@@ -1407,3 +1407,29 @@ atm_args = {
1407
1407
  atms = SynapsePayRest::Atm.locate(atm_args)
1408
1408
  # => [#<SynapsePayRest::Atm>, #<SynapsePayRest::Atm>, ...]
1409
1409
  ```
1410
+
1411
+ ## Get Statement Method
1412
+
1413
+ #### Get Statement By User or Node
1414
+
1415
+ ##### a) Statement#by_user
1416
+
1417
+ ```ruby
1418
+ user = SynapsePayRest::User.find(client: client, id: '5b5f95dc83403300fbc76')
1419
+
1420
+ statements = SynapsePayRest::Statement.by_user(client: client, user: user)
1421
+ # => [#<SynapsePayRest::Statement>, #<SynapsePayRest::Statement>, ...]
1422
+ ```
1423
+
1424
+ ##### b) Statement#by_node
1425
+
1426
+ ```ruby
1427
+ user = SynapsePayRest::User.find(client: client, id: '5b5f95dc83403300fbc76')
1428
+
1429
+ node = user.find_node(id: '5b634a241jngjnei04c7b39b1')
1430
+
1431
+
1432
+
1433
+ statements = SynapsePayRest::Statement.by_node(client: client, node: node)
1434
+ # => [#<SynapsePayRest::Statement>, #<SynapsePayRest::Statement>, ...]
1435
+ ```
File without changes
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.4.1
4
+ version: 3.4.2
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-08-21 00:00:00.000000000 Z
12
+ date: 2018-09-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
@@ -156,6 +156,7 @@ files:
156
156
  - lib/synapse_pay_rest/api/crypto_quotes.rb
157
157
  - lib/synapse_pay_rest/api/institutions.rb
158
158
  - lib/synapse_pay_rest/api/nodes.rb
159
+ - lib/synapse_pay_rest/api/statements.rb
159
160
  - lib/synapse_pay_rest/api/subnets.rb
160
161
  - lib/synapse_pay_rest/api/subscriptions.rb
161
162
  - lib/synapse_pay_rest/api/transactions.rb
@@ -191,6 +192,7 @@ files:
191
192
  - lib/synapse_pay_rest/models/node/unverified_node.rb
192
193
  - lib/synapse_pay_rest/models/node/wire_int_node.rb
193
194
  - lib/synapse_pay_rest/models/node/wire_us_node.rb
195
+ - lib/synapse_pay_rest/models/statement/statement.rb
194
196
  - lib/synapse_pay_rest/models/subnet/subnet.rb
195
197
  - lib/synapse_pay_rest/models/subscription/subscription.rb
196
198
  - lib/synapse_pay_rest/models/transaction/transaction.rb
@@ -224,7 +226,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
224
226
  version: '0'
225
227
  requirements: []
226
228
  rubyforge_project:
227
- rubygems_version: 2.5.1
229
+ rubygems_version: 2.7.6
228
230
  signing_key:
229
231
  specification_version: 4
230
232
  summary: SynapsePay v3 Rest Native API Library