Sha256: d804982dece7541b1efe27d0079dd0a2e92da3dc453b29a06dcd9142ad39f841

Contents?: true

Size: 1.52 KB

Versions: 1

Compression:

Stored size: 1.52 KB

Contents

require 'jbuilder'

module ADIWG
  module Mdtranslator
    module Writers
      module SbJson
        module Contact
          def self.build(intObj)
            Jbuilder.new do |json|
              if intObj[:internal]
                json.nil!
              else
                type = intObj[:indName].nil? ? 'organization' : 'person'
                json.name intObj[:indName] || intObj[:orgName]
                json.contactType type
                json.email intObj[:address][:eMailList][0] unless intObj[:address].empty?
                json.organization type == 'person' ? intObj[:orgName] : nil
                json.primaryLocation do
                  json.officePhone intObj[:phones].collect { |ph|
                    ph[:phoneNumber] if ph[:phoneServiceType] == 'voice' }.reject(&:nil?).first
                  json.faxPhone intObj[:phones].collect { |ph|
                    ph[:phoneNumber] if ph[:phoneServiceType] == 'fax' }.reject(&:nil?).first
                end
                json.streetAddress do
                  add = intObj[:address]
                  unless[:deliveryPoints].empty?
                    json.line1 add[:deliveryPoints][0]
                    json.line2 add[:deliveryPoints][1]
                  end
                  json.city add[:city]
                  json.state add[:adminArea]
                  json.zip add[:postalCode]
                  json.country add[:country]
                end unless intObj[:address].empty?
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
adiwg-mdtranslator-1.4.0.beta5 lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_contact.rb