Module: Einvoice::Utils

Included in:
Neweb::Provider
Defined in:
lib/einvoice/utils.rb

Instance Method Summary collapse

Instance Method Details

#camelize(hash) ⇒ Object



15
16
17
# File 'lib/einvoice/utils.rb', line 15

def camelize(hash)
  hash.deep_transform_keys { |k| k.to_s.camelize }
end

#encode_xml(hash) ⇒ Object



19
20
21
# File 'lib/einvoice/utils.rb', line 19

def encode_xml(hash)
  ::Gyoku.xml(hash, key_converter: :none)
end

#serialize(object) ⇒ Object



5
6
7
# File 'lib/einvoice/utils.rb', line 5

def serialize(object)
  object.serializable_hash(except: [:errors, :validation_context], include: [:invoice_item, :contact, :customer_defined])
end

#wrap(hash) ⇒ Object



9
10
11
12
13
# File 'lib/einvoice/utils.rb', line 9

def wrap(hash)
  { invoice_root:
    { invoice: hash }
  }
end