Coupons API

PUT - /api/v1/courses/:course_id/coupons/:id - Updating

PUT /api/v1/courses/:course_id/coupons/:id

Parameters

Name Description
id coupon id
is_primary primary coupon?
code :text
currency :string(255)
discount_amount :integer
discount_in_months :integer
discount_percent :float
duration_kind forever, once, or repeating
expiration_date :date
is_published :boolean
name :text
number_available :integer
number_of_uses :integer
course_id course id

Request

Headers

Accept: application/json
X-Api-Token: 5nms8mmJK4v5tv45Ls9H91Q1fY-isaiHxQ
X-Api-Email: user-83@example.com

Route

PUT /api/v1/courses/25/coupons/27

Body

{"code":"FOO","discount_percent":0.2,"duration_kind":"forever","expiration_date":"2019-11-30"}

cURL

curl "http://localhost:3000/api/v1/courses/25/coupons/27" -d '{"code":"FOO","discount_percent":0.2,"duration_kind":"forever","expiration_date":"2019-11-30"}' -X PUT \
	-H "Accept: application/json" \
	-H "X-Api-Token: 5nms8mmJK4v5tv45Ls9H91Q1fY-isaiHxQ" \
	-H "X-Api-Email: user-83@example.com" \
	-H "Content-Type: application/json" \
	-H "Host: school.worksonmy.computer"

Response

Headers

Content-Type: application/json; charset=utf-8
Content-Length: 1058

Status

202 Accepted

Body

{
  "created_at": "2019-10-31T21:58:58Z",
  "new_purchase_price": 900,
  "formatted_discount": "$1",
  "formatted_price": "$9",
  "calculated_discount": 100,
  "currency": "USD",
  "discount_percent": null,
  "discount_amount": 100,
  "number_available": 10000,
  "code": "IONMBVWT",
  "name": "One Off Coupon Code 2 dollars off",
  "expiration_date": "2019-11-29T19:00:00-05:00",
  "product_id": 21,
  "is_published": true,
  "duration_kind": "once",
  "number_of_uses": null,
  "class_period_id": null,
  "site_wide": null,
  "id": 27,
  "meta": {
    "class": "coupon",
    "url": null,
    "name": "One Off Coupon Code 2 dollars off",
    "description": "",
    "image_url": null
  },
  "product": {
    "created_at": "2019-10-31T21:58:58Z",
    "formatted_price": "$10",
    "name": "product name",
    "description": "product description",
    "billing_interval": "month",
    "detailed_description": null,
    "currency": "USD",
    "position": 1,
    "price": 1000,
    "is_recurring": false,
    "is_published": true,
    "course_id": 25,
    "author_revenue_share": null,
    "num_payments_required": null,
    "id": 21,
    "meta": {
      "class": "product",
      "url": "/courses/25/products/21",
      "name": "product name",
      "description": "product description",
      "image_url": null
    }
  }
}