|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace Instagram\SDK\Client\Features; |
| 6 | + |
| 7 | +use GuzzleHttp\Promise\PromiseInterface; |
| 8 | +use Instagram\SDK\Exceptions\InstagramException; |
| 9 | +use Instagram\SDK\Request\Http\Factories\PayloadSerializerFactory; |
| 10 | +use Instagram\SDK\Request\Utils\SignatureUtils; |
| 11 | +use Instagram\SDK\Response\Responses\Common\GeneralResponse; |
| 12 | +use Instagram\SDK\Response\Responses\Notes\NotesResponse; |
| 13 | +use Instagram\SDK\Response\Responses\ResponseEnvelope; |
| 14 | + |
| 15 | +/** |
| 16 | + * Trait NotesFeaturesTrait |
| 17 | + * |
| 18 | + * @package Instagram\SDK\Client\Features |
| 19 | + * @phan-file-suppress PhanUnreferencedUseNormal |
| 20 | + */ |
| 21 | +trait NotesFeaturesTrait |
| 22 | +{ |
| 23 | + |
| 24 | + use DefaultFeaturesTrait; |
| 25 | + |
| 26 | + /** |
| 27 | + * Retrieve notes. |
| 28 | + * |
| 29 | + * @return PromiseInterface<NotesResponse|InstagramException> |
| 30 | + */ |
| 31 | + public function notes(): PromiseInterface |
| 32 | + { |
| 33 | + return $this->authenticated(function (): PromiseInterface { |
| 34 | + $request = $this->buildRequest('notes/get_notes/', new NotesResponse(), 'GET'); |
| 35 | + |
| 36 | + return $this->call($request); |
| 37 | + }); |
| 38 | + } |
| 39 | + |
| 40 | + /** |
| 41 | + * Create a note. |
| 42 | + * |
| 43 | + * @param string $text |
| 44 | + * @param int $audience |
| 45 | + * @return PromiseInterface<GeneralResponse|InstagramException> |
| 46 | + */ |
| 47 | + public function createNote(string $text, int $audience = 0): PromiseInterface |
| 48 | + { |
| 49 | + return $this->authenticated(function () use ($text, $audience): PromiseInterface { |
| 50 | + $request = $this->buildRequest('notes/create_note/', new GeneralResponse(), 'POST') |
| 51 | + ->addUuid($this->session) |
| 52 | + ->addPayloadParam('text', $text) |
| 53 | + ->addPayloadParam('audience', $audience); |
| 54 | + |
| 55 | + return $this->call($request); |
| 56 | + }); |
| 57 | + } |
| 58 | +} |
0 commit comments