Ejemplo n.º 1
0
        public Silanis.ESL.API.CustomField CreateCustomField(Silanis.ESL.API.CustomField apiField)
        {
            string path = template.UrlFor(UrlTemplate.ACCOUNT_CUSTOMFIELD_PATH).Build();

            try
            {
                string stringResponse;
                if (DoesCustomFieldExist(apiField.Id))
                {
                    stringResponse = client.Put(path, JsonConvert.SerializeObject(apiField, settings));
                }
                else
                {
                    stringResponse = client.Post(path, JsonConvert.SerializeObject(apiField, settings));
                }

                return(JsonConvert.DeserializeObject <Silanis.ESL.API.CustomField>(stringResponse));
            }
            catch (EslServerException e)
            {
                throw new EslServerException("Could not add/update the custom field to account." + " Exception: " + e.Message, e.ServerError, e);
            }
            catch (Exception e)
            {
                throw new EslException("Could not add/update the custom field to account." + " Exception: " + e.Message, e);
            }
        }
Ejemplo n.º 2
0
     public Account AddCustomField(CustomField value)
 {
     if (value == null)
     {
         throw new ArgumentNullException("Argument cannot be null");
     }
     
     _customFields.Add(value);
     return this;
 }
Ejemplo n.º 3
0
        /**
         * Builds the custom field
         *
         * @return the custom field
         */
        public CustomField Build() {
            CustomField customField = new CustomField();
            
            customField.Id = id;
            customField.Value = value;
            customField.Required = required;
            customField.AddTranslations(translations);

            return customField;
        }
Ejemplo n.º 4
0
        internal static CustomFieldBuilder CustomField(Silanis.ESL.API.CustomField apiCustomField)
        {
            CustomFieldBuilder result = new CustomFieldBuilder();

            result.WithId(apiCustomField.Id)
            .WithDefaultValue(apiCustomField.Value);

            foreach (Silanis.ESL.API.Translation tran in apiCustomField.Translations)
            {
                result.WithTranslation(TranslationBuilder.NewTranslation(tran));
            }
            return(result);
        }
Ejemplo n.º 5
0
     ///
      /// Create an account custom field.
      /// If the custom field already existed then update it.
      ///
      /// @param customField
      /// @return the custom field added created or updated
      /// @throws com.silanis.esl.sdk.EslException
      ///
     public CustomField CreateCustomField(CustomField customField ) {
         string path = template.UrlFor(UrlTemplate.ACCOUNT_CUSTOMFIELD_PATH).Build();
         
         CustomField sdkResponse = null;
         Silanis.ESL.API.CustomField apiResponse;
         Silanis.ESL.API.CustomField apiRequest;
 
         try {
             apiRequest = customField.toAPICustomField();
             string stringResponse;
             if ( DoesCustomFieldExist( customField.Id )){
                 stringResponse = client.Put(path,JsonConvert.SerializeObject(apiRequest, settings));
             }else{
                 stringResponse = client.Post(path,JsonConvert.SerializeObject(apiRequest, settings));
             }
             
             apiResponse = JsonConvert.DeserializeObject<Silanis.ESL.API.CustomField>(stringResponse);
             sdkResponse = CustomFieldBuilder.CustomField( apiResponse ).Build();
             return sdkResponse;
         } catch ( Exception e ) {
             throw new EslException( "Could not add/update the custom field to account." + e.Message );
         }
     }
Ejemplo n.º 6
0
 /// <summary>
 /// Get an account custom field.
 /// </summary>
 /// <returns>The account custom field.</returns>
 /// <param name="id">Id of custom field to get.</param>
 public CustomField GetCustomField(string id)
 {
     Silanis.ESL.API.CustomField apiCustomField = apiClient.GetCustomField(id);
     return(new CustomFieldConverter(apiCustomField).ToSDKCustomField());
 }
Ejemplo n.º 7
0
        /**
         * Builds the custom field
         *
         * @return the custom field
         */
        public CustomField Build() {
			Support.LogMethodEntry();
            CustomField customField = new CustomField();
            
            customField.Id = id;
            customField.Value = value;
            customField.Required = required;
            customField.AddTranslations(translations);
			Support.LogMethodExit(customField);
            return customField;
        }
Ejemplo n.º 8
0
		///
		/// Create an account custom field.
		/// If the custom field already existed then update it.
		///
		/// @param customField
		/// @return the custom field added created or updated
		/// @throws com.silanis.esl.sdk.EslException
		///
		public CustomField CreateCustomField(CustomField customField)
		{
            Silanis.ESL.API.CustomField apiCustomField = new CustomFieldConverter( customField ).ToAPICustomField();
            apiCustomField = apiClient.CreateCustomField( apiCustomField );
            return new CustomFieldConverter(apiCustomField).ToSDKCustomField();
		}