import copy from 'fast-copy' ; import { freezeSys , toPlainObject } from 'contentful-sdk-core' ; import enhanceWithMethods from '../enhance-with-methods' ; import { wrapCollection } from '../common-utils' ; import { DefaultElements , MakeRequest , MetaLinkProps , MetaSysProps , QueryOptions , } from '../common-types' ; export interface Options { teamId ? : string ; query ? : QueryOptions ; } export type TeamSpaceMembershipProps = { /**
     * System metadata
     */ sys : MetaSysProps & { team : { sys : MetaLinkProps ; } ; space : { sys : MetaLinkProps ; } ; } ; /**
     * Is admin
     */ admin : boolean ; /**
     * Roles
     */ roles : { sys : MetaLinkProps ; } [ ] ; } ; export type CreateTeamSpaceMembershipProps = Omit < TeamSpaceMembershipProps , 'sys' > ; export interface TeamSpaceMembership extends TeamSpaceMembershipProps , DefaultElements < TeamSpaceMembershipProps > { return example delete ( ) : Promise < void > ; return example update ( ) : Promise < TeamSpaceMembership > ; } private function createTeamSpaceMembershipApi ( makeRequest ) { const getParams = ( data ) => ( { teamSpaceMembershipId : data . sys . id , spaceId : data . sys . space . sys . id , } ) ; return { update : function ( ) { const raw = this . toPlainObject ( ) as TeamSpaceMembershipProps ; return makeRequest ( { entityType : 'TeamSpaceMembership' , action : 'update' , params : getParams ( raw ) , payload : raw , } ) . then ( ( data ) => wrapTeamSpaceMembership ( makeRequest , data ) ) ; } , delete : function del ( ) { const data = this . toPlainObject ( ) as TeamSpaceMembershipProps ; return makeRequest ( { entityType : 'TeamSpaceMembership' , action : 'delete' , params : getParams ( data ) , } ) ; } , } ; } private param makeRequest param data return export function wrapTeamSpaceMembership ( makeRequest , data ) { const teamSpaceMembership = toPlainObject ( copy ( data ) ) ; const teamSpaceMembershipWithMethods = enhanceWithMethods ( teamSpaceMembership , createTeamSpaceMembershipApi ( makeRequest ) ) ; return freezeSys ( teamSpaceMembershipWithMethods ) ; } private export const wrapTeamSpaceMembershipCollection = wrapCollection ( wrapTeamSpaceMembership ) ;