PluginProbe
Depicter — Popup & Slider Builder / 1.9.2
Depicter — Popup & Slider Builder v1.9.2
4.8.1 trunk 1.0.0 1.1.0 1.1.2 1.1.4 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.5 1.3.8 1.5.0 1.5.1 1.5.2 1.5.5 1.6.0 1.6.1 1.6.2 1.7.0 All 76 releases
← All changes | app/src/Controllers/Ajax/AppInfoAjaxController.php +28 -0 1.3.0 → 1.9.2 View file →
@@ -31,5 +31,33 @@
31 31 ])->withStatus( 503 );
32 32 }
33 33 }
34 34
35 + /**
36 + * Retrieves the existing promotion
37 + *
38 + * @param RequestInterface $request
39 + * @param string $view
40 + *
41 + * @return ResponseInterface
42 + * @throws GuzzleException
43 + */
44 + public function getPromotion( RequestInterface $request, string $view)
45 + {
46 + try {
47 + $response = \Depicter::remote()->get( 'v1/core/announcements', [ 'query' => [ 'category' => 'promotions-wp-dash' ] ] );
48 + $promotions = JSON::decode( $response->getBody(), true );
49 + $currentPromotion = [];
50 +
51 + if( ! empty( $promotions['hits'] ) ){
52 + $currentPromotion = reset($promotions['hits'] );
53 + }
54 + return \Depicter::json( $currentPromotion )->withStatus( 200 );
55 +
56 + } catch( \Exception $exception ) {
57 + return \Depicter::json([
58 + 'errors' => [ $exception->getMessage() ]
59 + ])->withStatus( 503 );
60 + }
61 + }
62 +
35 63 }