diff --git a/projects/entity-data-api/database/.#init.sql b/projects/entity-data-api/database/.#init.sql deleted file mode 120000 index d0e117c3..00000000 --- a/projects/entity-data-api/database/.#init.sql +++ /dev/null @@ -1 +0,0 @@ -paul@hyperv.891:1565686417 \ No newline at end of file diff --git a/projects/or_scs/Mirza.cabal b/projects/or_scs/Mirza.cabal index fd92b635..f3d6b78d 100644 --- a/projects/or_scs/Mirza.cabal +++ b/projects/or_scs/Mirza.cabal @@ -69,6 +69,7 @@ library , hashable , hoist-error >= 0.2 , http-client + , http-media , insert-ordered-containers , jose , katip >= 0.5.4 diff --git a/projects/or_scs/src/Mirza/SupplyChain/API.hs b/projects/or_scs/src/Mirza/SupplyChain/API.hs index f0121486..ac465675 100644 --- a/projects/or_scs/src/Mirza/SupplyChain/API.hs +++ b/projects/or_scs/src/Mirza/SupplyChain/API.hs @@ -22,8 +22,11 @@ import Mirza.SupplyChain.Types as ST import Mirza.SupplyChain.Handlers.UXUtils (PrettyEventResponse (..)) import qualified Data.GS1.Event as Ev +import Data.GS1.Parser.Parser ( parseBS ) import Data.GS1.EventId as EvId +import Data.ByteString.Lazy ( ByteString ) +import Network.HTTP.Media ( (//) ) import Servant import Servant.Swagger.UI @@ -39,6 +42,22 @@ serverAPI :: Proxy ServerAPI serverAPI = Proxy +data XML + +class FromXML a where + fromXML :: ByteString -> Either String a + +instance Accept XML where + contentType _ = "text" // "xml" + +instance FromXML a => MimeUnrender XML a where + mimeUnrender _ = fromXML + +instance FromXML Ev.Event where + fromXML bs = case parseBS bs of + [] -> Left "No events in document" + (x:_) -> either (Left . show) Right x + type ServerAPI = -- Health "healthz" :> Get '[JSON] HealthResponse @@ -56,7 +75,7 @@ type ServerAPI = :> Capture "eventId" EventId :> Get '[JSON] EventInfo -- Event Registration - :<|> "event" :> ReqBody '[JSON] Ev.Event + :<|> "event" :> ReqBody '[JSON, XML] Ev.Event :> Post '[JSON] (EventInfo, Schema.EventId) -- UI :<|> "prototype" :> "list" :> "events" diff --git a/projects/or_scs/stack.yaml b/projects/or_scs/stack.yaml index aa6a0ae6..baa62b63 100644 --- a/projects/or_scs/stack.yaml +++ b/projects/or_scs/stack.yaml @@ -13,7 +13,7 @@ extra-deps: - git: https://github.com/sajidanower23/hs-jose.git commit: d7aca4d13b27235af47d522b5d093e567750628e - git: https://github.com/data61/GS1Combinators.git - commit: 7f0f0c9c2ec6d91378ac56ba63de033fcc313326 # Head on 2019-06-14 + commit: ddb92e443055e7719fa46afa5913cf2276cfd71e # Head on 2019-08-13 - servant-flatten-0.2 - hoist-error-0.2.1.0 diff --git a/projects/or_scs/stack.yaml.lock b/projects/or_scs/stack.yaml.lock index 605bb621..5a0137f9 100644 --- a/projects/or_scs/stack.yaml.lock +++ b/projects/or_scs/stack.yaml.lock @@ -68,18 +68,18 @@ packages: commit: d7aca4d13b27235af47d522b5d093e567750628e - completed: cabal-file: - size: 2908 - sha256: cd111c999f253f8985a8b223cc3e493b97cd82cc2fbb03779afe54590ce29738 + size: 2942 + sha256: 8895b8bd234fe57d281f6a4db32c56850b9f0640fd07cb9753a09b8fbe1ce36e name: GS1Combinators version: 0.1.0.0 git: https://github.com/data61/GS1Combinators.git pantry-tree: size: 8991 - sha256: 5c079cf09bfdce60cb82ac2454a30631b3565067a202dd5ea0351a95cb2edec7 - commit: 7f0f0c9c2ec6d91378ac56ba63de033fcc313326 + sha256: 3f045313a67962e750526f46a42ca7190feac345fa6eb1384c17655e532564c8 + commit: ddb92e443055e7719fa46afa5913cf2276cfd71e original: git: https://github.com/data61/GS1Combinators.git - commit: 7f0f0c9c2ec6d91378ac56ba63de033fcc313326 + commit: ddb92e443055e7719fa46afa5913cf2276cfd71e - completed: hackage: servant-flatten-0.2@sha256:276896f7c5cdec5b8f8493f6205fded0cc602d050b58fdb09a6d7c85c3bb0837,1234 pantry-tree: