flamingo.me/flamingo-commerce/v3@v3.11.0/cart/interfaces/graphql/dto/dto.go (about) 1 package dto 2 3 import ( 4 "flamingo.me/flamingo-commerce/v3/cart/interfaces/controller/forms" 5 productDomain "flamingo.me/flamingo-commerce/v3/product/domain" 6 7 "time" 8 9 formDomain "flamingo.me/form/domain" 10 ) 11 12 type ( 13 // BillingAddressForm is the GraphQL representation of the billing form 14 BillingAddressForm struct { 15 FormData forms.AddressForm 16 Processed bool 17 ValidationInfo ValidationInfo 18 } 19 20 // DeliveryAddressForm is the GraphQL representation of the delivery form 21 DeliveryAddressForm struct { 22 FormData forms.AddressForm 23 Processed bool 24 ValidationInfo ValidationInfo 25 UseBillingAddress bool 26 DeliveryCode string 27 Method string 28 Carrier string 29 DesiredTime time.Time 30 } 31 32 // DeliveryShippingOption used to update shipping method/carrier for a specific delivery 33 DeliveryShippingOption struct { 34 DeliveryCode string 35 Method string 36 Carrier string 37 } 38 39 // ValidationInfo contains form related validation information 40 ValidationInfo struct { 41 GeneralErrors []formDomain.Error 42 FieldErrors []FieldError 43 } 44 45 // FieldError contains field related errors 46 FieldError struct { 47 // MessageKey - a key of the error message. Often used to pass to translation func in the template 48 MessageKey string 49 // DefaultLabel - a speaking error label. OFten used to show to end user - in case no translation exists 50 DefaultLabel string 51 // FieldName 52 FieldName string 53 } 54 55 // SelectedPaymentResult represents the selected payment 56 SelectedPaymentResult struct { 57 Processed bool 58 ValidationInfo ValidationInfo 59 } 60 61 // UpdateShippingOptionsResult definition 62 UpdateShippingOptionsResult struct { 63 Processed bool 64 } 65 66 AddToCart struct { 67 MarketplaceCode string 68 Qty int 69 DeliveryCode string 70 VariantMarketplaceCode string 71 BundleConfiguration []ChoiceConfiguration 72 } 73 74 ChoiceConfiguration struct { 75 Identifier string 76 MarketplaceCode string 77 VariantMarketplaceCode *string 78 Qty int 79 } 80 ) 81 82 func MapBundleConfigToDomain(graphqlBundleConfig []ChoiceConfiguration) productDomain.BundleConfiguration { 83 cartBundleConfiguration := make(map[productDomain.Identifier]productDomain.ChoiceConfiguration) 84 85 for _, configuration := range graphqlBundleConfig { 86 variantMarketplaceCode := "" 87 88 if configuration.VariantMarketplaceCode != nil { 89 variantMarketplaceCode = *configuration.VariantMarketplaceCode 90 } 91 92 cartBundleConfiguration[productDomain.Identifier(configuration.Identifier)] = productDomain.ChoiceConfiguration{ 93 MarketplaceCode: configuration.MarketplaceCode, 94 VariantMarketplaceCode: variantMarketplaceCode, 95 Qty: configuration.Qty, 96 } 97 } 98 99 return cartBundleConfiguration 100 }