Class: SVBClient::WireHandler
- Inherits:
-
Object
- Object
- SVBClient::WireHandler
- Defined in:
- lib/svbclient.rb
Instance Method Summary collapse
- #all ⇒ Object
- #create(wire_data) ⇒ Object
- #find(status: nil, effective_date_start: nil, effective_date_end: nil) ⇒ Object
- #get(id) ⇒ Object
-
#initialize(client) ⇒ WireHandler
constructor
A new instance of WireHandler.
Constructor Details
#initialize(client) ⇒ WireHandler
Returns a new instance of WireHandler.
207 208 209 210 |
# File 'lib/svbclient.rb', line 207 def initialize(client) raise 'provide an API client' if client.nil? @client = client end |
Instance Method Details
#all ⇒ Object
222 223 224 |
# File 'lib/svbclient.rb', line 222 def all find end |
#create(wire_data) ⇒ Object
212 213 214 215 |
# File 'lib/svbclient.rb', line 212 def create(wire_data) response = @client.post('/v1/wire', wire_data) SVBClient::Wire.new(@client, JSON.parse(response.body)["data"]["id"]) end |
#find(status: nil, effective_date_start: nil, effective_date_end: nil) ⇒ Object
226 227 228 229 230 231 232 233 234 235 236 |
# File 'lib/svbclient.rb', line 226 def find(status: nil, effective_date_start: nil, effective_date_end: nil) query = [] query << "filter%5Bstatus%5D=#{status}" unless status.nil? query << "filter%5Beffective_date_start%5D=#{effective_date_start}" unless effective_date_start.nil? query << "filter%5Beffective_date_end%5D=#{effective_date_end}" unless effective_date_end.nil? response = @client.get("/v1/wire", query.join('&')) list = JSON.parse(response.body)["data"] list.map do |wire| SVBClient::Wire.new(@client, wire["id"]) end end |
#get(id) ⇒ Object
217 218 219 220 |
# File 'lib/svbclient.rb', line 217 def get(id) @client.get("/v1/wire/#{id}") SVBClient::Wire.new(@client, id) end |