swagger: '2.0'
info:
  title: Kalliópê API
  description: Spatial storytelling is about to change
  version: 2.0.0
host: 'kapi.iglor.es'
schemes:
  - http
basePath: /v1
produces:
  - application/json
paths:
  /customers/:
    get:
     summary: List of customers
     description: >
      This query retuns a list of all customers
     produces:
      - application/json
     tags:
      - Admin
     responses:
       200:
         description: Customer list
         schema:
           $ref: '#/definitions/CustomerList'
       default:
        description: Unexpected error
        schema:
         $ref: '#/definitions/CustomerResponse'
    post:
     summary: Create a customer
     description: >
      Allow to create a customer 
     produces:
      - application/json
     parameters:
      - name: customer
        in: body
        required: true
        schema:
         $ref: '#/definitions/Customer'
     tags:
      - Admin
     responses:
       201:
         description: Customer created
         schema:
          $ref: '#/definitions/CustomerResponse'
       409:
        description: Customer already exist
        schema:
          $ref: '#/definitions/CustomerResponse'
       default:
        description: Unexpected error
        schema:
         $ref: '#/definitions/CustomerResponse'
  '/customers/{username}':
    get:
     summary: Retrieve Customer Info
     description: >
      This query retuns related information of customer profile
     produces:
      - application/json
     tags:
      - Dashboard
     parameters:
      - in: path
        name: username
        description: username of the customer
        required: true
        type: string
     responses:
       200:
         description: Customer info
         schema:
          $ref: '#/definitions/CustomerResponse'
       404:
         description: Customer does not exist
         schema:
          $ref: '#/definitions/Error'
       default:
        description: Unexpected error
        schema:
         $ref: '#/definitions/CustomerResponse'
    put:
     summary: Update a customer
     description: >
      Allow to update information for this customer 
     produces:
      - application/json
     parameters:
      - in: path
        name: username
        description: username of the customer
        required: true
        type: string     
      - name: customer
        in: body
        required: true
        schema:
         $ref: '#/definitions/Customer'
     tags:
      - Admin
     responses:
       200:
         description: Customer Modified
         schema:
          $ref: '#/definitions/CustomerResponse'
       404:
        description: Customer does not exist
        schema:
          $ref: '#/definitions/Error'
       default:
        description: Unexpected error
        schema:
         $ref: '#/definitions/CustomerResponse' 
    delete:
     summary: Delete a customer
     description: >
      Allow to update information for this customer 
     produces:
      - application/json
     parameters:
      - in: path
        name: username
        description: username of the customer
        required: true
        type: string  
     tags:
      - Admin
     responses:
       200:
         description: Customer delete
         schema:
          $ref: '#/definitions/CustomerResponse'
       404:
        description: Customer does not exist
        schema:
          $ref: '#/definitions/Error'
       default:
        description: Unexpected error
        schema:
         $ref: '#/definitions/CustomerResponse'
  '/customers/{username}/channels':
    get:
     summary: Return channel list
     description: >
      This query retuns a list of channels owned by username
     produces:
      - application/json
     tags:
      - Dashboard
     parameters:
      - in: path
        name: username
        description: username of the customer
        required: true
        type: string
     responses:
       200:
         description: Channel list
         schema:
           $ref: '#/definitions/ChannelList'
       404:
        description: Customer does not exist
        schema:
          $ref: '#/definitions/Error'       
       default:
        description: Unexpected error
        schema:
         $ref: '#/definitions/Error'
    post:
     summary: Create a channel
     description: >
      Allow to create a channel owned by username
     produces:
      - application/json
     parameters:
      - in: path
        name: username
        description: username of the customer
        required: true
        type: string
      - name: channel
        in: body
        required: true
        schema:
         $ref: '#/definitions/ChannelInput'
     tags:
      - Dashboard
     responses:
       201:
         description: Channel created
         schema:
          $ref: '#/definitions/ChannelResponse'
       404:
        description: Customer does not exist
        schema:
          $ref: '#/definitions/Error'
       409:
        description: Channel already exist
        schema:
          $ref: '#/definitions/Error'
       default:
        description: Unexpected error
        schema:
         $ref: '#/definitions/Error'
  '/customers/{username}/channels/{id}':
    get:
     summary: Return channel info
     description: >
      This query retuns a information from a channel owned by username
     produces:
      - application/json
     tags:
      - Dashboard
     parameters:
      - in: path
        name: username
        description: username of the customer
        required: true
        type: string
      - in: path
        name: id
        description: channel identifier
        required: true
        type: integer
     responses:
       200:
         description: Channel info
         schema:
           $ref: '#/definitions/ChannelResponse'
       404:
        description: Channel or customer does not exist
        schema:
          $ref: '#/definitions/Error'
       default:
        description: Unexpected error
        schema:
         $ref: '#/definitions/Error'
    put:
     summary: Modify channel
     description: >
      Allow to modify channel owned by username
     produces:
      - application/json
     parameters:
      - in: path
        name: username
        description: username of the customer
        required: true
        type: string
      - in: path
        name: id
        description: channel identifier
        required: true
        type: integer
      - name: channel
        in: body
        required: true
        schema:
         $ref: '#/definitions/Channel'
     tags:
      - Dashboard
     responses:
       200:
         description: Channel modified
         schema:
          $ref: '#/definitions/ChannelResponse'
       404:
        description: Channel or customer does not exist
        schema:
          $ref: '#/definitions/Error'
       default:
        description: Unexpected error
        schema:
         $ref: '#/definitions/Error'
    delete:
     summary: Delete channel
     description: >
      Allow to delete channel owned by username and identified by id
     produces:
      - application/json
     parameters:
      - in: path
        name: username
        description: username of the customer
        required: true
        type: string
      - in: path
        name: id
        description: channel identifier
        required: true
        type: integer
     tags:
      - Dashboard
     responses:
       200:
         description: Channel deleted
         schema:
          $ref: '#/definitions/ChannelResponse'
       404:
        description: Channel or customer does not exist
        schema:
          $ref: '#/definitions/Error'
       default:
        description: Unexpected error
        schema:
         $ref: '#/definitions/Error'

  '/customers/{username}/channels/{id}/push':
      post:
       summary: Send to all notifications
       description: >
        Send a notification to all devices of this channel
       produces:
        - application/json
       parameters:
        - in: path
          name: username
          description: username of the customer
          required: true
          type: string
        - in: path
          name: id
          description: channel identifier
          required: true
          type: integer
        - in: body
          name: field
          required: true
          schema:
            $ref: '#/definitions/PushMessage'
       tags:
        - Dashboard
       responses:
         201:
           description: Field created
           schema:
            $ref: '#/definitions/PushMessageResponse'
         404:
          description: Either channel or username does not exist
          schema:
            $ref: '#/definitions/Error'       
         409:
          description: Form field already exist
          schema:
            $ref: '#/definitions/Error'
         default:
          description: Unexpected error
          schema:
           $ref: '#/definitions/Error'  
  '/customers/{username}/channels/{id}/form':
      get:
       summary: Return form field list
       description: >
        This query retuns a list of fields for this channel
       produces:
        - application/json
       tags:
        - Dashboard
       parameters:
        - in: path
          name: username
          description: username of the customer
          required: true
          type: string
        - in: path
          name: id
          description: channel identifier
          required: true
          type: integer
       responses:
         200:
           description: Form fields list
           schema:
            type: array
            items:
             $ref: '#/definitions/FormFieldList'
         404:
          description: Channel or customer does not exist
          schema:
           $ref: '#/definitions/Error' 
         default:
          description: Unexpected error
          schema:
           $ref: '#/definitions/Error'
      post:
       summary: Create new form field
       description: >
        Allow to create a new form field for this channel
       produces:
        - application/json
       parameters:
        - in: path
          name: username
          description: username of the customer
          required: true
          type: string
        - in: path
          name: id
          description: channel identifier
          required: true
          type: integer
        - in: body
          name: field
          required: true
          schema:
            $ref: '#/definitions/FormField'
       tags:
        - Dashboard
       responses:
         201:
           description: Field created
           schema:
            $ref: '#/definitions/FormFieldResponse'
         404:
          description: Either channel or username does not exist
          schema:
            $ref: '#/definitions/Error'       
         409:
          description: Form field already exist
          schema:
            $ref: '#/definitions/Error'
         default:
          description: Unexpected error
          schema:
           $ref: '#/definitions/Error'
  '/customers/{username}/channels/{id}/form/{fid}':
      get:
       summary: Return form field info 
       description: >
        This query retuns related field info identified by fid
       produces:
        - application/json
       tags:
        - Dashboard
       parameters:
        - in: path
          name: username
          description: username of the customer
          required: true
          type: string
        - in: path
          name: id
          description: channel identifier
          required: true
          type: integer
        - in: path
          name: fid
          description: channel identifier
          required: true
          type: integer       
       responses:
         200:
           description: Form fields list
           schema:
            type: array
            items:
             $ref: '#/definitions/FormField'
         404:
           description: Customer, channel or form field does not exist
           schema:
             $ref: '#/definitions/Error'
         default:
          description: Unexpected error
          schema:
           $ref: '#/definitions/Error'      
      put:
       summary: Modify field a given field for this channel
       description: >
        Allow to modify
       produces:
        - application/json
       parameters:
        - in: path
          name: username
          description: username of the customer
          required: true
          type: string
        - in: path
          name: id
          description: channel identifier
          required: true
          type: integer
        - in: path
          name: fid
          description: channel identifier
          required: true
          type: integer          
        - in: body
          name: field
          required: true
          schema:
            $ref: '#/definitions/FormField'
       tags:
        - Dashboard
       responses:
         200:
           description: Field modified
           schema:
            $ref: '#/definitions/FormFieldResponse'
         404:
           description: Customer, channel or form field does not exist
           schema:
             $ref: '#/definitions/Error'       
         default:
          description: Unexpected error
          schema:
           $ref: '#/definitions/Error'
      delete:
       summary: Delete field
       description: >
        Delete form field 
       produces:
        - application/json
       parameters:
        - in: path
          name: username
          description: username of the customer
          required: true
          type: string
        - in: path
          name: id
          description: channel identifier
          required: true
          type: integer
        - in: path
          name: fid
          description: channel identifier
          required: true
          type: integer       
       tags:
        - Dashboard
       responses:
         200:
           description: Form field deleted
           schema:
            $ref: '#/definitions/FormFieldResponse'
         404:
           description: Customer, channel or form field does not exist
           schema:
             $ref: '#/definitions/Error'       
         default:
          description: Unexpected error
          schema:
           $ref: '#/definitions/Error'
  '/customers/{username}/channels/{id}/medias':
    get:
     summary: Return media list
     description: >
      This query retuns a list of channels owned by username
     produces:
      - application/json
     tags:
      - Dashboard
     parameters:
      - in: path
        name: username
        description: username of the customer
        required: true
        type: string
      - in: path
        name: id
        description: channel identifier
        required: true
        type: integer
     responses:
       200:
         description: Media list
         schema:
          type: array
          items:
           $ref: '#/definitions/MediaList'
       default:
        description: Unexpected error
        schema:
         $ref: '#/definitions/Error'
    post:
     summary: Create new media
     description: >
      Allow to create an associated media for a channel identified by cname
     produces:
      - application/json
     consumes:
      - multipart/form-data
     parameters:
      - in: path
        name: username
        description: username of the customer
        required: true
        type: string
      - in: path
        name: id
        description: channel identifier
        required: true
        type: integer
      - in: formData
        type: file
        name: file
        required: true
      - in: formData
        type: string
        name: device_filter
        required: true
     tags:
      - Dashboard
     responses:
       201:
         description: Media created
         schema:
          $ref: '#/definitions/MediaResponse'
       404:
        description: Either channel or username does not exist
        schema:
          $ref: '#/definitions/Error'       
       409:
        description: Media already exist
        schema:
          $ref: '#/definitions/MediaResponse'
       default:
        description: Unexpected error
        schema:
         $ref: '#/definitions/Error'
  '/customers/{username}/channels/{id}/medias/{mid}':
    get:
     summary: Return media info
     description: >
      This query related info for this media
     produces:
      - application/json
     tags:
      - Dashboard
     parameters:
      - in: path
        name: username
        description: username of the customer
        required: true
        type: string
      - in: path
        name: id
        description: channel identifier
        required: true
        type: integer
      - in: path
        name: mid
        description: media identifier
        required: true
        type: integer
     responses:
       200:
         description: Media list
         schema:
          type: array
          items:
           $ref: '#/definitions/MediaOutput'
       404:
        description: Channel,username or media does not exist
        schema:
          $ref: '#/definitions/Error' 
       default:
        description: Unexpected error
        schema:
         $ref: '#/definitions/Error'    
    put:
     summary: Modify media
     description: >
      Allow to modify a given media for this channel
     produces:
      - application/json
     consumes:
      - multipart/form-data
     parameters:
      - in: path
        name: username
        description: username of the customer
        required: true
        type: string
      - in: path
        name: id
        description: channel identifier
        required: true
        type: integer
      - in: path
        name: mid
        description: media identifier
        required: true
        type: integer
      - in: formData
        type: file
        name: file
        required: true
     tags:
      - Dashboard
     responses:
       200:
         description: Media modified
         schema:
          $ref: '#/definitions/MediaResponse'
       404:
        description: channel, username or media does not exist
        schema:
          $ref: '#/definitions/Error'       
       default:
        description: Unexpected error
        schema:
         $ref: '#/definitions/Error'
    delete:
     summary: Delete media
     description: >
      Delete media 
     produces:
      - application/json
     parameters:
      - in: path
        name: username
        description: username of the customer
        required: true
        type: string
      - in: path
        name: id
        description: channel identifier
        required: true
        type: integer
      - in: path
        name: mid
        description: media identifier
        required: true
        type: integer
     tags:
      - Dashboard
     responses:
       200:
         description: Media deleted
         schema:
          $ref: '#/definitions/MediaResponse'
       404:
        description: channel, username or media does not exist
        schema:
          $ref: '#/definitions/Error'       
       default:
        description: Unexpected error
        schema:
         $ref: '#/definitions/Error'
  /channels:
    get:
     summary: Return available channels
     description: >
      This query retuns a list of users
     produces:
      - application/json
     tags:
      - Admin
     responses:
       200:
         description: Channel list
         schema:
           $ref: '#/definitions/ChannelList'
       default:
        description: Unexpected error
        schema:
         $ref: '#/definitions/Error'

  /public/users:
    get:
     summary: Return a list of users
     description: >
      This query retuns a list of users
     produces:
      - application/json
     tags:
      - Admin
     responses:
       200:
         description: User list
         schema:
          type: array
          items:
           $ref: '#/definitions/PublicUserList'
       default:
        description: Unexpected error
        schema:
         $ref: '#/definitions/Error'
    post:
     summary: Create a public user
     description: >
      Allow to create a public user
     produces:
      - application/json
     parameters:
      - name: user
        in: body
        required: true
        schema:
         $ref: '#/definitions/PublicUser'
     tags:
      - APP
     responses:
       201:
         description: User created
         schema:
          $ref: '#/definitions/PublicUserResponse'
       409:
        description: User already exist
        schema:
          $ref: '#/definitions/PublicUserResponse'
       default:
        description: Unexpected error
        schema:
         $ref: '#/definitions/Error'
  '/public/users/{uuid}':
    get:
     summary: Return user info
     description: >
      Return Public user profile identified by uuid
     produces:
      - application/json
     parameters:
      - in: path
        name: uuid
        description: uuid of user
        required: true
        type: string
     tags:
      - APP
     responses:
       200:
         description: User Info
         schema:
           $ref: '#/definitions/PublicUserResponse'
       404:
         description: User does not exist
         schema:
          $ref: '#/definitions/PublicUserResponse'
       default:
        description: Unexpected error
        schema:
         $ref: '#/definitions/Error'
    put:
     summary: Modify user
     description: >
      Modify public profile information of a user
     produces:
      - application/json
     parameters:
      - in: path
        name: uuid
        description: uuid of user
        required: true
        type: string     
      - name: user
        in: body
        required: true
        schema:
         $ref: '#/definitions/PublicUser'
     tags:
      - APP
     responses:
       200:
         description: User modified
         schema:
          $ref: '#/definitions/PublicUserResponse'
       404:
        description: User does not exist
        schema:
          $ref: '#/definitions/PublicUserResponse'
       default:
        description: Unexpected error
        schema:
         $ref: '#/definitions/PublicUserResponse'

  '/public/users/{uuid}/locations':
    post:
     summary: Upload location data
     description: >
      Add new location event
     produces:
      - application/json
     parameters:
      - in: path
        name: uuid
        description: uuid of user
        required: true
        type: string  
      - in: body
        name: location
        schema:
         $ref: '#/definitions/Location'
     tags:
      - APP
     responses:
       200:
         description: Location Added
         schema:
          $ref: '#/definitions/LocationResponse'
       404:
        description: User does not exist
        schema:
          $ref: '#/definitions/Error'
       default:
        description: Unexpected error
        schema:
         $ref: '#/definitions/Error'
# --- Los usuarios no pueden borrarse desde aqui
#    delete:
#     summary: Delete public user
#     description: >
#      Delete  public user
#     produces:
#      - application/json
#     parameters:
#      - in: path
#        name: uuid
#        description: uuid of user
#        required: true
#        type: string     
#     tags:
#      - Dashboard
#      - APP
#     responses:
#       200:
#         description: User deleted
#         schema:
#          $ref: '#/definitions/UserSuccess'
#       404:
#        description: User does not exist
#        schema:
#          $ref: '#/definitions/Error'
#       default:
#        description: Unexpected error
#        schema:
#         $ref: '#/definitions/Error'

  '/public/users/{uuid}/channels':
    get:
     summary: Channel subscription list
     description: >
      Retun the list of channels subscribed by public user
     produces:
      - application/json
     parameters:
      - in: path
        name: uuid
        description: uuid of user
        required: true
        type: string
     tags:
      - APP
     responses:
       200:
        description: Available channels names
        schema:
          $ref: '#/definitions/ChannelNameList'
       404:
         description: User does not exist
         schema:
          $ref: '#/definitions/Error'
       default:
        description: Unexpected error
        schema:
         $ref: '#/definitions/Error'
    post:
     summary: Add new subscription
     description: >
      Add subscriptioin according to channel name
     produces:
      - application/json
     parameters:
      - in: path
        name: uuid
        description: uuid of user
        required: true
        type: string
      - in: body
        name: cname
        required: true
        schema:
         $ref: '#/definitions/ChannelSubscription'
     tags:
      - APP
     responses:
       201:
         description: Subscription created
         schema:
          $ref: '#/definitions/ChannelPublicResponse'
       404:
        description: User or Channel  does not exist
        schema:
          $ref: '#/definitions/Error'
       default:
        description: Unexpected error
        schema:
         $ref: '#/definitions/Error'
    delete:
     summary: Delete a subscription
     description: >
      Delete a subscription according to channel name
     produces:
      - application/json
     parameters:
      - in: path
        name: uuid
        description: uuid of user
        required: true
        type: string     
      - in: body
        name: cname
        required: true
        schema:
         $ref: '#/definitions/ChannelSubscription'
     tags:
      - APP
     responses:
       200:
         description: Subscription deleted
       404:
        description: User or Channel  does not exist
        schema:
          $ref: '#/definitions/Error'
       default:
        description: Unexpected error
        schema:
         $ref: '#/definitions/Error'  
  '/public/users/{uuid}/channels/{cname}':
    get:
     summary: Channel Info
     description: >
      Return info for a given channel name
     produces:
      - application/json
     parameters:
      - in: path
        name: uuid
        description: uuid of user
        required: true
        type: string
      - in: path
        name: cname
        description: Channel Name
        required: true
        type: string 
     tags:
      - APP
     responses:
       200:
        description: Channel Info
        schema:
          $ref: '#/definitions/ChannelPublicResponse'
       404:
         description: User or channel does not exist
         schema:
          $ref: '#/definitions/Error'
       default:
        description: Unexpected error
        schema:
         $ref: '#/definitions/Error'

  '/public/users/{uuid}/channels/{cname}/medias':
    get:
     summary: Media list
     description: >
      Return the list of medias associated with this channel
     produces:
      - application/json
     parameters:
      - in: path
        name: uuid
        description: uuid of user
        required: true
        type: string  
      - in: path
        name: cname
        description: Channel name
        required: true
        type: string
     tags:
      - APP
     responses:
       200:
        description: Media list
        schema:
          $ref: '#/definitions/MediaPublicList'
       404:
         description: User or Channel does not exist
         schema:
          $ref: '#/definitions/Error'
       default:
        description: Unexpected error
        schema:
         $ref: '#/definitions/Error'
  '/public/users/{uuid}/channels/{cname}/form':
    post:
     summary: Send answer's array
     description: >
      Send array of the form answers. If the answers already exists this method update its values
     produces:
      - application/json
     parameters:
      - in: path
        name: uuid
        description: uuid of user
        required: true
        type: string
      - in: path
        name: cname
        description: Channel Name
        required: true
        type: string 
      - in: body
        name: FormFields
        description: FormFields array
        required: true
        schema:
         $ref: '#/definitions/FormAnswerList'
     tags:
      - APP
     responses:
       201:
         description: Answers stored
       404:
        description: User or Channel  does not exist
        schema:
          $ref: '#/definitions/Error'
       default:
        description: Unexpected error
        schema:
         $ref: '#/definitions/Error'
#    put:
#     summary: Send and modify answer's array
#     description: >
#      Send array of the form answers given by the user
#     produces:
#      - application/json
#     parameters:
#      - in: path
#        name: uuid
#        description: uuid of user
#        required: true
#        type: string
#      - in: path
#        name: cname
#        description: Channel Name
#        required: true
#        type: string 
#      - in: body
#        name: FormFields
#        description: FormFields array
#        required: true
#        schema:
#         $ref: '#/definitions/FormAnswerList'
#     tags:
#      - APP
#     responses:
#       201:
#         description: Answers stored
#       404:
#        description: User,Channel or field  does not exist
#        schema:
#          $ref: '#/definitions/Error'
#       default:
#        description: Unexpected error
#        schema:
#         $ref: '#/definitions/Error'         

#  '/public/users/{uuid}/medias':
#    get:
#     summary: Media list
#     description: >
#      Return a list of media owned by this user
#     produces:
#      - application/json
#     parameters:
#      - in: path
#        name: uuid
#        description: uuid of user
#        required: true
#        type: string
#     tags:
#      - APP
#     responses:
#       200:
#        description: Media list
#        schema:
#         $ref: '#/definitions/MediaList'
#       404:
#         description: User does not exist
#         schema:
#          $ref: '#/definitions/Error'
#       default:
#        description: Unexpected error
#        schema:
#         $ref: '#/definitions/Error'
#    post:
#     summary: Add new media
#     description: >
#      Add subscriptioin according to channel name
#     produces:
#      - application/json
#     parameters:
#      - in: path
#        name: uuid
#        description: uuid of user
#        required: true
#        type: string     
#      - name: file
#        in: formData
#        description: Data
#        required: true
#        type: file
#     tags:
#      - APP
#     responses:
#       201:
#         description: Return file info stored
#         schema:
#          $ref: '#/definitions/MediaSuccess'
#       400:
#        description: Missing file data
#        schema:
#          $ref: '#/definitions/Error'
#       404:
#        description: User does not exist
#        schema:
#          $ref: '#/definitions/Error'
#       default:
#        description: Unexpected error
#        schema:
#         $ref: '#/definitions/Error'
#    put:
#     summary: Modify existing media
#     description: >
#      Replace existing media with a new one
#     produces:
#      - application/json
#     parameters:
#      - in: path
#        name: uuid
#        description: uuid of user
#        required: true
#        type: string     
#      - name: file
#        in: formData
#        description: Data
#        required: true
#        type: file
#     tags:
#      - APP
#     responses:
#       200:
#         description: Media modified
#         schema:
#          $ref: '#/definitions/MediaSuccess'
#       400:
#        description: Missing file data
#        schema:
#          $ref: '#/definitions/Error'
#       404:
#        description: User does not exist
#        schema:
#          $ref: '#/definitions/Error'
#       default:
#        description: Unexpected error
#        schema:
#         $ref: '#/definitions/Error'
#    delete:
#     summary: Delete a media
#     description: >
#      Delete a media for user space
#     produces:
#      - application/json
#     parameters:
#      - in: path
#        name: uuid
#        description: uuid of user
#        required: true
#        type: string     
#      - name: media
#        in: body
#        required: true
#        schema:
#          $ref: '#/definitions/Media'
#     tags:
#      - APP
#     responses:
#       200:
#         description: Media deleted
#       404:
#        description: User or Channel  does not exist
#        schema:
#          $ref: '#/definitions/Error'
#       default:
#        description: Unexpected error
#        schema:
#         $ref: '#/definitions/Error'

  '/public/users/{uuid}/channels/{cname}/activities':
    post:
     summary: Add new activity
     description: >
      Add activities to the user history
     produces:
      - application/json
     parameters:
      - in: path
        name: uuid
        description: uuid of user
        required: true
        type: string
      - in: path
        name: cname
        description: Channel Name
        required: true
        type: string  
      - in: body
        name: activity
        schema:
         $ref: '#/definitions/Activity'         
     tags:
      - APP
     responses:
       201:
        description: Activity submited
        schema:
          $ref: '#/definitions/ActivityResponse'
       404:
        description: Channel or User does not exist
        schema:
          $ref: '#/definitions/Error'
       default:
        description: Unexpected error
        schema:
         $ref: '#/definitions/Error'
  
definitions:
# Meta Input Models
  Customer:
    type: object
    properties:
      customer:
        $ref: '#/definitions/CustomerInput'
  Channel:
    type: object
    properties:
      channel:
        $ref: '#/definitions/ChannelInput'

  FormField:
    type: object
    properties:
      form_field:
        $ref: '#/definitions/FormFieldInput'
  Media:
    type: object
    properties:
      media_file:
        $ref: '#/definitions/MediaInput'
  PublicUser:
    type: object
    properties:
      public_user:
        $ref: '#/definitions/PublicUserInput' 
  Form:
    type: object
    properties:
     fields:
      type: array
      items: 
       $ref: '#/definitions/FormFieldInput'

  Activity:
    type: object
    properties:
     activity:
      $ref: '#/definitions/ActivityInput'
  Location:
    type: object
    properties:
     location:
      $ref: '#/definitions/LocationInput'
  PushMessage:
    type: object
    properties:
     message:
      $ref: '#/definitions/PushMessageInput'

# Input Models 
  CustomerInput:
   type: object
   required:
   - email
   - username
   properties:
    cuid:
      type: string
      description: Unique identifier customer related to license.
    email:
     type: string
     description: Customer email
    username:
     type: string
     description: Username for this customer

  ChannelInput:
   type: object
   properties:
    name:
     type: string
     description: Channel name
    description:
     type: string
     description: Channel brief description
    iconUrl:
     type: string
     description: Url to where icon can be found
    documentationUrl:
     type: string
     description: Url to get information to for landing page
    distance:
     type: number
     format: integer
     description: Reference distance to update device location in meters

  MediaInput:
    type: object
    properties:
     name:
      type: string
      description: Media name
     media_type:
      type: string
      description: type of media (image,audio,video)
     device_filter:
      type: string
      description: device string filter (smartphone,...)

  FormFieldInput:
    type: object
    properties:
     name:
      type: string
      description: Field name to display
     field_type:
      type: string
      description: 'Type of the field (input,select,option)'
     value:
      type: array
      items:
        type: string

  PublicUserInput:
    type: object
    required:
    - uuid
    - device_type
    - push_uuid
    properties:
      uuid:
        type: string
        description: Unique identifier for the user.
      device_type:
        type: string
        description: User type (i.e. smartphones)
      push_uuid:
        type: string
        description: User id push
      hardware:
        type: string
        description: Hardware in wich the Public App is installed.
      so:
        type: string
        description: Operating system where Public App is installed.
      first_name:
        type: string
        description: First name of the Public user.
      last_name:
        type: string
        description: Last name of the Public user.
      gender:
        type: string
        description: Gender of the Public user.
      age:
        type: integer
        format: int32
        description: Age of the Public user.
      country:
        type: string
        description: Country of the Public user.
      language:
        type: string
        description: Language of the Public user.
      email:
        type: string
        description: Email address of the Public user
      phone:
        type: string
        description: Phone number of the Public user
      picture:
        type: string
        description: Image URL of the Public user.


  FormAnswerInput:
    type: object
    properties:
     field_id:
      type: string
      description: Field name to display
     value:
      type: array
      items:
        type: string

  ActivityInput:
    properties:
      device_type:
        type: string
        description: Activity type
      description:
        type: string
        description: Description of the activity
      module:
        type: string
        description: Module like multimedia,gps,etc..
      value:
        type: string
        description: play,stop,...
      aref:
        type: string
        description: action reference
      data:
        type: string
        description: other information related to the activity
        
  LocationInput:
    type: object
    required:
    - lat
    - lon
    properties:
      lat:
        type: number
        format: float
        description: Location latitude value
      lon:
        type: number
        format: float
        description: Location longitude value
      accuracy:
        type: integer
        description: Location's accuracy
  PushMessageInput:
    type: object
    required:
    - text
    properties:
      text:
        type: string
        description: Message string to send
      data:
       type: string
       description: json object describing a mosquitto action 

#Output Models
  CustomerOutput:
   type: object
   required:
   - email
   - username
   properties:
    cuid:
      type: string
      description: Unique identifier customer related to license.
    email:
     type: string
     description: Customer email
    username:
     type: string
     description: Username for this customer
    max_channels:
     type: string
     description: Username for this customer
    expirationDate:
     type: string
     description: Username for this customer
  ChannelOutput:
   type: object
   properties:
    id:
     type: string
     description: Channel identifier
    name:
     type: string
     description: Channel name
    description:
     type: string
     description: Channel brief description
    expirationDate:
     type: string
     format: date-time
     description: 'Date expiration for this channel'
    iconUrl:
     type: string
     description: Url to where icon can be found
    documentationUrl:
     type: string
     description: Url to get information to for landing page
    messagesScopeUrl:
     type: string
     description: >
      URL scope reference to receive messages according to a channel. Refers to msgServer scoping.
    distance:
     type: number
     format: integer
     description: Reference distance to update device location in meters
  ChannelPublicOutput:
   type: object
   properties:
    name:
     type: string
     description: Channel name
    description:
     type: string
     description: Channel brief description
    expirationDate:
     type: string
     format: date-time
     description: 'Date expiration for this channel'
    iconUrl:
     type: string
     description: Url to where icon can be found
    documentationUrl:
     type: string
     description: Url to get information to for landing page
    messagesScopeUrl:
     type: string
     description: >
      URL scope reference to receive messages according to a channel. Refers to msgServer scoping.
    distance:
     type: number
     format: integer
     description: Reference distance to update device location in meters
    FormFields:
      $ref: '#/definitions/FormOutput'
  
  FormOutput:
    type: array
    items: 
     $ref: '#/definitions/FormFieldOutput'
       
  MediaOutput:
    type: object
    properties:
     id:
      type: string
      description: Media identifier 
     name:
      type: string
      description: Media name
     media_type:
      type: string
      description: type of media (image,audio,video)
     device_filter:
      type: string
      description: device string filter (smartphone,...)
     sha1:
      type: string
      description: sha1 code representing media content 
     content_url:
      type: string
      description: URL to download the content 

  MediaPublicOutput:
    type: object
    properties:
     name:
      type: string
      description: Media name
     media_type:
      type: string
      description: type of media (image,audio,video)
     device_type:
      type: string
      description: Device type associated with this media
     sha1:
      type: string
      description: sha1 code representing media content 
     content_url:
      type: string
      description: URL to download the content 

  FormFieldOutput:
    type: object
    properties:
     id:
      type: string
      description: Form field identifier 
     name:
      type: string
      description: Field name to display
     field_type:
      type: string
      description: 'Type of the field (input,select,option)'
     value:
      type: array
      items:
        type: string
     user_value:
      type: string
      description: 'Value linked with this user in this channel'

  ActivityOutput:
    properties:
      uuid:
        type: string
        description: JSON Data generated by the activity    
      cname:
        type: string
        description: Channel name
      device_type:
        type: string
        description: Activity type
      description:
        type: string
        description: Description of the activity
      module:
        type: string
        description: JSON Data generated by the activity
      value:
        type: string
        description: JSON Data generated by the activity
      data:
        type: string
        description: JSON Data generated by the activity
  LocationOutput:
    type: object
    required:
    - lat
    - lon
    properties:
      lat:
        type: number
        format: float
        description: Location latitude value
      lon:
        type: number
        format: float
        description: Location longitude value
      accuracy:
        type: integer
        description: Location's accuracy
  PushMessageOutput:
    type: object
    properties:
      android:
        type: integer
        description: Number of notifications for android devices
      ios:
        type: integer
        description: Number of notifications for ios devices
  ChannelSubscription:
   type: object
   properties:
    cname:
     type: string
     description: Channel name

#Lists
  FormAnswerList:
    properties:
      answers:
        type: array
        description: List of Medias
        items:
         $ref: '#/definitions/FormAnswerInput'
  FormFieldList:
    properties:
      code:
        type: integer
        format: int32
      message:
        type: string
      fields:
        type: array
        description: List of Medias
        items:
         $ref: '#/definitions/FormFieldOutput'
  MediaList:
    properties:
      code:
        type: integer
        format: int32
      message:
        type: string
      fields:
        type: array
        description: List of Medias
        items:
         $ref: '#/definitions/MediaOutput'
  MediaPublicList:
    properties:
      code:
        type: integer
        format: int32
      message:
        type: string
      fields:
        type: array
        description: List of Medias
        items:
         $ref: '#/definitions/MediaPublicOutput'
  CustomerList:
    properties:
      code:
        type: integer
        format: int32
      message:
        type: string
      fields:
        type: array
        description: List of Customers
        items:
         $ref: '#/definitions/CustomerOutput'
  ChannelList:
    properties:
      code:
        type: integer
        format: int32
      message:
        type: string
      fields:
        type: array
        description: List of Channels
        items:
         $ref: '#/definitions/ChannelOutput'
  ChannelNameList:
    properties:
      code:
        type: integer
        format: int32
      message:
        type: string
      fields:
        type: array
        description: List of channels names
        items:
         type: string
  PublicUserList:
    properties:
      code:
        type: integer
        format: int32
      message:
        type: string
      fields:
        type: array
        description: List of Public users
        items:
         $ref: '#/definitions/PublicUserInput'
 #RESPONSES

  PublicUserResponse:
    properties:
      code:
        type: integer
        format: int32
      message:
        type: string
      fields:
        $ref: '#/definitions/PublicUserInput'
  MediaResponse:
    properties:
      code:
        type: integer
        format: int32
      message:
        type: string
      fields:
        $ref: '#/definitions/MediaOutput'
  CustomerResponse:
    properties:
      code:
        type: integer
        format: int32
      message:
        type: string
      fields:
        $ref: '#/definitions/CustomerOutput'
  ChannelResponse:
    properties:
      code:
        type: integer
        format: int32
      message:
        type: string
      fields:
        $ref: '#/definitions/ChannelOutput'
  ChannelPublicResponse:
    properties:
      code:
        type: integer
        format: int32
      message:
        type: string
      fields:
        $ref: '#/definitions/ChannelPublicOutput'
  FormFieldResponse:
    properties:
      code:
        type: integer
        format: int32
      message:
        type: string
      fields:
        $ref: '#/definitions/FormFieldOutput'
  ActivityResponse:
    properties:
      code:
        type: integer
        format: int32
      message:
        type: string
      fields:
        $ref: '#/definitions/ActivityInput'
  LocationResponse:
    properties:
      code:
        type: integer
        format: int32
      message:
        type: string
      fields:
        $ref: '#/definitions/LocationOutput'
  PushMessageResponse:
    properties:
      code:
        type: integer
        format: int32
      message:
        type: string
      fields:
        $ref: '#/definitions/PushMessageOutput'
  Error:
    properties:
      code:
        type: integer
        format: int32
      message:
        type: string
      fields:
        type: string

