design

package
v0.0.0-...-2469c04 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2018 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PurchaseMedia = MediaType("application/json", func() {
	TypeName("Purchase")
	Reference(PurchasePayload)

	Attributes(func() {

		Attribute("transaction_id", String, "Unique transaction identifier", func() {
			Metadata("struct:tag:json", "transaction_id")
			Metadata("struct:field:name", "TransactionID")
			Metadata("struct:tag:bson", "_id,omitempty")
			Pattern("^[0-9a-fA-F]{24}$")
		})
		Attribute("locator", String, "Operation reference code", func() {
			Metadata("struct:tag:json", "locator")
			Metadata("struct:field:name", "Locator")
		})

		Attribute("purchase_value", Number, "Total amount paid", func() {
			Metadata("struct:tag:json", "purchase_value")
			Metadata("struct:field:name", "PurchaseValue")
		})

		Attribute("status", String, "Purchase status", func() {
			Metadata("struct:tag:json", "status")
			Metadata("struct:field:name", "Status")
		})

		Attribute("href", String, "API href of Purchase", func() {
			Example("/pos/v1/purchases/5a06839d42e6552b004a7e03")
			Metadata("struct:tag:json", "href")
			Metadata("struct:field:name", "Href")
		})

		Required("transaction_id", "locator", "purchase_value", "status", "href")
	})

	View("default", func() {
		Attribute("transaction_id")
		Attribute("locator")
		Attribute("purchase_value")
		Attribute("status")
		Attribute("href")
	})
})
View Source
var PurchasePayload = Type("PurchasePayload", func() {
	Description("Detailed information regarding a POS purchase operation")

	Attribute("id", func() {
		Metadata("struct:tag:bson", "_id,omitempty")
		Metadata("struct:field:name", "ID")
		Metadata("struct:field:type", "bson.ObjectId", "gopkg.in/mgo.v2/bson")
		Example("")
	})

	Attribute("status", String, func() {
		Metadata("struct:tag:bson", "status,omitempty")
		Metadata("struct:field:name", "Status")
		Example("")
	})

	Attribute("locator", String, "Operation reference code", func() {
		Metadata("struct:field:name", "Locator")
		Metadata("struct:tag:bson", "locator,omitempty")

		Example("MPOS00123820-UAT-A02")

		MinLength(1)
		MaxLength(30)
	})

	Attribute("purchase_value", Number, "Total amount paid", func() {
		Metadata("struct:field:name", "PurchaseValue")
		Metadata("struct:tag:bson", "purchase_value,omitempty")

		Example(119.99)

		Minimum(0.01)
	})

	Required("locator", "purchase_value")
})

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL