Sha256: 7f42f6b340606e71527d5a87ef3d97e37c613f4b81e68567dd45745db70d0a97

Contents?: true

Size: 994 Bytes

Versions: 2

Compression:

Stored size: 994 Bytes

Contents

module RockRMS
  class Client
    module Batch
      def list_batches(options = {})
        res = get(batches_path, options)
        Response::Batch.format(res)
      end

      def find_batch(id)
        res = get(batches_path(id))
        Response::Batch.format(res)
      end

      def create_batch(name:, start_time:, end_time:, foreign_key: nil, campus_id: nil)
        options = {
          'Name' => name,
          'BatchStartDateTime' => start_time,
          'CampusId' => campus_id,
          'BatchEndDateTime' => end_time,
          'ForeignKey' => foreign_key
        }

        post(batches_path, options)
      end

      def update_batch(id, options = {})
        options = options.collect { |k, v| [k.to_s, v] }.to_h
        patch(batches_path(id), options)
      end

      def delete_batch(id)
        delete(batches_path(id))
      end

      private

      def batches_path(id = nil)
        id ? "FinancialBatches/#{id}" : 'FinancialBatches'
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rock_rms-3.4.1 lib/rock_rms/resources/batch.rb
rock_rms-3.4.0 lib/rock_rms/resources/batch.rb