Northwind Web Services

<back to all web services

QueryOrders

AutoQuery
The following routes are available for this service:
All Verbs/query/orders
import datetime
import decimal
from marshmallow.fields import *
from servicestack import *
from typing import *
from dataclasses import dataclass, field
from dataclasses_json import dataclass_json, LetterCase, Undefined, config
from enum import Enum, IntEnum


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class QueryBase:
    skip: Optional[int] = None
    take: Optional[int] = None
    order_by: Optional[str] = None
    order_by_desc: Optional[str] = None
    include: Optional[str] = None
    fields: Optional[str] = None
    meta: Optional[Dict[str, str]] = None


T = TypeVar('T')


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class QueryDb(Generic[T], QueryBase, IReturn[QueryResponse[T]]):
    @staticmethod
    def response_type(): return QueryResponse[T]


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Order:
    id: int = 0
    customer_id: Optional[str] = None
    employee_id: int = 0
    order_date: Optional[datetime.datetime] = None
    required_date: Optional[datetime.datetime] = None
    shipped_date: Optional[datetime.datetime] = None
    ship_via: Optional[int] = None
    freight: Decimal = decimal.Decimal(0)
    ship_name: Optional[str] = None
    ship_address: Optional[str] = None
    ship_city: Optional[str] = None
    ship_region: Optional[str] = None
    ship_postal_code: Optional[str] = None
    ship_country: Optional[str] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class QueryOrders(QueryDb[Order]):
    freight: Optional[Decimal] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Customer:
    id: Optional[str] = None
    company_name: Optional[str] = None
    contact_name: Optional[str] = None
    contact_title: Optional[str] = None
    address: Optional[str] = None
    city: Optional[str] = None
    region: Optional[str] = None
    postal_code: Optional[str] = None
    country: Optional[str] = None
    phone: Optional[str] = None
    fax: Optional[str] = None


Customer = TypeVar('Customer')


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class QueryResponse(Generic[Customer]):
    offset: int = 0
    total: int = 0
    results: Optional[List[Customer]] = None
    meta: Optional[Dict[str, str]] = None
    response_status: Optional[ResponseStatus] = None

Python QueryOrders DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv

HTTP + JSV

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /query/orders HTTP/1.1 
Host: northwind.netcore.io 
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length

{
	freight: 0,
	skip: 0,
	take: 0,
	orderBy: String,
	orderByDesc: String,
	include: String,
	fields: String,
	meta: 
	{
		String: String
	}
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	offset: 0,
	total: 0,
	results: 
	[
		{
			id: 0,
			customerId: String,
			employeeId: 0,
			orderDate: 0001-01-01,
			requiredDate: 0001-01-01,
			shippedDate: 0001-01-01,
			shipVia: 0,
			freight: 0,
			shipName: String,
			shipAddress: String,
			shipCity: String,
			shipRegion: String,
			shipPostalCode: String,
			shipCountry: String
		}
	],
	meta: 
	{
		String: String
	},
	responseStatus: 
	{
		errorCode: String,
		message: String,
		stackTrace: String,
		errors: 
		[
			{
				errorCode: String,
				fieldName: String,
				message: String,
				meta: 
				{
					String: String
				}
			}
		],
		meta: 
		{
			String: String
		}
	}
}