Module: RockRMS::Client::Batch

Included in:
RockRMS::Client
Defined in:
lib/rock_rms/resources/batch.rb

Instance Method Summary collapse

Instance Method Details

#create_batch(name:, start_time:, end_time:, foreign_key: nil, campus_id: nil, status: 1, control_amount: nil, control_count: nil) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/rock_rms/resources/batch.rb', line 14

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

  options['ControlAmount'] = control_amount if control_amount
  options['ControlItemCount'] = control_count if control_count

  post(batches_path, options)
end

#delete_batch(id) ⇒ Object



44
45
46
# File 'lib/rock_rms/resources/batch.rb', line 44

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

#find_batch(id) ⇒ Object



9
10
11
12
# File 'lib/rock_rms/resources/batch.rb', line 9

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

#list_batches(options = {}) ⇒ Object



4
5
6
7
# File 'lib/rock_rms/resources/batch.rb', line 4

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

#update_batch(id, options = {}) ⇒ Object



39
40
41
42
# File 'lib/rock_rms/resources/batch.rb', line 39

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