Skip to content

Commit

Permalink
增加S2BsCService
Browse files Browse the repository at this point in the history
  • Loading branch information
钟云昶 authored and 钟云昶 committed Apr 15, 2020
2 parents bcb2742 + 955076f commit d11abc7
Show file tree
Hide file tree
Showing 7 changed files with 438 additions and 7 deletions.
18 changes: 18 additions & 0 deletions src/Constants/PlatformNewsBlockTypes.php
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;
}
22 changes: 22 additions & 0 deletions src/QiQiuYunSDK.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
use Psr\Log\LoggerInterface;
use QiQiuYun\SDK\HttpClient\ClientInterface;
use QiQiuYun\SDK\Exception\SDKException;
<<<<<<< HEAD
=======
use QiQiuYun\SDK\Service\NotificationService;
use QiQiuYun\SDK\Service\PlatformNewsService;
>>>>>>> 955076f4df301c8a2592e26cf4e32071142fe376

class QiQiuYunSDK
{
Expand Down Expand Up @@ -139,7 +144,24 @@ public function getWeChatService()
}

/**
<<<<<<< HEAD
* @return \QiQiuYun\SDK\Service\S2B2CService
=======
* @return PlatformNewsService
*/
public function getPlatformNewsService()
{
return $this->getService('PlatformNews');
}

/**
* 创建API请求认证类实例
*
* @param string $accessKey
* @param string $secretKey
*
* @return Auth
>>>>>>> 955076f4df301c8a2592e26cf4e32071142fe376
*/
public function getS2B2CService()
{
Expand Down
15 changes: 12 additions & 3 deletions src/Service/ESopService.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,19 @@ class ESopService extends BaseService
{
protected $host = 'esop-service.qiqiuyun.net';

private $siteTracePath = '/api/v1/site_trace';

public function getTraceScript($data)
{
return $this->request('POST', $this->siteTracePath, $data);
return $this->request('POST', '/api/v1/site_trace', $data);
}

/**
* @param $data
* @return array
* * action
* * data array
*/
public function submitEventTracking($data)
{
return $this->request('POST', '/api/v1/event_tracking', $data);
}
}
114 changes: 114 additions & 0 deletions src/Service/PlatformNewsService.php
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));
}
}
4 changes: 0 additions & 4 deletions tests/Service/DrpServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@

class DrpServiceTest extends BaseTestCase
{
public function testPostData()
{
}

public function testParseRegisterToken_normal()
{
$data = array(
Expand Down
43 changes: 43 additions & 0 deletions tests/Service/ESopServiceTest.php
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']);
}
}
Loading

0 comments on commit d11abc7

Please sign in to comment.