-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStorage.php
More file actions
89 lines (77 loc) · 2.34 KB
/
Copy pathStorage.php
File metadata and controls
89 lines (77 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
declare(strict_types=1);
namespace TestingBot\Resource;
use TestingBot\Http\Multipart;
use TestingBot\Http\Request;
/**
* App storage: upload APK/IPA files (or have TestingBot fetch them by URL) and
* reference them in tests via their `tb://` app URL.
*/
final class Storage extends AbstractResource
{
/**
* Upload a local app file.
*
* @return array<mixed>
*/
public function uploadFile(string $localFile): array
{
return $this->request(new Request('POST', 'storage', body: Multipart::fromFile($localFile)));
}
/**
* Have TestingBot fetch and store an app from a public URL.
*
* @return array<mixed>
*/
public function uploadRemoteUrl(string $url): array
{
return $this->request(new Request('POST', 'storage', body: ['url' => $url]));
}
/**
* Replace an already-stored app (by app key or `tb://` URL) with a local file.
*
* @return array<mixed>
*/
public function replaceFile(string $appUrl, string $localFile): array
{
$key = $this->stripAppScheme($appUrl);
return $this->request(new Request('POST', 'storage/' . $key, body: Multipart::fromFile($localFile)));
}
/**
* Replace an already-stored app (by app key or `tb://` URL) from a public URL.
*
* @return array<mixed>
*/
public function replaceRemoteUrl(string $appUrl, string $url): array
{
$key = $this->stripAppScheme($appUrl);
return $this->request(new Request('POST', 'storage/' . $key, body: ['url' => $url]));
}
/**
* List stored app files.
*
* @return array<mixed>
*/
public function list(int $offset = 0, int $count = 10): array
{
return $this->request(new Request('GET', 'storage', query: $this->paginationQuery($offset, $count)));
}
/**
* Get metadata for a stored app (by app key or `tb://` URL).
*
* @return array<mixed>
*/
public function get(string $appUrl): array
{
return $this->request(new Request('GET', 'storage/' . $this->stripAppScheme($appUrl)));
}
/**
* Delete a stored app (by app key or `tb://` URL).
*
* @return array<mixed>
*/
public function delete(string $appUrl): array
{
return $this->request(new Request('DELETE', 'storage/' . $this->stripAppScheme($appUrl)));
}
}