Add GetScrapePortals endpoint and related service functionality
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
- Introduced the GetScrapePortals method in the AI pipeline handler to list document scraping portals supported by the Opplens AI service. - Updated the service layer to include GetScrapePortals, which retrieves the portals from the client and handles errors appropriately. - Enhanced the routes to register the new endpoint for retrieving scrape portals. - Added a new error type for invalid date ranges in the document scraper, improving validation and error handling. This update expands the AI pipeline capabilities, allowing for better management of document scraping portals within the tender management system.
This commit is contained in:
@@ -195,6 +195,29 @@ func (c *Client) ScrapeDocumentsBatch(ctx context.Context, tenders []TenderRef)
|
||||
})
|
||||
}
|
||||
|
||||
// GetScrapePortals calls GET /scrape/portals.
|
||||
func (c *Client) GetScrapePortals(ctx context.Context) (*ScrapePortalsResponse, error) {
|
||||
url := c.config.APIBaseURL + "/scrape/portals"
|
||||
httpResp, bodyBytes, err := c.doRawGet(ctx, url)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer httpResp.Body.Close()
|
||||
|
||||
if httpResp.StatusCode >= 400 {
|
||||
return nil, apiNonSuccessError(httpResp.StatusCode, bodyBytes)
|
||||
}
|
||||
|
||||
var result ScrapePortalsResponse
|
||||
if len(bodyBytes) > 0 {
|
||||
if err := json.Unmarshal(bodyBytes, &result); err != nil {
|
||||
return nil, fmt.Errorf("ai_summarizer: failed to decode scrape portals response: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
// PipelineSync calls POST /pipeline/sync to pull the tender list from the backend.
|
||||
func (c *Client) PipelineSync(ctx context.Context) (*PipelineSyncResponse, error) {
|
||||
url := c.config.APIBaseURL + "/pipeline/sync"
|
||||
|
||||
@@ -173,6 +173,19 @@ type ScrapeDocumentsBatchRequest struct {
|
||||
Tenders []TenderRef `json:"tenders"`
|
||||
}
|
||||
|
||||
// ScrapePortal describes one document scraping portal supported by the AI service.
|
||||
type ScrapePortal struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
CountryCode string `json:"country_code,omitempty"`
|
||||
Countries []string `json:"countries,omitempty"`
|
||||
}
|
||||
|
||||
// ScrapePortalsResponse is returned by GET /scrape/portals.
|
||||
type ScrapePortalsResponse struct {
|
||||
Portals []ScrapePortal `json:"portals"`
|
||||
}
|
||||
|
||||
// SummarizeBatchRequest is the payload for POST /ai/summarize/batch.
|
||||
type SummarizeBatchRequest struct {
|
||||
Tenders []TenderRef `json:"tenders"`
|
||||
|
||||
Reference in New Issue
Block a user