Hmx Accounts

<back to all web services

CreatePurchaseOrder

The following routes are available for this service:
POST/api/purchaseordersCreate a new PurchaseOrder
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 PurchaseOrderItem:
    id: Optional[int] = None
    # @References(typeof(PurchaseOrder))
    purchase_order_id: Optional[int] = None

    # @References(typeof(Product))
    product_id: Optional[str] = None

    product_name: Optional[str] = None
    quantity: Optional[int] = None
    price: Optional[Decimal] = None
    discount_description: Optional[str] = None
    discount_source: Optional[str] = None
    discount: Optional[Decimal] = None
    created_date: Optional[datetime.datetime] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class PurchaseOrderDto:
    id: Optional[int] = None
    user_id: Optional[str] = None
    created_date: Optional[datetime.datetime] = None
    payment_type: Optional[str] = None
    void: Optional[bool] = None
    paid: Optional[bool] = None
    transaction_identifier: Optional[str] = None
    coupon_code: Optional[str] = None
    order_items: Optional[List[PurchaseOrderItem]] = None
    payer: Optional[str] = None
    billing_address_line1: Optional[str] = None
    billing_address_city: Optional[str] = None
    billing_address_state: Optional[str] = None
    billing_address_postal_code: Optional[str] = None
    billing_address_country_code: Optional[str] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Details:
    code: Optional[str] = None
    field: Optional[str] = None
    issue: Optional[str] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CreatePurchaseOrderResponse:
    message: Optional[str] = None
    status: Optional[HttpStatusCode] = None
    purchase_order: Optional[PurchaseOrderDto] = None
    details: Optional[List[Details]] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class PurchaseOrderItemDto:
    id: Optional[int] = None
    purchase_order_id: Optional[int] = None
    product_id: Optional[str] = None
    product_name: Optional[str] = None
    quantity: Optional[int] = None
    price: Optional[Decimal] = None
    discount_description: Optional[str] = None
    discount_source: Optional[str] = None
    discount: Optional[Decimal] = None
    created_date: Optional[datetime.datetime] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class BillingInformationDto:
    card_number: Optional[str] = None
    card_type: Optional[str] = None
    expire_month: Optional[int] = None
    expire_year: Optional[int] = None
    cvv2: Optional[str] = None
    first_name: Optional[str] = None
    last_name: Optional[str] = None
    city: Optional[str] = None
    country_code: Optional[str] = None
    line1: Optional[str] = None
    postal_code: Optional[str] = None
    state: Optional[str] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CreatePurchaseOrder:
    user_id: Optional[str] = None
    user_email: Optional[str] = None
    created_date: Optional[datetime.datetime] = None
    void: Optional[bool] = None
    coupon_code: Optional[str] = None
    order_items: Optional[List[PurchaseOrderItemDto]] = None
    payment_type: Optional[str] = None
    billing_information_dto: Optional[BillingInformationDto] = None

Python CreatePurchaseOrder 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 /api/purchaseorders HTTP/1.1 
Host: accounts.dev.healthmonix.com 
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length

{
	userId: String,
	userEmail: String,
	createdDate: 0001-01-01,
	void: False,
	couponCode: String,
	orderItems: 
	[
		{
			id: 0,
			purchaseOrderId: 0,
			productId: String,
			productName: String,
			quantity: 0,
			price: 0,
			discountDescription: String,
			discountSource: String,
			discount: 0,
			createdDate: 0001-01-01
		}
	],
	paymentType: String,
	billingInformationDto: 
	{
		cardNumber: String,
		cardType: String,
		expireMonth: 0,
		expireYear: 0,
		cvv2: String,
		firstName: String,
		lastName: String,
		city: String,
		countryCode: String,
		line1: String,
		postalCode: String,
		state: String
	}
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	message: String,
	status: Continue,
	purchaseOrder: 
	{
		id: 0,
		userId: String,
		createdDate: 0001-01-01,
		paymentType: String,
		void: False,
		paid: False,
		transactionIdentifier: String,
		couponCode: String,
		orderItems: 
		[
			{
				id: 0,
				purchaseOrderId: 0,
				productId: String,
				productName: String,
				quantity: 0,
				price: 0,
				discountDescription: String,
				discountSource: String,
				discount: 0,
				createdDate: 0001-01-01
			}
		],
		payer: String,
		billingAddressLine1: String,
		billingAddressCity: String,
		billingAddressState: String,
		billingAddressPostalCode: String,
		billingAddressCountryCode: String
	},
	details: 
	[
		{
			code: String,
			field: String,
			issue: String
		}
	]
}