Enhance GET items

This commit is contained in:
Rene Vergara 2023-05-25 10:42:40 -05:00
parent 958f04ee11
commit 857a298b96
Signed by: pitmutt
GPG key ID: 65122AD495A7F5B2
5 changed files with 21 additions and 13 deletions

View file

@ -4,11 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [1.5.1]
## [1.6.0]
### Changed
- Modified the process to mark paid orders to ensure only payments to the shop's wallet get marked as paid
- Modified the `items` endpoint to use the login session to identify records
## [1.5.0] - 2023-05-15

View file

@ -1,5 +1,5 @@
name: zgo-backend
version: 1.5.1
version: 1.6.0
git: "https://git.vergara.tech/Vergara_Tech/zgo-backend"
license: BOSL
author: "Rene Vergara"

View file

@ -12,6 +12,7 @@ import Data.Time.Clock
import Database.MongoDB
import GHC.Generics
import Test.QuickCheck
import User
-- | Type to represent a ZGo item
data Item =

View file

@ -1025,8 +1025,12 @@ routes pipe config = do
else status noContent204
--Get items associated with the given address
get "/api/items" $ do
addr <- param "address"
items <- liftAndCatchIO $ run (findItems addr)
session <- param "session"
user <- liftAndCatchIO $ run (findUser session)
case cast' . Doc =<< user of
Nothing -> status unauthorized401
Just u -> do
items <- liftAndCatchIO $ run (findItems $ uaddress u)
case items of
[] -> status noContent204
_ -> do
@ -1034,7 +1038,9 @@ routes pipe config = do
status ok200
Web.Scotty.json
(object
["message" .= ("Items found!" :: String), "items" .= toJSON pItems])
[ "message" .= ("Items found!" :: String)
, "items" .= toJSON pItems
])
--Upsert item
post "/api/item" $ do
i <- jsonData

View file

@ -5,7 +5,7 @@ cabal-version: 1.12
-- see: https://github.com/sol/hpack
name: zgo-backend
version: 1.5.1
version: 1.6.0
synopsis: Haskell Back-end for the ZGo point-of-sale application
description: Please see the README at <https://git.vergara.tech/Vergara_Tech//zgo-backend#readme>
category: Web