1 /**
2 * Copyright © DiamondMVC 2019
3 * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 * Author: Jacob Jensen (bausshf)
5 */
6 module diamond.seo.schema.structures.offer;
7 
8 import diamond.core.apptype;
9 
10 static if (isWeb)
11 {
12   import diamond.seo.schema.schemaobject;
13 
14   /// http://schema.org/ItemAvailability
15   enum ItemAvailability : string
16   {
17     /// Discontinued.
18     discontinued = "http://schema.org/Discontinued",
19 
20     /// In stock.
21     inStock = "http://schema.org/InStock",
22 
23     /// In store only.
24     inStoreOnly = "http://schema.org/InStoreOnly",
25 
26     /// Limited availability.
27     limitedAvailability = "http://schema.org/LimitedAvailability",
28 
29     /// Online only.
30     onlineOnly = "http://schema.org/OnlineOnly",
31 
32     /// Out of stock.
33     outOfStock = "http://schema.org/OutOfStock",
34 
35     /// Pre order.
36     preOrder = "http://schema.org/PreOrder",
37 
38     /// Pre sale.
39     preSale = "http://schema.org/PreSale",
40 
41     /// Sold out.
42     soldOut = "http://schema.org/SoldOut"
43   }
44 
45   /// http://schema.org/Offer
46   final class Offer : SchemaObject
47   {
48     private:
49     /// The price.
50     string _price;
51     /// The price currency.
52     string _priceCurrency;
53     /// The url.
54     string _url;
55     /// The availability.
56     ItemAvailability _availability;
57 
58     public:
59     final:
60     /// Creates a new offer.
61     this()
62     {
63       super("Offer");
64     }
65 
66     @property
67     {
68       /// Gets the price.
69       string price() { return _price; }
70 
71       /// Sets the price.
72       void price(string newPrice)
73       {
74         _price = newPrice;
75 
76         super.addField("price", _price);
77       }
78 
79       /// Gets the price currency.
80       string priceCurrency() { return _priceCurrency; }
81 
82       /// Sets the price currency.
83       void priceCurrency(string newPriceCurrency)
84       {
85         _priceCurrency = newPriceCurrency;
86       }
87 
88       /// Gets the url.
89       string url() { return _url; }
90 
91       /// Sets the url.
92       void url(string newUrl)
93       {
94         _url = newUrl;
95 
96         super.addField("url", _url);
97       }
98 
99       /// Gets the availability.
100       ItemAvailability availability() { return _availability; }
101 
102       /// Sets the availability.
103       void availability(ItemAvailability newAvailability)
104       {
105         _availability = newAvailability;
106 
107         super.addField("availability", cast(string)_availability);
108       }
109     }
110   }
111 }