Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Api/ModuleLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ private function addModuleMapV4_0_0($functions, $moduleInfo, $version, $isStatic
}

array_push($urlParts, $prop);

if (isset($functionDefinition['segments'])) {
array_push($urlParts, ...$functionDefinition['segments']);
}

$apiUrl = Url::buildUrl($sharedOptions['baseUrl'], $urlParts);

$functionOptions = [
Expand Down
12 changes: 12 additions & 0 deletions src/Api/Modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ public static function getModules(): array
'method' => 'DELETE',
],
],
'password' => [
'resetCode' => [
'args' => null,
'method' => 'POST',
'segments' => ['reset-code']
],
'reset' => [
'args' => ['params'],
'method' => 'POST',
'segments' => ['reset']
],
],
'limits' => [
'get' => [
'args' => null,
Expand Down
5 changes: 5 additions & 0 deletions src/Api/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ public static function getSchema()
'to' => $toSchema,
],
],
'password' => [
'reset' => [
'code' => ['required'],
],
],
'limits' => [
'set' => [
'type' => self::getTypeSchema(),
Expand Down
28 changes: 28 additions & 0 deletions tests/AccountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,32 @@ public function testWhitelist()
$response = $this->utility->getInstance()->account->whitelist->add(['to' => '70000000000', 'module' => 'ALL', 'comment' => 'test']);
$this->assertEquals((object)['success' => 1], $response);
}

public function testPasswordResetCode()
{
try {
$response = $this->utility->getInstance()->account->password->resetCode();
$this->assertObjectHasAttribute('success', $response);
$this->assertTrue($response->success);
} catch (RestException $t) {
$this->assertEquals(3, $t->getCode());
}
}

public function testPasswordResetValidation()
{
$this->expectException(RestException::class);
$this->expectExceptionMessage('Validation Error');

$this->utility->getInstance()->account->password->reset();
}

public function testPasswordReset()
{
$this->expectException(RestException::class);
$this->expectExceptionMessage('Invalid or expired code');
$this->expectExceptionCode(2);

$this->utility->getInstance()->account->password->reset(['code' => '123456']);
}
}