Skip to content

Instantly share code, notes, and snippets.

@claudiosanches
Created April 21, 2016 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save claudiosanches/7947a599521b668a6cf6842566e70abd to your computer and use it in GitHub Desktop.
Save claudiosanches/7947a599521b668a6cf6842566e70abd to your computer and use it in GitHub Desktop.
WooCommerce - Example of coupons schema
{
"namespace": "wc/v1",
"methods": [
"GET",
"POST"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"context": {
"required": false,
"default": "view",
"enum": [
"view",
"edit"
],
"description": "Scope under which the request is made; determines fields present in response."
},
"page": {
"required": false,
"default": 1,
"description": "Current page of the collection."
},
"per_page": {
"required": false,
"default": 10,
"description": "Maximum number of items to be returned in result set."
},
"search": {
"required": false,
"description": "Limit results to those matching a string."
},
"after": {
"required": false,
"description": "Limit response to resources published after a given ISO8601 compliant date."
},
"before": {
"required": false,
"description": "Limit response to resources published before a given ISO8601 compliant date."
},
"exclude": {
"required": false,
"default": [],
"description": "Ensure result set excludes specific ids."
},
"include": {
"required": false,
"default": [],
"description": "Limit result set to specific ids."
},
"offset": {
"required": false,
"description": "Offset the result set by a specific number of items."
},
"order": {
"required": false,
"default": "desc",
"enum": [
"asc",
"desc"
],
"description": "Order sort attribute ascending or descending."
},
"orderby": {
"required": false,
"default": "date",
"enum": [
"date",
"id",
"include",
"title",
"slug"
],
"description": "Sort collection by object attribute."
},
"slug": {
"required": false,
"description": "Limit result set to posts with a specific slug."
},
"filter": {
"required": false,
"description": "Use WP Query arguments to modify the response; private query vars require appropriate authorization."
},
"code": {
"required": false,
"description": "Limit result set to resources with a specific code."
}
}
},
{
"methods": [
"POST"
],
"args": {
"code": {
"required": true
},
"description": {
"required": false
},
"discount_type": {
"required": false,
"enum": [
"fixed_cart",
"percent",
"fixed_product",
"percent_product"
]
},
"amount": {
"required": false
},
"expiry_date": {
"required": false
},
"individual_use": {
"required": false
},
"product_ids": {
"required": false
},
"exclude_product_ids": {
"required": false
},
"usage_limit": {
"required": false
},
"usage_limit_per_user": {
"required": false
},
"limit_usage_to_x_items": {
"required": false
},
"free_shipping": {
"required": false
},
"product_categories": {
"required": false
},
"excluded_product_categories": {
"required": false
},
"exclude_sale_items": {
"required": false
},
"minimum_amount": {
"required": false
},
"maximum_amount": {
"required": false
},
"email_restrictions": {
"required": false
}
}
}
],
"schema": {
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "shop_coupon",
"type": "object",
"properties": {
"id": {
"description": "Unique identifier for the object.",
"type": "integer",
"context": [
"view",
"edit"
],
"readonly": true
},
"code": {
"description": "Coupon code.",
"type": "string",
"context": [
"view",
"edit"
]
},
"date_created": {
"description": "The date the coupon was created, in the site's timezone.",
"type": "date-time",
"context": [
"view",
"edit"
],
"readonly": true
},
"date_modified": {
"description": "The date the coupon was last modified, in the site's timezone.",
"type": "date-time",
"context": [
"view",
"edit"
],
"readonly": true
},
"description": {
"description": "Coupon description.",
"type": "string",
"context": [
"view",
"edit"
]
},
"discount_type": {
"description": "Determines the type of discount that will be applied.",
"type": "string",
"enum": [
"fixed_cart",
"percent",
"fixed_product",
"percent_product"
],
"context": [
"view",
"edit"
]
},
"amount": {
"description": "The amount of discount.",
"type": "float",
"context": [
"view",
"edit"
]
},
"expiry_date": {
"description": "UTC DateTime when the coupon expires.",
"type": "string",
"context": [
"view",
"edit"
]
},
"usage_count": {
"description": "Number of times the coupon has been used already.",
"type": "integer",
"context": [
"view",
"edit"
],
"readonly": true
},
"individual_use": {
"description": "Whether coupon can only be used individually.",
"type": "boolean",
"context": [
"view",
"edit"
]
},
"product_ids": {
"description": "List of product ID's the coupon can be used on.",
"type": "array",
"context": [
"view",
"edit"
]
},
"exclude_product_ids": {
"description": "List of product ID's the coupon cannot be used on.",
"type": "array",
"context": [
"view",
"edit"
]
},
"usage_limit": {
"description": "How many times the coupon can be used.",
"type": "integer",
"context": [
"view",
"edit"
]
},
"usage_limit_per_user": {
"description": "How many times the coupon can be user per customer.",
"type": "integer",
"context": [
"view",
"edit"
]
},
"limit_usage_to_x_items": {
"description": "Max number of items in the cart the coupon can be applied to.",
"type": "integer",
"context": [
"view",
"edit"
]
},
"free_shipping": {
"description": "Define if can be applied for free shipping.",
"type": "boolean",
"context": [
"view",
"edit"
]
},
"product_categories": {
"description": "List of category ID's the coupon applies to.",
"type": "array",
"context": [
"view",
"edit"
]
},
"excluded_product_categories": {
"description": "List of category ID's the coupon does not apply to.",
"type": "array",
"context": [
"view",
"edit"
]
},
"exclude_sale_items": {
"description": "Define if should not apply when have sale items.",
"type": "boolean",
"context": [
"view",
"edit"
]
},
"minimum_amount": {
"description": "Minimum order amount that needs to be in the cart before coupon applies.",
"type": "float",
"context": [
"view",
"edit"
]
},
"maximum_amount": {
"description": "Maximum order amount allowed when using the coupon.",
"type": "float",
"context": [
"view",
"edit"
]
},
"email_restrictions": {
"description": "List of email addresses that can use this coupon.",
"type": "array",
"context": [
"view",
"edit"
]
},
"used_by": {
"description": "List of user IDs who have used the coupon.",
"type": "array",
"context": [
"view",
"edit"
],
"readonly": true
}
}
},
"_links": {
"self": "https://woo.dev/wp-json/wc/v1/coupons"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment