public function handlerAction(
        Request $request,
        $sourceId = null,
        $main,
        $campaignId = null,
        $object,
        $action
    ) {
        $start = microtime(true);

        // Handle documentation authentication.
        if ($request->get('documentationAuthAttempt')) {
            if (!$sourceId) {
                $sourceId = (int) $request->get('sourceId');
            }

            /** @var \MauticPlugin\MauticContactSourceBundle\Model\Api $ApiModel */
            $ApiModel = $this->get('mautic.contactsource.model.api');
            $ApiModel
                ->setRequest($request)
                ->setSourceId((int) $sourceId)
                ->setCampaignId((int) $campaignId)
                ->handleInputPublic();

            return $this->redirect($this->request->getUri());
        }

        $object = strtolower($object);
        if ('contact' == $object) {
            /** @var \MauticPlugin\MauticContactSourceBundle\Model\Api $ApiModel */
            $ApiModel = $this->get('mautic.contactsource.model.api');
            $ApiModel
                ->setRequest($request)
                ->setSourceId((int) $sourceId)
                ->setCampaignId((int) $campaignId)
                ->validateAndImportContact();

            $result = $ApiModel->getResult();
        } elseif ('contacts' == $object) {
            $result = [
                'errors'     => ['Sorry, the bulk import option is not yet available.'],
                'statusCode' => Codes::HTTP_NOT_IMPLEMENTED,
            ];
        } else {
            $result = [
                'errors'     => ['Sorry, posting a '.$object.' is not yet available. Did you mean "contact"?'],
                'statusCode' => Codes::HTTP_NOT_IMPLEMENTED,
            ];
        }
        $result['time'] = [
            'completed' => new \DateTime(),
            'duration'  => microtime(true) - $start,
        ];
        ksort($result);

        $view = $this->view($result, $result['statusCode'] ? $result['statusCode'] : Codes::HTTP_OK);

        // By default we'll always respond with JSON.
        // @todo - Support any inbound format automatically.
        $view->setFormat('json');

        return $this->handleView($view);
    }
public function handlerAction(
        Request $request,
        $sourceId = null,
        $main,
        $campaignId = null,
        $object,
        $action
    ) {
        $start = microtime(true);

        // Handle documentation authentication.
        if ($request->get('documentationAuthAttempt')) {
            if (!$sourceId) {
                $sourceId = (int) $request->get('sourceId');
            }

            /** @var \MauticPlugin\MauticContactSourceBundle\Model\Api $ApiModel */
            $ApiModel = $this->get('mautic.contactsource.model.api');
            $ApiModel
                ->setRequest($request)
                ->setSourceId((int) $sourceId)
                ->setCampaignId((int) $campaignId)
                ->handleInputPublic();

            return $this->redirect($this->request->getUri());
        }

        $object = strtolower($object);
        if ('contact' == $object) {
            /** @var \MauticPlugin\MauticContactSourceBundle\Model\Api $ApiModel */
            $ApiModel = $this->get('mautic.contactsource.model.api');
            $ApiModel
                ->setRequest($request)
                ->setSourceId((int) $sourceId)
                ->setCampaignId((int) $campaignId)
                ->validateAndImportContact();

            $result = $ApiModel->getResult();
        } elseif ('contacts' == $object) {
            $result = [
                'errors'     => ['Sorry, the bulk import option is not yet available.'],
                'statusCode' => Codes::HTTP_NOT_IMPLEMENTED,
            ];
        } else {
            $result = [
                'errors'     => ['Sorry, posting a '.$object.' is not yet available. Did you mean "contact"?'],
                'statusCode' => Codes::HTTP_NOT_IMPLEMENTED,
            ];
        }
        $result['time'] = [
            'completed' => new \DateTime(),
            'duration'  => microtime(true) - $start,
        ];
        ksort($result);

        $view = $this->view($result, $result['statusCode'] ? $result['statusCode'] : Codes::HTTP_OK);

        // By default we'll always respond with JSON.
        // @todo - Support any inbound format automatically.
        $view->setFormat('json');

        return $this->handleView($view);
    }
public function handlerAction ( Request $ request , $ sourceId = null , $ main , $ campaignId = null , $ object , $ action ) { $ start = microtime ( true ) ; // Handle documentation authentication. if ( $ request -> get ( 'documentationAuthAttempt' ) ) { if ( ! $ sourceId ) { $ sourceId = ( int ) $ request -> get ( 'sourceId' ) ; } /** @var \MauticPlugin\MauticContactSourceBundle\Model\Api $ApiModel */ $ ApiModel = $ this -> get ( 'mautic.contactsource.model.api' ) ; $ ApiModel -> setRequest ( $ request ) -> setSourceId ( ( int ) $ sourceId ) -> setCampaignId ( ( int ) $ campaignId ) -> handleInputPublic ( ) ; return $ this -> redirect ( $ this -> request -> getUri ( ) ) ; } $ object = strtolower ( $ object ) ; if ( 'contact' == $ object ) { /** @var \MauticPlugin\MauticContactSourceBundle\Model\Api $ApiModel */ $ ApiModel = $ this -> get ( 'mautic.contactsource.model.api' ) ; $ ApiModel -> setRequest ( $ request ) -> setSourceId ( ( int ) $ sourceId ) -> setCampaignId ( ( int ) $ campaignId ) -> validateAndImportContact ( ) ; $ result = $ ApiModel -> getResult ( ) ; } elseif ( 'contacts' == $ object ) { $ result = [ 'errors' => [ 'Sorry, the bulk import option is not yet available.' ] , 'statusCode' => Codes :: HTTP_NOT_IMPLEMENTED , ] ; } else { $ result = [ 'errors' => [ 'Sorry, posting a ' . $ object . ' is not yet available. Did you mean "contact"?' ] , 'statusCode' => Codes :: HTTP_NOT_IMPLEMENTED , ] ; } $ result [ 'time' ] = [ 'completed' => new \ DateTime ( ) , 'duration' => microtime ( true ) - $ start , ] ; ksort ( $ result ) ; $ view = $ this -> view ( $ result , $ result [ 'statusCode' ] ? $ result [ 'statusCode' ] : Codes :: HTTP_OK ) ; // By default we'll always respond with JSON. // @todo - Support any inbound format automatically. $ view -> setFormat ( 'json' ) ; return $ this -> handleView ( $ view ) ; }
Primary API endpoint for sources to post contacts.

@param Request $request
@param null    $sourceId
@param         $main
@param null    $campaignId
@param         $object
@param         $action

@return \Symfony\Component\HttpFoundation\RedirectResponse|Response

@throws \Exception
Primary API endpoint for sources to post contacts .