Skip to content

Membership

Nick Maher edited this page Sep 26, 2016 · 1 revision

CiscoSpark::Membership

API reference

Class methods

fetch_all

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

membership = CiscoSpark::Membership.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.

membership = CiscoSpark::Membership.fetch('Y2lzY...', options_hash)
=> #<CiscoSpark::Membership>

create

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

membership = CiscoSpark::Membership.create(person_id: 'Y2lzY...', room_id: 'Sd238f...')
=> #<CiscoSpark::Membership>

update

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

membership = CiscoSpark::Membership.update('Y2lzY...', is_moderator: true)
=> #<CiscoSpark::Membership>

destroy

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

CiscoSpark::Membership.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" }]}'
membership = CiscoSpark::Membership.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" }'
membership = CiscoSpark::Membership.parse(json_string)
=> #<CiscoSpark::Membership>

Instance methods

person

Returns the person for this membership

room

Returns the room this membership belongs to

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

membership = CiscoSpark::Membership.new(person_id: 'Y2lzY...', room_id: 'Sd238f...')
membership.persist
=> #<CiscoSpark::Membership>

fetch

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

membership = CiscoSpark::Membership.new(id: 'Y2lzY...')
membership.fetch
=> #<CiscoSpark::Membership>

destroy

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

membership = CiscoSpark::Membership.new(id: 'Y2lzY...')
membership.destroy
=> true

to_h

Convert a model instance into a hash

membership = CiscoSpark::Membership.fetch('Y2lzY...')
membership.to_h
=> Hash

Models

Clone this wiki locally