-
Notifications
You must be signed in to change notification settings - Fork 18
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
7 changed files
with
438 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace QiQiuYun\SDK\Constants; | ||
|
||
final class PlatformNewsBlockTypes | ||
{ | ||
// ES商学院课程推荐 | ||
const ADVICE_BLOCK = 1; | ||
|
||
// ES后台插件推荐 | ||
const PLUGIN_BLOCK = 2; | ||
|
||
// 公众号二维码 | ||
const QR_CODE_BLOCK = 3; | ||
|
||
// 站长公告 | ||
const ANNOUNCEMENT_BLOCK = 4; | ||
} |
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,114 @@ | ||
<?php | ||
|
||
namespace QiQiuYun\SDK\Service; | ||
|
||
use QiQiuYun\SDK\Constants\PlatformNewsBlockTypes; | ||
|
||
/** | ||
* Open站 | ||
*/ | ||
class PlatformNewsService extends BaseService | ||
{ | ||
protected $host = 'platform-news-service.qiqiuyun.net'; | ||
|
||
/** | ||
* 获取ES商学院课程推荐 | ||
* | ||
* @param $limit | ||
* | ||
* @return array | ||
* id int 区块id | ||
* name string 区块名 | ||
* returnUrl string 跳转es商学院url | ||
* details array 取回的信息 | ||
* *title string 课程名 | ||
* *subtitle string 课程说明 | ||
* *image string 课程封面 | ||
* *url string 课程url | ||
* *position int 课程推荐排序 | ||
*/ | ||
public function getAdvice($limit = 4) | ||
{ | ||
return $this->getFromPlatformNews(PlatformNewsBlockTypes::ADVICE_BLOCK, $limit); | ||
} | ||
|
||
/** | ||
* 获取推荐应用 | ||
* | ||
* @param $limit | ||
* | ||
* @return array | ||
* id int 区块id | ||
* name string 区块名 | ||
* returnUrl string 跳转营销云url | ||
* details array 取回的信息 | ||
* *title string 应用名 | ||
* *subtitle string 应用说明 | ||
* *image string 应用封面 | ||
* *url string 应用url | ||
* *position int 应用排序 | ||
*/ | ||
public function getApplications($limit = 4) | ||
{ | ||
return $this->getFromPlatformNews(PlatformNewsBlockTypes::PLUGIN_BLOCK, $limit); | ||
} | ||
|
||
/** | ||
* 获取公众号二维码 | ||
* | ||
* @param $limit | ||
* | ||
* @return array | ||
* id int 区块id | ||
* name string 区块名 | ||
* returnUrl string 跳转url | ||
* details array 取回的信息 | ||
* *title string 公众号名 | ||
* *subtitle string 二维码描述 | ||
* *image string 二维码图片 | ||
* *url string 二维码图片url | ||
* *position int | ||
*/ | ||
public function getQrCode($limit = 1) | ||
{ | ||
return $this->getFromPlatformNews(PlatformNewsBlockTypes::QR_CODE_BLOCK, $limit); | ||
} | ||
|
||
/** | ||
* 获取站长公告 | ||
* | ||
* @param $limit | ||
* | ||
* @return array | ||
* id int 区块id | ||
* name string 区块名 | ||
* returnUrl string 跳转url | ||
* details array 取回的信息 | ||
* *title string 公告title | ||
* *subtitle string 公告内容 | ||
* *image string 公告图片 | ||
* *url string 公告url | ||
* *position int | ||
*/ | ||
public function getAnnouncements($limit = 1) | ||
{ | ||
return $this->getFromPlatformNews(PlatformNewsBlockTypes::ANNOUNCEMENT_BLOCK, $limit); | ||
} | ||
|
||
/** | ||
* 根据区块id获取区块信息 | ||
* | ||
* @param $blockId | ||
* @param int $limit | ||
* | ||
* @return array | ||
* id int 区块id | ||
* name string 区块名 | ||
* returnUrl string 跳转url | ||
* details array 取回的信息 | ||
*/ | ||
protected function getFromPlatformNews($blockId, $limit = 4) | ||
{ | ||
return $this->request('GET', "/api/news/block/{$blockId}", array('limit' => $limit)); | ||
} | ||
} |
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,43 @@ | ||
<?php | ||
|
||
namespace QiQiuYun\SDK\Tests\Service; | ||
|
||
use QiQiuYun\SDK\Service\ESopService; | ||
use QiQiuYun\SDK\Tests\BaseTestCase; | ||
|
||
class ESopServiceTest extends BaseTestCase | ||
{ | ||
public function testGetTraceScript() | ||
{ | ||
$httpClient = $this->mockHttpClient(array( | ||
'id' => 123, | ||
'script' => "script...", | ||
'enable' => 1, | ||
)); | ||
|
||
$service = new ESopService($this->auth, array(), null, $httpClient); | ||
|
||
$result = $service->getTraceScript(array( | ||
'domain' => 'https://xxx.com', | ||
'enable' => 1, | ||
)); | ||
|
||
$this->assertEquals(1, $result['enable']); | ||
} | ||
|
||
public function testSubmitEventTracking() | ||
{ | ||
$httpClient = $this->mockHttpClient(array( | ||
'trackId' => 1, | ||
)); | ||
|
||
$service = new ESopService($this->auth, array(), null, $httpClient); | ||
|
||
$result = $service->getTraceScript(array( | ||
'action' => 123, | ||
'data' => array(), | ||
)); | ||
|
||
$this->assertEquals(1, $result['trackId']); | ||
} | ||
} |
Oops, something went wrong.