from marshmallow import fields, EXCLUDE, post_load

from cc_py_commons.schemas.camel_case_schema import CamelCaseSchema
from cc_py_commons.projects.project import Project


class ProjectSchema(CamelCaseSchema):
	class Meta:
		unknown = EXCLUDE

	id = fields.UUID(allow_none=True)
	user_id = fields.Integer(allow_none=True)
	account_id = fields.Integer(allow_none=True)
	name = fields.String(allow_none=True)
	assignee_id = fields.Integer(allow_none=True)
	commodity = fields.String(allow_none=True)
	due_date = fields.Date(allow_none=True)
	truck_lane_search_id = fields.UUID(allow_none=True)
	equipment_type = fields.String(allow_none=True)
	origin_city = fields.String(allow_none=True)
	origin_state = fields.String(allow_none=True)
	origin_zip = fields.String(allow_none=True)
	dest_city = fields.String(allow_none=True)
	dest_state = fields.String(allow_none=True)
	dest_zip = fields.String(allow_none=True)
	min_rate = fields.Integer(allow_none=True)
	max_rate = fields.Integer(allow_none=True)
	max_buy = fields.Integer(allow_none=True)
	packaging = fields.String(allow_none=True)
	trailer_requirements = fields.String(allow_none=True)
	shipper_notes = fields.String(allow_none=True)
	receiver_notes = fields.String(allow_none=True)
	value = fields.Integer(allow_none=True)
	monday = fields.Boolean(allow_none=True)
	tuesday = fields.Boolean(allow_none=True)
	wednesday = fields.Boolean(allow_none=True)
	thursday = fields.Boolean(allow_none=True)
	friday = fields.Boolean(allow_none=True)
	saturday = fields.Boolean(allow_none=True)
	sunday = fields.Boolean(allow_none=True)
	weight = fields.Integer(allow_none=True)
	origin_lat = fields.Float(allow_none=True)
	origin_lng = fields.Float(allow_none=True)
	dest_lat = fields.Float(allow_none=True)
	dest_lng = fields.Float(allow_none=True)
	load_volume = fields.Integer(allow_none=True)
	rfp_requested_date = fields.Date(allow_none=True)
	load_volume_duration = fields.String(allow_none=True)
	task_count = fields.Integer(allow_none=True)
	load_capacity = fields.Integer(allow_none=True)
	load_count = fields.Integer(allow_none=True)
	stage_id = fields.UUID(allow_none=True)
	carrier_count = fields.Integer(allow_none=True)
	position = fields.String(allow_none=True)
	last_bid = fields.Integer(allow_none=True)
	upload_count = fields.Integer(allow_none=True)
	last_upload = fields.Date(allow_none=True)
	best_rate = fields.Integer(allow_none=True)
	match_count = fields.Integer(allow_none=True)
	network_match_count = fields.Integer(allow_none=True)
	probability = fields.Integer(allow_none=True)
	lane_id = fields.UUID(allow_none=True)
	next_pickup_date = fields.Date(allow_none=True)
	load_id = fields.UUID(allow_none=True)
	approximate_miles = fields.Integer(allow_none=True)
	require_teams = fields.Boolean(allow_none=True)
	revenue_code = fields.String(allow_none=True)
	invite_ungrouped_carriers = fields.Boolean(allow_none=True)
	type = fields.String(allow_none=True)
	ungrouped_carriers_delay = fields.Integer(allow_none=True)
	send_to_out_of_network_carriers = fields.Boolean(allow_none=True)
	send_to_out_of_network_carriers_delay = fields.Integer(allow_none=True)
	procured_carrier_id_list = fields.List(fields.UUID, allow_none=True)
	enabled = fields.Boolean(allow_none=True)
	notify_procured_carriers = fields.Boolean(allow_none=True)
	assignee_is_dispatcher = fields.Boolean(allow_none=True)
	send_to_network_carriers = fields.Boolean(allow_none=True)
	send_to_network_carriers_delay = fields.Integer(allow_none=True)
	deleted = fields.Boolean(allow_none=True)

	@post_load
	def make_project(self, data, **kwargs):
		return Project(**data)
