Skip to content

resolvers

api.resolvers.get_address(session, filter, page_size, page_number) async

Get all addresses from database or all plugins.

Parameters:

Name Type Description Default
session AsyncSession

get the session of database from get_session

required
filter AddressFilterInput

Strawberry input dataclass, everything can be None (based on sqlmodel model)

required
page_size PositiveInt

How many elements in each page

required
page_number PositiveInt

Number of the page

required

Returns:

Name Type Description
DictResponse DictResponse

'data' key has all addresses (db model) based on filter or empty list; 'provider' key has the service provider local or some plugin

Source code in api/resolvers.py
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
async def get_address(
	session: AsyncSession,
	filter: AddressFilterInput,
	page_size: PositiveInt,
	page_number: PositiveInt,
) -> DictResponse:
	"""
	Get all addresses from database or all plugins.

	Args:
			session (AsyncSession): get the session of database from get_session
			filter (AddressFilterInput): Strawberry input dataclass,
					everything can be None (based on sqlmodel model)
			page_size (PositiveInt): How many elements in each page
			page_number (PositiveInt): Number of the page

	Returns:
			DictResponse: 'data' key has all addresses
					(db model) based on filter or empty list;
					'provider' key has the service provider local or some plugin

	"""
	result = await functions.get_address_by_dc_join_state_join_city(
		session, filter, page_size, page_number
	)
	if result or not filter.zipcode:
		return {'data': result, 'provider': 'local'}

	return await get_zipcode_from_plugins(filter.zipcode)

api.resolvers.insert_address(session, address) async

Insert address and city if not exists on database.

Parameters:

Name Type Description Default
session AsyncSession

get the session of database from get_session

required
address AddressInsertInput

Strict address class, all needed fields need to be passed

required

Returns:

Name Type Description
Address Address

Address (db model)

Source code in api/resolvers.py
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
async def insert_address(
	session: AsyncSession, address: AddressInsertInput
) -> Address:
	"""
	Insert address and city if not exists on database.

	Args:
			session (AsyncSession): get the session of database from get_session
			address (AddressInsertInput): Strict address class,
					all needed fields need to be passed

	Returns:
			Address: Address (db model)

	"""
	return await functions.insert_address_by_dc(session, address)