public function testNotifySuccess()
 {
     $credentials = (require __DIR__ . '/../credentials.php');
     $instance = new PushProcessor($credentials['profile'], $credentials['token']);
     /** @var ResponseInterface $response */
     $response = $instance->notify($credentials['device_tokens'], ['message' => 'Hello World!!']);
     $this->assertEquals(201, $response->getStatusCode());
 }
 /**
  * Registers services on the given app.
  *
  * This method should only be used to configure services and parameters.
  * It should not get services.
  */
 public function register(Application $app)
 {
     $app['ionicPush.processor'] = $app->share(function () use($app) {
         $pusher = new PushProcessor($app['ionicPush.appId'], $app['ionicPush.appSecretId']);
         if (isset($app['ionicPush.endPoint'])) {
             $pusher->setPushEndPoint($app['ionicPush.endPoint']);
         }
         return $pusher;
     });
 }
 public function updateStatus($orderId, $deliverymanId, $status)
 {
     $order = $this->orderRepository->getByIdAndDeliveryman($orderId, $deliverymanId);
     $order->status = $status;
     switch ((int) $status) {
         case 1:
             if (!$order->hash) {
                 $order->hash = md5((new \DateTime())->getTimestamp());
             }
             $order->save();
             break;
         case 2:
             $user = $order->client->user;
             $this->pushProcessor->notify([$user->device_token], ['alert' => "Seu pedido #{$order->id} acabou de ser entregue."]);
             $order->save();
             break;
     }
     return $order;
 }
 /**
  * @expectedException \Dmitrovskiy\IonicPush\Exception\RequestException
  */
 public function testNotifyFailedRequest()
 {
     $instance = new PushProcessor('appID', 'appEndPoint', 'wrong http address');
     $instance->notify(array(), array());
 }