-
-
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.
- Loading branch information
Showing
8 changed files
with
87 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Astrotomic\SteamSdk\Enums; | ||
|
||
enum VanityType: int | ||
{ | ||
case Individual = 1; | ||
case Group = 2; | ||
case GameGroup = 3; | ||
} |
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,30 @@ | ||
<?php | ||
|
||
namespace Astrotomic\SteamSdk\Requests; | ||
|
||
use Astrotomic\SteamSdk\Enums\VanityType; | ||
use Sammyjo20\Saloon\Http\SaloonRequest; | ||
|
||
class ResolveVanityUrlRequest extends SaloonRequest | ||
{ | ||
protected ?string $method = 'GET'; | ||
|
||
public function __construct( | ||
public readonly string $vanityurl, | ||
public readonly VanityType $url_type, | ||
) { | ||
} | ||
|
||
public function defineEndpoint(): string | ||
{ | ||
return '/ISteamUser/ResolveVanityURL/v1'; | ||
} | ||
|
||
public function defaultQuery(): array | ||
{ | ||
return [ | ||
'vanityurl' => $this->vanityurl, | ||
'url_type' => $this->url_type->value, | ||
]; | ||
} | ||
} |
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,24 @@ | ||
<?php | ||
|
||
use PHPUnit\Framework\Assert; | ||
|
||
it('returns resolved steamid', closure: function (string $vanityurl, string $expected): void { | ||
$steamid = $this->steam->resolveVanityUrl(vanityurl: $vanityurl); | ||
|
||
Assert::assertInstanceOf(SteamID::class, $steamid); | ||
Assert::assertSame($expected, $steamid->ConvertToUInt64()); | ||
})->with([ | ||
['https://steamcommunity.com/profiles/76561198061912622', '76561198061912622'], | ||
['https://steamcommunity.com/profiles/[U:1:101646894]', '76561198061912622'], | ||
['https://steamcommunity.com/id/gummibeer/', '76561198061912622'], | ||
['https://s.team/p/jbw-bddv', '76561198061912622'], | ||
['https://steamcommunity.com/groups/archiasf', '103582791440160998'], | ||
]); | ||
|
||
it('returns null for invalid vanity', closure: function (string $vanityurl): void { | ||
$steamid = $this->steam->resolveVanityUrl(vanityurl: $vanityurl); | ||
|
||
Assert::assertNull($steamid); | ||
})->with([ | ||
'https://steamcommunity.com/profiles/[U:1:jbw-bddv]', | ||
]); |
1 change: 1 addition & 0 deletions
1
...pi.steampowered.com/GET/ISteamUser/ResolveVanityURL/v1/vanityurl=archiasf&url_type=2.json
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 @@ | ||
{"statusCode":200,"headers":{"Server":["nginx"],"Content-Type":["application\/json; charset=UTF-8"],"Expires":["Mon, 07 Nov 2022 20:53:39 GMT"],"Date":["Mon, 07 Nov 2022 20:53:39 GMT"],"Content-Length":["57"],"Connection":["keep-alive"]},"data":"{\"response\":{\"steamid\":\"103582791440160998\",\"success\":1}}"} |
1 change: 1 addition & 0 deletions
1
...i.steampowered.com/GET/ISteamUser/ResolveVanityURL/v1/vanityurl=gummibeer&url_type=1.json
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 @@ | ||
{"statusCode":200,"headers":{"Server":["nginx"],"Content-Type":["application\/json; charset=UTF-8"],"Expires":["Mon, 07 Nov 2022 20:52:02 GMT"],"Date":["Mon, 07 Nov 2022 20:52:02 GMT"],"Content-Length":["56"],"Connection":["keep-alive"]},"data":"{\"response\":{\"steamid\":\"76561198061912622\",\"success\":1}}"} |