refactored HistoricalEmployees for stocks.fa.emp

This commit is contained in:
Pratyush Shukla
2023-08-01 19:10:27 +05:30
parent 10fae1552c
commit ab8be21300
2 changed files with 39 additions and 62 deletions

View File

@@ -1,16 +1,15 @@
"""FMP Historical Employees fetcher."""
from datetime import date, datetime
from datetime import datetime
from typing import Any, Dict, List, Optional
from openbb_provider.abstract.data import Data
from openbb_provider.abstract.fetcher import Fetcher
from openbb_provider.models.historical_employees import (
HistoricalEmployeesData,
HistoricalEmployeesQueryParams,
)
from pydantic import Field, validator
from pydantic import validator
from openbb_fmp.utils.helpers import create_url, get_data_many
@@ -19,36 +18,31 @@ class FMPHistoricalEmployeesQueryParams(HistoricalEmployeesQueryParams):
"""FMP Historical Employees query.
Source: https://site.financialmodelingprep.com/developer/docs/historical-numer-of-employees-api/
Parameter
---------
symbol : str
The symbol of the company.
"""
class FMPHistoricalEmployeesData(Data):
"""FMP Historical Employees data."""
class FMPHistoricalEmployeesData(HistoricalEmployeesData):
"""FMP Historical Employees Data."""
symbol: str = Field(min_length=1)
cik: int
acceptanceTime: datetime = Field(alias="acceptance_time")
periodOfReport: date = Field(alias="period_of_report")
companyName: str = Field(alias="company_name")
formType: str = Field(alias="form_type")
filingDate: date = Field(alias="filing_date")
employeeCount: int = Field(alias="employee_count")
source: str
class Config:
fields = {
"acceptance_time": "acceptanceTime",
"period_of_report": "periodOfReport",
"company_name": "companyName",
"form_type": "formType",
"filing_date": "filingDate",
"employee_count": "employeeCount",
}
@validator("acceptanceTime", pre=True)
@validator("acceptanceTime", pre=True, check_fields=False)
def acceptance_time_validate(cls, v): # pylint: disable=E0213
return datetime.strptime(v, "%Y-%m-%d %H:%M:%S")
@validator("periodOfReport", pre=True)
@validator("periodOfReport", pre=True, check_fields=False)
def period_of_report_validate(cls, v): # pylint: disable=E0213
return datetime.strptime(v, "%Y-%m-%d")
@validator("filingDate", pre=True)
@validator("filingDate", pre=True, check_fields=False)
def filing_date_validate(cls, v): # pylint: disable=E0213
return datetime.strptime(v, "%Y-%m-%d")

View File

@@ -7,48 +7,31 @@ from openbb_provider.abstract.data import Data
from openbb_provider.abstract.query_params import QueryParams
from openbb_provider.models.base import BaseSymbol
from pydantic import Field
class HistoricalEmployeesQueryParams(QueryParams, BaseSymbol):
"""Historical Employees query model.
Parameter
---------
symbol : str
The symbol of the company.
"""
"""Historical Employees Query."""
class HistoricalEmployeesData(Data):
"""Historical Employees data.
class HistoricalEmployeesData(Data, BaseSymbol):
"""Historical Employees Data."""
Returns
-------
symbol : str
The symbol of the company to retrieve the historical employees of.
cik : int
The CIK of the company to retrieve the historical employees of.
acceptance_time : datetime
The time of acceptance of the company employee.
period_of_report : date
The date of reporting of the company employee.
company_name : str
The registered name of the company to retrieve the historical employees of.
form_type : float
The form type of the company employee.
filing_date : date
The filing date of the company employee
employee_count : int
The count of employees of the company.
source : str
The source URL which retrieves this data for the company.
"""
symbol: str
cik: int
acceptance_time: datetime
period_of_report: date
company_name: str
form_type: str
filing_date: date
employee_count: int
source: str
cik: int = Field(
description="The CIK of the company to retrieve the historical employees of."
)
acceptance_time: datetime = Field(
description="The time of acceptance of the company employee."
)
period_of_report: date = Field(
description="The date of reporting of the company employee."
)
company_name: str = Field(
description="The registered name of the company to retrieve the historical employees of."
)
form_type: str = Field(description="The form type of the company employee.")
filing_date: date = Field(description="The filing date of the company employee")
employee_count: int = Field(description="The count of employees of the company.")
source: str = Field(
description="The source URL which retrieves this data for the company."
)