public function createMultiple(array $subscribers)
    {
        $defaults = ['language' => 'sv', 'update_on_duplicate' => true, 'tags' => [], 'automation' => false];

        $subscribers = array_merge($defaults, $subscribers);

        foreach ($subscribers['subscribers'] as $subscriber) {
            $this->assertValidSubscriberParams($subscriber);
        }

        $params = [
            'automation' =>  $subscribers['automation'],
            'update_on_duplicate' => $subscribers['update_on_duplicate'],
            'tags' => $subscribers['tags']
        ];

        $params['subscribers'] = array_map(function($subscriber){
            return $this->getSubscriberParams($subscriber);
        }, $subscribers['subscribers']);

        $request = new Request('subscribers');
        $request->setParams($params);

        $response = $this->client->post($request);

        $this->assertSuccessResponse($response);

        return $response->getData();
    }
public function createMultiple(array $subscribers)
    {
        $defaults = ['language' => 'sv', 'update_on_duplicate' => true, 'tags' => [], 'automation' => false];

        $subscribers = array_merge($defaults, $subscribers);

        foreach ($subscribers['subscribers'] as $subscriber) {
            $this->assertValidSubscriberParams($subscriber);
        }

        $params = [
            'automation' =>  $subscribers['automation'],
            'update_on_duplicate' => $subscribers['update_on_duplicate'],
            'tags' => $subscribers['tags']
        ];

        $params['subscribers'] = array_map(function($subscriber){
            return $this->getSubscriberParams($subscriber);
        }, $subscribers['subscribers']);

        $request = new Request('subscribers');
        $request->setParams($params);

        $response = $this->client->post($request);

        $this->assertSuccessResponse($response);

        return $response->getData();
    }
public function createMultiple ( array $ subscribers ) { $ defaults = [ 'language' => 'sv' , 'update_on_duplicate' => true , 'tags' => [ ] , 'automation' => false ] ; $ subscribers = array_merge ( $ defaults , $ subscribers ) ; foreach ( $ subscribers [ 'subscribers' ] as $ subscriber ) { $ this -> assertValidSubscriberParams ( $ subscriber ) ; } $ params = [ 'automation' => $ subscribers [ 'automation' ] , 'update_on_duplicate' => $ subscribers [ 'update_on_duplicate' ] , 'tags' => $ subscribers [ 'tags' ] ] ; $ params [ 'subscribers' ] = array_map ( function ( $ subscriber ) { return $ this -> getSubscriberParams ( $ subscriber ) ; } , $ subscribers [ 'subscribers' ] ) ; $ request = new Request ( 'subscribers' ) ; $ request -> setParams ( $ params ) ; $ response = $ this -> client -> post ( $ request ) ; $ this -> assertSuccessResponse ( $ response ) ; return $ response -> getData ( ) ; }
Create new subscribers

@link https://rule.se/apidoc/#subscribers-create-new-subscriber-post

@param array $subscribers
@return array
@throws \Exception
Create new subscribers