JobSpy/api/core/jobs/__init__.py

69 lines
1.3 KiB
Python
Raw Normal View History

2023-07-11 06:24:59 -07:00
from typing import Union
2023-07-06 16:44:38 -07:00
from datetime import datetime
from enum import Enum
from pydantic import BaseModel, validator
2023-07-11 06:24:59 -07:00
2023-07-06 16:44:38 -07:00
class JobType(Enum):
2023-07-11 06:24:59 -07:00
FULL_TIME = "fulltime"
PART_TIME = "parttime"
CONTRACT = "contract"
2023-07-07 19:00:59 -07:00
TEMPORARY = "temporary"
2023-07-11 06:24:59 -07:00
INTERNSHIP = "internship"
PER_DIEM = "perdiem"
2023-07-08 04:57:36 -07:00
NIGHTS = "nights"
OTHER = "other"
2023-07-11 07:50:44 -07:00
SUMMER = "summer"
2023-07-06 16:44:38 -07:00
class Location(BaseModel):
country: str = "USA"
city: str = None
state: str = None
2023-07-06 16:44:38 -07:00
2023-07-08 04:57:36 -07:00
class CompensationInterval(Enum):
YEARLY = "yearly"
MONTHLY = "monthly"
WEEKLY = "weekly"
DAILY = "daily"
HOURLY = "hourly"
2023-07-06 16:44:38 -07:00
class Compensation(BaseModel):
interval: CompensationInterval
2023-07-08 04:57:36 -07:00
min_amount: float
max_amount: float
currency: str = "USA"
2023-07-06 16:44:38 -07:00
class JobPost(BaseModel):
title: str
company_name: str
2023-07-11 03:42:20 -07:00
job_url: str
2023-07-06 16:44:38 -07:00
location: Location
2023-07-11 03:42:20 -07:00
description: str = None
2023-07-08 04:57:36 -07:00
job_type: JobType = None
2023-07-07 19:00:59 -07:00
compensation: Compensation = None
date_posted: datetime = None
2023-07-06 17:12:01 -07:00
class JobResponse(BaseModel):
success: bool
error: str = None
2023-08-27 18:32:46 -07:00
total_results: int = None
2023-07-11 10:30:13 -07:00
jobs: list[JobPost] = []
returned_results: int = None
2023-08-27 18:32:46 -07:00
@validator("returned_results", pre=True, always=True)
def set_returned_results(cls, v, values):
if v is None and values.get("jobs"):
return len(values["jobs"])
return v