public function synchronise(Subscription $subscription)
    {
        try {
            $contact = [
                'update' => true,
                'purge' => false,
                'contact' => [
                    'externalId' => $subscription->getId(),
                    'properties' => [
                        'email' => $subscription->getEmail(),
                    ],
                ],
            ];

            $response = $this->post('contact', $contact);

            if ($response->getStatusCode() == '204') { //Contact added successfully status code
                $this->subscriptionManager->updateStatus($subscription, Subscription::STATUS_SYNCED);

                return true;
            } else {
                $this->subscriptionManager->updateStatus($subscription, Subscription::STATUS_FAILED);

                return false;
            }
        } catch (\Exception $e) {
            $this->subscriptionManager->updateStatus($subscription, Subscription::STATUS_FAILED);

            return true;
        }
    }
public function synchronise(Subscription $subscription)
    {
        try {
            $contact = [
                'update' => true,
                'purge' => false,
                'contact' => [
                    'externalId' => $subscription->getId(),
                    'properties' => [
                        'email' => $subscription->getEmail(),
                    ],
                ],
            ];

            $response = $this->post('contact', $contact);

            if ($response->getStatusCode() == '204') { //Contact added successfully status code
                $this->subscriptionManager->updateStatus($subscription, Subscription::STATUS_SYNCED);

                return true;
            } else {
                $this->subscriptionManager->updateStatus($subscription, Subscription::STATUS_FAILED);

                return false;
            }
        } catch (\Exception $e) {
            $this->subscriptionManager->updateStatus($subscription, Subscription::STATUS_FAILED);

            return true;
        }
    }
public function synchronise ( Subscription $ subscription ) { try { $ contact = [ 'update' => true , 'purge' => false , 'contact' => [ 'externalId' => $ subscription -> getId ( ) , 'properties' => [ 'email' => $ subscription -> getEmail ( ) , ] , ] , ] ; $ response = $ this -> post ( 'contact' , $ contact ) ; if ( $ response -> getStatusCode ( ) == '204' ) { //Contact added successfully status code $ this -> subscriptionManager -> updateStatus ( $ subscription , Subscription :: STATUS_SYNCED ) ; return true ; } else { $ this -> subscriptionManager -> updateStatus ( $ subscription , Subscription :: STATUS_FAILED ) ; return false ; } } catch ( \ Exception $ e ) { $ this -> subscriptionManager -> updateStatus ( $ subscription , Subscription :: STATUS_FAILED ) ; return true ; } }
Synchronize a subscription

@param Subscription $subscription
@return bool
Synchronize a subscription