Sha256: 658024a776354caffcba36deb1d482938a921b14ba7dd34c78145215375a5bce
Contents?: true
Size: 1.64 KB
Versions: 3
Compression:
Stored size: 1.64 KB
Contents
require "g5_updatable/g5_client" require "g5_updatable/g5_location" require "microformats2" class G5Updatable::FeedMapper def initialize(urn) @urn = urn @feed = Microformats2.parse(client_uid).first if @urn end def client G5Updatable::G5Client.new(client_parameters) if @feed end def locations return [] if @feed.blank? @feed.orgs.map do |location| G5Updatable::G5Location.new(location_parameters(location.format)) end end private def client_uid "#{G5Updatable.feed_endpoint}#{@urn}" if @urn.present? end def client_parameters { name: @feed.name.to_s, vertical: @feed.g5_vertical.to_s, domain: @feed.g5_domain.to_s, type: @feed.g5_domain_type.to_s } end def location_parameters(location) { uid: location.uid.to_s, urn: location.uid.to_s.split("/").last, name: location.name.to_s, domain: location.g5_domain.to_s, street_address: location.adr.try(:format).try(:street_address).to_s, state: location.adr.try(:format).try(:region).to_s, city: location.adr.try(:format).try(:locality).to_s, neighborhood: location.adr.try(:format).try(:g5_neighborhood).to_s, postal_code: location.adr.try(:format).try(:postal_code).to_s, phone_number: location.adr.try(:format).try(:tel).to_s, default_number: location.adr.try(:format).try(:tel).to_s, corporate: location.g5_corporate.to_s, floor_plans: location.g5_floorplan.to_s, primary_amenity: location.g5_aparment_amenity_1.to_s, qualifier: location.g5_aparment_feature_1.to_s, primary_landmark: location.g5_landmark_1.to_s } end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
g5_updatable-0.2.1 | lib/g5_updatable/feed_mapper.rb |
g5_updatable-0.2.0 | lib/g5_updatable/feed_mapper.rb |
g5_updatable-0.1.0 | lib/g5_updatable/feed_mapper.rb |