POST | /api/purchaseorders | Create a new PurchaseOrder |
---|
import 'package:servicestack/servicestack.dart';
class PurchaseOrderItem implements IConvertible
{
int? id;
// @References(typeof(PurchaseOrder))
int? purchaseOrderId;
// @References(typeof(Product))
String? productId;
String? productName;
int? quantity;
double? price;
String? discountDescription;
String? discountSource;
double? discount;
DateTime? createdDate;
PurchaseOrderItem({this.id,this.purchaseOrderId,this.productId,this.productName,this.quantity,this.price,this.discountDescription,this.discountSource,this.discount,this.createdDate});
PurchaseOrderItem.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
id = json['id'];
purchaseOrderId = json['purchaseOrderId'];
productId = json['productId'];
productName = json['productName'];
quantity = json['quantity'];
price = JsonConverters.toDouble(json['price']);
discountDescription = json['discountDescription'];
discountSource = json['discountSource'];
discount = JsonConverters.toDouble(json['discount']);
createdDate = JsonConverters.fromJson(json['createdDate'],'DateTime',context!);
return this;
}
Map<String, dynamic> toJson() => {
'id': id,
'purchaseOrderId': purchaseOrderId,
'productId': productId,
'productName': productName,
'quantity': quantity,
'price': price,
'discountDescription': discountDescription,
'discountSource': discountSource,
'discount': discount,
'createdDate': JsonConverters.toJson(createdDate,'DateTime',context!)
};
getTypeName() => "PurchaseOrderItem";
TypeContext? context = _ctx;
}
class PurchaseOrderDto implements IConvertible
{
int? id;
String? userId;
DateTime? createdDate;
String? paymentType;
bool? Void;
bool? paid;
String? transactionIdentifier;
String? couponCode;
List<PurchaseOrderItem>? orderItems;
String? payer;
String? billingAddressLine1;
String? billingAddressCity;
String? billingAddressState;
String? billingAddressPostalCode;
String? billingAddressCountryCode;
PurchaseOrderDto({this.id,this.userId,this.createdDate,this.paymentType,this.Void,this.paid,this.transactionIdentifier,this.couponCode,this.orderItems,this.payer,this.billingAddressLine1,this.billingAddressCity,this.billingAddressState,this.billingAddressPostalCode,this.billingAddressCountryCode});
PurchaseOrderDto.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
id = json['id'];
userId = json['userId'];
createdDate = JsonConverters.fromJson(json['createdDate'],'DateTime',context!);
paymentType = json['paymentType'];
Void = json['void'];
paid = json['paid'];
transactionIdentifier = json['transactionIdentifier'];
couponCode = json['couponCode'];
orderItems = JsonConverters.fromJson(json['orderItems'],'List<PurchaseOrderItem>',context!);
payer = json['payer'];
billingAddressLine1 = json['billingAddressLine1'];
billingAddressCity = json['billingAddressCity'];
billingAddressState = json['billingAddressState'];
billingAddressPostalCode = json['billingAddressPostalCode'];
billingAddressCountryCode = json['billingAddressCountryCode'];
return this;
}
Map<String, dynamic> toJson() => {
'id': id,
'userId': userId,
'createdDate': JsonConverters.toJson(createdDate,'DateTime',context!),
'paymentType': paymentType,
'void': Void,
'paid': paid,
'transactionIdentifier': transactionIdentifier,
'couponCode': couponCode,
'orderItems': JsonConverters.toJson(orderItems,'List<PurchaseOrderItem>',context!),
'payer': payer,
'billingAddressLine1': billingAddressLine1,
'billingAddressCity': billingAddressCity,
'billingAddressState': billingAddressState,
'billingAddressPostalCode': billingAddressPostalCode,
'billingAddressCountryCode': billingAddressCountryCode
};
getTypeName() => "PurchaseOrderDto";
TypeContext? context = _ctx;
}
class Details implements IConvertible
{
String? code;
String? field;
String? issue;
Details({this.code,this.field,this.issue});
Details.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
code = json['code'];
field = json['field'];
issue = json['issue'];
return this;
}
Map<String, dynamic> toJson() => {
'code': code,
'field': field,
'issue': issue
};
getTypeName() => "Details";
TypeContext? context = _ctx;
}
class CreatePurchaseOrderResponse implements IConvertible
{
String? message;
HttpStatusCode? status;
PurchaseOrderDto? purchaseOrder;
List<Details>? details;
CreatePurchaseOrderResponse({this.message,this.status,this.purchaseOrder,this.details});
CreatePurchaseOrderResponse.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
message = json['message'];
status = JsonConverters.fromJson(json['status'],'HttpStatusCode',context!);
purchaseOrder = JsonConverters.fromJson(json['purchaseOrder'],'PurchaseOrderDto',context!);
details = JsonConverters.fromJson(json['details'],'List<Details>',context!);
return this;
}
Map<String, dynamic> toJson() => {
'message': message,
'status': JsonConverters.toJson(status,'HttpStatusCode',context!),
'purchaseOrder': JsonConverters.toJson(purchaseOrder,'PurchaseOrderDto',context!),
'details': JsonConverters.toJson(details,'List<Details>',context!)
};
getTypeName() => "CreatePurchaseOrderResponse";
TypeContext? context = _ctx;
}
class PurchaseOrderItemDto implements IConvertible
{
int? id;
int? purchaseOrderId;
String? productId;
String? productName;
int? quantity;
double? price;
String? discountDescription;
String? discountSource;
double? discount;
DateTime? createdDate;
PurchaseOrderItemDto({this.id,this.purchaseOrderId,this.productId,this.productName,this.quantity,this.price,this.discountDescription,this.discountSource,this.discount,this.createdDate});
PurchaseOrderItemDto.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
id = json['id'];
purchaseOrderId = json['purchaseOrderId'];
productId = json['productId'];
productName = json['productName'];
quantity = json['quantity'];
price = JsonConverters.toDouble(json['price']);
discountDescription = json['discountDescription'];
discountSource = json['discountSource'];
discount = JsonConverters.toDouble(json['discount']);
createdDate = JsonConverters.fromJson(json['createdDate'],'DateTime',context!);
return this;
}
Map<String, dynamic> toJson() => {
'id': id,
'purchaseOrderId': purchaseOrderId,
'productId': productId,
'productName': productName,
'quantity': quantity,
'price': price,
'discountDescription': discountDescription,
'discountSource': discountSource,
'discount': discount,
'createdDate': JsonConverters.toJson(createdDate,'DateTime',context!)
};
getTypeName() => "PurchaseOrderItemDto";
TypeContext? context = _ctx;
}
class BillingInformationDto implements IConvertible
{
String? cardNumber;
String? cardType;
int? expireMonth;
int? expireYear;
String? cvv2;
String? firstName;
String? lastName;
String? city;
String? countryCode;
String? line1;
String? postalCode;
String? state;
BillingInformationDto({this.cardNumber,this.cardType,this.expireMonth,this.expireYear,this.cvv2,this.firstName,this.lastName,this.city,this.countryCode,this.line1,this.postalCode,this.state});
BillingInformationDto.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
cardNumber = json['cardNumber'];
cardType = json['cardType'];
expireMonth = json['expireMonth'];
expireYear = json['expireYear'];
cvv2 = json['cvv2'];
firstName = json['firstName'];
lastName = json['lastName'];
city = json['city'];
countryCode = json['countryCode'];
line1 = json['line1'];
postalCode = json['postalCode'];
state = json['state'];
return this;
}
Map<String, dynamic> toJson() => {
'cardNumber': cardNumber,
'cardType': cardType,
'expireMonth': expireMonth,
'expireYear': expireYear,
'cvv2': cvv2,
'firstName': firstName,
'lastName': lastName,
'city': city,
'countryCode': countryCode,
'line1': line1,
'postalCode': postalCode,
'state': state
};
getTypeName() => "BillingInformationDto";
TypeContext? context = _ctx;
}
class CreatePurchaseOrder implements IConvertible
{
String? userId;
String? userEmail;
DateTime? createdDate;
bool? Void;
String? couponCode;
List<PurchaseOrderItemDto>? orderItems;
String? paymentType;
BillingInformationDto? billingInformationDto;
CreatePurchaseOrder({this.userId,this.userEmail,this.createdDate,this.Void,this.couponCode,this.orderItems,this.paymentType,this.billingInformationDto});
CreatePurchaseOrder.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
userId = json['userId'];
userEmail = json['userEmail'];
createdDate = JsonConverters.fromJson(json['createdDate'],'DateTime',context!);
Void = json['void'];
couponCode = json['couponCode'];
orderItems = JsonConverters.fromJson(json['orderItems'],'List<PurchaseOrderItemDto>',context!);
paymentType = json['paymentType'];
billingInformationDto = JsonConverters.fromJson(json['billingInformationDto'],'BillingInformationDto',context!);
return this;
}
Map<String, dynamic> toJson() => {
'userId': userId,
'userEmail': userEmail,
'createdDate': JsonConverters.toJson(createdDate,'DateTime',context!),
'void': Void,
'couponCode': couponCode,
'orderItems': JsonConverters.toJson(orderItems,'List<PurchaseOrderItemDto>',context!),
'paymentType': paymentType,
'billingInformationDto': JsonConverters.toJson(billingInformationDto,'BillingInformationDto',context!)
};
getTypeName() => "CreatePurchaseOrder";
TypeContext? context = _ctx;
}
TypeContext _ctx = TypeContext(library: 'accounts.dev.healthmonix.com', types: <String, TypeInfo> {
'PurchaseOrderItem': TypeInfo(TypeOf.Class, create:() => PurchaseOrderItem()),
'PurchaseOrderDto': TypeInfo(TypeOf.Class, create:() => PurchaseOrderDto()),
'List<PurchaseOrderItem>': TypeInfo(TypeOf.Class, create:() => <PurchaseOrderItem>[]),
'Details': TypeInfo(TypeOf.Class, create:() => Details()),
'CreatePurchaseOrderResponse': TypeInfo(TypeOf.Class, create:() => CreatePurchaseOrderResponse()),
'HttpStatusCode': TypeInfo(TypeOf.Class, create:() => HttpStatusCode()),
'List<Details>': TypeInfo(TypeOf.Class, create:() => <Details>[]),
'PurchaseOrderItemDto': TypeInfo(TypeOf.Class, create:() => PurchaseOrderItemDto()),
'BillingInformationDto': TypeInfo(TypeOf.Class, create:() => BillingInformationDto()),
'CreatePurchaseOrder': TypeInfo(TypeOf.Class, create:() => CreatePurchaseOrder()),
'List<PurchaseOrderItemDto>': TypeInfo(TypeOf.Class, create:() => <PurchaseOrderItemDto>[]),
});
To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml
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: application/xml
Content-Type: application/xml
Content-Length: length
<CreatePurchaseOrder xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Hmx.Accounts.ServiceModels">
<BillingInformationDto>
<CardNumber>String</CardNumber>
<CardType>String</CardType>
<City>String</City>
<CountryCode>String</CountryCode>
<Cvv2>String</Cvv2>
<ExpireMonth>0</ExpireMonth>
<ExpireYear>0</ExpireYear>
<FirstName>String</FirstName>
<LastName>String</LastName>
<Line1>String</Line1>
<PostalCode>String</PostalCode>
<State>String</State>
</BillingInformationDto>
<CouponCode>String</CouponCode>
<CreatedDate>0001-01-01T00:00:00</CreatedDate>
<OrderItems>
<PurchaseOrderItemDto>
<CreatedDate>0001-01-01T00:00:00</CreatedDate>
<Discount>0</Discount>
<DiscountDescription>String</DiscountDescription>
<DiscountSource>String</DiscountSource>
<Id>0</Id>
<Price>0</Price>
<ProductId>String</ProductId>
<ProductName>String</ProductName>
<PurchaseOrderId>0</PurchaseOrderId>
<Quantity>0</Quantity>
</PurchaseOrderItemDto>
</OrderItems>
<PaymentType>String</PaymentType>
<UserEmail>String</UserEmail>
<UserId>String</UserId>
<Void>false</Void>
</CreatePurchaseOrder>
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: length <CreatePurchaseOrderResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Hmx.Accounts.ServiceModels"> <Details> <Details> <Code>String</Code> <Field>String</Field> <Issue>String</Issue> </Details> </Details> <Message>String</Message> <PurchaseOrder> <BillingAddressCity>String</BillingAddressCity> <BillingAddressCountryCode>String</BillingAddressCountryCode> <BillingAddressLine1>String</BillingAddressLine1> <BillingAddressPostalCode>String</BillingAddressPostalCode> <BillingAddressState>String</BillingAddressState> <CouponCode>String</CouponCode> <CreatedDate>0001-01-01T00:00:00</CreatedDate> <Id>0</Id> <OrderItems xmlns:d3p1="http://schemas.datacontract.org/2004/07/Hmx.Accounts.Models"> <d3p1:PurchaseOrderItem> <d3p1:CreatedDate>0001-01-01T00:00:00</d3p1:CreatedDate> <d3p1:Discount>0</d3p1:Discount> <d3p1:DiscountDescription>String</d3p1:DiscountDescription> <d3p1:DiscountSource>String</d3p1:DiscountSource> <d3p1:Id>0</d3p1:Id> <d3p1:Price>0</d3p1:Price> <d3p1:ProductId>String</d3p1:ProductId> <d3p1:ProductName>String</d3p1:ProductName> <d3p1:PurchaseOrderId>0</d3p1:PurchaseOrderId> <d3p1:Quantity>0</d3p1:Quantity> </d3p1:PurchaseOrderItem> </OrderItems> <Paid>false</Paid> <Payer>String</Payer> <PaymentType>String</PaymentType> <TransactionIdentifier>String</TransactionIdentifier> <UserId>String</UserId> <Void>false</Void> </PurchaseOrder> <Status>Continue</Status> </CreatePurchaseOrderResponse>