# sendy/3.0.3/src/Repositories/Shops.php

Sendy, version 3.0.3. 36 lines.

- Page: https://pluginprobe.com/plugins/sendy/3.0.3/code/src/Repositories/Shops.php
- Raw: https://pluginprobe.com/plugins/sendy/3.0.3/raw/src/Repositories/Shops.php
- Modified: 2024-12-02T11:23:28+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/sendy/3.0.3/code/src/Repositories/Shops.php#L10-L20`.

```php
<?php

namespace Sendy\WooCommerce\Repositories;

class Shops extends Repository
{
    /**
     * Returns a map of shops
     *
     * The shops are stored in the transient for the duration of one hour. The results from the API are transformed to
     * a map of shops with the UUID as key and the name as value.
     *
     * @return array
     * @throws \GuzzleHttp\Exception\GuzzleException
     * @throws \Sendy\Api\ApiException
     */
    public function list(): array
    {
        $shops = get_transient('sendy_shops');

        if (! $shops) {
            $result = $this->connection->shop->list();

            $shops = [];

            foreach ($result as $shop) {
                $shops[$shop['uuid']] = $shop['name'];
            }

            set_transient('sendy_shops', $shops, 3600);
        }

        return $shops;
    }
}

```
