Class: GeoCerts::Event

Inherits:
ApiObject show all
Defined in:
lib/geo_certs/event.rb

Overview

GeoCerts tracks events which occur that are related to your Order(s). This class interfaces with those events to provide collections of all of your events or events against a particular GeoCerts::Order.

Instance Attribute Summary (collapse)

Attributes inherited from ApiObject

#response_parameters

Class Method Summary (collapse)

Methods inherited from ApiObject

#errors, #errors=, #initialize, #warnings, #warnings=

Constructor Details

This class inherits a constructor from GeoCerts::ApiObject

Instance Attribute Details

- (Object) created_at

Returns the value of attribute created_at



10
11
12
# File 'lib/geo_certs/event.rb', line 10

def created_at
  @created_at
end

- (Object) id

Returns the value of attribute id



10
11
12
# File 'lib/geo_certs/event.rb', line 10

def id
  @id
end

- (Object) name

Returns the value of attribute name



10
11
12
# File 'lib/geo_certs/event.rb', line 10

def name
  @name
end

- (Object) order_id

Returns the value of attribute order_id



10
11
12
# File 'lib/geo_certs/event.rb', line 10

def order_id
  @order_id
end

Class Method Details

+ (Object) all(options = {})

Returns all events which occurred within the requested time window. The server defaults to a 15 minute window.

Options

:start_at

The starting DateTime for the date range

:end_at

The ending DateTime for the date range



25
26
27
28
29
# File 'lib/geo_certs/event.rb', line 25

def self.all(options = {})
  prep_date_ranges!(options)
  response = call_api { GeoCerts.api.events(options) }
  build_collection(response) { |response| response[:events][:event] }
end

+ (Object) find(order_id, options = {})

Returns all events which occurred within the requested time window for the requested GeoCerts::Order. The server defaults to a 15 minute window.

Options

:start_at

The starting DateTime for the date range

:end_at

The ending DateTime for the date range

Exceptions

This method will raise GeoCerts exceptions if the requested order_id cannot be found.



44
45
46
47
48
49
50
51
# File 'lib/geo_certs/event.rb', line 44

def self.find(order_id, options = {})
  prep_date_ranges!(options)
  order_id = order_id.id if order_id.kind_of?(GeoCerts::Order)
  options[:order_id]  = order_id
  build_collection(call_api { GeoCerts.api.order_events(options) }) { |response|
    response[:events][:event]
  }
end

+ (Object) find_by_order_id(order_id, options = {})

This method will not raise an exception for a missing order_id in the GeoCerts system. Instead, it will return an empty collection.

See GeoCerts::Event.find for more information.



59
60
61
62
63
# File 'lib/geo_certs/event.rb', line 59

def self.find_by_order_id(order_id, options = {})
  find(order_id, options)
rescue GeoCerts::AllowableExceptionWithResponse
  []
end