Class: MovidaEvents::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/movida_events/client.rb

Overview

The interface to the Movida event stream API

Manages authentication and API configuration

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Create a new MovidaEvents::Client

Parameters:

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

    API setup options

Options Hash (options):

  • :username (String)

    The username to authenticate with Required.

  • :password (String)

    The password to authenticate with. Required.

  • :domain (String)

    The API domain to use. Default: 'movida.bebanjo.net'.


17
18
19
20
21
22
23
24
# File 'lib/movida_events/client.rb', line 17

def initialize(options = {})
  @options = default_options.merge(options)
  @auth = Almodovar::DigestAuth.new(
    @options[:realm],
    @options[:username],
    @options[:password]
  )
end

Instance Method Details

#events(params = {}) {|event| ... } ⇒ Enumerator<Almodovar::Resource>

Request a list of events

Parameters:

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

    Request parameters

Options Hash (params):

  • newer_than (String)

    An event ID indicating the position in the event stream where the request starts.

  • event_type (String)

    A comma separated list of event types.

Yields:

  • Each returned event

Yield Parameters:

  • event (Almodovar::Resource)

    The event object

Returns:

  • (Enumerator<Almodovar::Resource>)

    An enumerator over the returned events


36
37
38
39
40
41
# File 'lib/movida_events/client.rb', line 36

def events(params = {}, &block)
  Enumerator.new do |yielder|
    events = events_collection(params)
    events.each { |e| yielder << e }
  end.each(&block)
end