<?php
namespace wechat\models;

use Yii;

class GroupApi extends BaseApi
{
    public $apiUrl = 'group';

    /**
     * @param array $data
     * @return array
     */
    public function getList($data)
    {
        $result = $this->post($this->apiUrl . '/list', $data);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data'], $result['message']);
        } else {
            return $this->returnArray(0, [], $result['message']);
        }
    }
    
    /**
     * @param array $data
     * @return array
     */
    public function getCurrentGroup($data)
    {
        $result = $this->post($this->apiUrl . '/get-current-group', $data);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data'], $result['message']);
        } else {
            return $this->returnArray(0, [], $result['message']);
        }
    }
    
    /**
     * @param array $data
     * @return array
     */
    public function save($data)
    {
        $result = $this->post($this->apiUrl . '/save', $data);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data'], $result['message']);
        } else {
            return $this->returnArray(0, [], $result['message']);
        }
    }
    
    /**
     * @param array $data
     * @return array
     */
    public function getGroupById($data)
    {
        $result = $this->post($this->apiUrl . '/get-group-by-id', $data);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data'], $result['message']);
        } else {
            return $this->returnArray(0, [], $result['message']);
        }
    }
    
    /**
     * @param array $data
     * @return array
     */
    public function deleteGroup($data)
    {
        $result = $this->post($this->apiUrl . '/delete', $data);
        if ($result['code'] == 1) {
            return $this->returnArray(1, $result['data'], $result['message']);
        } else {
            return $this->returnArray(0, [], $result['message']);
        }
    }
}

