openapi: 3.0.0
info:
  title: Solid Wallet Service
  description: API to manage resources, access prompts, collections, and access grants.
  version: "1.0"

servers:
  - url: "https://api.wallet.example.com"
    description: Wallet Server

paths:
  /wallet:
    get:
      summary: Retrieve all wallet resources
      responses:
        "200":
          description: A list of all wallet resources.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/WalletContainer"
    post:
      summary: Create a new wallet resource
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                file:
                  type: string
                  format: binary
                  description: Binary file to be uploaded.
                metadata:
                  type: object
                  description: Metadata associated with the file.
            encoding:
              file:
                contentType: application/octet-stream
              metadata:
                contentType: application/json
      responses:
        "201":
          description: Wallet resource created.

  /wallet/{resourceID}:
    parameters:
      - in: path
        name: resourceID
        required: true
        schema:
          type: string
        description: ID of the wallet resource

    get:
      summary: Retrieve a specific wallet resource by ID
      responses:
        "200":
          description: Specific wallet resource details.
          content:
            application/octet-stream:
              schema:
                type: string
                format: binary
    put:
      summary: Update a specific wallet resource
      requestBody:
        required: true
        content:
         application/octet-stream:
              schema:
                type: string
                format: binary

      responses:
        "200":
          description: Wallet resource updated.
    delete:
      summary: Delete a specific wallet resource
      responses:
        "204":
          description: Wallet resource deleted.

  /accessprompt:
    post:
      summary: Handle access prompt after Front end scans Access Pormpt QR Code. WebID can be taken from Session.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                accessPromptUrl:
                  type: string
                  example: https://examplecorp.com/accessprompt
                method:
                  type: string
                  example: POST
                options:
                  type: object
                  properties:
                    resourceUri:
                      type: string
                      example: https://mypod.com/23789283783729/foo
                inbox:
                  type: string
                  example: https://mypod.com/23789283783729/inbox
                  nullable: true

      responses:
        "200":
          description: Access prompt handled successfully.
        "401":
          description: Unathorized - The requestor cannot prove ownership of the WebID for the access prompt

  /collect:
    post:
      summary: Collect specified resource into pod.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                resourceUrl:
                  type: string
      responses:
        "200":
          description: Resource collected successfully.
        "401":
          description: Unathorized
        "500":
          description: Server Error    
  /accessgrants/{ID}:
    parameters:
      - in: path
        name: ID
        required: true
        schema:
          type: string
        description: The ID of the access grant
    get:
      summary: Retrieve specific access grant by UUID
      responses:
        "200":
          description: Access grant details.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AccessGrant"
        "500":
          description: Server error
    put:
      summary: Revoke an access grant
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/AccessRevocation"
            example:  
                status: "revoked"
      responses:
        "204":
          description: Access grant revoked.
        "500":
          description: Server error
  /accessgrants:
    get:
      summary: List all active access grants
      parameters:
        - in: query
          name: all
          schema:
            type: boolean
            default: false
          description: Return whole body of full valid access grants if true.
      responses:
        "200":
          description: List of access grants.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/AccessGrant"
    post:
      summary: Create a new access grant
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/AccessGrant"
      responses:
        "201":
          description: Access grant created.
        "500":
          description: Server error
  /accessrequests:
    get:
      summary: List all active access requests
      parameters:
        - in: query
          name: all
          schema:
            type: boolean
            default: false
          description: Return whole body of full valid access request if true.
      responses:
        "200":
          description: List of access requests.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/AccessRequest"
  /accessrequests/{ID}:
    parameters:
      - in: path
        name: ID
        required: true
        schema:
          type: string
        description: The ID of the access request
    get:
      summary: Retrieve specific access request by UUID
      responses:
        "200":
          description: Access request details.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AccessRequest"
        "500":
          description: Server error
    put:
      summary: Reject an access request
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/AccessRevocation"
            example:  
                status: "rejected"
      responses:
        "204":
          description: Access request rejected.
        "500":
          description: Server error
  /inbox:
    get:
      summary: Get contents of inbox
      responses:
        "200":
          description: Access grant details.
          content:
            application/json:
              schema:
                type: array
                items: 
                    $ref: "#/components/schemas/Inbox"

  /inbox/{ID}:
      parameters:
        - in: path
          name: ID
          required: true
          schema:
            type: string
          description: The ID of the inbox item
      get:
        summary: Retrieve specific inbox item by ID
        responses:
          "200":
            description: Access grant details.
            content:
              application/json:
                schema:
                  $ref: "#/components/schemas/AccessRequest"
      delete:
        summary: Delete an inbox item
        responses:
          "204":
            description: Access grant revoked.

components:
  schemas:
    WalletContainer:
      type: object
      properties:
        id:
          type: string
        resourceUri:
          type: string
        name:
          type: string
        size:
          type: string
        metaData:
          type: object
          additionalProperties: true

    WalletResourceJson:
      type: object
      properties:
        id:
          type: string
        resourceUri:
          type: string
        name:
          type: string
        size:
          type: string
        metaData:
          type: object
          additionalProperties: true
    AccessGrant:
      type: object
      properties:
        resource:
          type: string
        accessRequestUri:
          type: string
        expirationDate:
          type: string
        forPurpose:
          type: string
        mode:
          type: array
          items:
            type: string
    Inbox: 
      type: object
      properties: 
        resourceUri:
          type: string

    AccessRevocation:
      type: object 
      required: 
        - status
      properties:
        status:
          type: string
          description: "Revoked"

      

    AccessRequest:
      type: object
      required:
        - id
        - type
        - proof
        - credentialStatus
        - credentialSubject
        - expirationDate
        - issuanceDate
        - issuer
        - "@context"
      properties:
        id:
          type: string
          format: uri
          description: "A URI uniquely identifying the credential."
        type:
          type: array
          items:
            type: string
          description: "Types of the credential indicating the nature and purpose."
        proof:
          type: object
          required:
            - type
            - created
            - domain
            - proofPurpose
            - proofValue
            - verificationMethod
          properties:
            type:
              type: string
              description: "Type of the cryptographic proof."
            created:
              type: string
              format: date-time
              description: "Timestamp of when the proof was created."
            domain:
              type: string
              description: "The domain associated with the proof."
            proofPurpose:
              type: string
              description: "The intended purpose of the proof."
            proofValue:
              type: string
              description: "Cryptographic proof value."
            verificationMethod:
              type: string
              format: uri
              description: "A URI to the method used for verification."
        credentialStatus:
          type: object
          required:
            - id
            - type
            - revocationListCredential
            - revocationListIndex
          properties:
            id:
              type: string
              format: uri
              description: "A URI uniquely identifying the credential status."
            type:
              type: string
              description: "Type of the credential status."
            revocationListCredential:
              type: string
              format: uri
              description: "A URI to the revocation list credential."
            revocationListIndex:
              type: string
              description: "Index in the revocation list."
        credentialSubject:
          type: object
          properties:
            id:
              type: string
              format: uri
              description: "A URI uniquely identifying the credential subject."
            inbox:
              type: string
              format: uri
              description: "A URI to the inbox associated with the credential subject."
            hasConsent:
              type: object
              properties:
                mode:
                  type: array
                  items:
                    type: string
                forPersonalData:
                  type: string
                  format: uri
                  description: "A URI to the personal data involved in the consent."
                forPurpose:
                  type: string
                  format: uri
                  description: "A URI indicating the purpose of the consent."
                hasStatus:
                  type: string
                  description: "Status of the consent."
                isConsentForDataSubject:
                  type: string
                  format: uri
                  description: "A URI identifying the data subject for the consent."
        expirationDate:
          type: string
          format: date-time
          description: "Date and time when the credential expires."
        issuanceDate:
          type: string
          format: date-time
          description: "Date and time when the credential was issued."
        issuer:
          type: string
          format: uri
          description: "A URI identifying the issuer of the credential."
        "@context":
          type: array
          items:
            type: string
          description: "List of contexts defining the semantic meaning of the properties."
