<?php

namespace stripe\endpoints;

use Exception;
use Stripe\Collection;
use Stripe\Exception\ApiErrorException;
use stripe\helpers\stripe_price;
use traits\stripe_endpoint_t;

class stripe_endpoint_prices
{
    use stripe_endpoint_t;

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

    /**
     * @throws ApiErrorException
     * @throws Exception
     */
    public function create(stripe_price $stripe_price): \Stripe\Price
    {
        return self::getClient()->prices->create([
            'unit_amount' => $stripe_price->getUnitAmount(),
            'currency' => $stripe_price->getCurrency(),
            'product' => $stripe_price->getProductID(),
        ]);
    }

    /**
     * @throws ApiErrorException
     * @throws Exception
     */
    public function retrieve(string $id): \Stripe\Price
    {
        return self::getClient()->prices->retrieve($id);
    }


}