S++Core systems, human-reviewable
DEMO SOURCE · SPP / APP / PHYRead the book

petshop-10-services.spp

petshop/membership/petshop-10-services.spp

Download original file · Petstore source contents

1domain petshop;23atomic check checkCustomerProfile(Buyer) {4    require(buyer.name != BLANK, RejectionCode.NAME_REQUIRED);5    require(buyer.email != BLANK, RejectionCode.EMAIL_REQUIRED);6    require(buyer.address != BLANK, RejectionCode.ADDRESS_REQUIRED);7    require(8        buyer.tier == MemberTier.NORMAL || buyer.tier == MemberTier.VIP,9        RejectionCode.INVALID_MEMBER_TIER10    );11}1213atomic calculate registerCustomer(Buyer, Cart) {14    cart.buyer = buyer;15    cart.lines = new CartLine[] {16    };17}1819atomic calculate updateProfile(ProfileAgreement, Buyer) {20    buyer.name = profileAgreement.newName;21    buyer.email = profileAgreement.newEmail;22    buyer.address = profileAgreement.newAddress;23    buyer.tier = profileAgreement.newTier;24}2526atomic check checkNewCustomer(Buyer) {27    require(!buyer, RejectionCode.CUSTOMER_EXISTS);28}2930atomic check checkBuyerCredential(Buyer) {31    require(buyer.membershipNumber != BLANK, RejectionCode.MEMBERSHIP_NUMBER_REQUIRED);32}3334atomic calculate locateBuyerCart(Buyer, Cart) {35    cart.buyer = buyer;36}