unique ids
This commit is contained in:
@@ -65,6 +65,7 @@ type CartNotification struct {
|
|||||||
|
|
||||||
type SubscriptionDetails struct {
|
type SubscriptionDetails struct {
|
||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
|
Version uint16 `json:"version"`
|
||||||
OfferingCode string `json:"offeringCode,omitempty"`
|
OfferingCode string `json:"offeringCode,omitempty"`
|
||||||
SigningType string `json:"signingType,omitempty"`
|
SigningType string `json:"signingType,omitempty"`
|
||||||
Meta json.RawMessage `json:"data,omitempty"`
|
Meta json.RawMessage `json:"data,omitempty"`
|
||||||
|
|||||||
@@ -24,8 +24,10 @@ func UpsertSubscriptionDetails(g *CartGrain, m *messages.UpsertSubscriptionDetai
|
|||||||
}
|
}
|
||||||
|
|
||||||
id := MustNewCartId().String()
|
id := MustNewCartId().String()
|
||||||
|
|
||||||
g.SubscriptionDetails[id] = &SubscriptionDetails{
|
g.SubscriptionDetails[id] = &SubscriptionDetails{
|
||||||
Id: id,
|
Id: id,
|
||||||
|
Version: 1,
|
||||||
OfferingCode: m.OfferingCode,
|
OfferingCode: m.OfferingCode,
|
||||||
SigningType: m.SigningType,
|
SigningType: m.SigningType,
|
||||||
Meta: meta,
|
Meta: meta,
|
||||||
@@ -38,11 +40,14 @@ func UpsertSubscriptionDetails(g *CartGrain, m *messages.UpsertSubscriptionDetai
|
|||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("subscription details not found")
|
return fmt.Errorf("subscription details not found")
|
||||||
}
|
}
|
||||||
|
changed := false
|
||||||
if m.OfferingCode != "" {
|
if m.OfferingCode != "" {
|
||||||
existing.OfferingCode = m.OfferingCode
|
existing.OfferingCode = m.OfferingCode
|
||||||
|
changed = true
|
||||||
}
|
}
|
||||||
if m.SigningType != "" {
|
if m.SigningType != "" {
|
||||||
existing.SigningType = m.SigningType
|
existing.SigningType = m.SigningType
|
||||||
|
changed = true
|
||||||
}
|
}
|
||||||
if m.Data != nil {
|
if m.Data != nil {
|
||||||
// Only validate & assign if there is content; empty -> leave as-is.
|
// Only validate & assign if there is content; empty -> leave as-is.
|
||||||
@@ -51,7 +56,11 @@ func UpsertSubscriptionDetails(g *CartGrain, m *messages.UpsertSubscriptionDetai
|
|||||||
return fmt.Errorf("subscription details invalid json")
|
return fmt.Errorf("subscription details invalid json")
|
||||||
}
|
}
|
||||||
existing.Meta = m.Data.Value
|
existing.Meta = m.Data.Value
|
||||||
|
changed = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if changed {
|
||||||
|
existing.Version++
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user