添加客服帐号
@param array $account
@return bool
@throws \yii\web\HttpException
320553
public function addAccount(array $account)
    {
        $result = $this->wechat->httpRaw(self::WECHAT_ACCOUNT_ADD_PREFIX, $account, [
            'access_token' => $this->wechat->getAccessToken()
        ]);
        return isset($result['errmsg']) && $result['errmsg'] == 'ok';
    }
721395
public function multiAccountImport($accounts)
    {
        $request = new MultiAccountImportRequest($accounts);
        $response = new MultiAccountImportResponse();
        return $this->client->sendRequest($request, $response);
    }
1363361
public function create(string $account, string $openid)
    {
        $params = [
            'kf_account' => $account,
            'openid' => $openid,
        ];

        return $this->httpPostJson('customservice/kfsession/create', $params);
    }
1008552
public function activate($activate = [])
    {
        if (empty($activate) || !is_array($activate)) {
            $this->setError('参数错误');

            return false;
        }

        $queryStr = $activate;

        $this->apitype = 'card';
        $this->module  = 'membercard';
        $res           = $this->_post('activate', $queryStr);

        return $res;
    }
823216
public function addPage(array $data)
    {
        $result = $this->wechat->httpRaw(self::WECHAT_PAGE_ADD_PREFIX, $data, [
            'access_token' => $this->wechat->getAccessToken()
        ]);
        return isset($result['errcode']) && !$result['errcode'] ? $result['data'] : false;
    }
1033524
private function loadAccountsAndUser()
    {
        if (!$this->accounts_and_user_loaded) {
            $email_address = $this->getEmailAddress();
            $password = $this->getPassword();

            if (empty($email_address) || empty($password)) {
                throw new Authentication('Email address and password are required');
            }

            $response = $this->getConnector()->post('https://my.activecollab.com/api/v1/external/login', null, [
                'email' => $this->getEmailAddress(),
                'password' => $this->getPassword(),
            ]);

            if ($response instanceof ResponseInterface) {
                if ($response->isJson()) {
                    $result = $response->getJson();

                    if (empty($result['is_ok'])) {
                        if (empty($result['message'])) {
                            throw new ListAccounts();
                        } else {
                            throw new ListAccounts($result['message']);
                        }
                    } elseif (empty($result['user']) || empty($result['user']['intent'])) {
                        throw new ListAccounts('Invalid response');
                    } else {
                        $this->accounts = $this->all_accounts = [];

                        if (!empty($result['accounts']) && is_array($result['accounts'])) {
                            foreach ($result['accounts'] as $account) {
                                $this->all_accounts[] = $account;

                                if ($account['class'] == 'FeatherApplicationInstance' || $account['class'] == 'ActiveCollab\Shepherd\Model\Account\ActiveCollab\FeatherAccount') {
                                    $account_id = (integer) $account['name'];

                                    $this->accounts[$account_id] = [
                                        'id' => (integer) $account['name'],
                                        'name' => $account['display_name'],
                                        'url' => $account['url'],
                                    ];
                                }
                            }
                        }

                        $this->intent = $result['user']['intent'];
                        unset($result['user']['intent']);
                        $this->user = $result['user'];
                    }
                } else {
                    throw new Authentication(
                        sprintf(
                            'Invalid response. JSON expected, got "%s", status code "%s"',
                            $response->getContentType(),
                            $response->getHttpCode()
                        )
                    );
                }
            } else {
                throw new Authentication('Invalid response');
            }
        }
    }
865211
protected function getAccountId($account)
    {
        if($account instanceof Account){
            if(!empty($account->id)){
                $id = $account->id;
            } elseif(!empty($account->domain)){
                $id = $this->api->searchAccountId($account->domain);
            } else {
                throw new YouHostingException("You need to provide either an account ID (recommended) or account domain to search for");
            }
        } elseif(is_numeric($account)){
            $id = $account;
        } else {
            $id = $this->api->searchAccountId($account);
        }

        return (int)$id;
    }
1321950
public function push($amount = null, $number = null, $reference = null, $command = null, $account = null)
    {
        $account = $account ?: $this->account;
        $configs = (new ConfigurationRepository)->useAccount($account);

        if (!$configs->getAccountKey('sandbox')) {
            throw new ErrorException('Cannot simulate a transaction in the live environment.');
        }

        $shortCode = $configs->getAccountKey('lnmo.shortcode');

        $body = [
            'CommandID'     => $command ?: $this->command,
            'Amount'        => $amount ?: $this->amount,
            'Msisdn'        => $number ?: $this->number,
            'ShortCode'     => $shortCode,
            'BillRefNumber' => $reference ?: $this->reference,
        ];

        try {
            $response = $this->makeRequest(
                $body,
                Core::instance()->getEndpoint(MPESA_SIMULATE, $account),
                $account
            );

            return json_decode($response->getBody());
        } catch (RequestException $exception) {
            return json_decode($exception->getResponse()->getBody());
        }
    }
115703
public function addKFAccount($account,$nickname,$password){
        $data=array(
            "kf_account" =>$account,
            "nickname" => $nickname,
            "password" => md5($password)
        );
        if (!$this->access_token && !$this->checkAuth()) return false;
        $result = $this->http_post(self::API_BASE_URL_PREFIX.self::CS_KF_ACCOUNT_ADD_URL.'access_token='.$this->access_token,self::json_encode($data));
        if ($result)
        {
            $json = json_decode($result,true);
            if (!$json || !empty($json['errcode'])) {
                $this->errCode = $json['errcode'];
                $this->errMsg = $json['errmsg'];
                return false;
            }
            return $json;
        }
        return false;
    }
953396
public function update(array $account)
    {
        if(!isset($account['account_id'])) {
            throw new MonetivoException('$account["account_id"] is required');
        }

        $id = $account['account_id'];
        unset($account['account_id']);
        $account['id'] = $id;

        return $this->merchantApi->call('put', 'accounts/' . $id, [
            'form_params' => $account
        ])->toArray();
    }
806720
protected function write(array $record)
    {
        if ($record['level'] < Logger::ERROR) {
            return false;
        }

        if (isset($record['context']['exception'])
            && ($record['context']['exception'] instanceof NotFoundHttpException
                || $record['context']['exception'] instanceof AccessDeniedHttpException
                || $record['context']['exception'] instanceof ResourceNotFoundException)
        ) {
            return false;
        }

        $msg = '';
        if ($this->server->get('HTTP_HOST') && $this->server->get('REQUEST_URI')) {
            $scheme = $this->httpScheme ? $this->httpScheme : $this->server->get('REQUEST_SCHEME');
            if (is_null($scheme)) {
                $https = $this->server->get('HTTPS');
                $scheme = (empty($https) || 'off' === $https) ? 'http' : 'https';
            }
            $host = $this->httpHost ? $this->httpHost : $this->server->get('HTTP_HOST');
            if (false !== idn_to_utf8($host)) {
                $host = idn_to_utf8($host);
            }

            $msg = sprintf('Request url: %s://%s%s<br/>', $scheme, $host, $this->server->get('REQUEST_URI'));
        }

        if ($this->post->count() > 0 || $this->get->count() > 0) {
            $data = array_merge($this->post->all(), $this->get->all());
            $msg .= "Request data: " . json_encode($data) . "<br>";
        }

        if (isset($record['message'])) {
            $msg .= $record['message'];
            $this->hipchat->message_room($this->room, $this->name, $msg, true);

            return true;
        }

        return false;
    }
1086306
public function addAccount($kf_account, $nickname)
    {
        $data = ['kf_account' => $kf_account, 'nickname' => $nickname];
        $url = "https://api.weixin.qq.com/customservice/kfaccount/add?access_token=ACCESS_TOKEN";
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->httpPostForJson($url, $data);
    }
830299
protected function isAdmin(AccountInterface $account)
    {
        /** @var Model $resource */
        if ($this->isAuthenticated($account) === true) {
            /** @var User $user */
            $user    = $account->user();
            $isAdmin = $user->hasRole(Role::ENUM_ROLE_ADMIN_ID);

            return $isAdmin;
        }

        return false;
    }
961858
public function addProduct(array $data)
    {
        $result = $this->wechat->httpRaw(self::WECHAT_PRODUCT_ADD_PREFIX, $data, [
            'access_token' => $this->wechat->getAccessToken()
        ]);
        return isset($result['errmsg']) && $result['errmsg'] == 'success' ? $result['product_id'] : false;
    }
413516
public function editAccountAction(Account $account)
    {
        $this->view->assignMultiple([
            'account' => $account,
            'user' => $this->userService->getUser($account->getAccountIdentifier(), $account->getAuthenticationProviderName())
        ]);
    }
1114379
public function add(array $data)
    {
        $data = &$this->loadFilterData($data);
        if ( $data == false ) {
            return false;
        }
        if ( !isset($data[$this->primaryKey]) && $this->autoPrimary ) {
            $data[$this->primaryKey] = StringUtils::genGlobalUid();
        }

        $result = $this->db->insert($this->table, $data);
        if ( $result === true ) { //非自增ID
            $result = $data[$this->primaryKey];
        }

        return $result;
    }
1045390
public function setService($account = null) {
        if (!empty($account)) {
            $this->setData('TransInfo', [
                'KfAccount' => [
                    '@cdata' => $account
                ]
            ]);
        }
        return $this->setType(MessageEnum::Service);
    }