Example #1
0
        /// <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 PublishSubscribeModel CreatePublishSubscribe(string publishToUrl, PublishSubscribeAuthenticationData_Salesforce salesforce, int?vehicleId = null)
        {
            PublishSubscribeCreateModel model = CreatePublishSubscribeCreateModel(publishToUrl, ApiPublishSubscribeAuthenticationType.Salesforce, vehicleId);

            model.AuthenticationData = Newtonsoft.Json.JsonConvert.SerializeObject(salesforce);
            return(CreatePublishSubscribe(model));
        }
Example #2
0
        /// <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 PublishSubscribeModel CreatePublishSubscribe(string publishToUrl, PublishSubscribeAuthenticationData_Basic basicUsernamePassword, int?vehicleId = null)
        {
            PublishSubscribeCreateModel model = CreatePublishSubscribeCreateModel(publishToUrl, ApiPublishSubscribeAuthenticationType.BasicUsernameAndPassword, vehicleId);

            model.AuthenticationData = Newtonsoft.Json.JsonConvert.SerializeObject(basicUsernamePassword);
            return(CreatePublishSubscribe(model));
        }
Example #3
0
        /// <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 PublishSubscribeModel CreatePublishSubscribe(string publishToUrl, PublishSubscribeAuthenticationData_Bearer bearerToken, int?vehicleId = null)
        {
            PublishSubscribeCreateModel model = CreatePublishSubscribeCreateModel(publishToUrl, ApiPublishSubscribeAuthenticationType.BearerToken, vehicleId);

            model.AuthenticationData = Newtonsoft.Json.JsonConvert.SerializeObject(bearerToken);
            return(CreatePublishSubscribe(model));
        }
Example #4
0
        private PublishSubscribeCreateModel CreatePublishSubscribeCreateModel(string publishToUrl, ApiPublishSubscribeAuthenticationType authType,
                                                                              int?vehicleId = null)
        {
            PublishSubscribeCreateModel model = new PublishSubscribeCreateModel();

            model.PublishToUrl       = publishToUrl;
            model.AuthenticationType = authType;
            model.VehicleId          = vehicleId;
            model.PublishType        = ApiPublishType.JsonDefault;

            return(model);
        }
Example #5
0
        private PublishSubscribeModel CreatePublishSubscribe(PublishSubscribeCreateModel model)
        {
            string stringPayload = JsonConvert.SerializeObject(model);
            var    content       = new StringContent(stringPayload, Encoding.UTF8, "application/json");
            var    response      = client.PostAsync($"/v1/resourceowner/publishsubscribe", content).Result;

            response.EnsureSuccessStatusCodeWithProperExceptionMessage();
            var urlToCreatedPublishSubscribe = response.Headers.GetValues("Location").First();
            var publishSubscribeModel        = client.GetAsync(urlToCreatedPublishSubscribe).Result;

            publishSubscribeModel.EnsureSuccessStatusCodeWithProperExceptionMessage();
            return(JsonConvert.DeserializeObject <PublishSubscribeModel>(publishSubscribeModel.Content.ReadAsStringAsync().Result));
        }
Example #6
0
        /// <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 PublishSubscribeModel CreatePublishSubscribe(string publishToUrl, int?vehicleId = null)
        {
            PublishSubscribeCreateModel model = CreatePublishSubscribeCreateModel(publishToUrl, ApiPublishSubscribeAuthenticationType.NoneAnonymous, vehicleId);

            return(CreatePublishSubscribe(model));
        }