Class: SigepWeb::Models::Sender

Inherits:
Object
  • Object
show all
Defined in:
lib/sigep_web/models/sender.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Sender

Returns a new instance of Sender.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/sigep_web/models/sender.rb', line 6

def initialize(options = {})
  authenticate = SigepWeb.configuration.authenticate

  @card = authenticate.card
  @contract_number = authenticate.contract
  @directorship_number = options[:directorship_number]
  @administrative_code = authenticate.administrative_code
  @name = options[:name]
  @address = options[:address]
  @number = options[:number]
  @complement = options[:complement]
  @neighborhood = options[:neighborhood]
  @zip_code = options[:zip_code]
  @city = options[:city]
  @uf = options[:uf]
  @phone = options[:phone]
  @fax = options[:fax]
  @email = options[:email]
  @payment_form = options[:payment_form]
  @postal_objects = options[:postal_objects]
end

Instance Method Details

#to_xmlObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/sigep_web/models/sender.rb', line 28

def to_xml
  builder = Nokogiri::XML::Builder.new(encoding: 'ISO-8859-1') do |xml|
    xml.correioslog do
      xml.tipo_arquivo 'Postagem'
      xml.versao_arquivo '2.3'
      plp_xml(xml)
      receiver_xml(xml)
      xml.forma_pagamento @payment_form

      XML::PostalObject.new(xml, @postal_objects).build_xml
    end
  end

  builder.to_xml.delete("\n").encode(Encoding::UTF_8)
end