Example #1
0
        public async Task <EnrichmentResult> FindBy(string text)
        {
            (string entity, string country)entityWithCountry = _findEnityAndCountryInTextStrategy.GetEntityAndCountryFrom(text);

            if (string.IsNullOrEmpty(entityWithCountry.country))
            {
                return(EnrichmentResult.CreateWithError("Country Not Found In Countries List"));
            }

            FullContactResponse result = await _client.Enrichment(entityWithCountry.country, entityWithCountry.entity);

            if (result.Status == FullContactResponseStatus.DataFound)
            {
                Value  value   = result.Enrichment.entities.value.FirstOrDefault();
                string info    = value.description;
                string name    = value.name;
                string website = value.url;

                bool isCompany = _findEnityAndCountryInTextStrategy.IsCompany(value.entityPresentationInfo.entityTypeHints);

                return(EnrichmentResult.CreateNew(Enrichment.CreateNew(value.name, "", value.image.thumbnailUrl, value.description, value.url, isCompany)));
            }
            else if (result.Status == FullContactResponseStatus.DataNotFound)
            {
                return(EnrichmentResult.CreateNew(null));
            }
            else
            {
                return(EnrichmentResult.CreateWithError(result.ErrorMessage));
            }
        }
Example #2
0
 public static EnrichmentResult CreateNew(Enrichment enrichment) => new EnrichmentResult(enrichment);
Example #3
0
 protected EnrichmentResult(Enrichment enrichment)
 {
     Enrichment = enrichment;
     Status     = enrichment != null ? EnrichmentResultStatus.Found : EnrichmentResultStatus.NotFound;
 }