| @@ 56-74 (lines=19) @@ | ||
| 53 | * |
|
| 54 | * @return RequestInterface |
|
| 55 | */ |
|
| 56 | public function getAppendRequest($datasetName, array $rows) |
|
| 57 | { |
|
| 58 | $data = []; |
|
| 59 | foreach ($rows as $row) { |
|
| 60 | $data[] = $row->getData(); |
|
| 61 | } |
|
| 62 | ||
| 63 | return $this->client->createRequest( |
|
| 64 | 'POST', |
|
| 65 | sprintf('/datasets/%s/data', $datasetName), |
|
| 66 | [ |
|
| 67 | 'headers' => [ |
|
| 68 | 'Content-Type' => 'application/json', |
|
| 69 | ], |
|
| 70 | 'auth' => [$this->apiKey, ''], |
|
| 71 | 'json' => ['data' => $data], |
|
| 72 | ] |
|
| 73 | ); |
|
| 74 | } |
|
| 75 | ||
| 76 | /** |
|
| 77 | * @param string $datasetName |
|
| @@ 82-100 (lines=19) @@ | ||
| 79 | * |
|
| 80 | * @return RequestInterface |
|
| 81 | */ |
|
| 82 | public function getReplaceRequest($datasetName, array $rows) |
|
| 83 | { |
|
| 84 | $data = []; |
|
| 85 | foreach ($rows as $row) { |
|
| 86 | $data[] = $row->getData(); |
|
| 87 | } |
|
| 88 | ||
| 89 | return $this->client->createRequest( |
|
| 90 | 'PUT', |
|
| 91 | sprintf('/datasets/%s/data', $datasetName), |
|
| 92 | [ |
|
| 93 | 'headers' => [ |
|
| 94 | 'Content-Type' => 'application/json', |
|
| 95 | ], |
|
| 96 | 'auth' => [$this->apiKey, ''], |
|
| 97 | 'json' => ['data' => $data], |
|
| 98 | ] |
|
| 99 | ); |
|
| 100 | } |
|
| 101 | ||
| 102 | /** |
|
| 103 | * @param string $datasetName |
|