Class: MyTankInfo::TankReconciliationRecordsResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/my_tank_info/resources/tank_reconciliation_records.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:, reconciliation_period:, **params) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/my_tank_info/resources/tank_reconciliation_records.rb', line 5

def list(site_id:, reconciliation_period:, **params)
  response = get_request("api/recon/sites/#{site_id}", params: params)
  TankReconciliationRecordCollection.from_response(
    response,
    reconciliation_period: reconciliation_period
  )
end

#retrieve(site_id:, date:, reconciliation_period:) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/my_tank_info/resources/tank_reconciliation_records.rb', line 13

def retrieve(site_id:, date:, reconciliation_period:)
  date =
    if date.instance_of?(DateTime) ||
        date.instance_of?(Date) ||
        date.instance_of?(Time)
      date.strftime(MYTI_DATE_TIME_FORMAT)
    else
      date
    end

  response = get_request("api/recon/sites/#{site_id}/#{date}")
  TankReconciliationRecordCollection.from_response(
    response,
    reconciliation_period: reconciliation_period
  )
end

#update(site_id:, date:, reconciliation_period:, attributes:) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/my_tank_info/resources/tank_reconciliation_records.rb', line 30

def update(site_id:, date:, reconciliation_period:, attributes:)
  response = put_request("api/recon/sites/#{site_id}/#{date}", body: attributes)

  TankReconciliationRecordCollection.from_response(
    response,
    reconciliation_period: reconciliation_period
  )
end