Class: SVBClient::ACHHandler
- Inherits:
-
Object
- Object
- SVBClient::ACHHandler
- Defined in:
- lib/svbclient.rb
Instance Method Summary collapse
- #all ⇒ Object
- #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
Returns a new instance of ACHHandler.
120 121 122 123 |
# File 'lib/svbclient.rb', line 120 def initialize(client) raise 'provide an API client' if client.nil? @client = client end |
Instance Method Details
#all ⇒ Object
135 136 137 |
# File 'lib/svbclient.rb', line 135 def all find end |
#create(ach_data) ⇒ Object
125 126 127 128 |
# File 'lib/svbclient.rb', line 125 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
139 140 141 142 143 144 145 146 147 148 |
# File 'lib/svbclient.rb', line 139 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.join('&')) list = JSON.parse(response.body)["data"] list.map do |ach| SVBClient::ACH.new(@client, ach["id"]) end end |
#get(id) ⇒ Object
130 131 132 133 |
# File 'lib/svbclient.rb', line 130 def get(id) @client.get("/v1/ach/#{id}") SVBClient::ACH.new(@client, id) end |