/// <summary> /// Creates a new subscription with Salesforce specific authentication /// </summary> /// <param name="publishToUrl">URL to receive HTTP post</param> /// <param name="salesforce">The Salesforce authenatication parameters</param> /// <param name="vehicleId">Optional if you want only to subscribe to a specific vehicle</param> /// <returns></returns> public void EditPublishSubscribe(int publishSubscribeId, string publishToUrl, PublishSubscribeAuthenticationData_Salesforce salesforce, int?vehicleId = null) { PublishSubscribeEditModel model = CreatePublishSubscribeEditModel(publishToUrl, ApiPublishSubscribeAuthenticationType.Salesforce, vehicleId); model.AuthenticationData = Newtonsoft.Json.JsonConvert.SerializeObject(salesforce); EditPublishSubscribe(publishSubscribeId, model); }
/// <summary> /// Creates a new subscription with basic authentication (username and password) /// </summary> /// <param name="publishToUrl">URL to receive HTTP post</param> /// <param name="basicUsernamePassword">The username and password information for the basic authentication</param> /// <param name="vehicleId">Optional if you want only to subscribe to a specific vehicle</param> /// <returns></returns> public void EditPublishSubscribe(int publishSubscribeId, string publishToUrl, PublishSubscribeAuthenticationData_Basic basicUsernamePassword, int?vehicleId = null) { PublishSubscribeEditModel model = CreatePublishSubscribeEditModel(publishToUrl, ApiPublishSubscribeAuthenticationType.BasicUsernameAndPassword, vehicleId); model.AuthenticationData = Newtonsoft.Json.JsonConvert.SerializeObject(basicUsernamePassword); EditPublishSubscribe(publishSubscribeId, model); }
/// <summary> /// Creates a new subscription with bearer token authentication /// </summary> /// <param name="publishToUrl">URL to receive HTTP post</param> /// <param name="bearerToken">The bearer token</param> /// <param name="vehicleId">Optional if you want only to subscribe to a specific vehicle</param> /// <returns></returns> public void EditPublishSubscribe(int publishSubscribeId, string publishToUrl, PublishSubscribeAuthenticationData_Bearer bearerToken, int?vehicleId = null) { PublishSubscribeEditModel model = CreatePublishSubscribeEditModel(publishToUrl, ApiPublishSubscribeAuthenticationType.BearerToken, vehicleId); model.AuthenticationData = Newtonsoft.Json.JsonConvert.SerializeObject(bearerToken); EditPublishSubscribe(publishSubscribeId, model); }
private void EditPublishSubscribe(int publishSubscribeId, PublishSubscribeEditModel model) { string stringPayload = JsonConvert.SerializeObject(model); var content = new StringContent(stringPayload, Encoding.UTF8, "application/json"); var response = client.PutAsync($"/v1/resourceowner/publishsubscribe/{publishSubscribeId}", content).Result; response.EnsureSuccessStatusCodeWithProperExceptionMessage(); }
private PublishSubscribeEditModel CreatePublishSubscribeEditModel(string publishToUrl, ApiPublishSubscribeAuthenticationType authType, int?vehicleId = null) { PublishSubscribeEditModel model = new PublishSubscribeEditModel(); model.PublishToUrl = publishToUrl; model.AuthenticationType = authType; model.VehicleId = vehicleId; model.PublishType = ApiPublishType.JsonDefault; return(model); }
/// <summary> /// Creates a new subscription with anonymous authentication /// </summary> /// <param name="publishToUrl">URL to receive HTTP post</param> /// <param name="vehicleId">Optional if you want only to subscribe to a specific vehicle</param> /// <returns></returns> public void EditPublishSubscribe(int publishSubscribeId, string publishToUrl, int?vehicleId = null) { PublishSubscribeEditModel model = CreatePublishSubscribeEditModel(publishToUrl, ApiPublishSubscribeAuthenticationType.NoneAnonymous, vehicleId); EditPublishSubscribe(publishSubscribeId, model); }