-
Notifications
You must be signed in to change notification settings - Fork 6
Person
Fetches all records for a given model, returns a CiscoSpark::Collection
Accepts any parameters that the API allows.
room = CiscoSpark::Room.fetch_all(max: 5, ...)
=> #<CiscoSpark::Collection>
Fetches a single record for the given resource ID, returns an instance Accepts any parameters that the API allows.
room = CiscoSpark::Room.fetch('Y2lzY...', options_hash)
=> #<CiscoSpark::Room>
Creates a resource with given attributes, returns an instance Accepts any parameters that the API allows.
room = CiscoSpark::Room.create(email: '[email protected]')
=> #<CiscoSpark::Room>
Updates a resource with given attributes, returns an instance Accepts any parameters that the API allows.
room = CiscoSpark::Room.update('Y2lzY...', name: 'Ruby room')
=> #<CiscoSpark::Room>
Destroys a resource with the given ID, returns an boolean to indicate success Accepts any parameters that the API allows.
room = CiscoSpark::Room.destroy('Y2lzY...')
=> true
Parses a valid JSON string or a ruby hash/array into a collection of models. This is useful for processing data received from a webhook etc.
json_string = '{"items": [{ "id": "Y2lzY...", "key": "value" }]}'
people = CiscoSpark::Room.parse_collection(json_string)
=> #<CiscoSpark::Collection>
Parses a valid JSON string or a ruby hash/array into a model. This is useful for processing data received from a webhook etc.
json_string = '{ "id": "Y2lzY...", "key": "value" }'
room = CiscoSpark::Room.parse(json_string)
=> #<CiscoSpark::Room>
Get all memberships for room
room = CiscoSpark::Room.new(id: 'Y3de...')
room.memberships(max: 5)
=> #<CiscoSpark::Collection>
Get all messages for room
room = CiscoSpark::Room.new(id: 'Y3de...')
room.messages(max: 5)
=> #<CiscoSpark::Collection>
Get all message before a given message, accepts a CiscoSpark::Message
or a message ID
room.all_before_message('Y3de...', max: 5)
=> #<CiscoSpark::Collection>
Get all message before a given time, accepts a DateTime
or a string
room.messages_before(DateTime.now, max: 5)
=> #<CiscoSpark::Collection>
Send a message to the room
message = CiscoSpark::Message.new(text: 'Hello Spark')
room = CiscoSpark::Room.new(id: 'Y3de...')
room.send_message(message)
=> #<CiscoSpark::Message>
Creates a new membership to the room for a given person
person = CiscoSpark::Person.fetch('Y2lz')
room = CiscoSpark::Room.new(id: 'Y3de...')
room.add_person(person)
=> #<CiscoSpark::Membership>
You can call persist on an instance to create or update it through the API.
If the instance already has an ID a PUT
will be made to update the mutable attributes
room = CiscoSpark::Room.new(name: 'Ruby room')
room.persist
=> #<CiscoSpark::Room>
You can call fetch on an instance fetch or refresh an instance
room = CiscoSpark::Room.new(id: 'Y2lzY...')
room.fetch
=> #<CiscoSpark::Room>
You can call destroy on an instance to destroy it through the API
room = CiscoSpark::Room.new(id: 'Y2lzY...')
room.destroy
=> true
Convert a model instance into a hash
room = CiscoSpark::Room.fetch('Y2lzY...')
room.to_h
=> Hash