Class: Eet::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(certificate, data) ⇒ Client

Returns a new instance of Client.



5
6
7
8
# File 'lib/eet/client.rb', line 5

def initialize(certificate, data)
  @certificate = certificate
  @data = data
end

Instance Attribute Details

#certificateObject (readonly)

Returns the value of attribute certificate.



3
4
5
# File 'lib/eet/client.rb', line 3

def certificate
  @certificate
end

#dataObject (readonly)

Returns the value of attribute data.



3
4
5
# File 'lib/eet/client.rb', line 3

def data
  @data
end

Instance Method Details

#submit(environment) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/eet/client.rb', line 10

def submit(environment)
  message = Eet::Message.new(data)
  message.pkp = Eet::Utils.create_pkp(message, certificate)
  message.bkp = Eet::Utils.create_bkp(message.pkp)

  signed_message = Eet::Utils.sign(message.to_xml, certificate)

  sender = Eet::Sender.new

  if environment == :playground
    sender.send_to_playground(signed_message)
  elsif environment == :production
    sender.send_to_production(signed_message)
  else
    raise Eet::UnknownEnvironmentError, "Unknown EET environment: #{environment}"
  end
end