Class: Amiando::Sync
Overview
The main attributes are events and next_id.
Read through [Amiando::Sync::Event] to know how to understand the information returned.
Defined Under Namespace
Classes: Event
Instance Attribute Summary collapse
-
#events ⇒ Object
Returns the value of attribute events.
-
#next_id ⇒ Object
Returns the value of attribute next_id.
Attributes inherited from Resource
Class Method Summary collapse
-
.find(last_id) ⇒ Amiando::Sync
Get the latest ‘synchronization’ events.
Instance Method Summary collapse
-
#initialize(events, next_id) ⇒ Sync
constructor
A new instance of Sync.
Methods inherited from Resource
#==, #extract_attributes_from, method_missing, #populate, #populate_create
Methods included from Attributes
#[], #id, included, #method_missing, #respond_to?, #type
Methods included from Autorun
Constructor Details
#initialize(events, next_id) ⇒ Sync
Returns a new instance of Sync.
11 12 13 |
# File 'lib/amiando/sync.rb', line 11 def initialize(events, next_id) @events, @next_id = events, next_id end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Amiando::Attributes
Instance Attribute Details
#events ⇒ Object
Returns the value of attribute events.
9 10 11 |
# File 'lib/amiando/sync.rb', line 9 def events @events end |
#next_id ⇒ Object
Returns the value of attribute next_id.
9 10 11 |
# File 'lib/amiando/sync.rb', line 9 def next_id @next_id end |
Class Method Details
.find(last_id) ⇒ Amiando::Sync
Get the latest ‘synchronization’ events. Let’s not forget that in this case an ‘event’ is something that happened. It could be, for instance, that a new ticket was bought, that an event was modified, or similar.
Read the developers.amiando.com/index.php/REST_API_DataSync docs to find out how it really works. Simplifying, you find by the latest id you have, and go through the events returned.
When you find a data synchronization you get everything that happened (events) and the next id you should query for. Next time you should use that id when calling this method.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/amiando/sync.rb', line 32 def self.find(last_id) object = Result.new do |response_body, result| if response_body["success"] events = response_body['events'].map do |event| Sync::Event.new(event) end Sync.new(events, response_body['nextId']) else result.errors = response_body['errors'] false end end get object, "api/sync/#{last_id}" object end |