Beispiel #1
0
        public static async Task <string> Authorization(IAuthAlfaCRM authAlfaCRM)
        {
            string url = authAlfaCRM.HostName + "/v2api/auth/login";

            string data = QueryGeneraterUtility.GetAuthAlfaCRMData(authAlfaCRM.Email, authAlfaCRM.ApiKey);

            int requestId = LogService.QueryLog.WriteRequest(data, (int)QueryType.Autorization, "Авторизация в системе AlfaCRM", authAlfaCRM.ServiceId);

            try
            {
                var responseString = await Send(url : url,   //"https://demo.s20.online/v2api/auth/login",
                                                data : data, //"{\"email\": \""+ authAlfaCRM.Email + "\" , \"api_key\": \"" + authAlfaCRM.ApiKey + "\" }",
                                                method : NetworkMethod.POST);

                LogService.QueryLog.WriteResponse(responseString, (int)QueryType.Autorization, "Авторизация в системе AlfaCRM", authAlfaCRM.ServiceId, requestId);

                var json = JObject.Parse(responseString);

                var tokenJson = json.GetValue("token");

                return(tokenJson.ToString().Trim('{', '}'));
            }
            catch (Exception e)
            {
                LogService.QueryLog.WriteResponse(e.Message, (int)QueryType.Autorization, "Ошибка авторизация в системе AlfaCRM", authAlfaCRM.ServiceId, requestId);
                throw e;
            }
        }
Beispiel #2
0
        public static async Task <string> GetCustomes(string customer_id, IAuthAlfaCRM auth, string token)
        {
            string url = auth.HostName + "/v2api/" + auth.Branch + "/customer/index";

            var data = new
            {
                id   = customer_id,
                page = 0
            };

            string json = JsonConvert.SerializeObject(data);

            string response = await SendAlfaCRM(url, token, json, NetworkMethod.POST);

            return(response);
        }
Beispiel #3
0
        public static async Task <String> UpdateCustomer(string id, string token, decimal balance, IAuthAlfaCRM auth)
        {
            string url = auth.HostName + "/v2api/1/customer/update?id=" + id;

            var data = new
            {
                balance = balance.ToString().Replace(',', '.')
            };

            string json = JsonConvert.SerializeObject(data);

            string response = await SendAlfaCRM(url, token, json, NetworkMethod.POST);

            return(response);
        }