Skip to content
Nick Maher edited this page Sep 26, 2016 · 4 revisions

CiscoSpark::Person

API reference

Class methods

all_by_email

Search all people by email,

people = CiscoSpark::Person.all_by_email('[email protected]', max: 5)
=> #<CiscoSpark::Collection>

all_by_name

Search all people by display name

people = CiscoSpark::Person.all_by_name('Nick', max: 5)
=> #<CiscoSpark::Collection>

fetch_all

Fetches all records for a given model, returns a CiscoSpark::Collection Accepts any parameters that the API allows.

people = CiscoSpark::Person.fetch_all(max: 5)
=> #<CiscoSpark::Collection>

fetch

Fetches a single record for the given resource ID, returns an instance Accepts any parameters that the API allows.

person = CiscoSpark::Person.fetch('Y2lzY...', show_sip_address: true)
=> #<CiscoSpark::Person>

create

Creates a resource with given attributes, returns an instance Accepts any parameters that the API allows.

person = CiscoSpark::Person.create(title: 'Ruby Room')
=> #<CiscoSpark::Person>

update

Updates a resource with given attributes, returns an instance Accepts any parameters that the API allows.

person = CiscoSpark::Person.update('Y2lzY...', email: '[email protected]')
=> #<CiscoSpark::Person>

destroy

Destroys a resource with the given ID, returns an boolean to indicate success Accepts any parameters that the API allows.

room = CiscoSpark::Person.destroy('Y2lzY...')
=> true

parse_collection

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::Person.parse_collection(json_string)
=> #<CiscoSpark::Collection>

parse

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::Person.parse(json_string)
=> #<CiscoSpark::Person>

Instance methods

memberships

Get all memberships for person

person = CiscoSpark::Person.new(id: 'Y2lz...')
person.memberships(max: 5)
=> #<CiscoSpark::Collection>

persist

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

person = CiscoSpark::Person.new(email: '[email protected]')
person.persist
=> #<CiscoSpark::Person>

fetch

You can call fetch on an instance fetch or refresh an instance

person = CiscoSpark::Person.new(id: 'Y2lzY...')
person.fetch
=> #<CiscoSpark::Person>

destroy

You can call destroy on an instance to destroy it through the API

person = CiscoSpark::Person.new(id: 'Y2lzY...')
person.destroy
=> true

to_h

Convert a model instance into a hash

person = CiscoSpark::Person.fetch('Y2lzY...')
person.to_h
=> Hash

Models

Clone this wiki locally