generated from spatie/package-skeleton-laravel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement MobileConfig endpoint (#28)
- Loading branch information
Showing
7 changed files
with
93 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rapkis\Controld\Resources; | ||
|
||
use Illuminate\Http\Client\PendingRequest; | ||
|
||
class MobileConfig | ||
{ | ||
public function __construct(private readonly PendingRequest $client) | ||
{ | ||
} | ||
|
||
public function generateProfile( | ||
string $devicePk, | ||
array $excludeWifi = [], | ||
array $excludeDomain = [], | ||
bool $dontSign = false, | ||
bool $excludeCommon = false, | ||
string $clientId = null, | ||
): string { | ||
return $this->client->get("mobileconfig/{$devicePk}", [ | ||
'exclude_wifi' => $excludeWifi, | ||
'exclude_domain' => $excludeDomain, | ||
'dont_sign' => (int) $dontSign, | ||
'exclude_common' => (int) $excludeCommon, | ||
'client_id' => $clientId, | ||
])->body(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
²§Ë¿¶>¾ópºµxÞxõ`¿Ã¹dcRo"iÏ ifÀ]ºDrÒ±BÙx/éX_Og`Äɧ۾ãBǼÚüÁ̪UÞågl9ÿÅ&1HAëÐ5ÛX{¯â£Ð¬'Ö¨ÞU | ||
|
||
¹f+BéÔ~ á sJØWt | ||
Xp-¬[jQ]Ä~õrÏt¤ | ||
Uo±çÚ_¬¢vÛÕ:'c¹kÓx ~ÂÓnc»°©ç?©Ë]>Á^Ý}TH¿ûØõãÔ5Я0+çtäÈÕé°Òõ>D!:kLûÊ6@ð |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Illuminate\Support\Facades\Http; | ||
use Rapkis\Controld\Resources\MobileConfig; | ||
|
||
beforeEach(function () { | ||
Http::preventStrayRequests(); | ||
}); | ||
|
||
it('displays mobile config', function () { | ||
$dummyBinary = file_get_contents(__DIR__.'/../Mocks/Endpoints/mobile-config.bin'); | ||
|
||
$request = Http::fake([ | ||
'mobileconfig/device_pk?dont_sign=0&exclude_common=0' => Http::response($dummyBinary), | ||
])->asJson(); | ||
|
||
$resource = new MobileConfig($request); | ||
|
||
$result = $resource->generateProfile('device_pk'); | ||
|
||
expect($result)->toBe($dummyBinary); | ||
}); |