diff --git a/model/offer/offer-apis.smithy b/model/offer/offer-apis.smithy new file mode 100644 index 0000000..2645640 --- /dev/null +++ b/model/offer/offer-apis.smithy @@ -0,0 +1,80 @@ +$version: "2" + +namespace com.shopping.inandout.offer + +use com.shopping.inandout#ResourceAlreadyExistsError +use com.shopping.inandout#ResourceNotFoundError +use com.shopping.inandout.util#ID +use com.shopping.inandout.util#NaturalNumber +use com.shopping.inandout.util#Percentage +use com.shopping.inandout.util#Slug +use com.shopping.inandout.util#SlugList +use com.shopping.inandout.util#TimeRange +use com.shopping.inandout.util#UIDList + +resource Offer { + identifiers: { + brandSlug: Slug + offerId: ID + } + properties: { + percentage: Percentage + storeIdList: UIDList + articleSlugList: SlugList + dependencyList: DependencyList + timeRange: TimeRange + lifetime: NaturalNumber + createdAt: Timestamp + updatedAt: Timestamp + } + create: CreateOffer + read: GetOffer + list: ListOffers + update: UpdateOffer + delete: DeleteOffer +} + +@http(method: "POST", uri: "/api/brands/{brandSlug}/offers") +operation CreateOffer { + input: CreateOfferInput + output: OfferSummary + errors: [ + ResourceAlreadyExistsError + ] +} + +@readonly +@http(method: "GET", uri: "/api/brands/{brandSlug}/offers/{offerId}") +operation GetOffer { + input: GetOfferInput + output: OfferSummary + errors: [ + ResourceNotFoundError + ] +} + +@readonly +@paginated +@http(method: "GET", uri: "/api/brands/{brandSlug}/offers") +operation ListOffers { + input: ListOffersInput + output: OfferSummaries +} + +@http(method: "PATCH", uri: "/api/brands/{brandSlug}/offers/{offerId}") +@documentation("Non-idempotent cascading operation, creates/deletes internal resources as needed") +operation UpdateOffer { + input: UpdateOfferInput + output: OfferSummary + errors: [ + ResourceNotFoundError + ] +} + +@idempotent +@http(method: "DELETE", uri: "/api/brands/{brandSlug}/offers/{offerId}") +@documentation("Not restricted cascading operation, deletes discounts, dependencies, etc.") +operation DeleteOffer { + input: DeleteOfferInput + output: OfferSummary +} diff --git a/model/offer/offer-io.smithy b/model/offer/offer-io.smithy new file mode 100644 index 0000000..fb497b5 --- /dev/null +++ b/model/offer/offer-io.smithy @@ -0,0 +1,81 @@ +$version: "2" + +namespace com.shopping.inandout.offer + +use com.shopping.inandout.util#ID +use com.shopping.inandout.util#InputPagination +use com.shopping.inandout.util#NaturalNumber +use com.shopping.inandout.util#Percentage +use com.shopping.inandout.util#Slug +use com.shopping.inandout.util#SlugList +use com.shopping.inandout.util#TimeRange +use com.shopping.inandout.util#UIDList + +structure CreateOfferInput { + @required + @httpLabel + brandSlug: Slug + + @required + percentage: Percentage + + storeIdList: UIDList + + @required + articleSlugList: SlugList + + dependencyList: DependencyList + + timeRange: TimeRange + + @required + lifetime: NaturalNumber +} + +structure GetOfferInput { + @required + @httpLabel + brandSlug: Slug + + @required + @httpLabel + offerId: ID +} + +structure ListOffersInput with [InputPagination] { + @required + @httpLabel + brandSlug: Slug +} + +structure UpdateOfferInput { + @required + @httpLabel + brandSlug: Slug + + @required + @httpLabel + offerId: ID + + percentage: Percentage + + storeIdList: UIDList + + articleSlugList: SlugList + + dependencyList: DependencyList + + timeRange: TimeRange + + lifetime: NaturalNumber +} + +structure DeleteOfferInput { + @required + @httpLabel + brandSlug: Slug + + @required + @httpLabel + offerId: ID +} diff --git a/model/offer/offer-types.smithy b/model/offer/offer-types.smithy new file mode 100644 index 0000000..4bd90b6 --- /dev/null +++ b/model/offer/offer-types.smithy @@ -0,0 +1,61 @@ +$version: "2" + +namespace com.shopping.inandout.offer + +use com.shopping.inandout.util#ID +use com.shopping.inandout.util#NaturalNumber +use com.shopping.inandout.util#OutputPagination +use com.shopping.inandout.util#Percentage +use com.shopping.inandout.util#Slug +use com.shopping.inandout.util#SlugList +use com.shopping.inandout.util#TimeRange +use com.shopping.inandout.util#UIDList + +@documentation("Product dependency; it must be bought in order for the offer to activate.") +structure Dependency { + @required + articleSlug: Slug + + quantity: NaturalNumber +} + +list DependencyList { + member: Dependency +} + +structure OfferSummary { + @required + brandSlug: Slug + + @required + offerId: ID + + @required + percentage: Percentage + + storeIdList: UIDList + + @required + articleSlugList: SlugList + + dependencyList: DependencyList + + timeRange: TimeRange + + @required + lifetime: NaturalNumber + + @required + createdAt: Timestamp + + @required + updatedAt: Timestamp +} + +list OfferSummaryList { + member: OfferSummary +} + +structure OfferSummaries with [OutputPagination] { + tokens: OfferSummaryList +}