Skip to content

Commit 0a72b8c

Browse files
committed
Code review fixes part 81
Signed-off-by: Konstantin Myakshin <[email protected]>
1 parent aefdb09 commit 0a72b8c

File tree

6 files changed

+34
-37
lines changed

6 files changed

+34
-37
lines changed

appinfo/routes.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
'url' => '/api/{apiVersion}/form/{id}',
100100
'verb' => 'GET',
101101
'requirements' => [
102-
'apiVersion' => 'v2(\.[1-3])?'
102+
'apiVersion' => 'v2(\.[1-4])?'
103103
]
104104
],
105105
[
@@ -304,15 +304,15 @@
304304
'url' => '/api/{apiVersion}/submissions/export/{hash}',
305305
'verb' => 'GET',
306306
'requirements' => [
307-
'apiVersion' => 'v2(\.[1-3])?'
307+
'apiVersion' => 'v2(\.[1-4])?'
308308
]
309309
],
310310
[
311311
'name' => 'api#exportSubmissionsToCloud',
312312
'url' => '/api/{apiVersion}/submissions/export',
313313
'verb' => 'POST',
314314
'requirements' => [
315-
'apiVersion' => 'v2(\.[1-3])?'
315+
'apiVersion' => 'v2(\.[1-4])?'
316316
]
317317
],
318318
[
@@ -345,7 +345,7 @@
345345
'url' => '/api/{apiVersion}/form/link/{fileFormat}',
346346
'verb' => 'POST',
347347
'requirements' => [
348-
'apiVersion' => 'v2.3',
348+
'apiVersion' => 'v2.4',
349349
'fileFormat' => 'csv|ods|xlsx'
350350
]
351351
],
@@ -354,7 +354,7 @@
354354
'url' => '/api/{apiVersion}/form/unlink',
355355
'verb' => 'POST',
356356
'requirements' => [
357-
'apiVersion' => 'v2.3',
357+
'apiVersion' => 'v2.4',
358358
]
359359
]
360360
]

docs/API.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ This file contains the API-Documentation. For more information on the returned D
2828
- Completely new way of handling access & shares.
2929

3030
### Other API changes
31-
- In API version 2.3 the following endpoints were introduced:
32-
- `POST /api/2.3/form/link/{fileFormat}` to link form to a file
33-
- `POST /api/2.3/form/unlink` to unlink form from a file
34-
- In API version 2.3 the following endpoints were changed:
35-
- `GET /api/v2.3/submissions/export/{hash}` was extended with optional parameter `fileFormat` to export submissions in different formats
36-
- `GET /api/v2.3/submissions/export` was extended with optional parameter `fileFormat` to export submissions to cloud in different formats
37-
- `GET /api/v2.3/form/{id}` was extended with optional parameters `fileFormat`, `fileId`, `filePath` to link form to a file
38-
- In API version 2.1 the endpoint `/api/v2.1/share/update` was added to update a Share
39-
- In API version 2.2 the endpoint `/api/v2.2/form/transfer` was added to transfer ownership of a form
31+
- In API version 2.4 the following endpoints were introduced:
32+
- `POST /api/2.4/form/link/{fileFormat}` to link form to a file
33+
- `POST /api/2.4/form/unlink` to unlink form from a file
34+
- In API version 2.4 the following endpoints were changed:
35+
- `GET /api/v2.4/submissions/export/{hash}` was extended with optional parameter `fileFormat` to export submissions in different formats
36+
- `GET /api/v2.4/submissions/export` was extended with optional parameter `fileFormat` to export submissions to cloud in different formats
37+
- `GET /api/v2.4/form/{id}` was extended with optional parameters `fileFormat`, `fileId`, `filePath` to link form to a file
4038
- In API version 2.3 the endpoint `/api/v2.3/question/clone` was added to clone a question
39+
- In API version 2.2 the endpoint `/api/v2.2/form/transfer` was added to transfer ownership of a form
40+
- In API version 2.1 the endpoint `/api/v2.1/share/update` was added to update a Share
4141

4242
## Form Endpoints
4343
### List owned Forms
@@ -118,7 +118,7 @@ See next section, 'Request full data of a form'
118118

119119
### Request full data of a form
120120
Returns the full-depth object of the requested form (without submissions).
121-
- Endpoint: `/api/v2.2/form/{id}`
121+
- Endpoint: `/api/v2.4/form/{id}`
122122
- Url-Parameter:
123123
| Parameter | Type | Description |
124124
|-----------|---------|-------------|
@@ -261,7 +261,7 @@ Transfer the ownership of a form to another user
261261
```
262262

263263
### Link a form to a file
264-
- Endpoint: `/api/v2.3/form/link/{fileFormat}`
264+
- Endpoint: `/api/v2.4/form/link/{fileFormat}`
265265
- Url-Parameter:
266266
| Parameter | Type | Description |
267267
|--------------|---------|--------------|
@@ -283,7 +283,7 @@ Transfer the ownership of a form to another user
283283
```
284284

285285
### Unlink file from form
286-
- Endpoint: `/api/v2.3/form/unlink`
286+
- Endpoint: `/api/v2.4/form/unlink`
287287
- Method: `POST`
288288
- Parameters:
289289
| Parameter | Type | Description |
@@ -583,7 +583,7 @@ Get all Submissions to a Form
583583

584584
### Get Submissions as csv (Download)
585585
Returns all submissions to the form in form of a csv-file.
586-
- Endpoint: `/api/v2.2/submissions/export/{hash}`
586+
- Endpoint: `/api/v2.4/submissions/export/{hash}`
587587
- Url-Parameter:
588588
| Parameter | Type | Description |
589589
|--------------|---------|-------------|
@@ -599,7 +599,7 @@ Returns all submissions to the form in form of a csv-file.
599599

600600
### Export Submissions to Cloud (Files-App)
601601
Creates a csv file and stores it to the cloud, resp. Files-App.
602-
- Endpoint: `/api/v2.2/submissions/export`
602+
- Endpoint: `/api/v2.4/submissions/export`
603603
- Method: `POST`
604604
- Parameters:
605605
| Parameter | Type | Description |

lib/Migration/Version030200Date20231001200100.php renamed to lib/Migration/Version040010Date20240122133700.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
declare(strict_types=1);
44

55
/**
6-
* @copyright Copyright (c) 2023 Ferdinand Thiessen <[email protected]>
6+
* @copyright Copyright (c) 2024 Kostiantyn Miakshyn <[email protected]>
77
*
88
* @author Kostiantyn Miakshyn <[email protected]>
99
*
@@ -32,7 +32,7 @@
3232
use OCP\Migration\IOutput;
3333
use OCP\Migration\SimpleMigrationStep;
3434

35-
class Version030200Date20231001200100 extends SimpleMigrationStep {
35+
class Version040010Date20240122133700 extends SimpleMigrationStep {
3636
/**
3737
* @param IOutput $output
3838
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`

lib/Service/SubmissionService.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,6 @@ class SubmissionService {
9090
/** @var IMailer */
9191
private $mailer;
9292

93-
/** @var ITempManager */
94-
private $tempManager;
95-
9693
public function __construct(FormMapper $formMapper,
9794
QuestionMapper $questionMapper,
9895
SubmissionMapper $submissionMapper,
@@ -104,8 +101,9 @@ public function __construct(FormMapper $formMapper,
104101
IUserManager $userManager,
105102
IUserSession $userSession,
106103
IMailer $mailer,
107-
ITempManager $tempManager,
108-
private FormsService $formsService) {
104+
private ITempManager $tempManager,
105+
private FormsService $formsService,
106+
) {
109107
$this->formMapper = $formMapper;
110108
$this->questionMapper = $questionMapper;
111109
$this->submissionMapper = $submissionMapper;
@@ -116,7 +114,6 @@ public function __construct(FormMapper $formMapper,
116114
$this->logger = $logger;
117115
$this->userManager = $userManager;
118116
$this->mailer = $mailer;
119-
$this->tempManager = $tempManager;
120117

121118
$this->currentUser = $userSession->getUser();
122119
}
@@ -332,7 +329,7 @@ private function exportData(array $header, array $data, string $fileFormat, ?Fil
332329
$spreadsheet = new Spreadsheet();
333330
}
334331

335-
$activeWorksheet = $spreadsheet->getActiveSheet();
332+
$activeWorksheet = $spreadsheet->getSheet(0);
336333
foreach ($header as $columnIndex => $value) {
337334
$activeWorksheet->setCellValue([$columnIndex + 1, 1], $value);
338335
}

src/views/Results.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ export default {
369369
370370
methods: {
371371
async onUnlinkFile() {
372-
await axios.post(generateOcsUrl('apps/forms/api/v2.3/form/unlink'), {
372+
await axios.post(generateOcsUrl('apps/forms/api/v2.4/form/unlink'), {
373373
hash: this.form.hash,
374374
})
375375
@@ -401,7 +401,7 @@ export default {
401401
},
402402
403403
async onDownloadFile(fileFormat) {
404-
const exportUrl = generateOcsUrl('apps/forms/api/v2.1/submissions/export/{hash}', { hash: this.form.hash })
404+
const exportUrl = generateOcsUrl('apps/forms/api/v2.4/submissions/export/{hash}', { hash: this.form.hash })
405405
+ '?requesttoken=' + encodeURIComponent(getRequestToken())
406406
+ '&fileFormat=' + fileFormat
407407
window.open(exportUrl, '_self')
@@ -412,7 +412,7 @@ export default {
412412
await this.getPicker().pick()
413413
.then(async (path) => {
414414
try {
415-
const response = await axios.post(generateOcsUrl('apps/forms/api/v2.3/form/link/{fileFormat}', { fileFormat }), {
415+
const response = await axios.post(generateOcsUrl('apps/forms/api/v2.4/form/link/{fileFormat}', { fileFormat }), {
416416
hash: this.form.hash,
417417
path,
418418
})
@@ -440,7 +440,7 @@ export default {
440440
await this.getPicker().pick()
441441
.then(async (path) => {
442442
try {
443-
const response = await axios.post(generateOcsUrl('apps/forms/api/v2.2/submissions/export'), { hash: this.form.hash, path, fileFormat })
443+
const response = await axios.post(generateOcsUrl('apps/forms/api/v2.4/submissions/export'), { hash: this.form.hash, path, fileFormat })
444444
showSuccess(t('forms', 'Export successful to {file}', { file: OcsResponse2Data(response) }))
445445
} catch (error) {
446446
logger.error('Error while exporting to Files', { error })
@@ -454,7 +454,7 @@ export default {
454454
},
455455
456456
async fetchLinkedFileInfo() {
457-
const response = await axios.get(generateOcsUrl('apps/forms/api/v2.2/form/{id}', { id: this.form.id }))
457+
const response = await axios.get(generateOcsUrl('apps/forms/api/v2.4/form/{id}', { id: this.form.id }))
458458
const form = OcsResponse2Data(response)
459459
this.$set(this.form, 'fileFormat', form.fileFormat)
460460
this.$set(this.form, 'fileId', form.fileId)

tests/Integration/Api/ApiV2Test.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,7 +1323,7 @@ public function dataExportSubmissions() {
13231323
* @param array $expected
13241324
*/
13251325
public function testExportSubmissions(string $expected) {
1326-
$resp = $this->http->request('GET', "api/v2.1/submissions/export/{$this->testForms[0]['hash']}");
1326+
$resp = $this->http->request('GET', "api/v2.4/submissions/export/{$this->testForms[0]['hash']}");
13271327
$data = substr($resp->getBody()->getContents(), 3); // Some strange Character removed at the beginning
13281328

13291329
$this->assertEquals(200, $resp->getStatusCode());
@@ -1335,7 +1335,7 @@ public function testExportSubmissions(string $expected) {
13351335
}
13361336

13371337
public function testLinkFile() {
1338-
$resp = $this->http->request('POST', 'api/v2.3/form/link/csv', [
1338+
$resp = $this->http->request('POST', 'api/v2.4/form/link/csv', [
13391339
'json' => [
13401340
'hash' => $this->testForms[0]['hash'],
13411341
'path' => ''
@@ -1348,7 +1348,7 @@ public function testLinkFile() {
13481348
}
13491349

13501350
public function testUnlinkFile() {
1351-
$resp = $this->http->request('POST', 'api/v2.3/form/unlink', [
1351+
$resp = $this->http->request('POST', 'api/v2.4/form/unlink', [
13521352
'json' => [
13531353
'hash' => $this->testForms[2]['hash'],
13541354
'path' => ''
@@ -1361,7 +1361,7 @@ public function testUnlinkFile() {
13611361
}
13621362

13631363
public function testExportToCloud() {
1364-
$resp = $this->http->request('POST', 'api/v2.2/submissions/export', [
1364+
$resp = $this->http->request('POST', 'api/v2.4/submissions/export', [
13651365
'json' => [
13661366
'hash' => $this->testForms[0]['hash'],
13671367
'path' => ''

0 commit comments

Comments
 (0)