codenix-sv/bitfinex-api-ws

View on GitHub
src/Request/SubscribeStatus.php

Summary

Maintainability
A
30 mins
Test Coverage
<?php

declare(strict_types=1);

namespace Codenixsv\BitfinexWs\Request;

use Ratchet\RFC6455\Messaging\Frame;

/**
 * Class SubscribeStatus
 * @package Codenixsv\BitfinexWs\Request
 */
class SubscribeStatus implements Request
{
    /** @var string */
    private $key;

    /**
     * SubscribeStatus constructor.
     * @param string $key
     */
    public function __construct(string $key)
    {
        $this->key = $key;
    }

    /**
     * @return array
     */
    public function getPayload(): array
    {
        return [
            'event' => 'subscribe',
            'channel' => 'status',
            'key' => $this->key
        ];
    }

    /**
     * @return Frame
     */
    public function getFrame(): Frame
    {
        return new Frame(json_encode($this->getPayload()));
    }
}