Schema.hs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. {-# LANGUAGE TemplateHaskell #-}
  2. module Codec.ActivityStream.Schema where
  3. import Data.Aeson hiding (Object)
  4. import Data.Aeson.TH
  5. import Data.DateTime
  6. import Data.Text (Text)
  7. import Codec.ActivityStream.Internal
  8. import Codec.ActivityStream.Representation
  9. data SchemaVerb
  10. = Accept -- ^ Indicates that that the actor has accepted the object.
  11. -- For instance, a person accepting an award, or accepting
  12. -- an assignment.
  13. | Access -- ^ Indicates that the actor has accessed the object. For
  14. -- instance, a person accessing a room, or accessing a file.
  15. | Acknowledge -- ^ Indicates that the actor has acknowledged the object.
  16. -- This effectively signals that the actor is aware of the
  17. -- object's existence.
  18. | Add -- ^ Indicates that the actor has added the object to the target.
  19. -- For instance, adding a photo to an album.
  20. | Agree -- ^ Indicates that the actor agrees with the object. For example,
  21. -- a person agreeing with an argument, or expressing agreement
  22. -- with a particular issue.
  23. | Append -- ^ Indicates that the actor has appended the object to the
  24. -- target. For instance, a person appending a new record
  25. -- to a database.
  26. | Approve -- ^ Indicates that the actor has approved the object. For
  27. -- instance, a manager might approve a travel request.
  28. | Archive -- ^ Indicates that the actor has archived the object.
  29. | Assign -- ^ Indicates that the actor has assigned the object to the target.
  30. | At -- ^ Indicates that the actor is currently located at the object.
  31. -- For instance, a person being at a specific physical location.
  32. | Attach -- ^ Indicates that the actor has attached the object to the
  33. -- target. For instance, a person attaching a file to a wiki
  34. -- page or an email.
  35. | Attend -- ^
  36. | Author -- ^
  37. | Authorize -- ^
  38. | Borrow -- ^
  39. | Build -- ^
  40. | Cancel -- ^
  41. | Close -- ^
  42. | Complete -- ^
  43. | Confirm -- ^
  44. | Consume -- ^
  45. | Checkin -- ^
  46. | Create -- ^
  47. | Delete -- ^
  48. | Deliver -- ^
  49. | Deny -- ^
  50. | Disagree -- ^
  51. | Dislike -- ^
  52. | Experience -- ^
  53. | Favorite -- ^
  54. | Find -- ^
  55. | FlagAsInappropriate -- ^
  56. | Follow -- ^
  57. | Give -- ^
  58. | Host -- ^
  59. | Ignore -- ^
  60. | Insert -- ^
  61. | Install -- ^
  62. | Interact -- ^
  63. | Invite -- ^
  64. | Join -- ^
  65. | Leave -- ^
  66. | Like -- ^
  67. | Listen -- ^
  68. | Lose -- ^
  69. | MakeFriend -- ^
  70. | Open -- ^
  71. | Play -- ^
  72. | Post -- ^
  73. | Present -- ^
  74. | Purchase -- ^
  75. | Qualify -- ^
  76. | Read -- ^
  77. | Receive -- ^
  78. | Reject -- ^
  79. | Remove -- ^
  80. | RemoveFriend -- ^
  81. | Replace -- ^
  82. | Request -- ^
  83. | RequestFriend -- ^
  84. | Resolve -- ^
  85. | Return -- ^
  86. | Retract -- ^
  87. | RsvpMaybe -- ^
  88. | RsvpNo -- ^
  89. | RsvpYes -- ^
  90. | Satisfy -- ^
  91. | Save -- ^
  92. | Schedule -- ^
  93. | Search -- ^
  94. | Sell -- ^
  95. | Send -- ^
  96. | Share -- ^
  97. | Sponsor -- ^
  98. | Start -- ^
  99. | StopFollowing -- ^
  100. | Submit -- ^
  101. | Tag -- ^
  102. | Terminate -- ^
  103. | Tie -- ^
  104. | Unfavorite -- ^
  105. | Unlike -- ^
  106. | Unsatisfy -- ^
  107. | Unsave -- ^
  108. | Unshare -- ^
  109. | Update -- ^
  110. | Use -- ^
  111. | Watch -- ^
  112. | Win -- ^ foo
  113. deriving (Eq, Show, Read)
  114. deriveJSON (commonOptsCC "") ''SchemaVerb
  115. data SchemaObjectType
  116. = Alert
  117. | Application
  118. | Article
  119. | Audio
  120. | Badge
  121. | Binary
  122. | Bookmark
  123. | Collection
  124. | Comment
  125. | Device
  126. | Event
  127. | File
  128. | Game
  129. | Group
  130. | Image
  131. | Issue
  132. | Job
  133. | Note
  134. | Offer
  135. | Organization
  136. | Page
  137. | Person
  138. | Place
  139. | Process
  140. | Product
  141. | Question
  142. | Review
  143. | Service
  144. | Task
  145. | Video
  146. deriving (Eq, Show, Read)
  147. deriveJSON (commonOptsCC "") ''SchemaObjectType
  148. type SchemaObject = Object SchemaObjectType
  149. type SchemaCollection = Collection SchemaObjectType
  150. data AVObj = AVObj
  151. { avEmbedCode :: Maybe Text
  152. , avStream :: Maybe MediaLink
  153. , avRest :: SchemaObject
  154. } deriving (Eq, Show)
  155. data BinaryObj = BinaryObj
  156. { bnCompression :: Maybe Text
  157. , bnData :: Maybe Text
  158. , bnFileUrl :: Maybe Text
  159. , bnLength :: Maybe Int
  160. , bnMd5 :: Maybe Text
  161. , bnMimeType :: Maybe Text
  162. , bnRest :: SchemaObject
  163. } deriving (Eq, Show)
  164. data EventObj = EventObj
  165. { evAttendedBy :: Maybe SchemaCollection
  166. , evAttending :: Maybe SchemaCollection
  167. , evEndTime :: Maybe DateTime
  168. , evInvited :: Maybe SchemaCollection
  169. , evMaybeAttending :: Maybe SchemaCollection
  170. , evNotAttendedBy :: Maybe SchemaCollection
  171. , evNotAttending :: Maybe SchemaCollection
  172. , evStartTime :: Maybe DateTime
  173. , evRest :: SchemaObject
  174. } deriving (Eq, Show)
  175. data IssueObj = IssueObj
  176. { isTypes :: Maybe [Text]
  177. , isRest :: SchemaObject
  178. } deriving (Eq, Show)
  179. data PlaceObj = PlaceObj
  180. { plPosition :: Maybe PlacePositionObj
  181. , plAddress :: Maybe PlaceAddressObj
  182. , plRest :: SchemaObject
  183. } deriving (Eq, Show)
  184. data PlacePositionObj = PlacePositionObj
  185. { ppAltitude :: Integer
  186. , ppLatitude :: Integer
  187. , ppLongitude :: Integer
  188. } deriving (Eq, Show)
  189. data PlaceAddressObj = PlaceAddressObj
  190. { paFormatted :: Text
  191. , paStreetAddress :: Text
  192. , paLocality :: Text
  193. , paRegion :: Text
  194. , paPostalCode :: Text
  195. , paCountry :: Text
  196. } deriving (Eq, Show)
  197. data TaskObj = TaskObj
  198. { tsActor :: Maybe SchemaObject
  199. , tsBy :: Maybe DateTime
  200. , tsObject :: Maybe SchemaObject
  201. , tsPrerequisites :: Maybe [TaskObj]
  202. , tsRequired :: Maybe Bool
  203. , tsSupersedes :: Maybe [TaskObj]
  204. , tsVerb :: Maybe SchemaVerb
  205. , tsRest :: SchemaObject
  206. } deriving (Eq, Show)