class ShareNotify::NotificationQueryService

Queries the SHARE search api for an existing record. This assumes the class into which this module is included responds to url and that in turn is mapped to the docID of the Share document that was originally uploaded via the SHARE push API.

@see ShareNotify::PushDocument

Attributes

context[R]

Public Class Methods

new(context) click to toggle source
# File lib/share_notify/notification_query_service.rb, line 10
def initialize(context)
  self.context = context
end

Public Instance Methods

share_notified?() click to toggle source
# File lib/share_notify/notification_query_service.rb, line 14
def share_notified?
  response = search("shareProperties.docID:\"#{context.url}\"")
  return if response.status != 200
  return false if response.count < 1
  response.docs.first.doc_id == context.url
end

Private Instance Methods

api() click to toggle source
# File lib/share_notify/notification_query_service.rb, line 27
def api
  ShareNotify::API.new
end
context=(input) click to toggle source
# File lib/share_notify/notification_query_service.rb, line 33
def context=(input)
  raise ShareNotify::InitializationError.new(input, [:url]) unless input.respond_to?(:url)
  @context = input
end