Create a Push Notification.

Used by "sendNotification" and "sendNotificationToAll".

@private
@return object $response
558606
private function create()
    {
        $response = $this->sendRequest(
            self::METHOD_POST,
            self::$endPoints['create'],
            $this->requestData
        );
        $this->resetRequestData();
        return $response;
    }
80285
def deliver
      return self if @_push_was_called

      @_push_was_called = true

      apn = APNCertificate.instance
      @_notifications.each do |notification|
        apn.push(notification)
      end
    end
1209030
public function copyEventsAndNotifications()
    {
        // copy EVENTS
        $this->copyFilesFromSource($this->appPath . 'Events', app_path('Events'));

        // copy LISTENERS
        $this->copyFilesFromSource($this->appPath . 'Listeners', app_path('Listeners'));

        // copy Mail
        $this->copyFilesFromSource($this->appPath . 'Mail', app_path('Mail'));

        // copy Notifications
        $this->copyFilesFromSource($this->appPath . 'Events', app_path('Notifications'));

        // copy EventServiceProvider
        $source = $this->appPath . "Providers{$this->ds}EventServiceProvider.php";
        $this->copyFilesFromSource($source, app_path('Providers'));
    }
844893
function it_generates_the_expected_request_when_looking_up_notification(){

        //---------------------------------
        // Test Setup

        $id = self::SAMPLE_ID;

        $this->httpClient->sendRequest( Argument::type('Psr\Http\Message\RequestInterface') )->willReturn(
            new Response(
                200,
                ['Content-type'  => 'application/json'],
                json_encode(['notification_id' => $id])
            )
        );

        //---------------------------------
        // Perform action

        $this->getNotification( $id );

        //---------------------------------
        // Check result

        // Check the expected Request was sent.
        $this->httpClient->sendRequest( Argument::that(function( $v ) use ($id) {

            // Check a request was sent.
            if( !( $v instanceof RequestInterface ) ){
                return false;
            }

            // With the correct URL
            if( $v->getUri() != self::BASE_URL . sprintf( Client::PATH_NOTIFICATION_LOOKUP, $id ) ){
                return false;
            }

            // Include the correct token header
            if( $v->getHeader('Authorization') != [ 'Bearer '.self::TEST_JWT_TOKEN ] ){
                return false;
            }

            // And correct Content-type
            if( $v->getHeader('Content-type') != [ 'application/json' ] ){
                return false;
            }

            return true;

        }))->shouldHaveBeenCalled();

    }
789781
public function generateResponse(){
        // Create request
        $this->startTimeline("request.create");

        $request    = $this->container->get("app.request")
            ->withAttribute("app.debug", $this->debug)
        ;

        $this->endTimeline("request.create");

        // Create response
        $this->startTimeline("response.create");

        $response   = $this->container->newInstance(Response::class, [
            "handler"   => $this->generateHandler($request),
        ]);

        $this->endTimeline("response.create");

        return $response;
    }
94542
protected function withoutNotifications()
    {
        $mock = Mockery::mock(NotificationDispatcher::class);

        $mock->shouldReceive('send')->andReturnUsing(function ($notifiable, $instance, $channels = []) {
            $this->dispatchedNotifications[] = compact(
                'notifiable', 'instance', 'channels'
            );
        });

        $this->app->instance(NotificationDispatcher::class, $mock);

        return $this;
    }
1245182
public function createDeviceNotification($title = null, $body = null, $token = array())
    {
        $notification = new DeviceNotification();
        $notification
            ->setTitle($title)
            ->setBody($body);

        if(is_array($token)){
            $notification->setDeviceTokens($token);
        } else {
            $notification->addDeviceToken($token);
        }

        return $notification;
    }
36183
public function create()
    {
        // Create Response Model
        $response = new ResponseModel();

        // return response
        $response->setData(collect($this->model->getFillable()));
        $response->setMessage($this->getTrans('create', 'successful'));
        return SmartResponse::response($response);
    }
1099676
private function formatNotify() {

		$notify = null;

		if(true === isset($this -> headers['notify'])) {

			$notify = $this -> emailsToString($this -> headers['notify']);

			if(null === $notify) {

				if(true === isset($this -> headers['from'])) {
					$notify = $this -> emailsToString($this -> headers['from']);
				}
				else {
					$notify = ini_get('sendmail_from');
				}
			}
		}
		
		return $notify;
	}
730685
private function buildBody()
    {
        // Build Body Element
        $this->body = $this->getHTMLDocument()->getHTMLFactory()->buildHtmlElement('div', '', '', 'ui-notification-body');
        $this->append($this->body);

        // Populate the notification icon
        $icon = $this->getHTMLDocument()->getHTMLFactory()->buildHtmlElement('span', '', '', 'ui-notification-icon');
        $this->appendToBody($icon);

        return $this;
    }
1046762
protected function createResponse()
	{
		try {
			$body = $this->stream->createStream(fopen('php://temp', 'w+b'));
		}
		catch (InvalidArgumentException $e) {
			throw new RuntimeException('Unable to create stream "php://temp"');
		}

		return new ResponseBuilder(
			$this->message->createResponse(200, null, [], $body)
		);
	}
1279719
public function createIncidentAction()
    {
        try {
            $incident = execute(new CreateIncidentCommand(
                Binput::get('name'),
                Binput::get('status'),
                Binput::get('message', null, false, false),
                Binput::get('visible', true),
                Binput::get('component_id'),
                Binput::get('component_status'),
                Binput::get('notify', false),
                Binput::get('stickied', false),
                Binput::get('occurred_at'),
                null,
                [],
                ['seo' => Binput::get('seo', [])]
            ));
        } catch (ValidationException $e) {
            return cachet_redirect('dashboard.incidents.create')
                ->withInput(Binput::all())
                ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.incidents.add.failure')))
                ->withErrors($e->getMessageBag());
        }

        return cachet_redirect('dashboard.incidents')
            ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.incidents.add.success')));
    }
303244
public function createJsMessages()
    {
        $contents = $this->getMessagesJson();

        return response($contents)
            ->header('Content-Type', 'text/javascript')
            ->setLastModified(MessageCachingService::getLastRefreshTimestamp());
    }
1102836
public function notify()
    {
        $response = new Response;
        try {
            $input = [
                'namespace' => strtolower( Request::input( 'namespace' ) ),
                'type'      => Request::input( 'type' ),
            ];
            if ( $input['namespace'] && $input['type'] ) {
                $main_class = $input['type'] === 'theme' ? 'theme' : $input['namespace'];
                global $$main_class;
                if ( $$main_class ) {
                    update_option(
                        $$main_class->config->get( 'updater.option' ),
                        true,
                        true //autoload
                    );
                    do_action( 'wpmvc_'.$main_class.'_updated' );
                    $response->success = true;
                }
            }
        } catch (Exception $e) {
            Log::error( $e );
        }
        $response->json();
    }
1308898
public function send() {

		//Set default status
		$this -> response -> setStatus([

			'code' 		=> 0,
		    'protocol' 	=> '',
		    'status' 	=> '',
		    'text' 		=> ''
		]);

		$curl = curl_init();

		curl_setopt_array($curl, $this -> createOptions());

		$response = curl_exec($curl);

		if(false !== $response) {

			$header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
			$headers 	 = substr($response, 0, $header_size);
			$headers 	 = $this -> parseHeaders($headers);
			$body 		 = substr($response, $header_size);
			$json 		 = @json_decode($body, true);

			$this -> response -> setHeaders($headers['headers']);
			$this -> response -> setBody($body);
			$this -> response -> setStatus($headers['status']);
			$this -> response -> setCookies($this -> parseCookies($response));
			$this -> response -> setResponse($response);

			if(true === (json_last_error() == JSON_ERROR_NONE)) {
				$this -> response -> setJson($json);
			}
		}

		$this -> response -> setInfo(curl_getinfo($curl));

		curl_close($curl);

		return $this;
	}
144725
public function sendNotify($applicationName, $notificationName, $notificationTitle, $notificationText, $options = array())
    {
        $notification_options = $options;
        $notification_options['text'] = $notificationText;
        $register = new RegisterRequest($applicationName);
        $register->addNotification($notificationName);
        $notify = new NotificationRequest($applicationName, $notificationName, $notificationTitle, $notification_options);
        return $this->notifyOrRegister($notify, $register)->getStatus();
    }
1124565
public static function Send(){
            $oThis = self::CreateInstanceIfNotExists();
            
            if(is_object($oThis->oSmarty)){
                $oThis->CreateCacheCSS();
                $oThis->CreateCacheJS();
                
                Storage::AssignSmarty($oThis->oSmarty);
                Events::Call("BeforeSendingOutput");
                
                $oThis->oSmarty->display($oThis->sTemplateFilename);
            }
            else{
                $oThis = self::CreateInstanceIfNotExists();
                $oThis->CreateCacheCSS();
                $oThis->CreateCacheJS();
                $oThis->IncludeTemplate();
                $oThis->ReplaceVars();
                $oThis->RemoveUndefinedVars();
                $oThis->CheckConditions();
                //$oThis->ClearList();
                Events::Call("BeforeSendingOutput");

                @header('HTTP/1.1 200 OK');
                @header("Content-Type: text/html; charset=" . strtoupper(Storage::Get("app.charset", "UTF-8")), true);

                try{
                    //var_dump($oThis->sBuffer); die();
                    eval('?> ' . $oThis->sBuffer);
                    die();
                }
                catch(Exception $e){
                    die($e->getMessage());
                }
            }
        }