Class: ACube::Schema::Header::Customer

Inherits:
Object
  • Object
show all
Defined in:
lib/acube/schema/header/customer.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#addressObject

Returns the value of attribute address.



8
9
10
# File 'lib/acube/schema/header/customer.rb', line 8

def address
  @address
end

#cityObject

Returns the value of attribute city.



8
9
10
# File 'lib/acube/schema/header/customer.rb', line 8

def city
  @city
end

#civic_numberObject

Returns the value of attribute civic_number.



8
9
10
# File 'lib/acube/schema/header/customer.rb', line 8

def civic_number
  @civic_number
end

#denominationObject

Returns the value of attribute denomination.



7
8
9
# File 'lib/acube/schema/header/customer.rb', line 7

def denomination
  @denomination
end

#eori_codeObject

Returns the value of attribute eori_code.



7
8
9
# File 'lib/acube/schema/header/customer.rb', line 7

def eori_code
  @eori_code
end

#first_nameObject

Returns the value of attribute first_name.



7
8
9
# File 'lib/acube/schema/header/customer.rb', line 7

def first_name
  @first_name
end

#fiscal_codeObject

Returns the value of attribute fiscal_code.



6
7
8
# File 'lib/acube/schema/header/customer.rb', line 6

def fiscal_code
  @fiscal_code
end

#last_nameObject

Returns the value of attribute last_name.



7
8
9
# File 'lib/acube/schema/header/customer.rb', line 7

def last_name
  @last_name
end

#nationObject

Returns the value of attribute nation.



8
9
10
# File 'lib/acube/schema/header/customer.rb', line 8

def nation
  @nation
end

#provinceObject

Returns the value of attribute province.



8
9
10
# File 'lib/acube/schema/header/customer.rb', line 8

def province
  @province
end

#titleObject

Returns the value of attribute title.



7
8
9
# File 'lib/acube/schema/header/customer.rb', line 7

def title
  @title
end

#vat_fiscal_idObject

Returns the value of attribute vat_fiscal_id.



5
6
7
# File 'lib/acube/schema/header/customer.rb', line 5

def vat_fiscal_id
  @vat_fiscal_id
end

#zipObject

Returns the value of attribute zip.



8
9
10
# File 'lib/acube/schema/header/customer.rb', line 8

def zip
  @zip
end

Class Method Details

.from(customer) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/acube/schema/header/customer.rb', line 10

def self.from(customer)
  new.tap do |cust|
    customer.customer_data.each do |key, value|
      value = value.is_a?(Symbol) ? customer.send(value).to_s : value.to_s
      cust.send("#{key}=", value)
    end
  end
end

Instance Method Details

#to_xmlObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/acube/schema/header/customer.rb', line 19

def to_xml
  Nokogiri::XML::Builder.new do |xml|
    xml.CessionarioCommittente {
      xml.DatiAnagrafici {
        xml.CodiceFiscale fiscal_code
        xml.Anagrafica {
          if (first_name && last_name)
            xml.Nome first_name
            xml.Cognome last_name
          else
            xml.Denominazione denomination
          end
          xml.Titolo title if title
          xml.CodEORI eori_code if eori_code
        }
      }
      xml.Sede {
        xml.Indirizzo address
        xml.NumeroCivico civic_number if civic_number
        xml.CAP zip
        xml.Comune city
        xml.Provincia province
        xml.Nazione nation
      }
    }
  end.to_xml(save_with: 2)
end