Ejemplo n.º 1
0
        public Result <string> BatchAddTerminalToGroup(TerminalGroupRequest batchAddTerminalToGroupRequest)
        {
            List <string> validationErrs = new List <string>();

            if (batchAddTerminalToGroupRequest == null)
            {
                validationErrs.Add(GetMsgByKey("parameterBatchAddTerminalToGroupRequestNull"));
                return(new Result <string>(validationErrs));
            }
            RestRequest request     = new RestRequest(ADD_TERMINAL_TO_GROUP_URL, Method.POST);
            var         requestJson = JsonConvert.SerializeObject(batchAddTerminalToGroupRequest);

            request.AddParameter(Constants.CONTENT_TYPE_JSON, requestJson, ParameterType.RequestBody);
            string          responseContent = Execute(request);
            EmptyResponse   emptyResponse   = JsonConvert.DeserializeObject <EmptyResponse>(responseContent);
            Result <string> result          = new Result <string>(emptyResponse);

            return(result);
        }
        public void TestBatchAddTerminalToGroup()
        {
            TerminalGroupRequest request  = new TerminalGroupRequest();
            HashSet <long>       groupIds = new HashSet <long>();

            groupIds.Add(1);
            groupIds.Add(2);

            HashSet <long> terminalIds = new HashSet <long>();

            terminalIds.Add(1);
            terminalIds.Add(2);

            request.GroupIds    = groupIds;
            request.TerminalIds = terminalIds;
            Result <string> result = API.BatchAddTerminalToGroup(request);

            _logger.DebugFormat("Result=\n{0}", JsonConvert.SerializeObject(result));
            Assert.AreEqual(result.BusinessCode, 0);
        }