<?php
namespace WPT\Cf7Divi\Cf7;

use WP_REST_Request;
use WP_REST_Response;

/**
 * Api.
 */
class Api
{
    protected $container;

    /**
     * Constructor.
     */
    public function __construct( $container )
    {
        $this->container = $container;
    }

    /**
     * Get a list of "Contact Form 7"
     */
    public function forms( WP_REST_Request $request )
    {
        $data = [];

        $forms = $this->container['cf7_post_type']->get_forms();

        foreach($forms as $id => $form_name) {
            $data[$id] = ['label' => $form_name];
        }

        return new WP_REST_Response( $data, 200 );
    }
}
