-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
28 changed files
with
657 additions
and
350 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,25 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the overtrue/wechat. | ||
* | ||
* (c) overtrue <[email protected]> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace EasyWeChat\Kernel\Contracts; | ||
|
||
/** | ||
* Interface MediaInterface. | ||
* | ||
* @author overtrue <[email protected]> | ||
*/ | ||
interface MediaInterface extends MessageInterface | ||
{ | ||
/** | ||
* @return string | ||
*/ | ||
public function getMediaId(): string; | ||
} |
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,35 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the overtrue/wechat. | ||
* | ||
* (c) overtrue <[email protected]> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace EasyWeChat\Kernel\Contracts; | ||
|
||
/** | ||
* Interface MessageInterface. | ||
* | ||
* @author overtrue <[email protected]> | ||
*/ | ||
interface MessageInterface | ||
{ | ||
/** | ||
* @return string | ||
*/ | ||
public function getType(): string; | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function transformForJsonRequest(): array; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function transformToXml(): string; | ||
} |
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,36 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the overtrue/wechat. | ||
* | ||
* (c) overtrue <[email protected]> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace EasyWeChat\Kernel\Messages; | ||
|
||
/** | ||
* Class Factory. | ||
* | ||
* @author overtrue <[email protected]> | ||
*/ | ||
class Factory | ||
{ | ||
/** | ||
* @param array $attributes | ||
*/ | ||
public static function createFromMedia($attributes = []) | ||
{ | ||
//TODO: 从素材转换为消息对象 | ||
} | ||
|
||
/** | ||
* @param array $attributes | ||
*/ | ||
public static function createFromUserMessage($attributes = []) | ||
{ | ||
//TODO: 从请求消息解析为消息对象 | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
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,58 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the overtrue/wechat. | ||
* | ||
* (c) overtrue <[email protected]> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace EasyWeChat\Kernel\Messages; | ||
|
||
use EasyWeChat\Kernel\Contracts\MediaInterface; | ||
|
||
/** | ||
* Class Media. | ||
*/ | ||
class Media extends Message implements MediaInterface | ||
{ | ||
/** | ||
* Properties. | ||
* | ||
* @var array | ||
*/ | ||
protected $properties = ['media_id']; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $requirements = [ | ||
'media_id', | ||
]; | ||
|
||
/** | ||
* MaterialClient constructor. | ||
* | ||
* @param string $type | ||
* @param string $mediaId | ||
* @param array $attributes | ||
*/ | ||
public function __construct(string $type, string $mediaId, array $attributes = []) | ||
{ | ||
parent::__construct(array_merge(['media_id' => $mediaId], $attributes)); | ||
|
||
$this->setType($type); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getMediaId(): string | ||
{ | ||
$this->checkRequiredAttributes(); | ||
|
||
return $this->get('media_id'); | ||
} | ||
} |
Oops, something went wrong.