import type { AxiosInstance } from 'contentful-sdk-core' ; import copy from 'fast-copy' ; import { SetOptional } from 'type-fest' ; import { CollectionProp , GetOrganizationParams , GetSpaceParams , GetTeamSpaceMembershipParams , QueryParams , } from '../../../common-types' ; import { CreateTeamSpaceMembershipProps , TeamSpaceMembershipProps , } from '../../../entities/team-space-membership' ; import { RestEndpoint } from '../types' ; import * as raw from './raw' ; const getBaseUrl = ( params ) => `/spaces/${ params . spaceId }/team_space_memberships` ; const getEntityUrl = ( params ) => `${ getBaseUrl ( params ) }/${ params . teamSpaceMembershipId }` ; export const get = ( http , params ) => raw . get < TeamSpaceMembershipProps > ( http , getEntityUrl ( params ) ) ; export const getMany = ( http , params ) => raw . get < CollectionProp < TeamSpaceMembershipProps > > ( http , getBaseUrl ( params ) , { params : params . query , } ) ; export const getForOrganization = ( http , params ) => { return raw . get < TeamSpaceMembershipProps > ( http , `/organizations/${ params . organizationId }/team_space_memberships/${ params . teamSpaceMembershipId }` ) ; } ; export const getManyForOrganization = ( http , params ) => { const query = params . query || { } ; if ( params . teamId ) { query [ 'sys.team.sys.id' ] = params . teamId ; } return raw . get < CollectionProp < TeamSpaceMembershipProps > > ( http , `/organizations/${ params . organizationId }/team_space_memberships` , { params : params . query , } ) ; } ; export const create = ( http , params , rawData , headers ? ) => { return raw . post < TeamSpaceMembershipProps > ( http , getBaseUrl ( params ) , rawData , { headers : { 'x-contentful-team' : params . teamId , ... headers , } , } ) ; } ; export const update = ( http , params , rawData , headers ? ) => { const data = copy ( rawData ) ; delete data . sys ; return raw . put < TeamSpaceMembershipProps > ( http , getEntityUrl ( params ) , data , { headers : { 'X-Contentful-Version' : rawData . sys . version || 0 , 'x-contentful-team' : rawData . sys . team . sys . id , ... headers , } , } ) ; } ; export const del = ( http , params ) => { return raw . del ( http , getEntityUrl ( params ) ) ; } ;