Class: MediServ::API::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/mediserv/api/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(clientId, storage) ⇒ Client

  • Args :



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/mediserv/api/client.rb', line 8

def initialize(clientId, storage)
  @storage = storage
  @encoder = MediServ::API::Encoder.new
  @default_header = {
    programm: 'Denteo MediServ Client',
    programm_version: '0.3.0', # TODO: Load from gemspec
    version: 'v2',
    kundennummer: clientId,
    stapelnummer: 0,
  }
end

Instance Method Details

#batch(id, invoices, created_at: DateTime.now) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/mediserv/api/client.rb', line 20

def batch(id, invoices, created_at: DateTime.now)
  b = MediServ::API::Batch.new({
    allgemein: @default_header.merge({
      stapelnummer: id,
    }),
    rechnungen: invoices,
    created_at: created_at,
  })
  @storage.put(id, @encoder.encode(b.to_h))
end