Module: ShelbyArena::Client::Batch

Included in:
ShelbyArena::Client
Defined in:
lib/shelby_arena/resources/batch.rb

Instance Method Summary collapse

Instance Method Details

#create_batch(name:, start_date:, end_date:) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/shelby_arena/resources/batch.rb', line 26

def create_batch(name:, start_date:, end_date:)
  path = 'batch/add'
  body = {
    BatchName: name,
    BatchDate: start_date,
    BatchDateEnd: end_date
  }

  options = {}
  options[:api_sig] = generate_api_sig(path, options)
  json_body = body.to_json

  res = json_post("#{path}?api_session=#{options[:api_session]}&api_sig=#{options[:api_sig]}", json_body)

  res.dig('ModifyResult', 'Link').split('/').last
end

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



43
44
45
46
47
# File 'lib/shelby_arena/resources/batch.rb', line 43

def delete_batch(id, options = {})
  path = "batch/#{id}"
  options[:api_sig] = generate_api_sig(path, options)
  delete(path, options.sort)
end

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



18
19
20
21
22
23
24
# File 'lib/shelby_arena/resources/batch.rb', line 18

def find_batch(id, options = {})
  path = "batch/#{id}"
  options[:api_sig] = generate_api_sig(path, options)

  res = get(path, options.sort)
  Response::Batch.format(res.dig('Batch'))
end

#list_batches(name: nil, start_date: nil, end_date: nil) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/shelby_arena/resources/batch.rb', line 4

def list_batches(name: nil, start_date: nil, end_date: nil)
  path = 'batch/list'
  options = {}

  options[:batchName] = name if name
  options[:startDate] = start_date if start_date
  options[:endDate] = end_date if end_date

  options[:api_sig] = generate_api_sig(path, options)

  res = get(path, options.sort)
  Response::Batch.format_list(res.dig('BatchListResult', 'Batches', 'Batch'))
end