Skip to content

Commit

Permalink
Methods to retrieve OneDrive storage ID
Browse files Browse the repository at this point in the history
  • Loading branch information
David Vicente committed Apr 26, 2017
1 parent cef416f commit dd55785
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Adapter/OneDriveAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,22 @@ public function listContents($directory = '', $recursive = false)
return $result;
}


public function getUserDriveMetadata()
{
$response = $this->client->getUserDriveMetadata();
$responseContent = json_decode((string) $response->getBody());
return $responseContent;
}


public function getOneDriveStorageId()
{
$userDriveMetadata = $this->getUserDriveMetadata();
return $userDriveMetadata->id;
}


public function getType($path)
{
$metadata = $this->getMetadata($path);
Expand Down
22 changes: 22 additions & 0 deletions src/Client/OneDriveClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,18 @@ public function getMetadata($path)
return $this->getResponse('GET', $url);
}

/**
* @return \Psr\Http\Message\ResponseInterface
*
* @link https://dev.onedrive.com/resources/drive.htm
*/
public function getUserDriveMetadata()
{
$url = self::BASE_URI.$this->getPathUserDriveMetadata();

return $this->getResponse('GET', $url);
}

/**
* @param string $path
* @param string $content
Expand Down Expand Up @@ -389,6 +401,16 @@ private function getPathUnderRootDrive($path)
return 'drive/root:/'.$path;
}

/**
* @param string $path
*
* @return string
*/
private function getPathUserDriveMetadata()
{
return 'drive';
}

/**
* @param string $method
* @param string $path
Expand Down

0 comments on commit dd55785

Please sign in to comment.