-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(memberships): add memberships adapter interface
- Loading branch information
1 parent
fa3963f
commit 7141890
Showing
3 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import {throwError} from 'rxjs'; | ||
|
||
import WebexAdapter from './WebexAdapter'; | ||
|
||
/** | ||
* A Membership object with details about the member. | ||
* | ||
* @typedef {Object} Membership | ||
* @property {string} ID The member identifier. | ||
* @property {string} destinationID ID of the destination for which to get members. | ||
* @property {string} destinationType type of the membership destination. | ||
* @property {Array.<Object>} members An array of members information. | ||
*/ | ||
|
||
/** | ||
* Enum for types of destinations. | ||
* | ||
* @readonly | ||
* @enum {string} | ||
*/ | ||
export const DestinationType = { | ||
ROOM: 'room', | ||
MEETING: 'meeting', | ||
}; | ||
|
||
/** | ||
* This is a base class that defines the interface that maps membership data. | ||
* Developers that want to extend `MembershipsAdapter` must implement all of its methods, | ||
* adhering to the exact parameters and structure of the returned objects. | ||
* | ||
* @interface | ||
*/ | ||
export default class MembershipsAdapter extends WebexAdapter { | ||
/** | ||
* Returns an observable that emits a Membership object. | ||
* Whenever there is an update to the membership, the observable | ||
* will emit a new updated Membership object, if datasource permits. | ||
* | ||
* @param {string} destinationID ID of the destination for which to get members. | ||
* @param {DestinationType} destinationType type of the membership destination. | ||
* @returns {Observable.<Membership>} | ||
* @memberof MembershipAdapter | ||
*/ | ||
getMembersFromDestination(destinationID, destinationType) { | ||
return throwError( | ||
new Error('getMembersFromDestination(destinationID, destinationType) must be defined in MembershipsAdapter') | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import {isObservable} from 'rxjs'; | ||
|
||
import MembershipsAdapter from './MembershipsAdapter'; | ||
|
||
describe('Memberships Adapter Interface', () => { | ||
let membershipsAdapter; | ||
|
||
beforeEach(() => { | ||
membershipsAdapter = new MembershipsAdapter(); | ||
}); | ||
|
||
afterEach(() => { | ||
membershipsAdapter = null; | ||
}); | ||
|
||
describe('getMembership()', () => { | ||
test('returns an observable', () => { | ||
expect(isObservable(membershipsAdapter.getMembersFromDestination())).toBeTruthy(); | ||
}); | ||
|
||
test('errors because it needs to be defined', (done) => { | ||
membershipsAdapter.getMembersFromDestination('meetingID', 'meetingType').subscribe( | ||
() => {}, | ||
(error) => { | ||
expect(error.message).toBe( | ||
'getMembersFromDestination(destinationID, destinationType) must be defined in MembershipsAdapter' | ||
); | ||
done(); | ||
} | ||
); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
export {default as WebexAdapter} from './WebexAdapter'; | ||
export {default as ActivitiesAdapter} from './ActivitiesAdapter'; | ||
export {default as MeetingsAdapter, MeetingControlState} from './MeetingsAdapter'; | ||
export {default as MembershipsAdapter, DestinationType} from './MembershipsAdapter'; | ||
export {default as PeopleAdapter, PersonStatus} from './PeopleAdapter'; | ||
export {default as RoomsAdapter, RoomType} from './RoomsAdapter'; |