{
    "openapi": "3.0.3",
    "info": {
        "title": "CareerByteCode ByteConnect API",
        "version": "1",
        "description": "Sell CareerByteCode programs from your website. Every request is signed: see https://www.careerbytecode.in/byteconnect/docs/#sign",
        "contact": {
            "url": "https://www.careerbytecode.in/byteconnect/docs/"
        }
    },
    "servers": [
        {
            "url": "https://www.careerbytecode.in/api/v1"
        }
    ],
    "security": [
        {
            "CbcKey": [],
            "CbcTimestamp": [],
            "CbcNonce": [],
            "CbcSignature": []
        }
    ],
    "paths": {
        "/ping": {
            "get": {
                "summary": "Check key, signature and server address",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "ok": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "object"
                                        },
                                        "request_id": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/catalogue": {
            "get": {
                "summary": "What you may sell now",
                "parameters": [
                    {
                        "name": "type",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "enum": [
                                "course",
                                "exam",
                                "byteclass",
                                "byteplay",
                                "bytelabs"
                            ]
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "ok": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "object",
                                            "properties": {
                                                "currency": {
                                                    "type": "string"
                                                },
                                                "gst_pct": {
                                                    "type": "integer"
                                                },
                                                "items": {
                                                    "type": "array",
                                                    "items": {
                                                        "$ref": "#/components/schemas/Item"
                                                    }
                                                }
                                            }
                                        },
                                        "request_id": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/checkout": {
            "post": {
                "summary": "Make an order and get the checkout link",
                "parameters": [
                    {
                        "name": "X-CBC-Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "minLength": 8,
                            "maxLength": 80
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "item"
                                ],
                                "properties": {
                                    "item": {
                                        "type": "string"
                                    },
                                    "partner_ref": {
                                        "type": "string",
                                        "maxLength": 64
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Created",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "ok": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "object",
                                            "properties": {
                                                "order": {
                                                    "$ref": "#/components/schemas/Order"
                                                }
                                            }
                                        },
                                        "request_id": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "409": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/orders": {
            "get": {
                "summary": "Your orders, newest first",
                "parameters": [
                    {
                        "name": "status",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "enum": [
                                "created",
                                "paid",
                                "refunded",
                                "expired"
                            ]
                        }
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 200
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "ok": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "object",
                                            "properties": {
                                                "orders": {
                                                    "type": "array",
                                                    "items": {
                                                        "$ref": "#/components/schemas/Order"
                                                    }
                                                }
                                            }
                                        },
                                        "request_id": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/orders/{id}": {
            "get": {
                "summary": "One order",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "ok": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "object",
                                            "properties": {
                                                "order": {
                                                    "$ref": "#/components/schemas/Order"
                                                }
                                            }
                                        },
                                        "request_id": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/ip-check": {
            "get": {
                "summary": "Server proof for an address change request",
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "ok": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "object",
                                            "properties": {
                                                "your_ip": {
                                                    "type": "string"
                                                },
                                                "on_whitelist": {
                                                    "type": "boolean"
                                                },
                                                "request_id": {
                                                    "type": "integer",
                                                    "nullable": true
                                                },
                                                "recorded_for_request": {
                                                    "type": "boolean"
                                                }
                                            }
                                        },
                                        "request_id": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "CbcKey": {
                "type": "apiKey",
                "in": "header",
                "name": "X-CBC-Key"
            },
            "CbcTimestamp": {
                "type": "apiKey",
                "in": "header",
                "name": "X-CBC-Timestamp",
                "description": "Unix seconds, within 5 minutes"
            },
            "CbcNonce": {
                "type": "apiKey",
                "in": "header",
                "name": "X-CBC-Nonce",
                "description": "New for every request"
            },
            "CbcSignature": {
                "type": "apiKey",
                "in": "header",
                "name": "X-CBC-Signature",
                "description": "hex HMAC-SHA256(secret, METHOD\\nPATH_AND_QUERY\\nTIMESTAMP\\nNONCE\\nsha256_hex(BODY))"
            }
        },
        "schemas": {
            "Item": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string",
                        "example": "course:kubernetes-bootcamp"
                    },
                    "type": {
                        "type": "string",
                        "enum": [
                            "course",
                            "exam",
                            "byteclass",
                            "byteplay",
                            "bytelabs"
                        ]
                    },
                    "ref": {
                        "type": "string"
                    },
                    "title": {
                        "type": "string"
                    },
                    "base_inr": {
                        "type": "integer"
                    },
                    "gst_inr": {
                        "type": "integer"
                    },
                    "total_inr": {
                        "type": "integer"
                    },
                    "summary": {
                        "type": "string"
                    },
                    "highlights": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    },
                    "image": {
                        "type": "string"
                    },
                    "creator": {
                        "type": "string"
                    },
                    "detail_url": {
                        "type": "string"
                    }
                }
            },
            "Order": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string"
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "created",
                            "paid",
                            "refunded",
                            "expired"
                        ]
                    },
                    "mode": {
                        "type": "string",
                        "enum": [
                            "test",
                            "live"
                        ]
                    },
                    "item": {
                        "type": "string"
                    },
                    "title": {
                        "type": "string"
                    },
                    "base_inr": {
                        "type": "integer"
                    },
                    "gst_inr": {
                        "type": "integer"
                    },
                    "total_inr": {
                        "type": "integer"
                    },
                    "partner_ref": {
                        "type": "string"
                    },
                    "checkout_url": {
                        "type": "string",
                        "format": "uri"
                    },
                    "paid_inr": {
                        "type": "integer"
                    },
                    "created_at": {
                        "type": "integer",
                        "nullable": true
                    },
                    "expires_at": {
                        "type": "integer",
                        "nullable": true
                    },
                    "paid_at": {
                        "type": "integer",
                        "nullable": true
                    },
                    "refunded_at": {
                        "type": "integer",
                        "nullable": true
                    }
                }
            },
            "Error": {
                "type": "object",
                "properties": {
                    "ok": {
                        "type": "boolean"
                    },
                    "error": {
                        "type": "object",
                        "properties": {
                            "code": {
                                "type": "string"
                            },
                            "message": {
                                "type": "string"
                            }
                        }
                    },
                    "request_id": {
                        "type": "string"
                    }
                }
            }
        }
    }
}