Class: EMIS::Messages::EdipiOrIcnMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/emis/messages/edipi_or_icn_message.rb

Overview

SOAP XML Message to be sent to EMIS API which contains user identifier data

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_name:, edipi: nil, icn: nil, custom_namespaces: {}) ⇒ EdipiOrIcnMessage

Create a new EdipiOrIcnMessage

Parameters:

  • edipi (String) (defaults to: nil)

    User’s Electronic Data Interchange Personal Identifier

  • icn (String) (defaults to: nil)

    User’s Integration Control Number

  • request_name (String)

    Request name used in XML request body

  • custom_namespaces (Hash) (defaults to: {})

    Namespace for API to be called



21
22
23
24
25
26
27
28
29
30
# File 'lib/emis/messages/edipi_or_icn_message.rb', line 21

def initialize(request_name:, edipi: nil, icn: nil, custom_namespaces: {})
  if (edipi.present? && icn.present?) || (edipi.nil? && icn.nil?)
    raise ArgumentError, 'must include either an EDIPI or ICN, but not both'
  end

  @edipi = edipi
  @icn = icn
  @request_name = request_name
  @custom_namespaces = custom_namespaces
end

Instance Attribute Details

#edipiObject (readonly)

User’s Electronic Data Interchange Personal Identifier



11
12
13
# File 'lib/emis/messages/edipi_or_icn_message.rb', line 11

def edipi
  @edipi
end

#icnObject (readonly)

User’s Integration Control Number



13
14
15
# File 'lib/emis/messages/edipi_or_icn_message.rb', line 13

def icn
  @icn
end

Instance Method Details

#to_xmlString

Creates XML request body

Returns:

  • (String)

    XML request body



34
35
36
37
38
39
40
41
42
43
# File 'lib/emis/messages/edipi_or_icn_message.rb', line 34

def to_xml
  header = build_header
  body = build_body
  envelope = build_envelope
  envelope << header
  envelope << body
  doc = Ox::Document.new(version: '1.0')
  doc << envelope
  Ox.dump(doc)
end