Module: Unloq::Events

Included in:
Client
Defined in:
lib/unloq/events.rb

Instance Method Summary collapse

Instance Method Details

#create_event(author, verb, recipient, meta = {}) ⇒ Object

Create an event via the Unloq API

Parameters:

  • author (Unloq::Entity)

    Author involved in the event

  • verb (String)

    The verb of the event

  • recipient (Unloq::Entity)

    Recipient involved in the event

  • meta (Hash) (defaults to: {})

    A hash of additional metadata to send with the request



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/unloq/events.rb', line 11

def create_event author, verb, recipient, meta = {}
  validate_author(author)
  validate_recipient(recipient)
 
  body_to_post = {
    author_id: author.id,
    author_type: author.type,
    recipient_id: recipient.id,
    recipient_type: recipient.type,
    verb: verb,
    meta: meta
  }
 
  post('/events', body_to_post)
end

#lookup_event(author, verb, recipient) ⇒ Object

Lookup an event via the Unloq API

Parameters:

  • author (Unloq::Entity)

    Author of the event you want to look up

  • verb (String)

    Verb of the event you want to look up

  • recipient (Unloq::Entity)

    Recipient of the event you want to look up



33
34
35
36
37
38
# File 'lib/unloq/events.rb', line 33

def lookup_event author, verb, recipient
  validate_author(author)
  validate_recipient(recipient)

  get('/events', "/#{author.type}/#{author.id}/#{verb}/#{recipient.type}/#{recipient.id}")
end