Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
In case your license usage is consumed before expiry and you just want to have some additional discounted calls, one could buy these add-ons
  • Loading branch information
anandrgitnirman authored and anandrgitnirman committed Aug 31, 2021
1 parent 84da7d2 commit 93feadb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
7 changes: 7 additions & 0 deletions blockchain/serviceMetadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ import (
"group_id": "EoFmN3nvaXpf6ew8jJbIPVghE5NXfYupFF7PkRmVyGQ=",
{
"licenses": {
"addOns":[
{ "discountInPercentage": 4,
"addOnCostInAGIX":70,
"creditsInAGIX":100
"name": "Get Additional Calls worth 100 AGIX for 70 AGIX"
}
],
"tiers": [{
"type": "Tier",
"planName": "Tier AAA",
Expand Down
19 changes: 14 additions & 5 deletions license_server/license_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ const (
const (
SUBSCRIPTION = "SUBSCRIPTION"
TIER = "TIER"
ADD_ON = "ADD_ON"
AMOUNT = "AMOUNT"
CALLS = "CALLS"
)
Expand Down Expand Up @@ -183,11 +184,19 @@ func (u ValidityPeriod) String() string {
u.StartTimeUTC, u.EndTimeUTC, u.UpdateTimeUTC)
}

type AddOn struct {
ChannelId *big.Int
Discount Discount
//Expiry of AddOn will be tied to the license Type associated with it .
AssociatedLicense License
Details *PricingDetails
}

type Subscription struct {
ChannelId *big.Int
ServiceId string
Validity *ValidityPeriod
Details *SubscriptionPricingDetails
Details *PricingDetails
Discount Discount
AuthorizedAddresses []string
}
Expand Down Expand Up @@ -232,7 +241,7 @@ type TierPricingDetails struct {
ActualAmountSigned *big.Int
}

type SubscriptionPricingDetails struct {
type PricingDetails struct {
CreditsInCogs *big.Int // 100
FeeInCogs *big.Int //20AGI ,
PlanName string
Expand All @@ -241,7 +250,7 @@ type SubscriptionPricingDetails struct {
ServiceMethodDetails *ServiceMethodDetails //If this is null , implies it applies to all methods of the Service or just the one defined here
}

func (s SubscriptionPricingDetails) String() string {
func (s PricingDetails) String() string {
return fmt.Sprintf("{CreditsInCogs:%v,FeeInCogs:%v,PlanName:%v"+
",ValidityInDays:%v,ActualAmountSigned:%v,ServiceMethodDetails:%v}",
s.CreditsInCogs, s.FeeInCogs, s.PlanName, s.ValidityInDays, s.ActualAmountSigned,
Expand Down Expand Up @@ -325,7 +334,7 @@ func serializeLicenseDetailsData(value interface{}) (slice string, err error) {
e := gob.NewEncoder(&b)
gob.Register(&Subscription{})
gob.Register(&ValidityPeriod{})
gob.Register(&SubscriptionPricingDetails{})
gob.Register(&PricingDetails{})
gob.Register(&TierPricingDetails{})
gob.Register(&DiscountPercentage{})
gob.Register(&ServiceMethodDetails{})
Expand All @@ -343,7 +352,7 @@ func deserializeLicenseDetailsData(slice string, value interface{}) (err error)
b := bytes.NewBuffer([]byte(slice))
gob.Register(&Subscription{})
gob.Register(&ValidityPeriod{})
gob.Register(&SubscriptionPricingDetails{})
gob.Register(&PricingDetails{})
gob.Register(&TierPricingDetails{})
gob.Register(&DiscountPercentage{})
gob.Register(&ServiceMethodDetails{})
Expand Down
2 changes: 1 addition & 1 deletion license_server/license_storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func Test_serializeLicenseDetailsData(t *testing.T) {
ValidityPeriod: validityPeriod,
},

Details: &SubscriptionPricingDetails{
Details: &PricingDetails{
PlanName: "MyTestPlan",
ActualAmountSigned: big.NewInt(340),
ValidityInDays: 120,
Expand Down

0 comments on commit 93feadb

Please sign in to comment.