Class: SVBClient::ACHHandler
- Inherits:
-
Object
- Object
- SVBClient::ACHHandler
- Defined in:
- lib/svbclient.rb
Instance Method Summary collapse
- #create(ach_data) ⇒ Object
- #find(status: nil, effective_date: nil) ⇒ Object
- #get(id) ⇒ Object
-
#initialize(client) ⇒ ACHHandler
constructor
A new instance of ACHHandler.
Constructor Details
#initialize(client) ⇒ ACHHandler
95 96 97 98 |
# File 'lib/svbclient.rb', line 95 def initialize(client) raise 'provide an API client' if client.nil? @client = client end |
Instance Method Details
#create(ach_data) ⇒ Object
100 101 102 103 |
# File 'lib/svbclient.rb', line 100 def create(ach_data) response = @client.post('/v1/ach', ach_data) SVBClient::ACH.new(@client, JSON.parse(response.body)["data"]["id"]) end |
#find(status: nil, effective_date: nil) ⇒ Object
110 111 112 113 114 115 116 117 118 119 |
# File 'lib/svbclient.rb', line 110 def find(status: nil, effective_date: nil) query = '' query += "filter%5Bstatus%5D=#{status}" unless status.nil? query += "filter%5Beffective_date%5D=#{effective_date}" unless effective_date.nil? response = @client.get("/v1/ach", query) list = JSON.parse(response.body)["data"] list.map do |ach| SVBClient::ACH.new(@client, ach["id"]) end end |
#get(id) ⇒ Object
105 106 107 108 |
# File 'lib/svbclient.rb', line 105 def get(id) @client.get("/v1/ach/#{id}") SVBClient::ACH.new(@client, id) end |