public void TestCreateEntityAttribute() { EntityAttributeCreateRequest request = new EntityAttributeCreateRequest(); request.EntityType = EntityAttributeType.Reseller; request.Key = "test"; request.MaxLength = 12; request.MinLength = 1; request.Required = false; request.InputType = EntityAttributeInputType.Text; request.DefaultLabel = "test"; Result <EntityAttribute> result = API.CreateEntityAttribute(request); _logger.DebugFormat("Result=\n{0}", JsonConvert.SerializeObject(result)); Assert.AreEqual(result.BusinessCode, 0); }
public Result <EntityAttribute> CreateEntityAttribute(EntityAttributeCreateRequest entityAttributeCreateRequest) { List <string> validationErrs = new List <string>(); if (entityAttributeCreateRequest == null) { validationErrs.Add(GetMsgByKey("parameterEntityAttributeCreateRequestNull")); } if (validationErrs.Count > 0) { return(new Result <EntityAttribute>(validationErrs)); } RestRequest request = new RestRequest(CREATE_ENTITY_ATTRIBUTES_URL, Method.POST); var requestJson = JsonConvert.SerializeObject(entityAttributeCreateRequest); request.AddParameter(Constants.CONTENT_TYPE_JSON, requestJson, ParameterType.RequestBody); string responseContent = Execute(request); EntityAttributeResponse entityAttributeResponse = JsonConvert.DeserializeObject <EntityAttributeResponse>(responseContent); Result <EntityAttribute> result = new Result <EntityAttribute>(entityAttributeResponse); return(result); }