import { AxiosInstance } from 'axios' ; import { Count , GroupData , GroupQuery , GroupSearchQuery , GroupSubscriberData , GroupSubscriberFlags , SubscriberGroupQuery , SubscriberType , } from '../@types' ; export interface MailerLiteGroup { id : number ; name : string ; total : number ; active : number ; unsubscribed : number ; bounced : number ; unconfirmed : number ; junk : number ; sent : number ; opened : number ; clicked : number ; parentId : number ; dateCreated : string ; dateUpdated : string ; } export default function ( client ) { return { async getGroups ( params = { } ) { return await client . get ( 'groups' , { params } ) ; } , async searchGroups ( groupName ) { return await client . post ( 'groups/search' , { group_name : groupName } ) ; } , async getGroup ( groupId ) { return await client . get ( `groups/${ groupId }` ) ; } , async createGroup ( group ) { return await client . post ( 'groups' , group ) ; } , async updateGroup ( groupId , groupUpdate ) { return await client . put ( `groups/${ groupId }` , groupUpdate ) ; } , async removeGroup ( groupId ) { return await client . delete ( `groups/${ groupId }` ) ; } , async addSubscriberToGroup ( groupId , subscriber ) { return await client . post ( `groups/${ groupId }/subscribers` , subscriber ) ; } , async addSubscribersToGroup ( groupId , subscribers , importOptions = { } ) { return await client . post ( `groups/${ groupId }/subscribers/import` , { subscribers , ... importOptions , } ) ; } , async getSubscribersGroupImport ( groupId , importId ) { return await client . get ( `groups/${ groupId }/subscribers/import/${ importId }` ) ; } , async getGroupSubscriber ( groupId , subscriberId ) { return await client . get ( `groups/${ groupId }/subscribers/${ subscriberId }` ) ; } , async getGroupSubscribers ( groupId , params = { } ) { return await client . get ( `groups/${ groupId }/subscribers` , { params } ) ; } , async getGroupSubscriberCount ( groupId ) { const { count } = await client . get ( `groups/${ groupId }/subscribers/count` ) ; return count ; } , async getGroupSubscribersByType ( groupId , subscriberType , params = { } ) { return await client . get ( `groups/${ groupId }/subscribers/${ subscriberType }` , { params } ) ; } , async getGroupSubscribersCountByType ( groupId , subscriberType ) { const { count } = await client . get ( `groups/${ groupId }/subscribers/${ subscriberType }/count` ) ; return count ; } , async removeGroupSubscriber ( groupId , subscriberIdentifier ) { return await client . delete ( `groups/${ groupId }/subscribers/${ subscriberIdentifier }` ) ; } , } ; }