import copy from 'fast-copy' ; import { freezeSys , toPlainObject } from 'contentful-sdk-core' ; import enhanceWithMethods from '../enhance-with-methods' ; import { wrapCollection } from '../common-utils' ; import { MetaSysProps , DefaultElements , MetaLinkProps , MakeRequest } from '../common-types' ; export type OrganizationMembershipProps = { /**
     * System metadata
     */ sys : MetaSysProps & { user : { sys : MetaLinkProps ; } ; } ; /**
     * Role
     */ role : string ; /**
     * status
     */ status : boolean ; } ; export interface OrganizationMembership extends OrganizationMembershipProps , DefaultElements < OrganizationMembershipProps > { return example update ( ) : Promise < OrganizationMembership > ; example delete ( ) : Promise < void > ; } private function createOrganizationMembershipApi ( makeRequest , organizationId ) { const getParams = ( data ) => ( { organizationMembershipId : data . sys . id , organizationId , } ) ; return { update : function ( ) { const raw = this . toPlainObject ( ) as OrganizationMembershipProps ; return makeRequest ( { entityType : 'OrganizationMembership' , action : 'update' , params : getParams ( raw ) , payload : raw , } ) . then ( ( data ) => wrapOrganizationMembership ( makeRequest , data , organizationId ) ) ; } , delete : function del ( ) { const raw = this . toPlainObject ( ) as OrganizationMembershipProps ; return makeRequest ( { entityType : 'OrganizationMembership' , action : 'delete' , params : getParams ( raw ) , } ) ; } , } ; } private param { function } makeRequest param { Object } data return { OrganizationMembership } export function wrapOrganizationMembership ( makeRequest , data , organizationId ) { const organizationMembership = toPlainObject ( copy ( data ) ) ; const organizationMembershipWithMethods = enhanceWithMethods ( organizationMembership , createOrganizationMembershipApi ( makeRequest , organizationId ) ) ; return freezeSys ( organizationMembershipWithMethods ) ; } private export const wrapOrganizationMembershipCollection = wrapCollection ( wrapOrganizationMembership ) ;