Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions model/offer/offer-apis.smithy
Original file line number Diff line number Diff line change
@@ -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
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also 404 error, in case that brandSlug does not exist

]
}

@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
}
81 changes: 81 additions & 0 deletions model/offer/offer-io.smithy
Original file line number Diff line number Diff line change
@@ -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
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dd some queries. offers added today? offer to expire today, tomorrow, in a week? offer to a product? offers in a store?

}

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
}
61 changes: 61 additions & 0 deletions model/offer/offer-types.smithy
Original file line number Diff line number Diff line change
@@ -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
}