Sha256: a5a0690c4164e79595954b6729526a1f3757f38fc369e348fb2bed64c710cea1

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

module MyTankInfo
  class TankReconciliationRecordsResource < Resource
    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

    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

    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
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
my_tank_info-1.1.1 lib/my_tank_info/resources/tank_reconciliation_records.rb
my_tank_info-1.1.0 lib/my_tank_info/resources/tank_reconciliation_records.rb
my_tank_info-1.0.2 lib/my_tank_info/resources/tank_reconciliation_records.rb