Class: MyTankInfo::TanksResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/my_tank_info/resources/tanks.rb

Instance Attribute Summary

Attributes inherited from Resource

#client

Instance Method Summary collapse

Methods inherited from Resource

#delete_request, #get_request, #initialize, #patch_request, #post_request, #put_request

Constructor Details

This class inherits a constructor from MyTankInfo::Resource

Instance Method Details

#list(site_id: nil) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/my_tank_info/resources/tanks.rb', line 5

def list(site_id: nil)
  response = get_request("api/tanks")

  if site_id.nil?
    Collection.from_response(response, type: Tank)
  else
    Collection.from_response(
      response,
      type: Tank,
      filter_attribute: :site_id,
      filter_value: site_id
    )
  end
end

#retrieve(tank_id:) ⇒ Object



20
21
22
# File 'lib/my_tank_info/resources/tanks.rb', line 20

def retrieve(tank_id:)
  Tank.new get_request("api/tanks/#{tank_id}").body
end