Sha256: 2d591c0a4eb4bcbbfd7061ccf20a2c0236360669fe3a998a3bd34267ae85375e

Contents?: true

Size: 1.61 KB

Versions: 4

Compression:

Stored size: 1.61 KB

Contents

module Workarea
  module Listrak
    module Models
      class Address
        attr_reader :workarea_address

        def initialize(workarea_address)
          @workarea_address = workarea_address
        end

        def as_json
          {
            address1: address1,
            address2: address2,
            address3: address3,
            city: city,
            country: country,
            state: state
          }.compact
        end

        # Home address line 1
        #
        # limited to 100 characters
        #
        # @return [String]
        #
        def address1
          workarea_address.street.to_s[0...100]
        end

        # Home address line 2
        #
        # limited to 100 characters
        #
        # @return [String]
        #
        def address2
          workarea_address.street_2.to_s[0..100]
        end

        # Home address line 3
        #
        # limited to 100 characters
        #
        # @return [String]
        #
        def address3
        end

        # Home address city
        #
        # limited to 100 characters
        #
        # @return [String]
        #
        def city
          workarea_address.city.to_s[0...100]
        end

        # Home address country
        #
        # limited to 100 characters
        #
        # @return [String]
        #
        def country
          workarea_address.country.name[0...100]
        end

        # Home address state
        #
        # limited to 100 characters
        #
        # @return [String]
        #
        def state
          workarea_address.region.to_s[0...100]
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
workarea-listrak-5.0.4 app/services/workarea/listrak/models/address.rb
workarea-listrak-5.0.3 app/services/workarea/listrak/models/address.rb
workarea-listrak-5.0.2 app/services/workarea/listrak/models/address.rb
workarea-listrak-5.0.1 app/services/workarea/listrak/models/address.rb