<?php

namespace stripe\endpoints;

use Exception;
use Stripe\Collection;
use Stripe\Exception\ApiErrorException;
use stripe\helpers\stripe_product;
use Stripe\Product;
use traits\stripe_endpoint_t;

class stripe_endpoint_product
{
    use stripe_endpoint_t;

    /**
     * Get all products
     * @return Collection
     * @throws ApiErrorException
     * @throws Exception
     */
    public function list(): Collection
    {
        return self::getClient()->products->all();
    }

    /**
     * Create a new product
     * @param stripe_product $product
     * @return Product
     * @throws ApiErrorException
     * @throws Exception
     */
    public function create(stripe_product $product): Product
    {
        return self::getClient()->products->create(
            $product->get()
        );
    }

    /**
     * Retrieve a product
     * @param string $id
     * @return Product
     * @throws ApiErrorException
     * @throws Exception
     */
    public function retrieve(string $id): Product
    {
        return self::getClient()->products->retrieve($id);
    }


}