hnhdigital-os/php-linode-api

View on GitHub
src/endpoints/Support/Ticket.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace HnhDigital\LinodeApi\Support;

/*
 * This file is part of the PHP Linode API.
 *
 * (c) H&H|Digital <hello@hnh.digital>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

use HnhDigital\LinodeApi\Foundation\Base;

/**
 * This is the Ticket class.
 *
 * This file is automatically generated.
 *
 * @link https://developers.linode.com/api/v4#tag/Support-Tickets
 *
 * @author Rocco Howard <rocco@hnh.digital>
 */
class Ticket extends Base
{
    /**
     * Endpoint.
     *
     * @var string
     */
    protected $endpoint = 'support/tickets/%s';

    /**
     * Ticket Id.
     *
     * @var int
     */
    protected $ticket_id;

    /**
     * This model is fillable.
     *
     * @var bool
     */
    protected $fillable = true;

    /**
     * This model's method that provides the data to fill it.
     *
     * @var string
     */
    protected $fill_method = 'get';

    /**
     * Constructor.
     *
     * @return void
     */
    public function __construct($ticket_id, $fill = [])
    {
        $this->ticket_id = $ticket_id;
        parent::__construct($ticket_id, $fill);
    }

    /**
     * Returns a Support Ticket under your Account.
     *
     * @link https://developers.linode.com/api/v4#operation/getTicket
     *
     * @return array
     */
    public function get()
    {
        return $this->apiCall('get', '', [], ['auto-fill' => true]);
    }

    /**
     * Returns a collection of replies to a Support Ticket on your Account.
     *
     * @link https://developers.linode.com/api/v4#operation/getTicketReplies
     *
     * @return array
     */
    public function getTicketReplies()
    {
        return $this->apiSearch($this->endpoint.'/replies', ['class' => 'Ticket\Replie', 'parameters' => ['id']]);
    }

    /**
     * Adds a file attachment to an existing Support Ticket on your Account. File attachments are used to assist our Support
     * team in resolving your Ticket. Examples of attachments are screen shots and text files that provide additional
     * information.
     *
     * @param int $ticket_id The ID of the Support Ticket.
     *
     * @link https://developers.linode.com/api/v4#operation/createTicketAttachment
     *
     * @return mixed
     */
    public function createTicketAttachment($optional = [])
    {
        return $this->apiCall('post', '/attachments', ['json' => array_merge([
            'ticket_id' => $ticket_id,
        ], $optional)]);
    }

    /**
     * Adds a reply to an existing Support Ticket.
     *
     * @param int $ticket_id The ID of the Support Ticket.
     *
     * @link https://developers.linode.com/api/v4#operation/createTicketReply
     *
     * @return mixed
     */
    public function createTicketReply($optional = [])
    {
        return $this->apiCall('post', '/replies', ['json' => array_merge([
            'ticket_id' => $ticket_id,
        ], $optional)]);
    }
}