Skip to content
This repository has been archived by the owner on Feb 23, 2023. It is now read-only.

Commit

Permalink
chore: Options
Browse files Browse the repository at this point in the history
  • Loading branch information
medz committed Feb 21, 2019
1 parent 017f956 commit f9fff03
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/Contracts/PushPayloadMakeable.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,9 @@

interface PushPayloadMakeable
{
/**
* Make push payload.
* @param \Medz\Laravel\Notifications\JPush\PushPayload $payload
*/
public function make(PushPayload $payload);
}
31 changes: 28 additions & 3 deletions src/PushPayload.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,40 @@
namespace Medz\Laravel\Notifications\JPush;

use JPush\PushPayload as Payload;
use Medz\Laravel\Notifications\JPush\Contracts\PushPayloadMakeable;

class PushPayload
{
/**
* JPush push payload
* @var \JPush\PushPayload
*/
protected $payload;

/**
* Create a push payload.
* @param \JPush\PushPayload $payload
*/
public function __construct(Payload $payload)
{
$this->payload = $payload;
}

public function make(PushPayloadMakeable $makeable)
/**
* Using makeable.
* @param Medz\Laravel\Notifications\JPush\Contracts\PushPayloadMakeable $makeable
*/
public function make(Contracts\PushPayloadMakeable $makeable)
{
$makeable->make($this);

return $this;
}

/**
* set push audiences.
* @param string $key
* @param mixed $value
*/
public function audiences(string $key, $value)
{
switch ($key) {
Expand Down Expand Up @@ -54,14 +70,23 @@ public function audiences(string $key, $value)
return $this;
}

/**
* Send payload to Jpush.
* @return mixed
*/
public function send()
{
return $this->payload->send();
}

/**
* Call payload methods.
* @param string $method
* @param array $params
*/
public function __call($method, $params)
{
$this->payload->{$method}($params);
$this->payload->{$method}(...$params);

return $this;
}
Expand Down

0 comments on commit f9fff03

Please sign in to comment.