Ejemplo n.º 1
0
        public GreenhouseClient(ILogger <GreenhouseClient> log, GreenhouseCrawlJobData greenhouseCrawlJobData, IRestClient client) // TODO: pass on any extra dependencies
        {
            if (greenhouseCrawlJobData == null)
            {
                throw new ArgumentNullException(nameof(greenhouseCrawlJobData));
            }

            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }

            this.log    = log ?? throw new ArgumentNullException(nameof(log));
            this.client = client ?? throw new ArgumentNullException(nameof(client));

            // TODO use info from greenhouseCrawlJobData to instantiate the connection
            client.BaseUrl = new Uri(BaseUri);
            client.AddDefaultParameter("api_key", greenhouseCrawlJobData.ApiKey, ParameterType.QueryString);
            _greenhouseCrawlJobData = greenhouseCrawlJobData;
        }
        public override async Task <CrawlJobData> GetCrawlJobData(
            ProviderUpdateContext context,
            IDictionary <string, object> configuration,
            Guid organizationId,
            Guid userId,
            Guid providerDefinitionId)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            var greenhouseCrawlJobData = new GreenhouseCrawlJobData();

            if (configuration.ContainsKey(GreenhouseConstants.KeyName.ApiKey))
            {
                greenhouseCrawlJobData.ApiKey = configuration[GreenhouseConstants.KeyName.ApiKey].ToString();
            }

            return(await Task.FromResult(greenhouseCrawlJobData));
        }