Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
        public void CustomContactClasses_Should_Have_Their_Properties_Injected_Into_The_Properties_Transport_Dictionary()
        {
            var payload = new CustomContact("goose", 40);

            var sut = new CreateOrUpdateContactTransportModel(payload);

            Assert.Equal(payload.Flavor, sut.Properties.Where(x => x.Property == "flavor").First().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);
        }