Endpoint for the mailjet events (webhooks)
https://dev.mailjet.com/guides/#events
https://live-event-dashboard-demo.mailjet.com/
@Route("/endpoint/{token}", name="mailjet_event_endpoint")
@Method({"POST"})
198202
public function indexAction(Request $request, $token)
    {
        // Token validation
        if ($this->getToken() !== $token) {
            throw new BadRequestHttpException('Token mismatch');
        }

        $data = $this->extractData($request);

        if(!$data){
            throw new BadRequestHttpException('Malformatted or missing data');
        }

        if(isset($data['event'])){
            $data = array($data);
        }
        /*
            Please note that the event types in the collection can be mixed.
            We group together all the events of the last second for the same webhook url.
        */
        // NOTE: use a better dispatcher such as rabbitMQ if you have a huge amount of events (sent, open, click can be a lot...)
        $dispatcher = $this->getDispatcher();

        foreach ($data as $key => $callbackData) {
            $type = $callbackData['event'];
            switch ($type) {
                case 'sent':
                    $dispatcher->dispatch(CallbackEvent::EVENT_SENT, new CallbackEvent($callbackData));
                    break;
                case 'open':
                    $dispatcher->dispatch(CallbackEvent::EVENT_OPEN, new CallbackEvent($callbackData));
                    break;
                case 'click':
                    $dispatcher->dispatch(CallbackEvent::EVENT_CLICK, new CallbackEvent($callbackData));
                    break;
                case 'bounce':
                    $dispatcher->dispatch(CallbackEvent::EVENT_BOUNCE, new CallbackEvent($callbackData));
                    break;
                case 'spam':
                    $dispatcher->dispatch(CallbackEvent::EVENT_SPAM, new CallbackEvent($callbackData));
                    break;
                case 'blocked':
                    $dispatcher->dispatch(CallbackEvent::EVENT_BLOCKED, new CallbackEvent($callbackData));
                    break;
                case 'unsub':
                    $dispatcher->dispatch(CallbackEvent::EVENT_UNSUB, new CallbackEvent($callbackData));
                    break;
                default:
                    throw new BadRequestHttpException('Type mismatch');
                    break;
            }
        }

        return $this->prepareResponse(200);
    }
544483
private function parseEndpoint()
    {
        $pieces = explode("//", $this->endpoint);
        $host = end($pieces);

        $host_pieces = explode(".", $host);
        $this->accountId = $host_pieces[0];
        $region_pieces = explode("-internal", $host_pieces[2]);
        $this->region = $region_pieces[0];
    }
511384
protected function _getEndpoint($method, $method_template)
  {
    $url = self::$_endpoints['rest'] . $method . '.json';
    if (substr($method_template, 0, 22) === 'oauth/invalidate_token') {
      $url = self::$_endpoints['rest'] . $method . '.json';
    } elseif (substr($method_template, 0, 5) === 'oauth') {
      $url = self::$_endpoints['oauth'] . $method;
    } elseif ($this->_detectMedia($method_template)) {
      $url = self::$_endpoints['media'] . $method . '.json';
    } elseif ($method_template === 'statuses/oembed') {
      $url = self::$_endpoints['publish'] . 'oembed';
    } elseif ($variant = $this->_detectStreaming($method_template)) {
      $url = self::$_endpoints['streaming'][$variant] . $method . '.json';
    } elseif ($this->_detectBinaryBody($method_template)) {
      $url = self::$_endpoints['ton'] . $method;
    } elseif (substr($method_template, 0, 12) === 'ads/sandbox/') {
      $url = self::$_endpoints['ads']['sandbox'] . substr($method, 12);
    } elseif (substr($method_template, 0, 4) === 'ads/') {
      $url = self::$_endpoints['ads']['production'] . substr($method, 4);
    }
    return $url;
  }
24346
function verifyEndpoint(request, respond)
{
  var challenge;

  if (typeof request.query == 'string')
  {
    request.query = qs.parse(request.query);
  }

  if (typeof request.query == 'object'
    && ((request.query['hub.verify_token'] === this.credentials.secret)
        // for hapi@10 and restify/express with queryParser check for `hub` object
    || (typeof request.query.hub == 'object' && request.query.hub['verify_token'] === this.credentials.secret)
    )
  )
  {
    challenge = request.query['hub.challenge'] || (request.query.hub ? request.query.hub.challenge : null);

    this.logger.debug({message: 'Successfully verified', challenge: challenge});
    respond(challenge);
    return;
  }

  this.logger.error({message: 'Unable to verify endpoint', query: request.query});
  respond(400, 'Error, wrong validation token');
}
528729
public function sendRequest($method, $endPoint, $data = '')
    {
        $data = json_encode($data);

        $headers = [
            'Authorization: Bearer ' . $this->ionicAPIToken,
            'Content-Type: application/json',
            'Content-Length: ' . strlen($data),
        ];

        $curlHandler = curl_init();

        curl_setopt($curlHandler, CURLOPT_CONNECTTIMEOUT, $this->connectTimeout);
        curl_setopt($curlHandler, CURLOPT_TIMEOUT, $this->timeout);
        curl_setopt($curlHandler, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curlHandler, CURLOPT_SSL_VERIFYPEER, $this->sslVerifyPeer);
        curl_setopt($curlHandler, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($curlHandler, CURLOPT_HEADER, false);

        switch ($method) {
            case self::METHOD_POST:
                curl_setopt($curlHandler, CURLOPT_POST, true);
                break;

            case self::METHOD_GET:
            case self::METHOD_DELETE:
            case self::METHOD_PATCH:
                curl_setopt($curlHandler, CURLOPT_CUSTOMREQUEST, $method);
                break;
        }

        if (!empty($data)) {
            curl_setopt($curlHandler, CURLOPT_POSTFIELDS, $data);
        }

        curl_setopt($curlHandler, CURLINFO_HEADER_OUT, true);
        curl_setopt($curlHandler, CURLOPT_URL, self::$ionicBaseURL . $endPoint);

        $response = curl_exec($curlHandler);

        $statusCode = curl_getinfo($curlHandler, CURLINFO_HTTP_CODE);

        curl_close($curlHandler);

        $response = json_decode($response);

        if (!$this->isSuccessResponse($statusCode)) {
            $this->throwRequestException($statusCode, $response);
        }

        // Return response.
        return $response;
    }
753543
public function endpoint(ApiEndpoint $endpoint)
    {
        $this->endpointsByName[$endpoint->getName()] = $endpoint;

        switch ($endpoint->getHttpMethod()) {

            case HttpMethods::GET:

                $this->get($endpoint->getPath(), $endpoint->getHandlerMethod(), $this->createRouteName($endpoint));
                break;

            case HttpMethods::POST:

                $this->post($endpoint->getPath(), $endpoint->getHandlerMethod(), $this->createRouteName($endpoint));
                break;

            case HttpMethods::PUT:

                $this->put($endpoint->getPath(), $endpoint->getHandlerMethod(), $this->createRouteName($endpoint));
                break;

            case HttpMethods::DELETE:

                $this->delete($endpoint->getPath(), $endpoint->getHandlerMethod(), $this->createRouteName($endpoint));
                break;
        }

        return $this;
    }
1352892
public function endpoint()
	{
		/**
		 * @var Processor $processor
		 */

		$type = Type::ENDPOINT;
		$input = $this->getVerifiedInput('endpoint', $type, Input::all());


		$errorMessage = 'Request error';
		$urlBack = '';

		if ($input) {

			$errorMessage = '';
			$urlBack = $input['back'];
			$opType = new Type($type, $input);

			try {
				$opType->validate();
			} catch (ProcessorException $e) {
				$errorMessage = $e->getMessage();
			}

		}

		if ($errorMessage) {
			return Redirect::route('ff-bank-em-error')->with(array(
				'errorMessage' => $errorMessage,
				'errorUrl'     => Views::url($urlBack, array('resultBankEmulatorPayment' => 'error')),
				'errorUrlName' => 'вернуться в магазин',
			));
		}

		$term = Terminal::find($input['term']);
		$paymentParams = $this->getPaymentFields($input);
		Secure::sign($paymentParams, $type, $term->secret);

		$this->layout = View::make('ff-bank-em::layouts.endpoint');

		return $this->layout->nest('content', 'ff-bank-em::demo.endpoint', compact('paymentParams'));

	}
65064
def endpoint(request):
    
    s = getServer(request)

    query = util.normalDict(request.GET or request.POST)

    # First, decode the incoming request into something the OpenID
    # library can use.
    try:
        openid_request = s.decodeRequest(query)
    except ProtocolError, why:
        # This means the incoming request was invalid.
        return direct_to_template(
            request,
            'server/endpoint.html',
            {'error': str(why)})

    # If we did not get a request, display text indicating that this
    # is an endpoint.
    if openid_request is None:
        return direct_to_template(
            request,
            'server/endpoint.html',
            {})

    # We got a request; if the mode is checkid_*, we will handle it by
    # getting feedback from the user or by checking the session.
    if openid_request.mode in ["checkid_immediate", "checkid_setup"]:
        return handleCheckIDRequest(request, openid_request)
    else:
        # We got some other kind of OpenID request, so we let the
        # server handle this.
        openid_response = s.handleRequest(openid_request)
        return displayResponse(request, openid_response)
1194292
public function endpoint_callback( \WP_REST_Request $request ) {
		$data = array_merge( [
			'site_name' => get_bloginfo( 'name' ),
			'site_description' => get_bloginfo( 'description' ),
			'site_icon' => get_site_icon_url(),
			'menus' => Menus::get_all_locations(),
			'widgets' => Widgets::get_all_areas(),
			'gravity_forms' => GravityForms::get_settings(),
		], Acf::get_option_field() );

		return $this->filter_data( $data );
	}
813259
function postSend() {
		$this->mock_sent[] = array(
			'to'      => $this->to,
			'cc'      => $this->cc,
			'bcc'     => $this->bcc,
			'header'  => $this->MIMEHeader . $this->mailHeader,
			'subject' => $this->Subject,
			'body'    => $this->MIMEBody,
		);

		return true;
	}
235010
function makeRequest(){
  output('Sending the request...');
  var options = {
    method: $method.value,
    headers: {
      Accept: document.getElementById('accept').value
    },
    followRedirect: $followRedirect.checked
  };
  if(options.method === 'POST'){
    options.body = $requestBody.value;
  }
  client.request($url.value, options, function(error, response){
    if(error){
      genericError();
    } else {
      displayResponse(response);
      
      if(response.statusCode === 401){
        $authStatus.classList.remove('loggedin');
        $tokenDisplay.value = '';
        
      } else {
        $authStatus.classList.add('loggedin');
        $tokenDisplay.value = 'Bearer ' + client.getAccessToken();
      }
    }
  });
}
627588
public function addEndpoint(Endpoint $newEndpoint)
    {
        if ($this->hasEndpoint((string) $newEndpoint->getUri())) {
            throw new InputException('Endpoint already added');
        }

        // all newly added Endpoints are set to DISABLED, apart from the first one
        $status = $this->getEndpoints()->isEmpty() ? Endpoint::STATUS_ACTIVE : Endpoint::STATUS_DISABLED;
        $newEndpoint->setStatus($status);

        $this->getEndpoints()->add($newEndpoint);
    }
590887
public function post($endpoint, array $parameters = array())
    {
        return $this->execute("POST", sprintf("%s%s", $this->host, $endpoint), $parameters);
    }
802605
protected function post($endpoint, array $params = [], $fileUpload = false)
    {
        if ($fileUpload) {
            $params = ['multipart' => $params];
        } else {

            if (array_key_exists('reply_markup', $params)) {
                $params['reply_markup'] = (string)$params['reply_markup'];
            }

            $params = ['form_params' => $params];
        }

        return $this->sendRequest(
            'POST',
            $endpoint,
            $params
        );
    }
1228430
def postWebhook(self, dev_id, external_id, url, event_types):
        
        path = 'notification/webhook'
        payload = {'device': {'id': dev_id}, 'externalId': external_id,
                   'url': url, 'eventTypes': event_types}
        return self.rachio.post(path, payload)
1028268
public function post($endpoint, array $options = [])
    {
        $jsonValues = [];

        if (isset($options['json'])) {
            $jsonValues = $options['json'];
        }

        return $this->httpClient->request('POST', 'https://api.craftcms.com/v1/'.$endpoint, [
            'auth' => $this->setAuth(),
            'json' => $jsonValues
        ]);
    }
1187238
public function post(
        string $endpoint,
        array $options
    )
    {
        $this->streamBody = $this->client
            ->post($endpoint, $options)
            ->getBody();
    }