add rules to MoDe

add rules to MoDe

#%RAML 1.0
---
title: Modify Delivery API
baseUri: https://www.mybring.com/modify-delivery

documentation:
- title: Introduction
  content: |
      The modify delivery api is used to modify a shipment currently on it's way.
      Below are the various modifications (which will be API calls) supported:
        - Stop shipment.
        - Change cash on deivery.
        - Change Address

- title: Authentication
  content: |
    The Modify Delivery API requires authentication. To make API requests, you will need an API key from Mybring. Steps for getting a key and description of headers can be found on the general API [Getting Started / Authentication](/api/#authentication) page.

- title: Criteria
  content: |
    To successfully modify a delivery, the shipment must have both sender and recipient address located in Norway. Additionally, any of the following events must not be registered on the shipment:
      - Damaged
      - Deviation
      - Returned
      - Delivered
      - Lost
      - Partly delivered
      - Stopped

/allowed-modification:
  displayName: Allowed modifications
  description: It gives us the list of allowed modifications on a shipment along with failure causes.

  get:
    description: List of allowed modifications, along with failure causes.
    queryParameters:
        q:
            description: Shipment number to be checked for.
            type: string
            required: true
            example: "707262014721"
    responses:
      200:
        body:
          application/json:
            examples:
              allowed_mods:
                displayName: Allowed modifications
                value: !include examples/allowed-modification.json

/stop-shipment:
  displayName: Stop shipment
  description: |
    This will stop the shipment and send it back to the sender.

    Stop delivery is available for the following products:
       - 1000
       - 1002
       - 1202
       - 1736
       - 1988
       - 3500
       - 4850
       - 5000
       - 5600
       - 5800

  post:
    description: Stop a shipment and return to sender.
    body:
      application/json:
        examples:
          stop_shipment:
            displayName: Stop shipment
            value: !include examples/stoprequest.json

    responses:
      200:
        body:
          application/json:
            examples:
              stop_shipment:
                displayName: Stop shipment
                value: !include examples/stopresponse.json

/change-cod:
  displayName: Change cash on delivery
  description: |
    This is used the change the COD amount on the shipment.

    A COD registered on the parcel is required. Additionally, the parcel must be one of the following products:
      - 1000
      - 1002
      - 1202
      - 1736
      - 1988
      - 3500
      - 5800

  post:
    description: Change cash on delivery amount to be paid.
    body:
      application/json:
        examples:
          change_cod:
            displayName: Change cash on delivery
            value: !include examples/changecodrequest.json

    responses:
      200:
        body:
          application/json:
            examples:
              change_cod:
                displayName: Change cash on delivery
                value: !include examples/changecodresponse.json

/modifications/changeAddress/price/{shipment}/{oldPostal}/{newPostal}:
  displayName: Get price for change address
  description: |
    Get the cost for changing address on a shipment.

    Change address is applicable for the following products:
      - 1000
      - 1202
      - 1736
      - 1988
      - 5000
      - 5600
      - 5800

    The following events cannot be registered on the shipment:
      - Transport to recipient
      - Partly delivered due to damage
      - Home delivery

    Must not have any of the following VAS associated with the parcel:
     - 0010
     - 1158
     - 1159

  uriParameters:
    shipment:
      description: Shipment number.
      type: string
      required: true
      example: "707262014721"
    oldPostal:
      description: Current postal code of recipient address.
      type: string
      required: true
      example: "0021"
    newPostal:
      description: New postal code to where shipment will be re-routed to.
      type: string
      required: true
      example: "0484"

  get:
    description: Get the cost for changing address on a shipment.
    responses:
      200:
        body:
          application/json:
            examples:
              change_cost:
                displayName: Price for address change
                value: !include examples/changeAddressCost.json

/modifications/{shipmentNumber}/address:
  displayName: Change recipient address of delivery
  description: This is used to change the recipient delivery address.
  uriParameters:
    shipmentNumber:
      description: Shipment number to change address for.
      type: string
      required: true
      example: "707262014721"

  post:
    description: Change recipient address of delivery.
    body:
      application/json:
        examples:
          change_recipient:
            displayName: Change recipient address
            value: !include examples/changeAddressRequest.json

    responses:
      200:
        body:
          application/json:
            examples:
              change_recipient:
                displayName: Change recipient address
                value: !include examples/changeAddressResponse.json

/modifications/fetchChangeAddressData/{shipmentNumber}:
  displayName: Current recipient address
  description: Get the current recipient address on the shipment.

  uriParameters:
    shipmentNumber:
      description: Shipment number to get current recipient address.
      type: string
      required: true
      example: "707262014721"

  get:
    description: Get current recipient address for shipment.
    responses:
      200:
        body:
          application/json:
            examples:
              current_recipient:
                displayName: Current recipient address
                value: !include examples/changeAddressRecipientData.json

/modifications/customer/{customerNumber}:
  displayName: Get modifications history
  description: Get list of all the shipments for the customer number on which COD, STOP Delivery and Change address have been done.

  uriParameters:
    customerNumber:
      description: Customer number.
      type: string
      required: true

  get:
    description: Get history for all the modifications done for a customer
    responses:
      200:
        body:
          application/json:
            examples:
              mod_history:
                displayName: Modification history
                value: !include examples/changeAddressHistoryData.json

#%RAML 1.0
---
title: Modify Delivery API
baseUri: https://www.mybring.com/modify-delivery

documentation:
- title: Introduction
  content: |
      The modify delivery api is used to modify a shipment currently on it's way.
      Below are the various modifications (which will be API calls) supported:
        - Stop shipment.
        - Change cash on deivery.
        - Change Address

- title: Authentication
  content: |
    The Modify Delivery API requires authentication. To make API requests, you will need an API key from Mybring. Steps for getting a key and description of headers can be found on the general API [Getting Started / Authentication](/api/#authentication) page.

/allowed-modification:
  displayName: Allowed modifications
  description: It gives us the list of allowed modifications on a shipment along with failure causes.

  get:
    description: List of allowed modifications, along with failure causes.
    queryParameters:
        q:
            description: Shipment number to be checked for.
            type: string
            required: true
            example: "707262014721"
    responses:
      200:
        body:
          application/json:
            examples:
              allowed_mods:
                displayName: Allowed modifications
                value: !include examples/allowed-modification.json

/stop-shipment:
  displayName: Stop shipment
  description: This will stop the shipment and send it back to the sender.
  post:
    description: Stop a shipment and return to sender.
    body:
      application/json:
        examples:
          stop_shipment:
            displayName: Stop shipment
            value: !include examples/stoprequest.json

    responses:
      200:
        body:
          application/json:
            examples:
              stop_shipment:
                displayName: Stop shipment
                value: !include examples/stopresponse.json

/change-cod:
  displayName: Change cash on delivery
  description: This is used the change the COD amount on the shipment.

  post:
    description: Change cash on delivery amount to be paid.
    body:
      application/json:
        examples:
          change_cod:
            displayName: Change cash on delivery
            value: !include examples/changecodrequest.json

    responses:
      200:
        body:
          application/json:
            examples:
              change_cod:
                displayName: Change cash on delivery
                value: !include examples/changecodresponse.json

/modifications/changeAddress/price/{shipment}/{oldPostal}/{newPostal}:
  displayName: Get price for change address
  description: Get the cost for changing address on a shipment.

  uriParameters:
    shipment:
      description: Shipment number.
      type: string
      required: true
      example: "707262014721"
    oldPostal:
      description: Current postal code of recipient address.
      type: string
      required: true
      example: "0021"
    newPostal:
      description: New postal code to where shipment will be re-routed to.
      type: string
      required: true
      example: "0484"

  get:
    description: Get the cost for changing address on a shipment.
    responses:
      200:
        body:
          application/json:
            examples:
              change_cost:
                displayName: Price for address change
                value: !include examples/changeAddressCost.json

/modifications/{shipmentNumber}/address:
  displayName: Change recipient address of delivery
  description: This is used to change the recipient delivery address.
  uriParameters:
    shipmentNumber:
      description: Shipment number to change address for.
      type: string
      required: true
      example: "707262014721"

  post:
    description: Change recipient address of delivery.
    body:
      application/json:
        examples:
          change_recipient:
            displayName: Change recipient address
            value: !include examples/changeAddressRequest.json

    responses:
      200:
        body:
          application/json:
            examples:
              change_recipient:
                displayName: Change recipient address
                value: !include examples/changeAddressResponse.json

/modifications/fetchChangeAddressData/{shipmentNumber}:
  displayName: Current recipient address
  description: Get the current recipient address on the shipment.

  uriParameters:
    shipmentNumber:
      description: Shipment number to get current recipient address.
      type: string
      required: true
      example: "707262014721"

  get:
    description: Get current recipient address for shipment.
    responses:
      200:
        body:
          application/json:
            examples:
              current_recipient:
                displayName: Current recipient address
                value: !include examples/changeAddressRecipientData.json

/modifications/customer/{customerNumber}:
  displayName: Get modifications history
  description: Get list of all the shipments for the customer number on which COD, STOP Delivery and Change address have been done.

  uriParameters:
    customerNumber:
      description: Customer number.
      type: string
      required: true

  get:
    description: Get history for all the modifications done for a customer
    responses:
      200:
        body:
          application/json:
            examples:
              mod_history:
                displayName: Modification history
                value: !include examples/changeAddressHistoryData.json


upgraded demo ref to poom-api-specs to version 1.4.0

#%RAML 1.0
title: Demo
version: 1
baseUri: https://api.codingmatters.org/demo
mediaType: application/json

/:
  displayName: stores
  (paged-collection):
  description: Stores
  get:
    description: |
      Lists all the stores
    is: [rfc7233Browsing: {entityType: object, error: Error}]

  /{store}:
    displayName: a store
    (paged-collection-entity):

    /movies:
      displayName: store movies
      (paged-collection):
      uriParameters:
        store: string
      description: |
        Movies available in this store.

      get:
        description: |
          Lists all the movies
        is: [rfc7233Browsing: {entityType: Movie, error: Error}]

      /{movie-id}:
        displayName: movie
        (paged-collection-entity):
        uriParameters:
          movie-id: string

        get:
          is: [entityRetrieve: {entityType: Movie, error: Error}]
        put:
          description: |
            The movie data is replaced entirely.
            The movie id cannot be changed :
            * if an id is setted in the body it should should be the same than in the uri (a 400 is returned is not)
            * it is ok not to set an id
          is: [entityReplace: {entityType: Movie, entityReplaceType: Movie, error: Error}]
        delete:
          is: [entityDelete: {error: Error}]

        /rentals:
          displayName: movie rentals
          (paged-collection):
          description: |
            Rentals for this movie
          get:
            is: [rfc7233Browsing: {entityType: Rental, error: Error}]
          post:
            description: |
              A rental request is :
              * accepted if the movie is not currently rented (201)
              * refused if the movie is already rented (400)
            is: [entityCreation: {entityType: Rental, entityCreationType: RentalRequest, error: Error}]

          /{rental-id}:
            displayName: rental
            (paged-collection-entity):
            uriParameters:
              rental-id: string

            get:
              is: [entityRetrieve: {entityType: Rental, error: Error}]
            patch:
              description: |
                Rental action can be :
                * a RETURN : the return date is filled, the price is caculated, the status is updated
                * an EXTENSION : the due-date is extended of a few days
              is: [entityUpdate: {entityType: Rental, entityUpdateType: RentalAction, error: Error}]

    /category/{category}:
      displayName: category movies
      (paged-collection):
      uriParameters:
        category: string

      get:
        is: [rfc7233Browsing: {entityType: Movie, error: Error}]
      post:
        description: |
          create a movie belonging to this category
        is: [entityCreation: {entityType: Movie, entityCreationType: MovieCreationData, error: Error}]

    /rentals:
      displayName: store rentals
      (paged-collection):
      description: |
        Rentals for this store (read only)
      get:
        is: [rfc7233Browsing: {entityType: Rental, error: Error}]

      /{rental-id}:
        displayName: a rental
        (paged-collection-entity):
        uriParameters:
          rental-id: string
        get:
          is: [entityRetrieve: {entityType: Rental, error: Error}]

    /customers/{customer}/rentals:
      displayName: customer rentals
      (paged-collection):
      uriParameters:
        customer: string
      get:
        description: |
          Lists this customer's rentals
        is: [rfc7233Browsing: {entityType: Rental, error: Error}]

  /late-rental-tasks:
    displayName: late rental tasks
    (paged-collection):
    description: |
      Late rental tasks mark rental tha have a passed due date as being late.
      When a task is created, the marking process starts for every stores and a 201 is immediatly returned.
      The task status reports the end of the process.
    get:
      description: |
        List the current and passed late rental tasks
      is: [rfc7233Browsing: {entityType: LateRentalTask, error: Error}]

    post:
      description: |
        create a movie belonging to this category
      is: [entityCreation: {entityType: LateRentalTask, entityCreationType: object, error: Error}]

    /{task-id}:
      displayName: late rental task
      (paged-collection-entity):
      uriParameters:
        task-id: string

      get:
        is: [entityRetrieve: {entityType: LateRentalTask, error: Error}]

annotationTypes: !include https://raw.githubusercontent.com/flexiooss/poom-api-specs/1.4.0/apis/core/annotation-types/codingmatters.raml

types:
  Movie:
    type: object
    properties:
      id: string
      title: string
      film-maker: string
      category:
        enum: [REGULAR, HORROR, CHILDREN]

  MovieCreationData:
    type: object
    properties:
      title: string
      film-maker: string

  Rental:
    type: object
    properties:
      id: string
      movie-id: string
      customer: string
      status:
        enum: [OUT, LATE, RETURNED]
      start: datetime-only
      due-date: datetime-only
      returned-date: datetime-only
      billing:
        type: object
        properties:
          price: number
          frequentRenterPoints: integer

  RentalRequest:
    type: object
    properties:
      customer: string

  RentalAction:
    type: object
    properties:
      type:
        enum: [RETURN, EXTENSION]

  LateRentalTask:
    type: object
    properties:
      id: string
      start: datetime-only
      end: datetime-only
      status:
        enum: [RUNNING, FAILED, DONE]
      report:
        type: object
        properties:
          accountProcessed: integer
          lateRentalCount: integer

  Message: !include https://raw.githubusercontent.com/flexiooss/poom-api-specs/1.4.0/apis/core/types/message.raml
  Error: !include https://raw.githubusercontent.com/flexiooss/poom-api-specs/1.4.0/apis/core/types/error-with-messages.raml

traits:
  rfc7233Browsing: !include https://raw.githubusercontent.com/flexiooss/poom-api-specs/1.4.0/apis/core/traits/collection/rfc7233-browse-collection.raml
  entityCreation: !include https://raw.githubusercontent.com/flexiooss/poom-api-specs/1.4.0/apis/core/traits/collection/create.raml
  entityRetrieve: !include https://raw.githubusercontent.com/flexiooss/poom-api-specs/1.4.0/apis/core/traits/entity/retrieve.raml
  entityReplace: !include https://raw.githubusercontent.com/flexiooss/poom-api-specs/1.4.0/apis/core/traits/entity/replace.raml
  entityUpdate: !include https://raw.githubusercontent.com/flexiooss/poom-api-specs/1.4.0/apis/core/traits/entity/update.raml
  entityDelete: !include https://raw.githubusercontent.com/flexiooss/poom-api-specs/1.4.0/apis/core/traits/entity/delete.raml

#%RAML 1.0
title: Demo
version: 1
baseUri: https://api.codingmatters.org/demo
mediaType: application/json

/:
  displayName: stores
  (paged-collection):
  description: Stores
  get:
    description: |
      Lists all the stores
    is: [rfc7233Browsing: {entityType: object, error: Error}]

  /{store}:
    displayName: a store
    (paged-collection-entity):

    /movies:
      displayName: store movies
      (paged-collection):
      uriParameters:
        store: string
      description: |
        Movies available in this store.

      get:
        description: |
          Lists all the movies
        is: [rfc7233Browsing: {entityType: Movie, error: Error}]

      /{movie-id}:
        displayName: movie
        (paged-collection-entity):
        uriParameters:
          movie-id: string

        get:
          is: [entityRetrieve: {entityType: Movie, error: Error}]
        put:
          description: |
            The movie data is replaced entirely.
            The movie id cannot be changed :
            * if an id is setted in the body it should should be the same than in the uri (a 400 is returned is not)
            * it is ok not to set an id
          is: [entityReplace: {entityType: Movie, entityReplaceType: Movie, error: Error}]
        delete:
          is: [entityDelete: {error: Error}]

        /rentals:
          displayName: movie rentals
          (paged-collection):
          description: |
            Rentals for this movie
          get:
            is: [rfc7233Browsing: {entityType: Rental, error: Error}]
          post:
            description: |
              A rental request is :
              * accepted if the movie is not currently rented (201)
              * refused if the movie is already rented (400)
            is: [entityCreation: {entityType: Rental, entityCreationType: RentalRequest, error: Error}]

          /{rental-id}:
            displayName: rental
            (paged-collection-entity):
            uriParameters:
              rental-id: string

            get:
              is: [entityRetrieve: {entityType: Rental, error: Error}]
            patch:
              description: |
                Rental action can be :
                * a RETURN : the return date is filled, the price is caculated, the status is updated
                * an EXTENSION : the due-date is extended of a few days
              is: [entityUpdate: {entityType: Rental, entityUpdateType: RentalAction, error: Error}]

    /category/{category}:
      displayName: category movies
      (paged-collection):
      uriParameters:
        category: string

      get:
        is: [rfc7233Browsing: {entityType: Movie, error: Error}]
      post:
        description: |
          create a movie belonging to this category
        is: [entityCreation: {entityType: Movie, entityCreationType: MovieCreationData, error: Error}]

    /rentals:
      displayName: store rentals
      (paged-collection):
      description: |
        Rentals for this store (read only)
      get:
        is: [rfc7233Browsing: {entityType: Rental, error: Error}]

      /{rental-id}:
        displayName: a rental
        (paged-collection-entity):
        uriParameters:
          rental-id: string
        get:
          is: [entityRetrieve: {entityType: Rental, error: Error}]

    /customers/{customer}/rentals:
      displayName: customer rentals
      (paged-collection):
      uriParameters:
        customer: string
      get:
        description: |
          Lists this customer's rentals
        is: [rfc7233Browsing: {entityType: Rental, error: Error}]

  /late-rental-tasks:
    displayName: late rental tasks
    (paged-collection):
    description: |
      Late rental tasks mark rental tha have a passed due date as being late.
      When a task is created, the marking process starts for every stores and a 201 is immediatly returned.
      The task status reports the end of the process.
    get:
      description: |
        List the current and passed late rental tasks
      is: [rfc7233Browsing: {entityType: LateRentalTask, error: Error}]

    post:
      description: |
        create a movie belonging to this category
      is: [entityCreation: {entityType: LateRentalTask, entityCreationType: object, error: Error}]

    /{task-id}:
      displayName: late rental task
      (paged-collection-entity):
      uriParameters:
        task-id: string

      get:
        is: [entityRetrieve: {entityType: LateRentalTask, error: Error}]

annotationTypes: !include https://raw.githubusercontent.com/flexiooss/poom-api-specs/1.3.0/apis/core/annotation-types/codingmatters.raml

types:
  Movie:
    type: object
    properties:
      id: string
      title: string
      film-maker: string
      category:
        enum: [REGULAR, HORROR, CHILDREN]

  MovieCreationData:
    type: object
    properties:
      title: string
      film-maker: string

  Rental:
    type: object
    properties:
      id: string
      movie-id: string
      customer: string
      status:
        enum: [OUT, LATE, RETURNED]
      start: datetime-only
      due-date: datetime-only
      returned-date: datetime-only
      billing:
        type: object
        properties:
          price: number
          frequentRenterPoints: integer

  RentalRequest:
    type: object
    properties:
      customer: string

  RentalAction:
    type: object
    properties:
      type:
        enum: [RETURN, EXTENSION]

  LateRentalTask:
    type: object
    properties:
      id: string
      start: datetime-only
      end: datetime-only
      status:
        enum: [RUNNING, FAILED, DONE]
      report:
        type: object
        properties:
          accountProcessed: integer
          lateRentalCount: integer

  Message: !include https://raw.githubusercontent.com/flexiooss/poom-api-specs/1.3.0/apis/core/types/message.raml
  Error: !include https://raw.githubusercontent.com/flexiooss/poom-api-specs/1.3.0/apis/core/types/error-with-messages.raml

traits:
  rfc7233Browsing: !include https://raw.githubusercontent.com/flexiooss/poom-api-specs/1.3.0/apis/core/traits/collection/rfc7233-browse-collection.raml
  entityCreation: !include https://raw.githubusercontent.com/flexiooss/poom-api-specs/1.3.0/apis/core/traits/collection/create.raml
  entityRetrieve: !include https://raw.githubusercontent.com/flexiooss/poom-api-specs/1.3.0/apis/core/traits/entity/retrieve.raml
  entityReplace: !include https://raw.githubusercontent.com/flexiooss/poom-api-specs/1.3.0/apis/core/traits/entity/replace.raml
  entityUpdate: !include https://raw.githubusercontent.com/flexiooss/poom-api-specs/1.3.0/apis/core/traits/entity/update.raml
  entityDelete: !include https://raw.githubusercontent.com/flexiooss/poom-api-specs/1.3.0/apis/core/traits/entity/delete.raml


raml changes

raml changes

#%RAML 0.8

title: rolling-spider-server-api
baseUri: http://localhost:7777/drone-api
version: v1.0.0
mediaType: application/json

resourceTypes:
  - command:
      description: <<commandName>> command
      post:
        description: execute <commandName>> command
        responses:
          200:
            body:
              example: |
                    <<commandSuccessRes>>
          500:
            body:
              example: |
                { "error":"an error occured executing <<commandName>>"}

  - paramCommand:
      description: <<commandName>> command
      post:
        description: |
          execute <<commandName>> with prameters from json
        body:
          #note a step is approximately 50ms
          #speed and step values are numbers between 0-100
          example: |
            { "speed": 65, "step": 40 }
        responses:
          200:
            body:
              example: |
                <<commandSuccessRes>>
          400:
            body:
              example: |
                { "error":"5d is not a valid value for speed!"}
          500:
            body:
              example: |
                { "error":"executing <<commandName>> failed!"}

/drone:
  description: The Rolling Spider drone control API
  get:
    description: Gets updated data for the drone
    responses:
      200:
        body:
          example: !include drone_json_example.json
      500:
        body:
          example: |
            { "error":"error getting data from drone" }

  /takeoff:
    type:
      command:
        commandName: takeOff
        commandSuccessRes: {"message":"drone took off, now hovering"}

  /land:
    type:
      command:
        commandName: land
        commandSuccessRes: {"message":"drone has landed"}

  /calibrate:
    type:
      command:
        commandName: calibrate
        commandSuccessRes: {"message":"calibrating drone trim for stability"}

  /emergency:
    type:
      command:
        commandName: emergency
        commandSuccessRes: {"message":"drone executed emergency command"}

  /up:
    description: Makes the drone go up
    type:
      paramCommand:
        commandName: up
        commandSuccessRes: {"message":"made the drone go up"}

  /down:
    description: Makes the drone go down
    type:
      paramCommand:
        commandName: down
        commandSuccessRes: {"message":"made the drone go down"}

  /turnRight:
    description: Makes the drone turn right
    type:
      paramCommand:
        commandName: turnRight
        commandSuccessRes: {"message":"made the drone turn right"}

  /turnLeft:
    description: Makes the drone turn left
    type:
      paramCommand:
        commandName: turnLeft
        commandSuccessRes: {"message":"made the drone turn left"}

  /forward:
    description: Makes the drone go forward
    type:
      paramCommand:
        commandName: forward
        commandSuccessRes: {"message":"made the drone go forward"}

  /left:
    description: Makes the drone move left
    type:
      paramCommand:
        commandName: left
        commandSuccessRes: {"message":"made the drone move left"}

  /right:
    description: Makes the drone move right
    type:
      paramCommand:
        commandName: right
        commandSuccessRes: {"message":"made the drone move right"}

  /tiltLeft:
    description: Make the drone tilt left
    type:
      paramCommand:
        commandName: tiltLeft
        commandSuccessRes: {"message":"made the drone tilt left"}

  /tiltRight:
    description: Make the drone tilt right
    type:
      paramCommand:
        commandName: tiltRight
        commandSuccessRes: {"message":"made the drone tilt right"}

  /frontFlip:
    description: Make the drone do an amazing front flip
    type:
      paramCommand:
        commandName: frontFlip
        commandSuccessRes: {"message":"made the drone do an awesome front flip"}

  /backFlip:
    description: Make the drone do an amazing back flip
    type:
      paramCommand:
        commandName: backFlip
        commandSuccessRes: {"message":"made the drone do an awesome back flip"}

  /leftFlip:
    description: Make the drone do an amazing left flip
    type:
      paramCommand:
        commandName: leftFlip
        commandSuccessRes: {"message":"made the drone do an awesome left flip"}

  /rightFlip:
    description: Make the drone do an amazing right flip
    type:
      paramCommand:
        commandName: rightFlip
        commandSuccessRes: {"message":"made the drone do an awesome right flip"}

#%RAML 0.8

title: rolling-spider-server-api
baseUri: http://localhost:7777/drone-api
version: v0.1.0
mediaType: application/json

resourceTypes:
  - command:
      description: <<commandName>> command
      post:
        description: execute <commandName>> command
        responses:
          200:
            body:
              example: |
                    <<commandSuccessRes>>
          500:
            body:
              example: |
                { "error":"an error occured executing <<commandName>>"}

  - paramCommand:
      description: <<commandName>> command
      post:
        description: |
          execute <<commandName>> with prameters from json
        body:
          #note a step is approximately 50ms
          example: |
            { "speed": 65, "step": 40 }
        responses:
          200:
            body:
              example: |
                <<commandSuccessRes>>
          400:
            body:
              example: |
                { "error":"5d is not a valid value for speed!"}
          500:
            body:
              example: |
                { "error":"executing <<commandName>> failed!"}

/drone:
  description: The Rolling Spider drone control API
  get:
    description: Gets updated data for the drone
    responses:
      200:
        body:
          example: !include drone_json_example.json
      500:
        body:
          example: |
            { "error":"error getting data from drone" }

  /takeoff:
    type:
      command:
        commandName: takeOff
        commandSuccessRes: {"message":"drone took off, now hovering"}

  /land:
    type:
      command:
        commandName: land
        commandSuccessRes: {"message":"drone has landed"}

  /calibrate:
    type:
      command:
        commandName: calibrate
        commandSuccessRes: {"message":"calibrating drone trim for stability"}

  /emergency:
    type:
      command:
        commandName: emergency
        commandSuccessRes: {"message":"drone executed emergency command"}

#  /disconnect:
#    type:
#      command:
#        commandName: disconnect
#        commandSuccessRes: {"message":"disconnecting from drone"}
#

  /up:
    description: Makes the drone go up
    type:
      paramCommand:
        commandName: up
        commandSuccessRes: {"message":"made the drone go up"}

  /down:
    description: Makes the drone go down
    type:
      paramCommand:
        commandName: down
        commandSuccessRes: {"message":"made the drone go down"}

  /turnRight:
    description: Makes the drone turn right
    type:
      paramCommand:
        commandName: turnRight
        commandSuccessRes: {"message":"made the drone turn right"}

  /turnLeft:
    description: Makes the drone turn left
    type:
      paramCommand:
        commandName: turnLeft
        commandSuccessRes: {"message":"made the drone turn left"}

  /forward:
    description: Makes the drone go forward
    type:
      paramCommand:
        commandName: forward
        commandSuccessRes: {"message":"made the drone go forward"}

  /left:
    description: Makes the drone move left
    type:
      paramCommand:
        commandName: left
        commandSuccessRes: {"message":"made the drone move left"}

  /right:
    description: Makes the drone move right
    type:
      paramCommand:
        commandName: right
        commandSuccessRes: {"message":"made the drone move right"}

  /tiltLeft:
    description: Make the drone tilt left
    type:
      paramCommand:
        commandName: tiltLeft
        commandSuccessRes: {"message":"made the drone tilt left"}

  /tiltRight:
    description: Make the drone tilt right
    type:
      paramCommand:
        commandName: tiltRight
        commandSuccessRes: {"message":"made the drone tilt right"}

  /frontFlip:
    description: Make the drone do an amazing front flip
    type:
      paramCommand:
        commandName: frontFlip
        commandSuccessRes: {"message":"made the drone do an awesome front flip"}

  /backFlip:
    description: Make the drone do an amazing back flip
    type:
      paramCommand:
        commandName: backFlip
        commandSuccessRes: {"message":"made the drone do an awesome back flip"}

  /leftFlip:
    description: Make the drone do an amazing left flip
    type:
      paramCommand:
        commandName: leftFlip
        commandSuccessRes: {"message":"made the drone do an awesome left flip"}

  /rightFlip:
    description: Make the drone do an amazing right flip
    type:
      paramCommand:
        commandName: rightFlip
        commandSuccessRes: {"message":"made the drone do an awesome right flip"}


Respond to newcrossfoodcoop/nxfc#70

Respond to newcrossfoodcoop/nxfc#70

#%RAML 0.8

title: NXFC Stock
baseUri: http://localhost:3040/api
version: 0.1.0

schemas:
  - Location: !include schema/location.json
  - Pickup: !include schema/pickup.json
  - Checkout: !include schema/checkout.json
  - Order: !include schema/order.json
  - Stock: !include schema/stock.json

resourceTypes:
  - base:
      get?:
        responses: &standardResponses
          200:
            description: OK
      delete?:
        responses: *standardResponses
  - collection:
      type: base
      get:
  - typedCollection:
      type: collection
      get:
        responses:
          200:
            body:
              application/json:
                schema: <<collectionSchema>>
      post:
        body:
          application/json:
            schema: <<schema>>
        responses:
          200:
            body:
              application/json:
                schema: <<schema>>
  - typedMemberCollection:
      type: collection
      get:
        description: List <<schema>>
        responses:
          200:
            body:
              application/json:
                schema: |
                  {
                    "$schema": "http://json-schema.org/draft-03/schema#",
                    "type": "array",
                    "properties": { "$ref": "<<schema>>" }
                  }
      post:
        description: Create <<schema>>
        body:
          application/json:
            schema: <<schema>>
        responses:
          200:
            body:
              application/json:
                schema: <<schema>>
  - member:
      type: base
      get:
      delete:
  - typedMember:
      type: member
      get:
        description: Read <<schema>>
        responses:
          200:
            body:
              application/json:
                schema: <<schema>>
      delete:
        description: Delete <<schema>>

/locations:
  displayName: Location
  type: { typedMemberCollection: { schema: Location } }
  post:
    body:
      application/json:
        schema: Location
        example: |
          {
            "name": "Test Location",
            "description": "This is a test Location",
            "url": "http://maps.google.com/longurl",
            "address": "Test Address"
          }
  /{locationId}:
    type: { typedMember: { schema: Location } }
    put:
      description: Update Location
      body:
        application/json:
          schema: Location
          example: |
            {
              "description": "Updated description"
            }
      responses:
        200:
          body:
            application/json:
              schema: Location
/pickups:
  displayName: Pickup
  type: { typedMemberCollection: { schema: Pickup } }
  post:
    body:
      application/json:
        example: |
          {
            "description": "Pickup description",
            "location": "1234567890abcdef123456a1",
            "start": "2016-10-28T12:00:00.000Z",
            "end": "2016-10-28T16:00:00.000Z",
            "state": "open"
          }
  /open:
    description: List open pickups
    get:
      responses:
        200:
          body:
            application/json:
              schema: |
                  {
                    "$schema": "http://json-schema.org/draft-03/schema#",
                    "type": "array",
                    "properties": { "$ref": "Pickup" }
                  }
  /active:
    description: List active pickups
    get:
      responses:
        200:
          body:
            application/json:
              schema: |
                  {
                    "$schema": "http://json-schema.org/draft-03/schema#",
                    "type": "array",
                    "properties": { "$ref": "Pickup" }
                  }

  /{pickupId}:
    type: { typedMember: { schema: Pickup } }
    put:
      description: Update Pickup
      body:
        application/json:
          schema: Pickup
          example: |
            {
              "description": "Updated description"
            }
      responses:
        200:
          body:
            application/json:
              schema: Pickup
    /close:
      get:
        description: "Close a pickup (prevent new orders)"
        responses:
          200:
            body:
              application/json:
                schema: Pickup

/checkouts:
  displayName: Checkout
  type: { typedMemberCollection: { schema: Checkout } }
  post:
    body:
      application/json:
        example: |
          {
            "orderId": "1234567890abcdef123456a2",
            "pickup": "1234567890abcdef123456a4",
            "items": [
              {
                "productId": "1234567890abcdef123456a2",
                "supplierId": "1234567890abcdef123456a3",
                "name": "Dummy Product",
                "price": 3.03,
                "cost": 3.03,
                "quantity": 4
              },
              {
                "productId": "1234567890abcdef123456a2",
                "supplierId": "1234567890abcdef123456a3",
                "name": "Dummy Product",
                "price": 3.03,
                "cost": 3.03,
                "quantity": 4
              }
            ]
          }
  /{checkoutId}:
    type: { typedMember: { schema: Checkout } }
    /confirm:
      get:
        description: "Confirm a checkout (payment received)"
        responses:
          200:
            body:
              application/json:
                schema: Checkout
    /cancel:
      get:
        description: "Cancel a checkout (payment rejected)"
        responses:
          200:
            body:
              application/json:
                schema: Checkout
    /stock:
      get:
        description: "Return stock for this checkout"
        responses:
          200:
            body:
              application/json:
                schema: |
                  {
                    "$schema": "http://json-schema.org/draft-03/schema#",
                    "type": "array",
                    "properties": { "$ref": "Stock" }
                  }
#    /finalise:
#      get:
#        description: "Finalise this checkout"
#        responses:
#          200:
#            body:
#              application/json:
#                schema: Checkout

/pickups/{pickupId}/checkouts:
    get:
        description: "Checkouts for this pickup"
        responses:
            200:
                body:
                    application/json:
                        schema: |
                            {
                                "$schema": "http://json-schema.org/draft-03/schema#",
                                "type": "array",
                                "items": {
                                    "type": "object",
                                    "properties": {
                                        "checkout": { "$ref": "Checkout" },
                                        "stock": {
                                            "type": "array",
                                            "properties": { "$ref": "Stock" }
                                        }
                                    }
                                }
                            }

/pickups/{pickupId}/orders:
    put:
        description: "Create supplier order(s) for this pickup"
        responses:
            200:
                body:
                    application/json:
                        schema: Pickup
    get:
        description: "Return the pickup with populated orders"
        responses:
            200:
                body:
                    application/json:
                        schema: Pickup

/pickups/{pickupId}/stocks/{stockId}:
    put:
        description: "Update stock state"
        body:
            application/json:
                schema: |
                    {
                        "$schema": "http://json-schema.org/draft-03/schema#",
                        "type": "object",
                        "properties": {
                            "state": {
                                "type": "string",
                                "enum": ["reserved", "ordered", "delivered", "picked", "pickedup", "cancelled"],
                                "required": true
                            }
                        }
                    }
                example: |
                    {
                        "state": "delivered"
                    }
        responses:
            200:
                body:
                    application/json:
                        schema: Stock
            400:
                body:
                    application/json:
                        schema: |
                            {
                                "$schema": "http://json-schema.org/draft-03/schema#",
                                "type": "object",
                                "properties": {
                                    "message": { "type": "string" }
                                }
                            }

/pickups/{pickupId}/checkouts/{checkoutId}/finalise:
    get:
        description: "Finalise this checkout"
        responses:
            200:
                body:
                    application/json:
                        schema: Checkout

/pickups/{pickupId}/archive:
    get:
        description: "Archive this pickup"
        responses:
            200:
                body:
                    application/json:
                        schema: Pickup
            400:
                body:
                    application/json:
                        schema: |
                            {
                                "$schema": "http://json-schema.org/draft-03/schema#",
                                "type": "object",
                                "properties": {
                                    "message": { "type": "string" }
                                }
                            }

/orders:
  get:
    description: List Orders
    responses:
      200:
        body:
          application/json:
            schema: |
              {
                "$schema": "http://json-schema.org/draft-03/schema#",
                "type": "array",
                "properties": { "$ref": "Order" }
              }
  /{orderId}:
    /delivered:
      put:
        description: "All items delivered"
        responses:
          200:
            body:
              application/json:
                schema: Order

#%RAML 0.8

title: NXFC Stock
baseUri: http://localhost:3040/api
version: 0.1.0

schemas:
  - Location: !include schema/location.json
  - Pickup: !include schema/pickup.json
  - Checkout: !include schema/checkout.json
  - Order: !include schema/order.json
  - Stock: !include schema/stock.json

resourceTypes:
  - base:
      get?:
        responses: &standardResponses
          200:
            description: OK
      delete?:
        responses: *standardResponses
  - collection:
      type: base
      get:
  - typedCollection:
      type: collection
      get:
        responses:
          200:
            body:
              application/json:
                schema: <<collectionSchema>>
      post:
        body:
          application/json:
            schema: <<schema>>
        responses:
          200:
            body:
              application/json:
                schema: <<schema>>
  - typedMemberCollection:
      type: collection
      get:
        description: List <<schema>>
        responses:
          200:
            body:
              application/json:
                schema: |
                  {
                    "$schema": "http://json-schema.org/draft-03/schema#",
                    "type": "array",
                    "properties": { "$ref": "<<schema>>" }
                  }
      post:
        description: Create <<schema>>
        body:
          application/json:
            schema: <<schema>>
        responses:
          200:
            body:
              application/json:
                schema: <<schema>>
  - member:
      type: base
      get:
      delete:
  - typedMember:
      type: member
      get:
        description: Read <<schema>>
        responses:
          200:
            body:
              application/json:
                schema: <<schema>>
      delete:
        description: Delete <<schema>>

/locations:
  displayName: Location
  type: { typedMemberCollection: { schema: Location } }
  post:
    body:
      application/json:
        schema: Location
        example: |
          {
            "name": "Test Location",
            "description": "This is a test Location",
            "url": "http://maps.google.com/longurl",
            "address": "Test Address"
          }
  /{locationId}:
    type: { typedMember: { schema: Location } }
    put:
      description: Update Location
      body:
        application/json:
          schema: Location
          example: |
            {
              "description": "Updated description"
            }
      responses:
        200:
          body:
            application/json:
              schema: Location
/pickups:
  displayName: Pickup
  type: { typedMemberCollection: { schema: Pickup } }
  post:
    body:
      application/json:
        example: |
          {
            "description": "Pickup description",
            "location": "1234567890abcdef123456a1",
            "start": "2016-10-28T12:00:00.000Z",
            "end": "2016-10-28T16:00:00.000Z",
            "state": "open"
          }

  /{pickupId}:
    type: { typedMember: { schema: Pickup } }
    put:
      description: Update Pickup
      body:
        application/json:
          schema: Pickup
          example: |
            {
              "description": "Updated description"
            }
      responses:
        200:
          body:
            application/json:
              schema: Pickup
    /close:
      get:
        description: "Close a pickup (prevent new orders)"
        responses:
          200:
            body:
              application/json:
                schema: Pickup
  /open:
    description: List open pickups
    get:
      responses:
        200:
          body:
            application/json:
              schema: |
                  {
                    "$schema": "http://json-schema.org/draft-03/schema#",
                    "type": "array",
                    "properties": { "$ref": "Pickup" }
                  }
  /active:
    description: List active pickups
    get:
      responses:
        200:
          body:
            application/json:
              schema: |
                  {
                    "$schema": "http://json-schema.org/draft-03/schema#",
                    "type": "array",
                    "properties": { "$ref": "Pickup" }
                  }

/checkouts:
  displayName: Checkout
  type: { typedMemberCollection: { schema: Checkout } }
  post:
    body:
      application/json:
        example: |
          {
            "orderId": "1234567890abcdef123456a2",
            "pickup": "1234567890abcdef123456a4",
            "items": [
              {
                "productId": "1234567890abcdef123456a2",
                "supplierId": "1234567890abcdef123456a3",
                "name": "Dummy Product",
                "price": 3.03,
                "cost": 3.03,
                "quantity": 4
              },
              {
                "productId": "1234567890abcdef123456a2",
                "supplierId": "1234567890abcdef123456a3",
                "name": "Dummy Product",
                "price": 3.03,
                "cost": 3.03,
                "quantity": 4
              }
            ]
          }
  /{checkoutId}:
    type: { typedMember: { schema: Checkout } }
    /confirm:
      get:
        description: "Confirm a checkout (payment received)"
        responses:
          200:
            body:
              application/json:
                schema: Checkout
    /cancel:
      get:
        description: "Cancel a checkout (payment rejected)"
        responses:
          200:
            body:
              application/json:
                schema: Checkout
    /stock:
      get:
        description: "Return stock for this checkout"
        responses:
          200:
            body:
              application/json:
                schema: |
                  {
                    "$schema": "http://json-schema.org/draft-03/schema#",
                    "type": "array",
                    "properties": { "$ref": "Stock" }
                  }
#    /finalise:
#      get:
#        description: "Finalise this checkout"
#        responses:
#          200:
#            body:
#              application/json:
#                schema: Checkout

/pickups/{pickupId}/checkouts:
    get:
        description: "Checkouts for this pickup"
        responses:
            200:
                body:
                    application/json:
                        schema: |
                            {
                                "$schema": "http://json-schema.org/draft-03/schema#",
                                "type": "array",
                                "items": {
                                    "type": "object",
                                    "properties": {
                                        "checkout": { "$ref": "Checkout" },
                                        "stock": {
                                            "type": "array",
                                            "properties": { "$ref": "Stock" }
                                        }
                                    }
                                }
                            }

/pickups/{pickupId}/orders:
    put:
        description: "Create supplier order(s) for this pickup"
        responses:
            200:
                body:
                    application/json:
                        schema: Pickup
    get:
        description: "Return the pickup with populated orders"
        responses:
            200:
                body:
                    application/json:
                        schema: Pickup

/pickups/{pickupId}/stocks/{stockId}:
    put:
        description: "Update stock state"
        body:
            application/json:
                schema: |
                    {
                        "$schema": "http://json-schema.org/draft-03/schema#",
                        "type": "object",
                        "properties": {
                            "state": {
                                "type": "string",
                                "enum": ["reserved", "ordered", "delivered", "picked", "pickedup", "cancelled"],
                                "required": true
                            }
                        }
                    }
                example: |
                    {
                        "state": "delivered"
                    }
        responses:
            200:
                body:
                    application/json:
                        schema: Stock
            400:
                body:
                    application/json:
                        schema: |
                            {
                                "$schema": "http://json-schema.org/draft-03/schema#",
                                "type": "object",
                                "properties": {
                                    "message": { "type": "string" }
                                }
                            }

/pickups/{pickupId}/checkouts/{checkoutId}/finalise:
    get:
        description: "Finalise this checkout"
        responses:
            200:
                body:
                    application/json:
                        schema: Checkout

/pickups/{pickupId}/archive:
    get:
        description: "Archive this pickup"
        responses:
            200:
                body:
                    application/json:
                        schema: Pickup
            400:
                body:
                    application/json:
                        schema: |
                            {
                                "$schema": "http://json-schema.org/draft-03/schema#",
                                "type": "object",
                                "properties": {
                                    "message": { "type": "string" }
                                }
                            }

/orders:
  get:
    description: List Orders
    responses:
      200:
        body:
          application/json:
            schema: |
              {
                "$schema": "http://json-schema.org/draft-03/schema#",
                "type": "array",
                "properties": { "$ref": "Order" }
              }
  /{orderId}:
    /delivered:
      put:
        description: "All items delivered"
        responses:
          200:
            body:
              application/json:
                schema: Order