Sha256: edef5d7436bb53892149842c6e438bf155bd7b150e40a3c7d2b2a24a4bd82808

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

class G5Updatable::ClientFeedProcessor
  attr_reader :client_uid

  def initialize(client_uid=nil)
    @client_uid = client_uid || ENV["CLIENT_UID"]
    raise "A client_uid must be either passed in or configured!" if @client_uid.blank?
  end

  class << self
    def load_all_clients(clients_url)
      client_uids = G5FoundationClient::Client.all_client_uids clients_url
      client_uids.collect { |client_uid| new(client_uid).work }
    end
  end

  def work
    client = update_client
    update_locations
    update_integrations

    client
  end

  private

  def update_integrations
    foundation_client.locations.each do |location|
      G5Updatable::IntegrationSettingsUpdater.new(location.integration_settings).update
    end
  end

  def update_locations
    G5Updatable::LocationsUpdater.new(foundation_client.locations).update
  end

  def update_client
    G5Updatable::ClientUpdater.new(foundation_client).update
  end

  def foundation_client
    @foundation_client ||= G5FoundationClient::Client.find_by_uid(@client_uid)
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
g5_updatable-0.3.1 lib/g5_updatable/client_feed_processor.rb