<?php

namespace AsyncAws\Iot\ValueObject;

/**
 * Thing group properties.
 */
final class ThingGroupProperties
{
    /**
     * The thing group description.
     *
     * @var string|null
     */
    private $thingGroupDescription;

    /**
     * The thing group attributes in JSON format.
     *
     * @var AttributePayload|null
     */
    private $attributePayload;

    /**
     * @param array{
     *   thingGroupDescription?: string|null,
     *   attributePayload?: AttributePayload|array|null,
     * } $input
     */
    public function __construct(array $input)
    {
        $this->thingGroupDescription = $input['thingGroupDescription'] ?? null;
        $this->attributePayload = isset($input['attributePayload']) ? AttributePayload::create($input['attributePayload']) : null;
    }

    /**
     * @param array{
     *   thingGroupDescription?: string|null,
     *   attributePayload?: AttributePayload|array|null,
     * }|ThingGroupProperties $input
     */
    public static function create($input): self
    {
        return $input instanceof self ? $input : new self($input);
    }

    public function getAttributePayload(): ?AttributePayload
    {
        return $this->attributePayload;
    }

    public function getThingGroupDescription(): ?string
    {
        return $this->thingGroupDescription;
    }

    /**
     * @internal
     */
    public function requestBody(): array
    {
        $payload = [];
        if (null !== $v = $this->thingGroupDescription) {
            $payload['thingGroupDescription'] = $v;
        }
        if (null !== $v = $this->attributePayload) {
            $payload['attributePayload'] = $v->requestBody();
        }

        return $payload;
    }
}
