コード例 #1
0
        /// <summary>
        /// Creates or updates a contact entity based on the entity's current email.
        /// </summary>
        /// <param name="originalEmail">The email the server knows, assuming the entity email may be different.</param>
        /// <param name="entity">The contact entity to update on the server.</param>
        /// <returns>The updated entity (with ID set)</returns>
        public ContactHubSpotModel CreateOrUpdate(string originalEmail, ContactHubSpotModel entity)
        {
            CreateOrUpdateContactTransportModel transport = new CreateOrUpdateContactTransportModel(entity);
            string path = GetRoute <ContactHubSpotModel>("contact", "createOrUpdate", "email", originalEmail);

            return(_client.Execute <ContactHubSpotModel, CreateOrUpdateContactTransportModel>(path, transport, Method.POST));
        }
コード例 #2
0
        /// <summary>
        /// Creates or updates a contact entity based on the entity's current email.
        /// </summary>
        /// <param name="originalEmail">The email the server knows, assuming the entity email may be different.</param>
        /// <param name="entity">The contact entity to update on the server.</param>
        /// <returns>The updated entity (with ID set)</returns>
        public Task <ContactHubSpotModel> CreateOrUpdateAsync(string originalEmail, ContactHubSpotModel entity, CancellationToken cancellationToken = default)
        {
            CreateOrUpdateContactTransportModel transport = new CreateOrUpdateContactTransportModel(entity);
            string path = GetRoute <ContactHubSpotModel>("contact", "createOrUpdate", "email", originalEmail);

            return(_client.ExecuteAsync <ContactHubSpotModel, CreateOrUpdateContactTransportModel>(path, transport, Method.POST, cancellationToken));
        }
コード例 #3
0
        /// <summary>
        /// Creates a contact entity
        /// </summary>
        /// <typeparam name="T">Implementation of ContactHubSpotModel</typeparam>
        /// <param name="entity">The entity</param>
        /// <returns>The created entity (with ID set)</returns>
        /// <exception cref="NotImplementedException"></exception>
        public ContactHubSpotModel Create(ContactHubSpotModel entity)
        {
            CreateOrUpdateContactTransportModel transport = new CreateOrUpdateContactTransportModel(entity);
            string path = GetRoute <ContactHubSpotModel>("contact");

            return(_client.Execute <ContactHubSpotModel, CreateOrUpdateContactTransportModel>(path, transport, Method.POST));
        }
コード例 #4
0
        /// <summary>
        /// Updates a given contact
        /// </summary>
        /// <typeparam name="T">Implementation of ContactHubSpotModel</typeparam>
        /// <param name="contact">The contact entity</param>
        public Task <ContactHubSpotModel> UpdateAsync(ContactHubSpotModel contact, CancellationToken cancellationToken = default)
        {
            if (contact.Id < 1)
            {
                throw new ArgumentException("Contact entity must have an id set!");
            }

            return(_client.ExecuteAsync <ContactHubSpotModel, ContactHubSpotModel>(GetRoute <ContactHubSpotModel>("contact", "vid", contact.Id.ToString(), "profile"), contact, Method.POST, cancellationToken));
        }
コード例 #5
0
        /// <summary>
        /// Updates a given contact
        /// </summary>
        /// <typeparam name="T">Implementation of ContactHubSpotModel</typeparam>
        /// <param name="contact">The contact entity</param>
        public ContactHubSpotModel Update(ContactHubSpotModel contact)
        {
            if (contact.Id < 1)
            {
                throw new ArgumentException("Contact entity must have an id set!");
            }

            return(_client.Execute <ContactHubSpotModel, ContactHubSpotModel>(GetRoute <ContactHubSpotModel>("contact", "vid", contact.Id.ToString(), "profile"), contact, Method.POST));
        }
コード例 #6
0
        public void CustomContactModels_WillLoadTheirProperties_IntoThePropertiesDictionary_OnLoadProperties()
        {
            sut = new CustomContact("cheese", 5);

            sut.LoadProperties();

            Assert.True(sut.Properties.ContainsKey("flavor"));
            Assert.True(sut.Properties.ContainsKey("legs"));

            Assert.Equal("cheese", sut.Properties["flavor"].Value);
            Assert.Equal(5, sut.Properties["legs"].Value);
        }
        public void AllContactProperties_Custom_Or_Otherwise_ShouldBeIn_Properties_Transport_Dictionary(string email,
                                                                                                        string fName,
                                                                                                        string lName,
                                                                                                        string site,
                                                                                                        string comp,
                                                                                                        string phone,
                                                                                                        string addr,
                                                                                                        string city,
                                                                                                        string state,
                                                                                                        string zip)
        {
            var payload = new ContactHubSpotModel()
            {
                Email     = email,
                FirstName = fName,
                LastName  = lName,
                Website   = site,
                Company   = comp,
                Phone     = phone,
                Address   = addr,
                City      = city,
                State     = state,
                ZipCode   = zip
            };

            var sut = new CreateOrUpdateContactTransportModel(payload);

            Assert.True(sut.Properties["email"] == null || email == sut.Properties["email"].Value);
            Assert.True(sut.Properties["firstname"] == null || fName == sut.Properties["firstname"].Value);
            Assert.True(sut.Properties["lastname"] == null || lName == sut.Properties["lastname"].Value);
            Assert.True(sut.Properties["website"] == null || site == sut.Properties["website"].Value);
            Assert.True(sut.Properties["company"] == null || comp == sut.Properties["company"].Value);
            Assert.True(sut.Properties["phone"] == null || phone == sut.Properties["phone"].Value);
            Assert.True(sut.Properties["address"] == null || addr == sut.Properties["address"].Value);
            Assert.True(sut.Properties["city"] == null || city == sut.Properties["city"].Value);
            Assert.True(sut.Properties["state"] == null || state == sut.Properties["state"].Value);
            Assert.True(sut.Properties["zip"] == null || zip == sut.Properties["zip"].Value);
        }
コード例 #8
0
        public void WhenPropertiesAssigned_ThroughConstructor_The_Values_In_PropertiesDictionary_Should_Match_object_properties(string email,
                                                                                                                                string fName,
                                                                                                                                string lName,
                                                                                                                                string site,
                                                                                                                                string comp,
                                                                                                                                string phone,
                                                                                                                                string addr,
                                                                                                                                string city,
                                                                                                                                string state,
                                                                                                                                string zip)
        {
            sut = new ContactHubSpotModel()
            {
                Email     = email,
                FirstName = fName,
                LastName  = lName,
                Website   = site,
                Company   = comp,
                Phone     = phone,
                Address   = addr,
                City      = city,
                State     = state,
                ZipCode   = zip
            };

            sut.LoadProperties();

            Assert.True(!sut.Properties.ContainsKey("email") || email == sut.Properties["email"].Value as string);
            Assert.True(!sut.Properties.ContainsKey("firstname") || fName == sut.Properties["firstname"].Value as string);
            Assert.True(!sut.Properties.ContainsKey("lastname") || lName == sut.Properties["lastname"].Value as string);
            Assert.True(!sut.Properties.ContainsKey("website") || site == sut.Properties["website"].Value as string);
            Assert.True(!sut.Properties.ContainsKey("company") || comp == sut.Properties["company"].Value as string);
            Assert.True(!sut.Properties.ContainsKey("phone") || phone == sut.Properties["phone"].Value as string);
            Assert.True(!sut.Properties.ContainsKey("address") || addr == sut.Properties["address"].Value as string);
            Assert.True(!sut.Properties.ContainsKey("city") || city == sut.Properties["city"].Value as string);
            Assert.True(!sut.Properties.ContainsKey("state") || state == sut.Properties["state"].Value as string);
            Assert.True(!sut.Properties.ContainsKey("zip") || zip == sut.Properties["zip"].Value as string);
        }