Skip to content

Commit

Permalink
feat(schemas): adds full patch schema
Browse files Browse the repository at this point in the history
  • Loading branch information
eljefedelrodeodeljefe committed Oct 27, 2018
1 parent 65f8924 commit 09f3ff7
Show file tree
Hide file tree
Showing 3 changed files with 193 additions and 325 deletions.
182 changes: 182 additions & 0 deletions lib/v0/vouchers/base.js
@@ -0,0 +1,182 @@
module.exports = {
code: {
description: 'The chosen or generated voucher code',
example: '1234 1234 1234',
anyOf: [
{
type: 'string'
},
{
type: 'null'
}
]
},
format: {
description: 'The format this voucher conforms to',
example: 'xxxx xxxx xxxx',
type: 'string'
},
format_type: {
description: '',
type: 'string',
'enum': [
'numeric',
'alphanumeric',
'alphabetic'
]
},
amount: {
description: 'decimal type',
example: '10.99',
anyOf: [
{
type: 'number',
minimum: 0
},
{
type: 'null'
}
]
},
amount_cents: {
description: '',
anyOf: [
{
type: 'integer',
minimum: 0
},
{
type: 'null'
}
]
},
amount_max: {
description: '',
anyOf: [
{
type: 'number',
minimum: 0
},
{
type: 'null'
}
]
},
currency: {
description: '',
type: 'string'
},
custom: {
description: '',
type: 'object'
},
metadata: {
description: '',
type: 'object'
},
issuable: {
description: '',
type: 'boolean'
},
reissuable: {
description: '',
type: 'boolean'
},
issuer: {
description: '',
type: 'string'
},
customer: {
description: '',
anyOf: [
{
type: 'object'
},
{
type: 'null'
}
]
},
comment: {
description: '',
type: 'string',
maxLength: 1024
},
expires_at: {
description: '',
type: 'string',
format: 'date-time'
},
barcodes: {
description: '',
type: 'object'
},
title: {
description: '',
type: 'string'
},
partial_redemption: {
description: '',
type: 'boolean'
},
active: {
description: '',
type: 'boolean'
},
bound_to: {
description: '',
type: 'object'
},
namespace: {
description: '',
type: 'string'
},
type: {
description: '',
type: 'string',
'enum': [
'amount',
'discount',
'product'
]
},
regions: {
description: '',
type: 'array',
minItems: 1,
maxItems: 1,
items: {
oneOf: [
{
type: 'string',
minLength: 2,
maxLength: 2,
pattern: '^[A-Z]{2}$'
},
{
type: 'null'
}
]
}
},
limited_to_region: {
description: '',
type: 'boolean'
},
refundable: {
description: '',
type: 'boolean'
},
mutable: {
description: '',
type: 'boolean'
},
exchange_for_cash: {
description: '',
type: 'boolean'
},
restriction_single_transaction: {
description: '',
type: 'boolean'
}
}
183 changes: 3 additions & 180 deletions lib/v0/vouchers/create.js
@@ -1,189 +1,12 @@
const base = require('./base')

module.exports = {
$id: 'https://schemas.tillhub.com/v0/vouchers.create.schema.json',
$schema: 'http://json-schema.org/draft-07/schema#',
additionalProperties: false,
type: 'object',
properties: {
code: {
description: 'The chosen or generated voucher code',
example: '1234 1234 1234',
anyOf: [
{
type: 'string'
},
{
type: 'null'
}
]
},
format: {
description: 'The format this voucher conforms to',
example: 'xxxx xxxx xxxx',
type: 'string'
},
format_type: {
description: '',
type: 'string',
'enum': [
'numeric',
'alphanumeric',
'alphabetic'
]
},
amount: {
description: 'decimal type',
example: '10.99',
anyOf: [
{
type: 'number',
minimum: 0
},
{
type: 'null'
}
]
},
amount_cents: {
description: '',
anyOf: [
{
type: 'integer',
minimum: 0
},
{
type: 'null'
}
]
},
amount_max: {
description: '',
anyOf: [
{
type: 'number',
minimum: 0
},
{
type: 'null'
}
]
},
currency: {
description: '',
type: 'string'
},
custom: {
description: '',
type: 'object'
},
metadata: {
description: '',
type: 'object'
},
issuable: {
description: '',
type: 'boolean'
},
reissuable: {
description: '',
type: 'boolean'
},
issuer: {
description: '',
type: 'string'
},
customer: {
description: '',
anyOf: [
{
type: 'object'
},
{
type: 'null'
}
]
},
comment: {
description: '',
type: 'string',
maxLength: 1024
},
expires_at: {
description: '',
type: 'string',
format: 'date-time'
},
barcodes: {
description: '',
type: 'object'
},
title: {
description: '',
type: 'string'
},
partial_redemption: {
description: '',
type: 'boolean'
},
active: {
description: '',
type: 'boolean'
},
bound_to: {
description: '',
type: 'object'
},
namespace: {
description: '',
type: 'string'
},
type: {
description: '',
type: 'string',
'enum': [
'amount',
'discount',
'product'
]
},
regions: {
description: '',
type: 'array',
minItems: 1,
maxItems: 1,
items: {
oneOf: [
{
type: 'string',
minLength: 2,
maxLength: 2,
pattern: '^[A-Z]{2}$'
},
{
type: 'null'
}
]
}
},
limited_to_region: {
description: '',
type: 'boolean'
},
refundable: {
description: '',
type: 'boolean'
},
mutable: {
description: '',
type: 'boolean'
},
exchange_for_cash: {
description: '',
type: 'boolean'
},
restriction_single_transaction: {
description: '',
type: 'boolean'
}
...base
},
required: [
'format',
Expand Down

0 comments on commit 09f3ff7

Please sign in to comment.