Skip to content

Commit

Permalink
revert shopper-products
Browse files Browse the repository at this point in the history
  • Loading branch information
alexvuong committed Mar 4, 2024
1 parent c921d4a commit f38e7bb
Show file tree
Hide file tree
Showing 38 changed files with 1,583 additions and 10 deletions.
30 changes: 30 additions & 0 deletions apis/product/shopper-products/Traits/GetProductBadRequest.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#%RAML 1.0 Trait
description: This trait represents API behavior for a 400 response.
responses:
400:
description: Bad Request.
body:
application/problem+json:
type: ErrorResponse
examples:
BadRequest: |
{
"title": "Bad Request",
"type": "https://api.commercecloud.salesforce.com/documentation/error/v1/errors/validation",
"detail": "Maximum number of products you can request in one call is 25."
}
MalformedSelector: |
{
"title": "Malformed Selector",
"type": "https://api.commercecloud.salesforce.com/documentation/error/v1/errors/malformed-selector",
"detail": "The property selector '(brand,imageGroups.(**)' is malformed.",
"selector": "(brand,imageGroups.(**)"
}
FilterExpressionBadRequest: |
{
"title": "Bad Request",
"type": "https://api.commercecloud.salesforce.com/documentation/error/v1/errors/bad-request",
"detail": "Filter expressions in select are not supported.",
"parameter": "Filter expressions in select are not supported.",
"selector": "(recommendations[?(recommendedItemId=='apple-ipod-nano'].(**))"
}
24 changes: 24 additions & 0 deletions apis/product/shopper-products/Traits/GetProductsBadRequest.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#%RAML 1.0 Trait
description: This trait represents API behavior for a 400 response.
responses:
400:
description: Bad Request.
body:
application/problem+json:
type: ErrorResponse
examples:
MalformedSelectorGetProducts: |
{
"title": "Malformed Selector",
"type": "https://api.commercecloud.salesforce.com/documentation/error/v1/errors/malformed-selector",
"detail": "The property selector '(data.(name, imageGroups.(**))' is malformed.",
"selector": "(data.(name, imageGroups.(**))"
}
FilterExpressionBadRequestGetProducts: |
{
"title": "Bad Request",
"type": "https://api.commercecloud.salesforce.com/documentation/error/v1/errors/bad-request",
"detail": "Filter expressions in select are not supported.",
"parameter": "Filter expressions in select are not supported.",
"selector": "(data[?(brand=='abc')].(**))"
}
2 changes: 1 addition & 1 deletion apis/product/shopper-products/exchange.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"main":"shopper-products.raml","name":"Shopper Products","classifier":"raml","tags":[],"groupId":"893f605e-10e2-423a-bdb4-f952f56eb6d8","backwardsCompatible":false,"assetId":"shopper-products","version":"0.0.24","apiVersion":"v1","dependencies":[{"groupId":"893f605e-10e2-423a-bdb4-f952f56eb6d8","assetId":"commerce-cloud-standards","version":"1.0.24"},{"groupId":"893f605e-10e2-423a-bdb4-f952f56eb6d8","assetId":"api-standards","version":"1.1.15"}],"originalFormatVersion":"1.0"}
{"main":"shopper-products.raml","name":"Shopper Products","classifier":"raml","tags":[],"groupId":"893f605e-10e2-423a-bdb4-f952f56eb6d8","backwardsCompatible":false,"assetId":"shopper-products","version":"0.0.25","apiVersion":"v1","dependencies":[{"groupId":"893f605e-10e2-423a-bdb4-f952f56eb6d8","assetId":"api-standards","version":"1.1.15"},{"groupId":"893f605e-10e2-423a-bdb4-f952f56eb6d8","assetId":"commerce-cloud-standards","version":"1.0.27"}],"originalFormatVersion":"1.0","organizationId":"893f605e-10e2-423a-bdb4-f952f56eb6d8"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#%RAML 1.0 DocumentationItem
title: Error Response Mapping from OCAPI to Mulesoft

content: |-
# NOTE: this documentation does not belong here any may be moved in the future.
- ErrorResponse defined in [API Standards RAML library](https://anypoint.mulesoft.com/exchange/893f605e-10e2-423a-bdb4-f952f56eb6d8/api-standards/) *MUST* be used in case of error. Teams MAY derive their own error response types from ErrorResponse.
- ErrorResponse.type *MUST* be unique CommerceCloud-wide. This is an unequivocal identification of the error and therefore should be unique.
- Work to write a common data weave that will transform the OCAPI Fault to [RFC 7807](https://tools.ietf.org/html/rfc7807) compliant messages
- Content-Type: `application/problem+json`
- `type`: URI in the format of https://api.commercecloud.salesforce.com/documentation/error/v1/errors/<kebab-case-`fault.type`>, with the word “Exception” removed from the last segment.
- `title`: the `fault.type`, Upper Space Case, with the word “Exception” removed.
- `detail`: the content of fault.message
- Any attributes in `fault.arguments` just map to extra attributes of the same name, following all camelCase conventions.
## Example Mapping:
### OCAPI Fault Response
{
"_v" : "20.2",
"fault": {
"arguments": {
"target_cartridge": "core"
},
"type": "InvalidOperationException",
"message": "Invalid operation on cartridge 'core'. The operation is only allowed on existing custom cartridge."
}
}
### Mapped ErrorResponse
{
"type": "https://api.commercecloud.salesforce.com/documentation/error/v1/errors/invalid-operation",
"title": "Invalid Operation",
"detail": "Invalid operation on cartridge 'core'. The operation is only allowed on existing custom cartridge.",
"targetCartridge": "core"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#%RAML 1.0 DocumentationItem
title: baseUri Standards
content: |
# NOTE: this is internal documentation.
The baseUri has been standardized as the following. You should use the below snippet in your RAML definitions:
baseUri: https://{shortCode}.api.commercecloud.salesforce.com/api-family/api-name/{version}
version: v1
baseUriParameters:
shortCode:
description: A region-specific merchant identifier.
example: 0dnz6oep
pattern: ^([a-z0-9]+)(-[a-z0-9]+)*$
Of note:
- the baseUri is templated URL that is templated for constency, all URLs accross commerce cloud will have the same baseUrl
- you MUST set the values of the api-family and api-name in the URI to your api-family and api-name. These shouldn't ever change and should be in lower case kebab case
- Api-family is also known as bounded context
- Api-name is also known as root aggregate
- the only baseUriParameter that will change between calls is `shortCode`.
- `version` is special and will use the version of the API.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"operator": "and",
"filters": [
{
"termFilter": {
"field": "id",
"operator": "is",
"values": [
"myId"
]
}
},
{
"termFilter": {
"field": "couponId",
"operator": "is",
"values": [
"couponOne"
]
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"must": [
{
"textQuery": {
"fields": [
"couponId"
],
"searchPhrase": "DEAL"
}
},
{
"textQuery": {
"fields": [
"description"
],
"searchPhrase": "Big bargain deal"
}
}
],
"mustNot": [
{
"termQuery": {
"fields": [
"enabled"
],
"operator": "is",
"values": [
false
]
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#%RAML 1.0 NamedExample
MultipleOperatorExample:
must:
- textQuery:
fields:
- couponId
searchPhrase: DEAL
should:
- textQuery:
fields:
- couponId
searchPhrase: DEAL
- textQuery:
fields:
- couponId
- description
searchPhrase: sale
must_not:
- textQuery:
fields:
- description
searchPhrase: Big bargain
AndOperatorExample:
must:
- textQuery:
fields:
- couponId
searchPhrase: DEAL
- termQuery:
fields:
- enabled
operator: is
values:
- true
OrOperatorExample:
should:
- textQuery:
fields:
- couponId
searchPhrase: DEAL
- textQuery:
fields:
- couponId
- description
searchPhrase: sale
NotOperatorExample:
must_not:
- textQuery:
fields:
- description
searchPhrase: Big bargain
- termQuery:
fields:
- enabled
operator: is
values:
- false
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"termFilter": {
"field": "enabled",
"operator": "is",
"values": [
false
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"query": {
"textQuery": {
"fields": [
"couponId"
],
"searchPhrase": "disabled"
}
},
"filter": {
"termFilter": {
"field": "enabled",
"operator": "is",
"values": [
false
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"path": "order.shippingAddresses",
"query": {
"boolQuery": {
"must": [
{
"boolQuery": {
"must": [
{
"termQuery": {
"fields": [
"order.shippingAddresses.firstName"
],
"operator": "is",
"values": [
"John"
]
}
}
]
}
},
{
"boolQuery": {
"must": [
{
"termQuery": {
"fields": [
"order.shippingAddresses.lastName"
],
"operator": "is",
"values": [
"Doe"
]
}
}
]
}
}
]
}
},
"scoreMode": "avg"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"limit" : 1,
"hits" : [
{
"couponId": "MyCoupon",
"creationDate": "2019-10-20T12:00:00Z",
"description": "This coupon is used to give 10% off stuff.",
"enabled": false,
"exportedCodeCount": 0,
"lastModified": "2019-10-30T04:23:59Z",
"redemptionCount": 3,
"redemptionLimits": {
"limitPerCode": 1,
"limitPerCustomer": 1,
"limitPerTimeFrame": {
"limit": 2,
"redemptionTimeFrame": 24
}
},
"singleCode": "MyCode",
"systemCodesConfig": {
"codePrefix": "SG",
"numberOfCodes": 500000
},
"totalCodesCount": 50,
"type": "single_code"
}
],
"query" : { "textQuery": { "fields": ["id", "description"], "searchPhrase": "stuff" } },
"sorts" : [
{ "field": "couponId", "sortOrder": "desc" }
],
"offset" : 2,
"total" : 8
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"filteredQuery": {
"query": {
"textQuery": {
"fields": [
"couponId"
],
"searchPhrase": "disabled"
}
},
"filter": {
"termFilter": {
"field": "enabled",
"operator": "is",
"values": [
false
]
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"query": {
"termQuery": {
"fields": [
"enabled",
"active"
],
"operator": "is",
"values": [
false
]
}
}
}
Loading

0 comments on commit f38e7bb

Please sign in to comment.