/// <summary> /// Explicitly provides keys /// </summary> /// <param name="uaAppKey">Required UA provided app key</param> /// <param name="uaAppMAsterSecret">Required UA provided app secret</param> /// <param name="host">Optionally override the host url (to use with traffic inspector or proxy forwarder when debugging for example)</param> public static ServiceModelConfig Create(String uaAppKey, String uaAppMAsterSecret, String host = null) { if (string.IsNullOrEmpty(uaAppKey)) { throw new ArgumentException("uaAppKey is required"); } if (string.IsNullOrEmpty(uaAppMAsterSecret)) { throw new ArgumentException("uaAppMAsterSecret is required"); } var auth = String.Format("{0}:{1}", uaAppKey, uaAppMAsterSecret); auth = Convert.ToBase64String(Encoding.ASCII.GetBytes(auth)); var cf = new ServiceModelConfig(host); cf.SerializerSettings.Converters.Add(new StringEnumConverter { CamelCaseText = true }); cf.SerializerSettings.NullValueHandling = NullValueHandling.Ignore; //cf.SerializerSettings.DefaultValueHandling = DefaultValueHandling.Ignore; cf.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc; cf.SerializerSettings.DateParseHandling = DateParseHandling.DateTime; cf.SerializerSettings.DateFormatHandling = DateFormatHandling.IsoDateFormat; cf.SerializerSettings.DateFormatString = "yyyy-MM-ddTH:mm:ss"; cf.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", auth); cf.HttpClient.DefaultRequestHeaders.TryAddWithoutValidation("Accept", "application/vnd.urbanairship+json; version=3;"); return(cf); }
/// <summary> /// Create a new gateway object utilizng a given key set. /// </summary> /// <param name="appKey">Application Key</param> /// <param name="appMasterSecret">Application Master Secret</param> public UrbanAirSharpGateway(string appKey, string appMasterSecret) { //UA has updated their endpoints to only allow TLS12 and TLS 11 connections, SSL 3 no longer works ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls; XmlConfigurator.Configure(); ServiceModelConfig.Create(appKey, appMasterSecret); }
/// <summary> /// Create a new gateway object utilizng a given key set. /// </summary> /// <param name="appKey">Application Key</param> /// <param name="appMasterSecret">Application Master Secret</param> public UrbanAirSharpGateway(string appKey, string appMasterSecret) { XmlConfigurator.Configure(); ServiceModelConfig.Create(appKey, appMasterSecret); }
public UrbanAirSharpGateway(String appKey, String appMasterSecret) { ServiceModelConfig.Create(appKey, appMasterSecret); }
public UrbanAirSharpGateway(ServiceModelConfig cfg) { _cfg = cfg; }
public UrbanAirSharpGateway(String appKey, String appMasterSecret, String host = null) : this(ServiceModelConfig.Create(appKey, appMasterSecret, host)) { }