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
|
|
|
|
|
2023-07-11 10:00:24 -07:00
|
|
|
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"
|
2023-07-10 20:07:19 -07:00
|
|
|
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
|
2023-07-08 19:16:34 -07:00
|
|
|
city: str = None
|
|
|
|
state: str = None
|
2023-07-06 16:44:38 -07:00
|
|
|
postal_code: str = None
|
|
|
|
address: str = None
|
|
|
|
|
|
|
|
|
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 = "US"
|
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
|
|
|
|
2023-07-09 05:37:18 -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
|
2023-07-09 05:37:18 -07:00
|
|
|
date_posted: datetime = None
|
2023-07-06 17:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
|
class JobResponse(BaseModel):
|
2023-07-10 15:43:45 -07:00
|
|
|
success: bool
|
|
|
|
error: str = None
|
|
|
|
|
2023-07-11 10:30:13 -07:00
|
|
|
jobs: list[JobPost] = []
|
|
|
|
|
2023-07-11 10:00:24 -07:00
|
|
|
total_results: int = None
|
|
|
|
returned_results: int = None
|
|
|
|
|
|
|
|
@validator("returned_results")
|
|
|
|
def set_returned_results(cls, v, values):
|
|
|
|
if v is None and values.get("jobs"):
|
|
|
|
return len(values["jobs"])
|
|
|
|
return v
|