import { Observable } from 'rxjs/Observable' ; import { SDKFetch } from '../../SDKFetch' ; import { MessageSchema } from '../../schemas/Message' ; import { MessageId } from 'teambition-types' ; export function getMessageFetch ( this , messageId , query ? ) { return this . get < MessageSchema > ( `v2/messages/${ messageId }` , query ) ; } export function getMessagesFetch ( this , query ? ) { return this . get < MessageSchema [ ] > ( `v2/messages` , query ) ; } export namespace MarkRead { export type PayloadForOne = { isRead : boolean ; unreadActivitiesCount : number ; } ; export type PayloadForAll = { type : string ; } ; } export function markMessageRead ( this , messageId , body ) { return this . put < MarkRead . PayloadForOne > ( `messages/${ messageId }` , body ) ; } export function markAllMessagesRead ( this , body ) { return this . put < void > ( `messages/markallread` , body ) ; } export function deleteMessageFetch ( this , _MessageId ) { return this . delete ( `messages/${ _MessageId }` ) ; } export function deleteReadedMessagesFetch ( this ) { return this . delete ( 'messages?type=private' ) ; } SDKFetch . prototype . getMessage = getMessageFetch ; SDKFetch . prototype . getMessages = getMessagesFetch ; SDKFetch . prototype . markMessageRead = markMessageRead ; SDKFetch . prototype . markAllMessagesRead = markAllMessagesRead ; SDKFetch . prototype . deleteMessage = deleteMessageFetch ; SDKFetch . prototype . deleteReadedMessages = deleteReadedMessagesFetch ; declare module '../../SDKFetch' { interface SDKFetch { getMessage : typeof getMessageFetch ; getMessages : typeof getMessagesFetch ; markMessageRead : typeof markMessageRead ; markAllMessagesRead : typeof markAllMessagesRead ; deleteMessage : typeof deleteMessageFetch ; deleteReadedMessages : typeof deleteReadedMessagesFetch ; } }