public HubSpotContactPropertyApi(IHubSpotClient client)
        {
            MidRoute = "/properties/v1/contacts";
            _client  = client;

            AddRoute <ContactPropertyModel>("properties");
        }
        public async Task <IReadOnlyList <Model.Contacts.Contact> > GetContacts(IHubSpotClient client, IReadOnlyList <IProperty> propertiesToQuery)
        {
            var contactIds = await GetAllContactIds();

            var contacts = new List <HubSpot.Model.Contacts.Contact>();

            foreach (var partition in contactIds.Batch(BatchSize))
            {
                var response = await client.Contacts.GetManyByIdAsync(partition.ToArray(), propertiesToQuery, PropertyMode.ValueOnly, FormSubmissionMode.None, false, false);

                contacts.AddRange(response.Values);
            }

            return(contacts);

            async Task <IReadOnlyList <long> > GetAllContactIds()
            {
                var ids = new List <long>();

                ContactIdList list = null;

                do
                {
                    list = await client.Companies.GetContactIdsInCompanyAsync(_companyId, 25, list?.Offset);

                    ids.AddRange(list.ContactIds);
                } while (list.HasMore);

                return(ids);
            }
        }
예제 #3
0
        public HubSpotTimelineApi(IHubSpotClient client)
        {
            _client  = client;
            MidRoute = $"/integrations/v1/{client.AppId}";

            AddRoute <TimelineEventHubSpotModel>("/timeline/event");
            AddRoute <TimelineEventTypeHubSpotModel>("/timeline/event-types");
        }
        public async Task GetAsync_invokes_selector_from_parameters_to_retrieve_deal([Frozen] IHubSpotClient hubSpotClient, [Frozen] IDealSelector dealSelector, HubSpotDealConnector sut)
        {
            //Arrange

            //Act
            await sut.GetAsync <HubSpot.Deals.Deal>(dealSelector);

            //Assert
            Mock.Get(dealSelector).Verify(x => x.GetDeal(hubSpotClient), Times.Once);
        }
예제 #5
0
 private void InitializeRepos(IHubSpotClient client, string clientId = "", string clientSecret = "")
 {
     OAuth              = new HubSpotOAuthApi(client, clientId, clientSecret);
     Company            = new HubSpotCompanyApi(client);
     Contact            = new HubSpotContactApi(client);
     ContactProperty    = new HubSpotContactPropertyApi(client);
     Deal               = new HubSpotDealApi(client);
     Engagement         = new HubSpotEngagementApi(client);
     File               = new HubSpotCosFileApi(client);
     Owner              = new HubSpotOwnerApi(client);
     CompanyProperties  = new HubSpotCompaniesPropertiesApi(client);
     EmailSubscriptions = new HubSpotEmailSubscriptionsApi(client);
     Timelines          = new HubSpotTimelineApi(client);
 }
예제 #6
0
        public async Task <IReadOnlyList <Model.Contacts.Contact> > GetContacts(IHubSpotClient client, IReadOnlyList <IProperty> propertiesToQuery)
        {
            long?offset = null;

            var result = new List <Model.Contacts.Contact>();

            (IReadOnlyList <Model.Contacts.Contact> list, bool hasMore, long?offset)tuple;

            do
            {
                tuple = await Get(client, propertiesToQuery, offset).ConfigureAwait(false);

                offset = tuple.offset;

                result.AddRange(tuple.list);
            } while (tuple.hasMore);

            return(result);
        }
예제 #7
0
 public EngagementsIterator(IHubSpotClient client, HubSpotCrawlJobData jobData) : base(client, jobData)
 {
 }
예제 #8
0
 public HubSpotDealApi(IHubSpotClient client)
 {
     _client = client;
     AddRoute <DealHubSpotModel>("/deal");
 }
 public HubSpotContactConnector(IHubSpotClient client, IContactTypeManager typeManager)
 {
     _client      = client ?? throw new ArgumentNullException(nameof(client));
     _typeManager = typeManager ?? throw new ArgumentNullException(nameof(typeManager));
 }
예제 #10
0
 public HubSpotDealApi(IHubSpotClient client) : base(client)
 {
 }
예제 #11
0
 public StaticContactListIterator(IHubSpotClient client, HubSpotCrawlJobData jobData) : base(client, jobData)
 {
 }
예제 #12
0
 public RecentDealsIterator(IHubSpotClient client, HubSpotCrawlJobData jobData) : base(client, jobData)
 {
 }
        protected override async Task <(IReadOnlyList <Model.Contacts.Contact> list, bool hasMore, long?offset)> Get(IHubSpotClient client, IReadOnlyList <IProperty> propertiesToQuery, long?offset)
        {
            var response = await client.Contacts.SearchAsync(_searchQuery, propertiesToQuery, 25, offset);

            return(response.Contacts, response.HasMore, response.Offset);
        }
예제 #14
0
 public HubSpotDealApi(IHubSpotClient client)
 {
     _client = client;
 }
예제 #15
0
 protected HubSpotIteratorBase(IHubSpotClient client, HubSpotCrawlJobData jobData)
 {
     Client  = client ?? throw new ArgumentNullException(nameof(client));
     JobData = jobData ?? throw new ArgumentNullException(nameof(jobData));
 }
예제 #16
0
        protected override async Task <(IReadOnlyList <Model.Deals.Deal> list, bool hasMore, long?offset)> GetDeals(IHubSpotClient client, IReadOnlyList <IProperty> propertiesToQuery, long?offset)
        {
            var response = await client.Deals.GetRecentlyCreatedAsync(count : 20, offset : offset);

            return(response.Results, response.HasMore, response.Offset);
        }
 public HubSpotEmailSubscriptionsApi(IHubSpotClient client)
 {
     _client = client;
 }
예제 #18
0
 public TemplatesIterator(IHubSpotClient client, HubSpotCrawlJobData jobData) : base(client, jobData)
 {
 }
예제 #19
0
 public HubSpotEngagementApi(IHubSpotClient client)
 {
     _client = client;
     AddRoute <EngagementHubSpotModel>("engagements/");
 }
        public async Task GetAsync_returns_converted_deal([Frozen] IDealTypeManager dealTypeManager, [Frozen] IHubSpotClient hubSpotClient, [Frozen] IDealSelector dealSelector, HubSpot.Deals.Deal convertedDeal, HubSpotDealConnector sut, IFixture fixture)
        {
            //Arrange
            Mock.Get(dealTypeManager).Setup(x => x.ConvertTo <HubSpot.Deals.Deal>(It.IsAny <HubSpot.Model.Deals.Deal>())).Returns(convertedDeal);

            //Act
            var result = await sut.GetAsync <HubSpot.Deals.Deal>(dealSelector);

            //Assert
            Assert.That(result, Is.EqualTo(convertedDeal));
        }
예제 #21
0
 public HubSpotEngagementApi(IHubSpotClient client)
 {
     _client = client;
 }
 public HubSpotEmailSubscriptionsApi(IHubSpotClient client)
 {
     _client = client;
     AddRoute <SubscriptionTimelineHubSpotModel>("timeline");
 }
        public async Task GetAsync_invokes_deal_type_manager_to_convert_selector_result([Frozen] IDealTypeManager dealTypeManager, [Frozen] IHubSpotClient hubSpotClient, [Frozen] IDealSelector dealSelector, HubSpotDealConnector sut, HubSpot.Model.Deals.Deal deal)
        {
            //Arrange
            Mock.Get(dealSelector).Setup(x => x.GetDeal(hubSpotClient)).Returns(Task.FromResult(deal));

            //Act
            await sut.GetAsync <HubSpot.Deals.Deal>(dealSelector);

            //Assert
            Mock.Get(dealTypeManager).Verify(x => x.ConvertTo <HubSpot.Deals.Deal>(deal), Times.Once);
        }
 public HubSpotCompaniesPropertiesApi(IHubSpotClient client)
 {
     _client = client;
 }
        public async Task GetAsync_returns_null_if_deal_retrieving_throws_NotFoundException([Frozen] IHubSpotClient hubSpotClient, [Frozen] IDealSelector dealSelector, HubSpotDealConnector sut, NotFoundException notFoundException)
        {
            //Arrange
            Mock.Get(dealSelector).Setup(x => x.GetDeal(hubSpotClient)).Throws(notFoundException);

            //Act
            var result = await sut.GetAsync <HubSpot.Deals.Deal>(dealSelector);

            //Assert
            Assert.That(result, Is.Null);
        }
예제 #26
0
 public Task <Model.Contacts.Contact> GetContact(IHubSpotClient client, IReadOnlyList <IProperty> propertiesToQuery)
 {
     return(client.Contacts.GetByIdAsync(_contactId, propertiesToQuery, PropertyMode.ValueOnly, FormSubmissionMode.None, false));
 }
예제 #27
0
 public HubSpotContactApi(IHubSpotClient client)
 {
     _client = client;
 }
예제 #28
0
 public TicketsIterator(IHubSpotClient client, HubSpotCrawlJobData jobData, Settings properties) : base(client, jobData)
 {
     _settings = properties ?? throw new ArgumentNullException(nameof(properties));
 }
예제 #29
0
 public BlogPostsIterator(IHubSpotClient client, HubSpotCrawlJobData jobData) : base(client, jobData)
 {
 }
예제 #30
0
 public HubSpotCompanyApi(IHubSpotClient client) : base(client)
 {
 }