Add Amazon support (#3)
This commit introduces the Amazon support with calls to the Product Advertising API (PA API). For now, I was only able to use the "www.amazon.fr" marketplace. I will add more marketplaces when my Amazon Associate accounts will be validated. Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
parent
f994093baf
commit
5ac5f78ae2
11 changed files with 394 additions and 111 deletions
10
models.go
10
models.go
|
|
@ -23,7 +23,13 @@ func (p *Product) Equal(other *Product) bool {
|
|||
|
||||
// IsValid returns true when a Product has all required values
|
||||
func (p *Product) IsValid() bool {
|
||||
return p.Name != "" && p.URL != "" && p.Price != 0 && p.PriceCurrency != ""
|
||||
if p.Name == "" || p.URL == "" {
|
||||
return false
|
||||
}
|
||||
if p.Available && p.PriceCurrency == "" {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// Merge one product with another
|
||||
|
|
@ -40,6 +46,6 @@ func (p *Product) ToMerge(o *Product) bool {
|
|||
|
||||
// Shop represents a retailer website
|
||||
type Shop struct {
|
||||
ID uint `gorm:"primaryKey"`
|
||||
ID uint `gorm:"primaryKey;autoIncrement"`
|
||||
Name string `gorm:"unique" json:"name"`
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue