# Coupon graphQL # 1. get all - not needed but just to show all fields from hygraph and explanation ``` query GetCoupons{ coupons { couponId type title // string couponImage { url // url for the image } shortDescription // string, don't know if we need this? longDescription { html // longer description - rich text editor content } singleUse // boolean, can the coupon be used multiple times or not rewardLevel // string, shows what reward level belongs to priceSystem // float, used for calculations priceView // string, visual can be anything posReply // json, sent to code service for POS query feedbackFormId // hubspot js embed } } ``` --- # 2. get by type ## coupon - List behind an icon on homescreen - Can be used **ONLY ONCE** per user - ReceiptService will update CodeService and update that user has used this coupon ``` query GetCouponsByType { coupons(where: {active: true, type: coupon}) { couponId type title couponImage { url } longDescription { html } priceView singleUse posReply } } ``` --- ## campaign - List behind an icon on homescreen - Can be used multiple times - Since can be used multiple times ReceiptService will **NOT** update CodeService and update that user has used this coupon ``` query GetCouponsByType { coupons(where: {active: true, type: campaign}) { couponId type title couponImage { url } longDescription { html } priceView singleUse posReply } } ``` --- ## reward - Can be used multiple times - No visible button or element for these, if userRewardLevel == rewardLevel send posReply to CodeService when quering for auth QRcode OTP - Since can be used multiple times ReceiptService will **NOT** update CodeService and update that user has used this coupon ``` query GetCouponsByType { coupons(where: {active: true, type: reward}) { couponId type rewardLevel singleUse posReply } } ``` --- ## task - Only one task shown on homescreen - user fills form that is specified in feedbackFormId field - once user submits form >> task completed, update CodeService* - once task is completed show next task: couponId: T1, T2, T3... **Note:** *ClientApp should update the CodeService that task(coupon) is "used" for this userId (needs more info from taras, what endpoint, how works...) ``` query GetCouponsByType { coupons(where: {active: true, type: task}) { couponId type title couponImage { url } longDescription { html } feedbackFormId singleUse } } ```