Пример #1
0
        public void CreateDataExtension(string dataExtensionTemplateObjectId,
                                        string externalKey,
                                        string name,
                                        HashSet <string> fields)
        {
            var de = new ExactTargetApi.DataExtension
            {
                Client = _config.ClientId.HasValue ? new ClientID {
                    ID = _config.ClientId.Value, IDSpecified = true
                } : null,
                Name        = name,
                CustomerKey = externalKey,
                Template    = new DataExtensionTemplate {
                    ObjectID = dataExtensionTemplateObjectId
                },
                Fields = fields.Select(field => new DataExtensionField
                {
                    Name               = field,
                    FieldType          = DataExtensionFieldType.Text,
                    FieldTypeSpecified = true,
                }).ToArray(),
            };

            string requestId, status;
            var    result = _client.Create(new CreateOptions(), new APIObject[] { de }, out requestId, out status);

            ExactTargetResultChecker.CheckResult(result.FirstOrDefault()); //we expect only one result because we've sent only one APIObject
        }
        public void CreateDataExtension(string dataExtensionTemplateObjectId,
                                           string externalKey,
                                           string name,
                                           HashSet<string> fields)
        {
            var de = new ExactTargetApi.DataExtension
            {
                Client = _config.ClientId.HasValue ? new ClientID { ID = _config.ClientId.Value, IDSpecified = true } : null,
                Name = name,
                CustomerKey = externalKey,
                Template = new DataExtensionTemplate { ObjectID = dataExtensionTemplateObjectId },
                Fields = fields.Select(field => new DataExtensionField
                {
                    Name = field,
                    FieldType = DataExtensionFieldType.Text,
                    FieldTypeSpecified = true,
                }).ToArray(),
            };

            string requestId, status;
            var result = _client.Create(new CreateOptions(), new APIObject[] { de }, out requestId, out status);

            ExactTargetResultChecker.CheckResult(result.FirstOrDefault()); //we expect only one result because we've sent only one APIObject
        }