<?php

namespace App\Services\Vendor\Xunfei;

/**
 * 讯飞基类
 */
class Voice2Text
{
    public const BASE_URI = 'https://raasr.xfyun.cn/api/';
    /**
     * 发送请求对象
     */
    private $httpClient;

    /**
     * 构造方法
     */
    public function __construct()
    {
        $this->httpClient = new HttpBase(self::BASE_URI);
    }

    /**
     * 预处理方法
     */
    public function prepare($extData)
    {
        return $this->httpClient->postForm('prepare', $extData);
    }

    /**
     * 上传方法
     */
    public function upload($extData)
    {
        return $this->httpClient->postMulti('upload', $extData);
    }

    /**
     * 合并方法
     */
    public function merge($taskId)
    {
        $extData = [
            'task_id' => $taskId,
        ];

        return $this->httpClient->postForm('merge', $extData);
    }

    /**
     * 预处理方法
     */
    public function getProgress($taskId)
    {
        $extData = [
            'task_id' => $taskId,
        ];

        return $this->httpClient->postForm('getProgress', $extData);
    }

    /**
     * 预处理方法
     */
    public function getResult($taskId)
    {
        $extData = [
            'task_id' => $taskId,
        ];

        return $this->httpClient->postForm('getResult', $extData);
    }
}
