swagger: "2.0"
info:
  description: "RESTful API to manage web push notifications"
  version: "1.0.0"
  title: "Web Push Service"
  termsOfService: "http://swagger.io/terms/"
  contact:
    email: "developersworkspace@gmail.com"
  license:
    name: "MIT"
    url: "https://opensource.org/licenses/MIT"
host: "your-domain.com"
basePath: "/api/v1"
schemes:
- "https"
- "http"
paths:
  /client:
    post:
      tags:
      - "Client"
      summary: "Create a client"
      description: "Obtain a key and a public key"
      operationId: "postClient"
      consumes:
      - "application/json"
      produces:
      - "application/json"
      parameters:
      - in: "body"
        name: "body"
        description: "Object containing endpoint"
        required: true
        schema:
          $ref: "#/definitions/ClientPostRequest"
      responses:
        201:
          description: "Created"
          schema:
            $ref: "#/definitions/ClientPostResponse"
        400:
          description: "Invalid Request Body"
        500:
          description: "Internal Error"
          schema:
            $ref: "#/definitions/ErrorResponse"
  /client/channels:
    get:
      tags:
      - "Client"
      summary: "Retrieve list of channels by client"
      description: ""
      operationId: "getClientChannels"
      consumes:
      - "application/json"
      produces:
      - "application/json"
      responses:
        200:
          description: "Success"
          schema:
            type: "array"
            items:
              type: "string"
        401:
          description: "Unauthorized"
        500:
          description: "Internal Error"
          schema:
            $ref: "#/definitions/ErrorResponse"
  /push/{channel}:
    post:
      tags:
      - "Push"
      summary: "Create a push notification"
      description: ""
      operationId: "postPushChannel"
      consumes:
      - "application/json"
      produces:
      - "application/json"
      parameters:
        - in: path
          name: channel
          schema:
            type: string
          required: true
          description: Channel Name
        - in: "body"
          name: "body"
          description: "Payload of push notification"
          required: true
          schema:
            $ref: "#/definitions/PushPostRequest"
      responses:
        200:
          description: "Success"
          schema:
            type: "string"
        400:
          description: "Invalid Request Parameters"
        401:
          description: "Unauthorized"
        500:
          description: "Internal Error"
          schema:
            $ref: "#/definitions/ErrorResponse"
  /subscription/{channel}:
    delete:
      tags:
      - "Subscription"
      summary: "Delete a subscription"
      description: ""
      operationId: "deleteSubscription"
      consumes:
      - "application/json"
      produces:
      - "application/json"
      parameters:
        - in: path
          name: channel
          schema:
            type: string
          required: true
          description: Channel Name
        - in: "body"
          name: "body"
          description: "Subscription Object"
          required: true
          schema:
            $ref: "#/definitions/SubscriptionDeleteRequest"
      responses:
        200:
          description: "Success"
          schema:
            type: "string"
        400:
          description: "Invalid Request Body/Parameters"
        401:
          description: "Unauthorized"
        500:
          description: "Internal Error"
          schema:
            $ref: "#/definitions/ErrorResponse"
    post:
      tags:
      - "Subscription"
      summary: "Create a subscription"
      description: ""
      operationId: "postSubscription"
      consumes:
      - "application/json"
      produces:
      - "application/json"
      parameters:
        - in: path
          name: channel
          schema:
            type: string
          required: true
          description: Channel Name
        - in: "body"
          name: "body"
          description: "Subscription Object"
          required: true
          schema:
            $ref: "#/definitions/SubscriptionPostRequest"
      responses:
        200:
          description: "Success"
          schema:
            type: "string"
        400:
          description: "Invalid Request Body/Parameters"
        401:
          description: "Unauthorized"
        500:
          description: "Internal Error"
          schema:
            $ref: "#/definitions/ErrorResponse"
securityDefinitions:
  Standard:
    type: "apiKey"
    name: "authorization"
    in: "header"
definitions:
  ClientPostRequest:
    type: "object"
    required:
    - "endpoint"
    properties:
      endpoint:
        type: "string"
        example: "https://your-domain.com"
  ClientPostResponse:
    type: "object"
    required:
    - "id"
    - "key"
    - "publicKey"
    properties:
      id:
        type: "string"
        example: "4fb730bb-924d-42ff-bf76-ac1fe232c89b"
      key:
        type: "string"
        example: "ecc58cd8-fc3f-4ee6-af05-5e25d4b707b9"
      publicKey:
        type: "string"
        example: "BEXzLx1Jpum77zWGzVUfxQnuCXp0O8GCnXM1rsgRfPmvEuUoRz4ML8T2ZbTLBA3oKOaOqgX/s71rom5J9xE2+us="
  PushPostRequest:
    type: "object"
  SubscriptionDeleteRequest:
    type: "object"
    required:
    - "endpoint"
    - "expirationTime"
    - "keys"
    properties:
      endpoint:
        type: "string"
        example: "https://fcm.googleapis.com/fcm/send/e3Nz_AF5KeE:APA91bGyIEnrkAX0vrqT-WjKE-3MtR5fro3fM0-WAe-LxU4raxA_LEPfuakJtdPhef9tzb7OMyrTcu21Tvp1HCLuya9n9rW82o-eAnnEoYQ5-tCBXJDKqJqJObOXMjoua1cWYWFNIqWLtRsj_TJJjIrAeEmDkOaWlw"
      expirationTime:
        type: "number"
      keys:
        type: "object"
  SubscriptionPostRequest:
    type: "object"
    required:
    - "endpoint"
    - "expirationTime"
    - "keys"
    properties:
      endpoint:
        type: "string"
        example: "https://fcm.googleapis.com/fcm/send/e3Nz_AF5KeE:APA91bGyIEnrkAX0vrqT-WjKE-3MtR5fro3fM0-WAe-LxU4raxA_LEPfuakJtdPhef9tzb7OMyrTcu21Tvp1HCLuya9n9rW82o-eAnnEoYQ5-tCBXJDKqJqJObOXMjoua1cWYWFNIqWLtRsj_TJJjIrAeEmDkOaWlw"
      expirationTime:
        type: "number"
      keys:
        type: "object"
  ErrorResponse:
    type: "object"
    required:
    - "message"
    properties:
      message:
        type: "string"
        example: "An error occurred"
externalDocs:
  description: "Find out more about Swagger"
  url: "http://swagger.io"