flamingo.me/flamingo-commerce/v3@v3.11.0/product/domain/productService.go (about)

     1  package domain
     2  
     3  import (
     4  	"context"
     5  	"fmt"
     6  
     7  	searchDomain "flamingo.me/flamingo-commerce/v3/search/domain"
     8  )
     9  
    10  //go:generate go run github.com/vektra/mockery/v2@v2.42.3 --name ProductService --case snake
    11  
    12  type (
    13  	// ProductService interface
    14  	ProductService interface {
    15  		// Get a product
    16  		Get(ctx context.Context, marketplaceCode string) (BasicProduct, error)
    17  	}
    18  
    19  	// SearchResult returns product hits
    20  	SearchResult struct {
    21  		searchDomain.Result
    22  		Hits []BasicProduct
    23  	}
    24  
    25  	// SearchService is a typed search for products
    26  	SearchService interface {
    27  		//Search returns Products based on given Filters
    28  		Search(ctx context.Context, filter ...searchDomain.Filter) (*SearchResult, error)
    29  		// SearchBy returns Products prefiltered by the given attribute (also based on additional given Filters)
    30  		// e.g. SearchBy(ctx,"brandCode","apple")
    31  		SearchBy(ctx context.Context, attribute string, values []string, filter ...searchDomain.Filter) (*SearchResult, error)
    32  	}
    33  
    34  	// ProductNotFound is an error
    35  	ProductNotFound struct {
    36  		MarketplaceCode string
    37  	}
    38  )
    39  
    40  // Error implements the error interface
    41  func (err ProductNotFound) Error() string {
    42  	return fmt.Sprintf("Product with Marketplace Code %q Not Found", err.MarketplaceCode)
    43  }