Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
lybc authored Sep 19, 2021
1 parent 7605f43 commit bfb5395
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/Providers/WeWork.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ class WeWork extends Base
protected bool $detailed = false;
protected ?int $agentId;
protected ?string $apiAccessToken;
protected string $baseUrl = 'https://qyapi.weixin.qq.com';

public function __construct(array $config)
{
parent::__construct($config);
if ($this->getConfig()->has('base_url')) {
$this->baseUrl = $this->getConfig()->get('base_url');
}
}

/**
* @param int $agentId
Expand All @@ -26,6 +35,11 @@ public function setAgentId(int $agentId)
return $this;
}

public function getBaseUrl()
{
return $this->baseUrl;
}

public function userFromCode(string $code): User
{
$token = $this->getApiAccessToken();
Expand Down Expand Up @@ -128,7 +142,7 @@ protected function getApiAccessToken()
protected function getUserId(string $token, string $code): array
{
$response = $this->getHttpClient()->get(
'https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo',
$this->baseUrl . '/cgi-bin/user/getuserinfo',
[
'query' => array_filter(
[
Expand Down Expand Up @@ -160,7 +174,7 @@ protected function getUserId(string $token, string $code): array
protected function getUserById(string $userId): array
{
$response = $this->getHttpClient()->post(
'https://qyapi.weixin.qq.com/cgi-bin/user/get',
$this->baseUrl . '/cgi-bin/user/get',
[
'query' => [
'access_token' => $this->getApiAccessToken(),
Expand Down Expand Up @@ -211,7 +225,7 @@ protected function mapUserToObject(array $user): User
protected function createApiAccessToken(): string
{
$response = $this->getHttpClient()->get(
'https://qyapi.weixin.qq.com/cgi-bin/gettoken',
$this->baseUrl . '/cgi-bin/gettoken',
[
'query' => array_filter(
[
Expand Down

0 comments on commit bfb5395

Please sign in to comment.