<commit_before>#%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": "<NAME>",
            "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": "<KEY>",
            "items": [
              { 
                "productId": "<KEY>", 
                "supplierId": "<KEY>",
                "name": "Dummy Product",
                "price": 3.03,
                "cost": 3.03,
                "quantity": 4
              },
              { 
                "productId": "<KEY>", 
                "supplierId": "<KEY>",
                "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

<commit_msg>Respond to newcrossfoodcoop/nxfc#70<commit_after>#%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": "<NAME>",
            "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": "<KEY>", 
                "supplierId": "<KEY>",
                "name": "Dummy Product",
                "price": 3.03,
                "cost": 3.03,
                "quantity": 4
              },
              { 
                "productId": "<KEY>", 
                "supplierId": "<KEY>",
                "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


{'fraction_non_alphanumeric': 0.1057424983223085, 'fraction_numerical': 0.018550474547023296, 'mean_word_length': 0.9398419339841934, 'pattern_counts': {'":': 150, '<': 58, '<?xml version=': 0, '>': 58, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7462355', 'n_tokens_mistral': 5452, 'n_tokens_neox': 4958, 'n_words': 1080}