Sha256: bba06911a10dc22666c5772dee917497dc9965ab2010aa929e07133d6ab6fc0b

Contents?: true

Size: 1.05 KB

Versions: 10

Compression:

Stored size: 1.05 KB

Contents

module SalesforceStreamer
  class SalesforceClient
    def initialize(client: Restforce.new)
      @client = client
    end

    def authenticate!
      @client.authenticate!
    end

    def subscribe(*args, &block)
      @client.subscribe(args, &block)
    end

    # Returns nil or an instance of Restforce::SObject
    def find_push_topic_by_name(name)
      query = QUERY.dup.gsub(/\s+/, ' ').gsub('{{NAME}}', name)
      @client.query(query).first
    end

    # Returns true or raises an exception if the upsert fails
    def upsert_push_topic(push_topic)
      @client.upsert!(
        'PushTopic', :Id,
        'Id' => push_topic.id,
        'Name' => push_topic.name,
        'ApiVersion' => push_topic.api_version,
        'Description' => push_topic.description,
        'NotifyForFields' => push_topic.notify_for_fields,
        'Query' => push_topic.query
      )
    end

    QUERY = <<~SOQL.chomp.freeze
      SELECT Id, Name, ApiVersion, Description, NotifyForFields, Query, isActive
      FROM PushTopic
      WHERE Name = '{{NAME}}'
    SOQL
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
salesforce_streamer-2.9.0 lib/salesforce_streamer/salesforce_client.rb
salesforce_streamer-2.8.0 lib/salesforce_streamer/salesforce_client.rb
salesforce_streamer-2.6.0 lib/salesforce_streamer/salesforce_client.rb
salesforce_streamer-2.5.0 lib/salesforce_streamer/salesforce_client.rb
salesforce_streamer-2.4.0 lib/salesforce_streamer/salesforce_client.rb
salesforce_streamer-2.4.0.rc1 lib/salesforce_streamer/salesforce_client.rb
salesforce_streamer-2.3.0 lib/salesforce_streamer/salesforce_client.rb
salesforce_streamer-2.2.0 lib/salesforce_streamer/salesforce_client.rb
salesforce_streamer-2.1.1 lib/salesforce_streamer/salesforce_client.rb
salesforce_streamer-2.1.0 lib/salesforce_streamer/salesforce_client.rb