| @@ 55-65 (lines=11) @@ | ||
| 52 | * |
|
| 53 | * @param array $data Application data |
|
| 54 | */ |
|
| 55 | public function add(array $data): array |
|
| 56 | { |
|
| 57 | $resolvedData = $this->resolverFactory->createAppResolver()->resolve($data); |
|
| 58 | ||
| 59 | $request = $this->createRequest('POST', '/apps'); |
|
| 60 | $request = $request->withHeader('Authorization', "Basic {$this->client->getConfig()->getUserAuthKey()}"); |
|
| 61 | $request = $request->withHeader('Content-Type', 'application/json'); |
|
| 62 | $request = $request->withBody($this->createStream($resolvedData)); |
|
| 63 | ||
| 64 | return $this->client->sendRequest($request); |
|
| 65 | } |
|
| 66 | ||
| 67 | /** |
|
| 68 | * Update application with provided data. |
|
| @@ 75-85 (lines=11) @@ | ||
| 72 | * @param string $id ID of your application |
|
| 73 | * @param array $data New application data |
|
| 74 | */ |
|
| 75 | public function update(string $id, array $data): array |
|
| 76 | { |
|
| 77 | $resolvedData = $this->resolverFactory->createAppResolver()->resolve($data); |
|
| 78 | ||
| 79 | $request = $this->createRequest('PUT', "/apps/$id"); |
|
| 80 | $request = $request->withHeader('Authorization', "Basic {$this->client->getConfig()->getUserAuthKey()}"); |
|
| 81 | $request = $request->withHeader('Content-Type', 'application/json'); |
|
| 82 | $request = $request->withBody($this->createStream($resolvedData)); |
|
| 83 | ||
| 84 | return $this->client->sendRequest($request); |
|
| 85 | } |
|
| 86 | ||
| 87 | /** |
|
| 88 | * Create a new segment for application with provided data. |
|
| @@ 93-103 (lines=11) @@ | ||
| 90 | * @param string $appId ID of your application |
|
| 91 | * @param array $data Segment Data |
|
| 92 | */ |
|
| 93 | public function createSegment($appId, array $data): array |
|
| 94 | { |
|
| 95 | $resolvedData = $this->resolverFactory->createSegmentResolver()->resolve($data); |
|
| 96 | ||
| 97 | $request = $this->createRequest('POST', "/apps/$appId/segments"); |
|
| 98 | $request = $request->withHeader('Authorization', "Basic {$this->client->getConfig()->getApplicationAuthKey()}"); |
|
| 99 | $request = $request->withHeader('Content-Type', 'application/json'); |
|
| 100 | $request = $request->withBody($this->createStream($resolvedData)); |
|
| 101 | ||
| 102 | return $this->client->sendRequest($request); |
|
| 103 | } |
|
| 104 | ||
| 105 | /** |
|
| 106 | * Delete existing segment from your application. |
|
| @@ 83-93 (lines=11) @@ | ||
| 80 | * |
|
| 81 | * Application authentication key and ID must be set. |
|
| 82 | */ |
|
| 83 | public function add(array $data): array |
|
| 84 | { |
|
| 85 | $resolvedData = $this->resolverFactory->createNotificationResolver()->resolve($data); |
|
| 86 | ||
| 87 | $request = $this->createRequest('POST', '/notifications'); |
|
| 88 | $request = $request->withHeader('Authorization', "Basic {$this->client->getConfig()->getApplicationAuthKey()}"); |
|
| 89 | $request = $request->withHeader('Content-Type', 'application/json'); |
|
| 90 | $request = $request->withBody($this->createStream($resolvedData)); |
|
| 91 | ||
| 92 | return $this->client->sendRequest($request); |
|
| 93 | } |
|
| 94 | ||
| 95 | /** |
|
| 96 | * Open notification. |
|