Skip to content

Commit

Permalink
Merge pull request ONDC-Official#61 from abhinavv245/main
Browse files Browse the repository at this point in the history
on_cancel schema checks added
  • Loading branch information
tanya-ondc authored Feb 16, 2024
2 parents fe4ab05 + 7ab3759 commit 7419f79
Show file tree
Hide file tree
Showing 20 changed files with 1,056 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ const validate_schema = (data, schema,version) => {
const statusSchema = loadSchema("status", version);
const onStatusSchema = loadSchema("on_status", version);

const cancelSchema = loadSchema("cancel", version);
const onCancelSchema = loadSchema("on_cancel", version);

const Ajv = require("ajv");
const ajv = new Ajv({
allErrors: true,
Expand Down Expand Up @@ -84,6 +87,8 @@ const validate_schema = (data, schema,version) => {
.addSchema(onUpdateSchema)
.addSchema(statusSchema)
.addSchema(onStatusSchema)
.addSchema(cancelSchema)
.addSchema(onCancelSchema)
.addKeyword("isEndTimeGreater", {
validate: (schema, data) => isEndTimeGreater(data),
})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
module.exports = {
$id: "http://example.com/schema/cancelSchema",
type: "object",
properties: {
context: {
type: "object",
properties: {
domain: {
type: "string",
},
location: {
type: "object",
properties: {
city: {
type: "object",
properties: {
code: {
type: "string",
const: { $data: "/on_confirm/0/context/location/city/code" },
},
},
required: ["code"],
},
country: {
type: "object",
properties: {
code: {
type: "string",
const: {
$data: "/on_confirm/0/context/location/country/code",
},
},
},
required: ["code"],
},
},
required: ["city", "country"],
},
action: {
type: "string",
const: "cancel",
},
version: {
type: "string",
const: "2.0.2",
},
bap_id: {
type: "string",
},
bap_uri: {
type: "string",
},
bpp_id: {
type: "string",
},
bpp_uri: {
type: "string",
},
transaction_id: {
type: "string",
const: { $data: "/on_confirm/0/context/transaction_id" },
},
message_id: {
type: "string",
},
timestamp: {
type: "string",
format: "date-time",
},
ttl: {
type: "string",
const: "PT30S",
},
},
required: [
"domain",
"location",
"action",
"version",
"bap_id",
"bap_uri",
"bpp_id",
"bpp_uri",
"transaction_id",
"message_id",
"timestamp",
"ttl",
],
},
message: {
type: "object",
properties: {
order_id: {
type: "string",
const: { $data: "/on_confirm/0/message/order/id" },
},
cancellation_reason_id: {
order_id: {
type: "string",
},
},

},
additionalProperties: false,
required: ["order_id", "cancellation_reason_id"],
},
},
required: ["context", "message"],

};
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ module.exports = {
properties: {
id: {
type: "string",
not: {
const: { $data: "3/context/transaction_id" },
},
errorMessage:"Order ID must not be the same as Transaction ID - ${3/context/transaction_id}."
},
state: {
type: "string",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ module.exports = {
},
tax_id: {
type: "string",
pattern: "^[0-9]{2}[A-Z]{5}[0-9]{4}[0-9A-Z]{4}$",
errorMessage: "should be valid",
},
email: {
type: "string",
Expand Down Expand Up @@ -493,7 +495,8 @@ module.exports = {
},
collected_by:{
type:"string",
enum:["BAP","BPP"]
enum:["BAP","BPP"],
const: { $data: "/on_select/0/message/order/payments/0/collected_by" },
}
},
required: ["type","collected_by"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ module.exports = {
items: {
$ref: "onStatusSchema#",
},
},
cancel: {
type: "array",
items: {
$ref: "cancelSchema#",
},
},
on_cancel: {
type: "array",
items: {
$ref: "onCancelSchema#",
},
}
},
};
Loading

0 comments on commit 7419f79

Please sign in to comment.