<?php
namespace backend\models;

class SmsApi extends BaseApi
{
    public $apiUrl = 'sms';

    /**
     * @param string $mobile
     * @return array
     */
    public function sendCode($mobile)
    {
        $result = $this->get($this->apiUrl . '/send-code', ['mobile' => $mobile]);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data'], '验证码发送成功');
        } else {
            return $this->returnArray(0, [], '验证码发送失败');
        }
    }

    /**
     * @param string $mobile
     * @return array
     */
    public function getCode($mobile)
    {
        $result = $this->get($this->apiUrl . '/get-code', ['mobile' => $mobile]);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data'], '获取验证码成功');
        } else {
            return $this->returnArray(0, [], '获取验证码失败');
        }
    }
}