Change contact point to whitelist an ip

Change contact point to whitelist an ip

#%RAML 0.8
---
title: Pickup Point API
baseUri: https://api.bring.com/pickuppoint/api/pickuppoint

documentation:
- title: Introduction
  content: |
      The Pickup point API provides a list of locations for package pickup. Based on a specified postal code or a geographical location, the 10 nearest pickup points are returned, sorted by driving time by car(source: Google). Response is available as either XML or JSON.

      A pickup point is defined as any location delivering shipments on behalf of Bring and Posten, such as post offices, selected grocery stores, lockers, etc.

      It is important to note, there are two sets of addresses in the response, postbox(address, postalCode) and visiting address(visitingAddress,visitingPostalCode).Postbox address is required to get a package produced correctly, use this AS RECIPIENT address on label. Visiting address is more appropriate for user interface (Street address of the PIB).

      ### Filtering results

      In addition to postal code or location, one or more optional parameters can be added to the request, adding additional restrictions to the pickup points being returned. One such parameter is `searchForText=<texts>`, resulting in a response where all pickup points have at least a partial match with the search string given in `<texts>`. This can be the name of the pickup point, its address, city, county, municipality or location. Go to the reference table or see additional examples for more information.

      ### Rate limiting

      The Pickup point API has a rate limit, primarily considered on a per-user basis. Currently it limits API users to no more than 60 requests within a minute from a single IP address.

      Once you go over the rate limit, you will receive a response with an HTTP response code of 429 (Too Many Requests). The body of the response will consist of the following fields:

      - `code`: `429`
      - `error_message`: `The maximum number of requests per minute has been exceeded.`

      As an additional note, While accessing the Pickup point API together with Shipping Guide API, the product list should be displayed even in the case that the request has been rate limited by the Pickup point API.

      #### High-volume users

      If you're a high-volume user of the Pickup Point API, please [contact us](mailto:developer@bring.com) to discuss your options.

      When contacting Bring support include a description of how you are using the Pickup Point API, also an estimate of current request volumes.

/{countryCode}/postalCode/{postalCode}{mediaTypeExtension}:
  displayName: Pickup points for postal code
  uriParameters:
    countryCode:
      displayName: Country
      enum: [ "NO", "DK", "SE", "FI" ]
    postalCode:
      displayName: Postal code
      type: string
    mediaTypeExtension:
      enum: [ .json, .xml ]
      description: Use .json to get application/json, .xml to get application/xml or .html to get HTML.
  get:
    description: List pickup points for postal code
    queryParameters:
      searchForText:
        displayName: Text filter
        type: string
      openingHoursSearchType:
        displayName: Filter using opening hours
        enum: [ ALL_WEEKDAYS, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY ]
      openOnOrBefore:
        description: Format `HHmm`. Return only pickup points that are open on or before the specified time.
        type: string
        pattern: ^([01][0-9]|2[0-3])[0-5][0-9]$
      openOnOrAfter:
        description: Format `HHmm`. Return only pickup points that are open on or after the specified time.
        type: string
        pattern: ^([01][0-9]|2[0-3])[0-5][0-9]$
      pickupPointType:
        displayName: Pickup-point type
        description: Currently available for Swedish, Finnish and Danish pickup point request only.
        enum: [ manned, locker ]
      numberOfResponses:
        description: Return the specified number of pickup points instead of the default. Try this param to get more pickup points, if a desired pickup point is missing in the response.
        type: integer
        default: 10
      street:
        description: Searches for the nearest pickup points to the given street. Use this param to get more accurate result.
        type: string
      streetNumber:
        description: Searches for the nearest pickup points to the given street number.Use this param to get more accurate result.
        type: string
      callback:
        description: JSONP callback function name.
        type: string
      requestCountryCode:
        description: Country code of the requester. Only applicable for Norwegian pickup points.
        type: string
    responses:
      200:
        displayName: Example response for NO/postalCode/1407
        body:
          application/json:
            example: !include examples/by_postal_code.json
          application/xml:
            example: !include examples/by_postal_code.xml
      250:
        displayName: Using postal code and street address
        description: |
          Sometimes (especially in Denmark) it's a good idea to also specify the address when searching for pickup points, to get more accurate results.

          In [this example](https://api.bring.com/pickuppoint/api/pickuppoint/DK/postalCode/2000.json?street=Smallegade&streetNumber=3), we look for pickup points in Smallegade 3, 2000 Frederiksberg.
        body:
          application/json:
            example: !include examples/filter_address.json
          application/xml:
            example: !include examples/filter_address.xml
      251:
        displayName: Find pickup points containing a specific string
        description: |
          If you want to return only the pickup points matching a specific string, you may use the `searchForText` query param. The given text can be the name of the pickup point, its address, city, county, municipality or location. Partial matches are also allowed.

          In [this example](https://api.bring.com/pickuppoint/api/pickuppoint/NO/postalCode/1407.json?searchForText=KIWI), we look for pickup points near NO/1407 cotaining "Kiwi".
        body:
          application/json:
            example: !include examples/filter_search.json
          application/xml:
            example: !include examples/filter_search.xml
      252:
        displayName: Find pickup points open on specific days
        description: |
          If you want to return only the pickup points open on specified days, you may use the `openingHoursSearchType=<day>` query param. `<day>` be:

          - `ALL_WEEKDAYS` (default)
          - `MONDAY`
          - `TUESDAY`
          - `WEDNESDAY`
          - `THURSDAY`
          - `FRIDAY`
          - `SATURDAY`
          - `SUNDAY`

          If you want you can also add `openOnOrBefore` and / or `openOnOrAfter`, to limit the search even more.

          In [this example](https://api.bring.com/pickuppoint/api/pickuppoint/NO/postalCode/1407.json?openingHoursSearchType=SUNDAY), we look for pickup points near NO/1407 that are open Sundays.
        body:
          application/json:
            example: !include examples/filter_days.json
          application/xml:
            example: !include examples/filter_days.xml
      253:
        displayName: Find pickup points open at specific hours
        description: |
          If you want to return only the pickup points open on specific hours, you may use the `openOnOrBefore=<time>` and/or `openOnOrAfter=<time>` query params.

          The format of `<time>` is `HHmm`.

          In [this example](https://api.bring.com/pickuppoint/api/pickuppoint/NO/postalCode/1407.json?openOnOrBefore=0800), we look for pickup points near NO/1407 open on or before 08:00.
        body:
          application/json:
            example: !include examples/filter_hours.json
          application/xml:
            example: !include examples/filter_hours.xml

/{countryCode}/location/{latitude},{longitude}{mediaTypeExtension}:
  displayName: Pickup points for location
  uriParameters:
    countryCode:
      displayName: Country
      enum: [ "NO", "DK", "SE", "FI" ]
    latitude:
      displayName: Latitude
      description: Geographic coordinate specifying the north-south position.
      type: string
    longitude:
      displayName: Longitude
      description: Geographic coordinate specifying the east-west position.
      type: string
    mediaTypeExtension:
      enum: [ .json, .xml ]
      description: Use .json to get application/json or .xml to get application/xml.
  get:
    description: List pickup points closest to location
    queryParameters:
      searchForText:
        displayName: Text filter
        type: string
      openingHoursSearchType:
        displayName: Filter using opening hours
        enum: [ ALL_WEEKDAYS, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY ]
      openOnOrBefore:
        description: Format `HHmm`. Return only pickup points that are open on or before the specified time.
        type: string
        pattern: ^([01][0-9]|2[0-3])[0-5][0-9]$
      openOnOrAfter:
        description: Format `HHmm`. Return only pickup points that are open on or after the specified time.
        type: string
        pattern: ^([01][0-9]|2[0-3])[0-5][0-9]$
      pickupPointType:
        displayName: Pickup-point type
        description: Currently available for Swedish, Finnish and Danish pickup point request only.
        enum: [ manned, locker ]
      numberOfResponses:
        description: Return the specified number of pickup points instead of the default.
        type: integer
        default: 10
      street:
        description: Searches for the nearest pickup points to the given street.
        type: string
      streetNumber:
        description: Searches for the nearest pickup points to the given street number.
        type: string
      callback:
        description: JSONP callback function name.
        type: string
      requestCountryCode:
        description: Country code of the requester. Only applicable for Norwegian pickup points.
        type: string
    responses:
      200:
        displayName: Example response for location/60.395226,5.321725
        body:
          application/json:
            example: !include examples/by_coordinates.json
          application/xml:
            example: !include examples/by_coordinates.xml

/{countryCode}/id/{id}{mediaTypeExtension}:
  displayName: A specific pickup point
  uriParameters:
    countryCode:
      displayName: Country
      enum: [ "NO", DK, SE, FI ]
    mediaTypeExtension:
      enum: [ .json, .xml ]
      description: Use .json to get application/json or .xml to get application/xml.
  get:
    description: Look up a specific pickup point
    queryParameters:
      callback:
        displayName: JSONP support
        description: Callback function name.
        type: string
      requestCountryCode:
        description: Country code of the requester. Only applicable for Norwegian pickup points.
        type: string
    responses:
      200:
        displayName: Example response for id/121110
        body:
          application/json:
            example: !include examples/by_id.json
          application/xml:
            example: !include examples/by_id.xml

/{countryCode}/all{mediaTypeExtension}:
  displayName: All pickup points in a country
  uriParameters:
    countryCode:
      displayName: Country
      enum: [ "NO", DK, SE, FI ]
    mediaTypeExtension:
      enum: [ .json, .xml ]
      description: Use .json to get application/json or .xml to get application/xml.
  get:
    description: All pickup points in a country
    queryParameters:
      callback:
        displayName: JSONP support
        description: Callback function name.
        type: string
      requestCountryCode:
        description: Country code of the requester. Only applicable for Norwegian pickup points.
        type: string

#%RAML 0.8
---
title: Pickup Point API
baseUri: https://api.bring.com/pickuppoint/api/pickuppoint

documentation:
- title: Introduction
  content: |
      The Pickup point API provides a list of locations for package pickup. Based on a specified postal code or a geographical location, the 10 nearest pickup points are returned, sorted by driving time by car(source: Google). Response is available as either XML or JSON.

      A pickup point is defined as any location delivering shipments on behalf of Bring and Posten, such as post offices, selected grocery stores, lockers, etc.

      It is important to note, there are two sets of addresses in the response, postbox(address, postalCode) and visiting address(visitingAddress,visitingPostalCode).Postbox address is required to get a package produced correctly, use this AS RECIPIENT address on label. Visiting address is more appropriate for user interface (Street address of the PIB).

      ### Filtering results

      In addition to postal code or location, one or more optional parameters can be added to the request, adding additional restrictions to the pickup points being returned. One such parameter is `searchForText=<texts>`, resulting in a response where all pickup points have at least a partial match with the search string given in `<texts>`. This can be the name of the pickup point, its address, city, county, municipality or location. Go to the reference table or see additional examples for more information.

      ### Rate limiting

      The Pickup point API has a rate limit, primarily considered on a per-user basis. Currently it limits API users to no more than 60 requests within a minute from a single IP address.

      Once you go over the rate limit, you will receive a response with an HTTP response code of 429 (Too Many Requests). The body of the response will consist of the following fields:

      - `code`: `429`
      - `error_message`: `The maximum number of requests per minute has been exceeded.`

      As an additional note, While accessing the Pickup point API together with Shipping Guide API, the product list should be displayed even in the case that the request has been rate limited by the Pickup point API.

      #### High-volume users

      If you're a high-volume user of the Pickup Point API, please [contact Customer Service](http://developer.bring.com/support/) to discuss your options.

      When contacting Bring support include a description of how you are using the Pickup Point API, also an estimate of current request volumes.

/{countryCode}/postalCode/{postalCode}{mediaTypeExtension}:
  displayName: Pickup points for postal code
  uriParameters:
    countryCode:
      displayName: Country
      enum: [ "NO", "DK", "SE", "FI" ]
    postalCode:
      displayName: Postal code
      type: string
    mediaTypeExtension:
      enum: [ .json, .xml ]
      description: Use .json to get application/json, .xml to get application/xml or .html to get HTML.
  get:
    description: List pickup points for postal code
    queryParameters:
      searchForText:
        displayName: Text filter
        type: string
      openingHoursSearchType:
        displayName: Filter using opening hours
        enum: [ ALL_WEEKDAYS, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY ]
      openOnOrBefore:
        description: Format `HHmm`. Return only pickup points that are open on or before the specified time.
        type: string
        pattern: ^([01][0-9]|2[0-3])[0-5][0-9]$
      openOnOrAfter:
        description: Format `HHmm`. Return only pickup points that are open on or after the specified time.
        type: string
        pattern: ^([01][0-9]|2[0-3])[0-5][0-9]$
      pickupPointType:
        displayName: Pickup-point type
        description: Currently available for Swedish, Finnish and Danish pickup point request only.
        enum: [ manned, locker ]
      numberOfResponses:
        description: Return the specified number of pickup points instead of the default. Try this param to get more pickup points, if a desired pickup point is missing in the response.
        type: integer
        default: 10
      street:
        description: Searches for the nearest pickup points to the given street. Use this param to get more accurate result.
        type: string
      streetNumber:
        description: Searches for the nearest pickup points to the given street number.Use this param to get more accurate result.
        type: string
      callback:
        description: JSONP callback function name.
        type: string
      requestCountryCode:
        description: Country code of the requester. Only applicable for Norwegian pickup points.
        type: string
    responses:
      200:
        displayName: Example response for NO/postalCode/1407
        body:
          application/json:
            example: !include examples/by_postal_code.json
          application/xml:
            example: !include examples/by_postal_code.xml
      250:
        displayName: Using postal code and street address
        description: |
          Sometimes (especially in Denmark) it's a good idea to also specify the address when searching for pickup points, to get more accurate results.

          In [this example](https://api.bring.com/pickuppoint/api/pickuppoint/DK/postalCode/2000.json?street=Smallegade&streetNumber=3), we look for pickup points in Smallegade 3, 2000 Frederiksberg.
        body:
          application/json:
            example: !include examples/filter_address.json
          application/xml:
            example: !include examples/filter_address.xml
      251:
        displayName: Find pickup points containing a specific string
        description: |
          If you want to return only the pickup points matching a specific string, you may use the `searchForText` query param. The given text can be the name of the pickup point, its address, city, county, municipality or location. Partial matches are also allowed.

          In [this example](https://api.bring.com/pickuppoint/api/pickuppoint/NO/postalCode/1407.json?searchForText=KIWI), we look for pickup points near NO/1407 cotaining "Kiwi".
        body:
          application/json:
            example: !include examples/filter_search.json
          application/xml:
            example: !include examples/filter_search.xml
      252:
        displayName: Find pickup points open on specific days
        description: |
          If you want to return only the pickup points open on specified days, you may use the `openingHoursSearchType=<day>` query param. `<day>` be:

          - `ALL_WEEKDAYS` (default)
          - `MONDAY`
          - `TUESDAY`
          - `WEDNESDAY`
          - `THURSDAY`
          - `FRIDAY`
          - `SATURDAY`
          - `SUNDAY`

          If you want you can also add `openOnOrBefore` and / or `openOnOrAfter`, to limit the search even more.

          In [this example](https://api.bring.com/pickuppoint/api/pickuppoint/NO/postalCode/1407.json?openingHoursSearchType=SUNDAY), we look for pickup points near NO/1407 that are open Sundays.
        body:
          application/json:
            example: !include examples/filter_days.json
          application/xml:
            example: !include examples/filter_days.xml
      253:
        displayName: Find pickup points open at specific hours
        description: |
          If you want to return only the pickup points open on specific hours, you may use the `openOnOrBefore=<time>` and/or `openOnOrAfter=<time>` query params.

          The format of `<time>` is `HHmm`.

          In [this example](https://api.bring.com/pickuppoint/api/pickuppoint/NO/postalCode/1407.json?openOnOrBefore=0800), we look for pickup points near NO/1407 open on or before 08:00.
        body:
          application/json:
            example: !include examples/filter_hours.json
          application/xml:
            example: !include examples/filter_hours.xml

/{countryCode}/location/{latitude},{longitude}{mediaTypeExtension}:
  displayName: Pickup points for location
  uriParameters:
    countryCode:
      displayName: Country
      enum: [ "NO", "DK", "SE", "FI" ]
    latitude:
      displayName: Latitude
      description: Geographic coordinate specifying the north-south position.
      type: string
    longitude:
      displayName: Longitude
      description: Geographic coordinate specifying the east-west position.
      type: string
    mediaTypeExtension:
      enum: [ .json, .xml ]
      description: Use .json to get application/json or .xml to get application/xml.
  get:
    description: List pickup points closest to location
    queryParameters:
      searchForText:
        displayName: Text filter
        type: string
      openingHoursSearchType:
        displayName: Filter using opening hours
        enum: [ ALL_WEEKDAYS, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY ]
      openOnOrBefore:
        description: Format `HHmm`. Return only pickup points that are open on or before the specified time.
        type: string
        pattern: ^([01][0-9]|2[0-3])[0-5][0-9]$
      openOnOrAfter:
        description: Format `HHmm`. Return only pickup points that are open on or after the specified time.
        type: string
        pattern: ^([01][0-9]|2[0-3])[0-5][0-9]$
      pickupPointType:
        displayName: Pickup-point type
        description: Currently available for Swedish, Finnish and Danish pickup point request only.
        enum: [ manned, locker ]
      numberOfResponses:
        description: Return the specified number of pickup points instead of the default.
        type: integer
        default: 10
      street:
        description: Searches for the nearest pickup points to the given street.
        type: string
      streetNumber:
        description: Searches for the nearest pickup points to the given street number.
        type: string
      callback:
        description: JSONP callback function name.
        type: string
      requestCountryCode:
        description: Country code of the requester. Only applicable for Norwegian pickup points.
        type: string
    responses:
      200:
        displayName: Example response for location/60.395226,5.321725
        body:
          application/json:
            example: !include examples/by_coordinates.json
          application/xml:
            example: !include examples/by_coordinates.xml

/{countryCode}/id/{id}{mediaTypeExtension}:
  displayName: A specific pickup point
  uriParameters:
    countryCode:
      displayName: Country
      enum: [ "NO", DK, SE, FI ]
    mediaTypeExtension:
      enum: [ .json, .xml ]
      description: Use .json to get application/json or .xml to get application/xml.
  get:
    description: Look up a specific pickup point
    queryParameters:
      callback:
        displayName: JSONP support
        description: Callback function name.
        type: string
      requestCountryCode:
        description: Country code of the requester. Only applicable for Norwegian pickup points.
        type: string
    responses:
      200:
        displayName: Example response for id/121110
        body:
          application/json:
            example: !include examples/by_id.json
          application/xml:
            example: !include examples/by_id.xml

/{countryCode}/all{mediaTypeExtension}:
  displayName: All pickup points in a country
  uriParameters:
    countryCode:
      displayName: Country
      enum: [ "NO", DK, SE, FI ]
    mediaTypeExtension:
      enum: [ .json, .xml ]
      description: Use .json to get application/json or .xml to get application/xml.
  get:
    description: All pickup points in a country
    queryParameters:
      callback:
        displayName: JSONP support
        description: Callback function name.
        type: string
      requestCountryCode:
        description: Country code of the requester. Only applicable for Norwegian pickup points.
        type: string


Remove irrelevant RAML file

Remove irrelevant RAML file

That file describes an ancient REST API that is not currently part of
Rulio.

#%RAML 0.8
title: Rules System REST API
protocols: [ HTTP, HTTPS ]
baseUri: http://{server}/{version}
version: v0
mediaType: application/json

############################################################################
# SCHEMAS
#

schemas:

  # Define some additional base types that will get reused often.
  - BaseSchema: |
      {
        "id": "http://{schemaserver}/schema/csv-base#",
        "$schema": "http://json-schema.org/schema#",
        "description": "Base Schema to extend types and other common functionality",
        "definitions": {
          "simpleType": {
              "allOf" : [
                  { "$ref": "http://json-schema.org/schema#/definitions/simpleType" },
                  {
                      "properties": {
                          "uuid": {
                            "type": "string",
                            "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"
                          },
                          "dateTime": {
                            "type": "string",
                            "pattern": "^(2[0-9]{3})-(0[1-9]|1[012])-([123]0|[012][1-9]|31)[T| ]?([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])(.[0-9]{1,3}[Z]?)?$"
                          },
                          "jsonString": {
                            "type": "string"
                          }
                      }
                  }
              ]
          }
        }
      }
  - Response: |
      {
        "id": "http://{schemaserver}/rest/apiResponse/response#",
        "$schema": "http://{schemaserver}/schema/csv-base",
        "type": "object",
        "properties": {
          "status": {
            "description": "The status code of the operation (corresponds to the HTTP code usually)",
            "type": "integer"
          },
          "message": {
            "description": "Human readable version of the message",
            "type": "string"
          },
          "code": {
            "description": "More specific application code if necessary",
            "type": "integer"
          },
          "id": {
            "description": "The transaction ID associated with this request.",
            "type": "uuid"
          }

        },
        "required": [ "status", "id" ]
      }
  - Pagination: |
      {
        "id": "http://{schemaserver}/rest/apiResponse/page#",
        "$schema": "http://{schemaserver}/schema/csv-base",
        "type": "object",
        "properties": {
          "offset": {
            "description": "The index of the first item returned.",
            "type": "integer"
          },
          "limit": {
            "description": "The maximum items returned in this group.",
            "type": "integer"
          },
          "total": {
            "description": "The total number of items in the complete set",
            "type": "integer"
          }
        },
        "required": [ "offset", "limit" ]
      }

  - APIResponse: |
      {
        "id": "http://{schemaserver}/rest/apiResponse#",
        "$schema": "http://{schemaserver}/schema/csv-base",
        "type": "object",
        "properties": {
          "response": { "$ref": "http://{schemaserver}/rest/apiResponse/response#" },
          "page": { "$ref": "http://{schemaserver}/rest/apiResponse/page#" }
        },
        "required": [ "response" ]
      }

  ######################
  # RULES ITEMS

  - RulesItem: |
      {
        "id": "http://{schemaserver}/rest/rules/item#",
        "$schema": "http://{schemaserver}/schema/csv-base",
        "type": "object"
      }

  - RulesItems: |
      {
        "id": "http://{schemaserver}/rest/rules/items#",
        "$schema": "http://{schemaserver}/schema/csv-base",
        "type": "array",
        "items": { "$ref": "http://{schemaserver}/rest/rules/item#" }
      }

  - RulesLocation: |
      {
        "id": "http://{schemaserver}/rest/rules/location#",
        "$schema": "http://{schemaserver}/schema/csv-base",
        "type": "string"
      }

  - RulesFact: |
      {
        "id": "http://{schemaserver}/rest/rules/fact#",
        "$schema": "http://{schemaserver}/schema/csv-base",
        "type": "object"
      }

  - RulesRule: |
      {
        "id": "http://{schemaserver}/rest/rules/rule#",
        "$schema": "http://{schemaserver}/schema/csv-base",
        "type": "object",
        "properties": {
          "action":  {
            "type": "object",
            "properties": {
              "code": { "type": "string" }
            }
          },
          "condition": {
            "properties": {
              "pattern": { "$ref": "http://{schemaserver}/rest/rules/pattern#" }
            }
          },
          "when": {
            "properties": {
              "pattern": { "$ref": "http://{schemaserver}/rest/rules/pattern#" }
            }
          }
        }
      }

  - RulesPattern: |
      {
        "id": "http://{schemaserver}/rest/rules/pattern#",
        "$schema": "http://{schemaserver}/schema/csv-base",
        "type": "object"
      }

  - RulesMatch: |
      {
        "id": "http://{schemaserver}/rest/rules/match#",
        "$schema": "http://{schemaserver}/schema/csv-base",
        "type": "object"
      }

  - RulesBindings: |
      {
        "id": "http://{schemaserver}/rest/rules/bindings#",
        "$schema": "http://{schemaserver}/schema/csv-base",
        "type": "array",
        "items": { "$ref": "http://{schemaserver}/rest/rules/item#" }
      }

  - RulesBindingsSet: |
      {
        "id": "http://{schemaserver}/rest/rules/bindingsSet#",
        "$schema": "http://{schemaserver}/schema/csv-base",
        "type": "array",
        "items": { "$ref": "http://{schemaserver}/rest/rules/bindings#" }
      }

  - RulesMatchResult: |
      {
        "id": "http://{schemaserver}/rest/rules/matchResult#",
        "$schema": "http://{schemaserver}/schema/csv-base",
        "type": "object",
        "properties": {
          "bindingsSet": { "$ref": "http://{schemaserver}/rest/#" },
          "factId": { "type": "string" },
          "fact": { "type": "jsonString" }
        }
      }

  - RulesEvent: |
      {
        "id": "http://{schemaserver}/rest/rules/event#",
        "$schema": "http://{schemaserver}/schema/csv-base",
        "type": "object"
      }

  ######################
  # RULES API RESPONSES

  - RulesItemResponse: |
      {
        "allOf": [
          { "$ref": "http://{schemaserver}/rest/rules/itemReponse#" },
          {
            "properties": {
              "item": { "$ref": "http://{schemaserver}/rest/rules/item#" }
            },
            "required": [ "item" ]
          }
        ]
      }

  - RulesItemsResponse: |
      {
        "allOf": [
          { "$ref": "http://{schemaserver}/rest/rules/itemReponse#" },
          {
            "properties": {
              "items": { "$ref": "http://{schemaserver}/rest/rules/items#" }
            },
            "required": [ "items" ]
          }
        ]
      }

  - RulesVersionResponse: |
      {
        "allOf": [
          { "$ref": "http://{schemaserver}/rest/api-response#" },
          {
            "properties": {
              "item": {
                "type": "object",
                "properties": {
                  "version": { "type": "string" }
                },
                "required": [ "version" ]
              }
            },
            "required": [ "item" ]
          }
        ]
      }

############################################################################
# Traits
#

traits:
  - successProducer:
      responses:
        200:
          body:
            application/json:
              schema: APIResponse
              example: |
                {
                  "response": { "status": 200, "message": "OK", "txId": "9aedf390-6720-4253-a025-0018a0c410b9" }
                }

  - errorGeneralProducer:
      responses:
        400:
          description: Invalid request response
          body:
            application/json:
              schema: APIResponse
              example: |
                {
                  "response": { "status": 400, "message": "Invalid request", "txId": "9aedf390-6720-4253-a025-0018a0c410b9" }
                }

        500:
          description: Generic server error
          body:
            application/json:
              schema: APIResponse
              example: |
                {
                  "response": { "status": 500, "message": "Internal Server Error", "txId": "9aedf390-6720-4253-a025-0018a0c410b9" }
                }

  - errorNotFound:
      responses:
        404:
          description: Resource not found
          body:
            application/json:
              schema: APIResponse
              example: |
                {
                  "response": { "status": 404, "message": "Not Found", "txId": "9aedf390-6720-4253-a025-0018a0c410b9" }
                }

  - errorAuthProducer:
      responses:
        401:
          description: Authentication requried response
          body:
            application/json:
              schema: APIResponse
              example: |
                {
                  "response": { "status": 401, "message": "Credentials not provided", "txId": "9aedf390-6720-4253-a025-0018a0c410b9" }
                }

        403:
          description: Forbidden response
          body:
            application/json:
              schema: APIResponse
              example: |
                {
                  "response": { "status": 403, "message": "No access privileges", "txId": "9aedf390-6720-4253-a025-0018a0c410b9" }
                }

  - errorConflictProducer:
      responses:
        409:
          description: Conflict Response
          body:
            application/json:
              schema: APIResponse
              example: |
                {
                  "response": { "status": 409, "message": "A conflict occurred with that resource", "txId": "9aedf390-6720-4253-a025-0018a0c410b9" }
                }

############################################################################
# URLS
#

/version:
  get:
    description: Report the version of the endpoint
    is: [ errorGeneralProducer ]
    responses:
      200:
        body:
          application/json:
            schema: RulesVersionResponse
            example: |
              {"response":{"status":200,"message":"OK","txId":"f990a397-ef06-4602-9c1c-0951f8234c66"},"item":"0.0.5"}

/sys:

  /stats:

    /metrics:
      delete:
        description:  Clear all (internal) state for everything
        is: [ successProducer, errorGeneralProducer ]

      get:
        description: Get basic system metrics
        is: [ errorGeneralProducer ]
        responses:
          200:
            body:
              application/json:
                schema: RulesItemResponse
                example: |
                  {"response":{"status":200,"message":"OK","txId":"32d203f0-c9c7-4d8b-9aa6-b21335cc2365"},"item":{"totalCalls":32,"errorCount":8,"totalTime":400278085,"newLocations":0,"addRules":8,"remRules":8,"getRules":0,"addFacts":5,"remFacts":5,"searchRules":0,"searchFacts":5,"listRules":1,"processEvents":0,"actionExecs":0}}

    /runtimes:
      get:
        description: Get a huge pile of Go runtime stats
        is: [ errorGeneralProducer ]
        responses:
          200:
            body:
              application/json:
                schema: RulesItemResponse
                example: |
                  {"response":{"status":200,"message":"OK","txId":"9f280bb2-1e3d-49c4-ad4a-b4dd1c310cf1"},"item":{"cgos":0,"goroutines":6,"goversion":"devel +c8059ac4e0ec Fri Jul 25 08:54:09 2014 -0700","memstats":{"alloc":887672,"buckHashSys":1.441928e+06,"bySize":[{"frees":0,"mallocs":0,"size":0},{"frees":260,"mallocs":379,"size":8},{"frees":2465,"mallocs":4364,"size":16},{"frees":785,"mallocs":1477,"size":32},{"frees":351,"mallocs":977,"size":48},{"frees":342,"mallocs":599,"size":64},{"frees":182,"mallocs":302,"size":80},{"frees":167,"mallocs":301,"size":96},{"frees":944,"mallocs":1263,"size":112},{"frees":150,"mallocs":208,"size":128},{"frees":53,"mallocs":94,"size":144},{"frees":126,"mallocs":285,"size":160},{"frees":113,"mallocs":135,"size":176},{"frees":7,"mallocs":17,"size":192},{"frees":29,"mallocs":55,"size":208},{"frees":45,"mallocs":50,"size":224},{"frees":2,"mallocs":7,"size":240},{"frees":121,"mallocs":185,"size":256},{"frees":33,"mallocs":64,"size":288},{"frees":73,"mallocs":148,"size":320},{"frees":5,"mallocs":17,"size":352},{"frees":8,"mallocs":10,"size":384},{"frees":16,"mallocs":41,"size":416},{"frees":14,"mallocs":27,"size":448},{"frees":9,"mallocs":18,"size":480},{"frees":83,"mallocs":139,"size":512},{"frees":21,"mallocs":28,"size":576},{"frees":66,"mallocs":91,"size":640},{"frees":8,"mallocs":15,"size":704},{"frees":6,"mallocs":7,"size":768},{"frees":10,"mallocs":20,"size":896},{"frees":70,"mallocs":94,"size":1024},{"frees":6,"mallocs":10,"size":1152},{"frees":1,"mallocs":61,"size":1280},{"frees":1,"mallocs":4,"size":1408},{"frees":0,"mallocs":0,"size":1536},{"frees":2,"mallocs":10,"size":1664},{"frees":14,"mallocs":80,"size":2048},{"frees":2,"mallocs":8,"size":2304},{"frees":0,"mallocs":5,"size":2560},{"frees":1,"mallocs":1,"size":2816},{"frees":0,"mallocs":1,"size":3072},{"frees":0,"mallocs":4,"size":3328},{"frees":2,"mallocs":26,"size":4096},{"frees":1,"mallocs":1,"size":4608},{"frees":0,"mallocs":2,"size":5376},{"frees":1,"mallocs":3,"size":6144},{"frees":0,"mallocs":0,"size":6400},{"frees":0,"mallocs":0,"size":6656},{"frees":0,"mallocs":0,"size":6912},{"frees":0,"mallocs":1,"size":8192},{"frees":0,"mallocs":0,"size":8448},{"frees":1,"mallocs":1,"size":8704},{"frees":0,"mallocs":0,"size":9472},{"frees":0,"mallocs":0,"size":10496},{"frees":1,"mallocs":1,"size":12288},{"frees":0,"mallocs":0,"size":13568},{"frees":0,"mallocs":0,"size":14080},{"frees":0,"mallocs":0,"size":16384},{"frees":0,"mallocs":0,"size":16640},{"frees":0,"mallocs":1,"size":17664}],"debugGC":false,"enableGC":true,"frees":6599,"gCSys":147456,"heapAlloc":887672,"heapIdle":8.4107264e+07,"heapInuse":1.8446744073625215e+19,"heapObjects":5041,"heapReleased":0,"heapSys":1.867776e+06,"lastGC":1.4080635158410652e+18,"lookups":9,"mCacheInuse":2248,"mCacheSys":16384,"mSpanInuse":17664,"mSpanSys":32768,"mallocs":11640,"nextGC":1.286896e+06,"numGC":9,"otherSys":264304,"pauseNs":[7.026303e+06,1.212189e+06,1.646128e+06,923263,1.201203e+06,293323,1.632967e+06,501754,403749,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"pauseTotalNs":1.4840879e+07,"stackInuse":229376,"stackSys":229376,"sys":3.999992e+06,"totalAlloc":1.650504e+06}}}

  /profile:

    /cpu:
      delete:
        description:  Stop/Get cpu profiling
        is: [ errorGeneralProducer ]
        responses:
          200:
            body:
              application/octet-stream:

      put:
        description: Start cpu profiling
        is: [ successProducer, errorGeneralProducer ]

      get:
        description: Get cpu profiling
        is: [ errorGeneralProducer, errorNotFound ]
        responses:
          200:
            body:
              application/octet-stream:

    /mem:
      get:
        description: Get memory profiling
        is: [ errorGeneralProducer ]
        responses:
          200:
            body:
              application/json:
                schema: RulesItemResponse
                example: |
                  {"response":{"status":200,"message":"OK","txId":"bbcabea0-7a5c-4e80-84e2-079a110290a8"},"item":"heap profile: 3: 3104 [6: 5376] @ heap/1048576\n1: 1664 [1: 1664] @ 0x40e143c 0x40e0ef9 0x40e2691 0x40e271a 0x40e6165 0x40bd774 0x40bca9d 0x44a0448 0x44a000c 0x44a7879 0x4486c45 0x4419db7 0x432bedb 0x4333996 0x4148866 0x40bab26 0x40d0d01 0x40d3790\n1: 1152 [1: 1152] @ 0x40e143c 0x40e0ef9 0x40e1489 0x40cf7a1 0x40c979e 0x40c96ce 0x40e7a52\n1: 288 [1: 288] @ 0x40e143c 0x40e0ef9 0x40e2691 0x40e26db 0x40d1e45 0x40d43ae 0x40cdd56 0x40d1240 0x40d0af4 0x40e7942\n0: 0 [1: 208] @ 0x40e143c 0x40e0ef9 0x40e2691 0x40e271a 0x40e6165 0x40bc6e2 0x4338e91 0x4185b16 0x431d3be 0x413f9a8 0x432becc 0x4333996 0x4148866 0x40bab26 0x40d0d01 0x40d3790\n0: 0 [1: 16] @ 0x40e143c 0x40e0ef9 0x40e1489 0x40e1c2c 0x40d0adb 0x40e7942\n0: 0 [0: 0] @ 0x40e143c 0x40e0ef9 0x40e25bb 0x434ac4d 0x43471e7 0x434aec6 0x43485de 0x434afcd 0x43485de 0x434b3da 0x43485de 0x4348909 0x4349584 0x43498a2 0x4147ef7 0x40baa8b 0x40d0d41 0x40d3790\n0: 0 [0: 0] @ 0x40e143c 0x40e0ef9 0x40e2691 0x40e271a 0x40e6165 0x40bbca8 0x430a052 0x430a515 0x430a85f 0x430a6af 0x4326d7e 0x43292c2 0x432a04a 0x43245db 0x4332be6 0x4148375 0x414821d 0x4147b20 0x40baa7d 0x40d0d41 0x40d3790\n0: 0 [1: 2048] @ 0x40e143c 0x40e0ef9 0x40e5d6f 0x40e5c0b 0x43104f8 0x43092a9 0x4310aff 0x431146b 0x4310ff3 0x430a14e 0x430a515 0x430a85f 0x430a6af 0x430ad0f 0x424834b 0x413f9e9 0x432becc 0x4333996 0x4148866 0x40bab26 0x40d0d01 0x40d3790\n"}

    /block:
      get:
        description: Get block profiling
        is: [ errorGeneralProducer ]
        responses:
          200:
            body:
              application/json:
                schema: RulesItemResponse
                example: |
                  {"response":{"status":200,"message":"OK","txId":"87b15949-8f67-4558-b808-aac1b8d089db"},"item":"--- contention:\ncycles/second=2195327221\n"}

  /time:
    get:
        description: Report the time that the endpoint thinks it is
        is: [ errorGeneralProducer ]
        responses:
          200:
            body:
              application/json:
                schema: RulesItemResponse
                example: |
                  {"response":{"status":200,"message":"OK","txId":"93069b37-30fb-4728-8fd5-2b6a8fbe82de"},"item":"2014-08-15T00:47:16Z"}

  /configs:
    get:
      description: Get the node's configurations
      is: [ errorGeneralProducer ]
      responses:
        200:
          body:
            application/json:
              schema: RulesItemResponse
              example: |
                {"response":{"status":200,"message":"OK","txId":"879a6856-85a2-4ff6-95c8-b47925d192b0"},"item":{"timing":false,"persisting":true,"verbosity":1,"logging":"Fast","maxLocations":10,"asyncInProcessActions":false,"expireFactsDuringSearch":false,"checkForFactExpiration":false,"appConf":{"services":null,"libraries":null,"props":null,"externalFactServiceTimeout":0},"locationConf":{"maxRules":1000,"maxFacts":1000},"mutationStore":"sqlite","mutationStoreConfig":"data/test","locationInitHook":null}}

    put:
      description: Set the node's configuration (complete set)
      is: [ successProducer, errorGeneralProducer ]
      body:
        application/json:
          schema: RulesItem
          example: |
            {
              "timing": true,
              "persisting": true,
              "verbosity": 10,
              "logging": "Fast",
              "maxLocations": 10,
              "asyncInProcessActions": false,
              "expireFactsDuringSearch": false,
              "checkForFactExpiration": false,
              "appConf": {
                "services": null,
                "libraries": null,
                "props": null,
                "externalFactServiceTimeout":0
              },
              "locationConf": {
                "maxRules": 1000,
                "maxFacts": 1000
              },
              "mutationStore": "sqlite",
              "mutationStoreConfig": "test",
              "locationInitHook": null
            }

    patch:
      description: Make a partial update to the configurations
      is: [ successProducer, errorGeneralProducer ]
      body:
        application/json:
          schema: RulesItem
          example: |
            {
              "timing": true,
              "persisting": true
            }

/codeblocks:
  post:
    description: Evaluate some in process code
    is: [ errorGeneralProducer ]
    body:
      application/json:
        example: 1+2
    responses:
      200:
          body:
            application/json:
              schema: RulesItemResponse
              example: |
                {"response":{"status":200,"message":"OK","txId":"05912de0-d6e4-4d2b-90bd-d062857eda77"},"item":3}

/matches:
  post:
    description: Match a fact against a pattern
    is: [ errorGeneralProducer ]
    body:
      application/json:
        example: |
          {
            "fact": {
              "kids": [
                "bart",
                "lisa"
              ],
              "person": "homer"
            },
            "pattern": {
              "kids": [
                "?kid"
              ],
              "person": "homer"
            }
          }
    responses:
      200:
        body:
          application/json:
            schema: RulesItemResponse
            example: |
              {"response":{"status":200,"message":"OK","txId":"dc824efd-e778-4a7e-b2f1-0539c0c66252"},"item":[{"?kid":"lisa"},{"?kid":"bart"}]}

/locations:
  get:
    description: Get all known locations
    is: [ errorGeneralProducer ]
    responses:
        200:
          body:
            application/json:
              schema: RulesItemsResponse
              example: |
                {"response":{"status":200,"message":"OK","txId":"91951875-d05a-4460-91a1-9a239e2668f7"},"items":["csv-rules-demo"]}

  delete:
    description: Clear all (internal) state for everything -- rules & facts for all locations
    is: [ successProducer, errorGeneralProducer ]

  /{location_id}:
    delete:
      description: Clear all (internal) state at the given location
      is: [ successProducer, errorGeneralProducer ]

    /stats:
      delete:
        description: Delete the stats for a location
        is: [ successProducer, errorGeneralProducer ]

      get:
        description: Get basic stats for the given location (put in total time)
        is: [ errorGeneralProducer ]
        responses:
          200:
            body:
              application/json:
                schema: RulesItemResponse
                example: |
                  {"response":{"status":200,"message":"OK","txId":"8e9826ad-ac05-4126-89b9-d43090128f80"},"item":{"totalCalls":33,"errorCount":8,"totalTime":19545844,"newLocations":0,"addRules":8,"remRules":8,"getRules":0,"addFacts":5,"remFacts":5,"searchRules":0,"searchFacts":6,"listRules":1,"processEvents":0,"actionExecs":0}}

    /configs:
      get:
        description: Get the node's configurations
        is: [ errorGeneralProducer ]
        responses:
          200:
            body:
              application/json:
                schema: RulesItemResponse
                example: |
                  {"response":{"status":200,"message":"OK","txId":"f4ef8dbb-76d0-4fcc-bc4f-68922f89a7d6"},"item":{"maxRules":1000,"maxFacts":2000}}

      put:
        description: Set the node's configuration (complete set)
        is: [ successProducer, errorGeneralProducer ]
        body:
          application/json:
            schema: RulesItem
            example: |
              {"maxRules": 1000,"maxFacts":2000}

      patch:
        description: Make a partial update to the configurations
        is: [ successProducer, errorGeneralProducer ]
        body:
          application/json:
            schema: RulesItem
            example: |

    /facts:
      post:
        description: Add a fact to the given location
        is: [ errorGeneralProducer ]
        body:
          application/json:
            example: |
              {
                "kids": [
                  "bart",
                  "lisa"
                ],
                "person": "homer"
              }
        responses:
          200:
            body:
              application/json:
                schema: RulesItemResponse
                example: |
                  {"response":{"status":200,"message":"OK","txId":"946e10c0-3f2d-4b59-9f29-490f0bbb7c6b"},"item":"d4add2cede05d6c9bc052124516c835170947793"}

      get:
        queryParameters:
          pattern:
            description: encoded json representation of a pattern
            example: '{"kids": ["?kid"],"person": "homer"}'
        description: Search (internal) facts at a given location with given pattern
        is: [ errorGeneralProducer ]
        responses:
          200:
            body:
              application/json:
                schema: RulesItemResponse
                example: |
                  {"response":{"status":200,"message":"OK","txId":"000c066d-c8fc-44ac-888d-de83a0a0af1e"},"item":{"found":[{"js":"{\n    \"kids\": [\n        \"bart\",\n        \"lisa\"\n    ],\n    \"person\": \"homer\"\n}","id":"pxW2cUzKkyC6MYvKxsJIJBtkNps=","bindingss":[{"?kid":"bart"},{"?kid":"lisa"}]}],"checked":1,"elapsed":291637,"expired":0}}

      patch:
        queryParameters:
          pattern:
            description: encoded json representation of a pattern
            example: '{"kids": ["?kid"],"person": "homer"}'
        description: Replace (internal) facts at a given location with the new one by a given pattern
        is: [ errorGeneralProducer ]
        body:
          application/json:
            example: |
              {
                "kids": [
                  "bart",
                  "lisa",
                  "maggie"
                ],
                "person": "homer"
              }
        responses:
          200:
            body:
              application/json:
                schema: RulesItemResponse
                example: |
                  {"response":{"status":200,"message":"OK","txId":"e1ca7c91-28c9-4894-9bea-835b2d52c46d"},"item":"429b0c9303ff76e576a9fee855e5c61626681807"}

      delete:
        queryParameters:
          pattern:
            description: encoded json representation of a pattern
            example: '{"kids": ["?kid"],"person": "homer"}'
        description: Remove facts from FDS at a given location with given pattern
        is: [ errorGeneralProducer ]
        responses:
          200:
            body:
              application/json:
                schema: RulesItemResponse
                example: |
                  {"response":{"status":200,"message":"OK","txId":"69c215fd-9831-4b70-b3f7-058f626352b3"},"item":{"found":[{"js":"{\n    \"kids\": [\n        \"bart\",\n        \"lisa\"\n    ],\n    \"person\": \"homer\"\n}","id":"pxW2cUzKkyC6MYvKxsJIJBtkNps=","bindingss":[{"?kid":"bart"},{"?kid":"lisa"}]}],"checked":1,"elapsed":1763537,"expired":0}}

      /{fact_id}:
        get:
          description: Get a particular fact's value
          is: [ errorGeneralProducer ]
          responses:
            200:
              body:
                application/json:
                  schema: RulesItemResponse
                  example: |
                    {"response":{"status":200,"message":"OK","txId":"b5456547-f315-4a86-aee1-700cf09ea688"},"item":"{\n    \"kids\": [\n        \"bart\",\n        \"lisa\"\n    ],\n    \"person\": \"homer\"\n}"}

        delete:
          description: Remove a particular fact
          is: [ successProducer, errorGeneralProducer, errorNotFound ]

    /rules:
      get:
        description: Get all rules at a given location
        is: [ errorGeneralProducer ]
        responses:
          200:
            body:
              application/json:
                schema: RulesItemsResponse
                example: |
                  {"response":{"status":200,"message":"OK","txId":"15b21700-1577-40c3-8d58-7d9951a17d8b"},"items":["621e0bbf0da7c1a9a73eb246bf9b0be9ab98b8ee","653c0332dcbc1889b2741f63bfd3c97ae09471c8","4ccece8188846b2f52466efab4aa9ec2c303d81c","17d65a035955bb1597ab65f6587861f163051870","f891d97c9d9848c2cf382be79e39373848b7a3bf","4a5787f82ce6a639d2c51c89bcf8307de43e5df4","36ab8f4cd2ea7c02c05b48be22442eebcc6430c2"]}

      post:
        description: Add a new rule to the given location
        is: [ errorGeneralProducer ]
        body:
          application/json:
            example: |
              {"when":{"pattern":{"0":"door","1":"is","2":"open"},"location":"csv-rules-demo"},"condition":{"and":[{"pattern":{"0":"temperature","1":"is","2":"?x"},"location":"csv-rules-demo"},{"code":"x \u003e 80"},{"pattern":{"0":"ac","1":"is","2":"off"},"location":"csv-rules-demo"}]},"action":{"code":"send('Turn on AC');fact('ac is on');","libraries":["send","fact"],"endpoint":"javascript"},"order":0}
        responses:
          200:
            body:
              application/json:
                schema: RulesItemResponse
                example: |
                  {"response":{"status":200,"message":"OK","txId":"d3547888-c4a1-4791-92c4-4e9cbaed3729"},"item":"afea1a54f95a349decdfbb8ed764fd4868471193"}

      /{rule_id}:
        delete:
          description: Remove a rule from a given location by id
          is: [ successProducer, errorGeneralProducer ]

        put:
          description: Update/add a rule to the given location with given id
          is: [ successProducer, errorGeneralProducer ]
          body:
            application/json:
              schema: RulesItemResponse
              example: |
                {"when":{"pattern":{"0":"door","1":"is","2":"open"},"location":"csv-rules-demo"},"condition":{"and":[{"pattern":{"0":"temperature","1":"is","2":"?x"},"location":"csv-rules-demo"},{"code":"x \u003e 80"},{"pattern":{"0":"ac","1":"is","2":"off"},"location":"csv-rules-demo"}]},"action":{"code":"send('Turn on AC');fact('ac is on');","libraries":["send","fact"],"endpoint":"javascript"},"order":0}

        get:
          description: Get a rule based on its id
          is: [ errorGeneralProducer, errorNotFound ]
          responses:
            200:
              body:
                application/json:
                  schema: RulesItemResponse
                  example: |
                    {"response":{"status":200,"message":"OK","txId":"b544c138-2058-4003-be1d-b2e95a551214"},"item":"{\"when\":{\"pattern\":{\"0\":\"door\",\"1\":\"is\",\"2\":\"open\"},\"location\":\"csv-rules-demo\"},\"condition\":{\"and\":[{\"not\":{\"pattern\":{\"0\":\"door\",\"1\":\"is\",\"2\":\"open\"},\"location\":\"csv-rules-demo\"}},{\"not\":{\"pattern\":{\"0\":\"count\",\"1\":\"is\",\"2\":\"set\"},\"location\":\"csv-rules-demo\"}}]},\"action\":{\"code\":\"send('Start count');fact('count is set');fact('count at 0');\",\"libraries\":[\"send\",\"fact\",\"fact\"],\"endpoint\":\"javascript\"},\"order\":0}"}

    /events:
      post:
        description: Submit an event for processing
        is: [ errorGeneralProducer, errorNotFound ]
        body:
          application/json:
            example: |
              {"person":"homer","at":"home"}
        responses:
          202:
            body:
              application/json:
                schema: RulesItemResponse
                example: |
                  {"response":{"status":202,"message":"Accepted","txId":"88d5ec8f-9525-4575-a36b-98fe18267199"},"item":{"eid":"q9gM5TjMQeTWL2qPck7ttCZoEGQ=","error":null}}

      /{event_id}:
        get:
          description: Get details of the event based on its id
          is: [ errorGeneralProducer, errorNotFound ]
          responses:
            200:
              body:
                application/json:
                  schema: RulesItemResponse
                  example: |
                    {"response":{"status":200,"message":"OK","txId":"3e1a9470-5b85-4984-8de3-d7bef1c6bca6"},"item":[{"wid":"cdxlcIY4mz6+dfuHiWoGD31CoLI=","eid":"A2JljY1F+eGVHB0AXDo3CFkhGfo=","parent":"A2JljY1F+eGVHB0AXDo3CFkhGfo=","type":"EventFindRules","work":{"event":{"0":"door","1":"is","2":"open"}},"cond":null,"started":"2014-08-15T02:39:34.917816062Z","done":""}]}


Update Warehousing order types.

Update Warehousing order types.

#%RAML 0.8
---
title: Warehousing API
baseUri: https://api.bring.com/po/api/v1

documentation:
- title: Introduction
  content: |
    A typical usage pattern for an Warehousing customer type is to create an order in Order Management that will go to the correct warehouse for picking, packing and sending. Then follow up with creating a packing list from the warehouse with transport information. All steps can be followed in Mybring Order Management.

    Warehousing API has several interfaces (SOAP and XML/JSON). Choose the option that fits your needs best (see table below). The XML/JSON interface is the core interface with complete functionality.

    Please note that this API currently doesn't support json on all of its methods yet. Look in the example section to see which are supported.

    ## SOAP

    ### Versioning

    Warehousing API makes an effort to always be backwards compatible regarding data format for requests and responses of the Web Service. To achieve this, a SchemaVersion element is used in the request, indicating which version the client is on and what data-format the client expects in the result.

    We make an effort not to return new elements in the response when an old schema version is specified. When changes in the schema are made, the SchemaVersion is incremented by one. The new schema is used at the same endpoint URL as before and uses the same namespace for its XML elements. A TraceMessage element (info message) in the response is added to inform the client that its schema should be updated. Old schema versions might in the future be unsupported.

    Regarding the XML API (not Web Services), an XML Schema is not used at all. Therefore, clients of the XML API are expected to handle new elements that appear. Nevertheless, the response will be backwards compatible in the sense that elements are not renamed or deleted.

    ### WSDL

    [https://api.bring.com/po/api/ws/purchaseorder-v1.wsdl](https://api.bring.com/po/api/ws/purchaseorder-v1.wsdl)

    [https://api.bring.com/po/api/ws/om-order-v1.wsdl](https://api.bring.com/po/api/ws/om-order-v1.wsdl)

    ## Error handling

    When using the Warehousing API, errors or service unavailability can occur, although we do our utmost to prevent any downtime. Thus it is important to use timeouts and other error handling techniques when making requests to the service.

    How you handle errors depends on the nature of your application, but one strategy for handling such situations is by providing a failover if the shipping guide responds with an error or does not respond at all (timeout).

    See [the list of error codes](#list-error-codes) for hints on how to implement error handling.

- title: Authentication
  content: |
    The Warehousing API requires authentication for all its endpoints. See the [getting started guide on authentication](/api/#authentication) if you're not sure what this means.

    | Header | Example | Comment |
    |:-------|:--------|:--------|
    | `X-MyBring-API-Uid` | `john.doe@example.com` | Mybring login ID |
    | `X-MyBring-API-Key` | `1234abc-abcd-1234-5678-abcd1234abcd ` | Mybring login's API key |
    | `X-Bring-Client-URL` | `https://example.com/ ` | A URL that sort of identifies where you're using the APIs. |

    Those headers must be set for all endpoints documented below.

/omorder:
  displayName: Send an order
  description: |
      Send an order to Warehousing system. There are different types of order supported in Warehousing system.

       - Order / SalesOrder (as an pickorder for Warehousing)
            - Warehousing functionality sends it to Warhousing system for picking and delivery.
       - PurchaseOrder (as an receiving order for Warehousing)
            - Warehousing functionality sends it to Warhousing system for receiving orderinfo.

  post:
    description: Send an order
    queryParameters:
      CreateOrderRequest messageFunction:
          description: Type of order.
"Order"
"OrderResponse"
"SalesOrder"
"NotifyTransport"
"PurchaseOrder"
"ArticleBalance"
"DespatchAdvice"
"ReceivingAdvice"
"PackageList"
"OrderReceipt"
"InventoryReport"
"InventoryReportAd"
"ItemData"
          type: string
          required: true
          example: Order
      MessageSender partyId:
          description: Customer Number which Bring has provided. It cannot be demo customer number.
          type: string
          required: true
          example: 10000000000
      MessageRecipient partyId:
          description: Receiving Bring system. Constant value.
          type: string
          required: true
          example: NO98466118506
      MessageDate:
          description: The date on which message is sent.
          type: dateTime
          required: true
          example: 22.01.2017 11:36:22
      OrderSet updateIndicator:
          description: Type of order data. Original, Update or Deletion
          type: string
          required: true
          example: Original
      Order orderId:
          description: Ordernumber.
          type: dateTime
          required: true
          example: 101010
      Reference:
          description: Set of references.
          type: sequence
          required: false
      Reference referenceType:
          description: Type of reference coded. https://www.stylusstudio.com/edifact/D04A/1153.htm
          type: String
          required: true
          example: CMR
      Reference ReferenceNo:
          description: Reference.
          type: String
          required: true
          example: 10003455TT
      DateAndTimes subClass DocumentDate:
          description: The date on which order is booked.
          type: dateTime
          required: true
          example: 22.01.2017 11:36:22
      TransportService BasicServiceCode:
          description: Transport product for shipment to customer. http://developer.bring.com/api/products/
          type: String
          required: true
          example: SERVICEPAKKE
      TransportService AdditionalService AdditionalServiceCode:
          description: Transport services for shipment to customer. http://developer.bring.com/api/products/
          type: String
          required: true
          example: EVARSLING
      TransportLeg TransportLegType:
          description: TransportLegType id. Default value 30.
          type: String
          required: true
          example: 30
      TransportLeg ModeOfTransport:
          description: Type of transport.
1 = Sea
2 = Train
3 = Road
4 = Air.
          type: String
          required: true
          example: 3
      Party/subClass OrderingParty:
          description: Details of sender. Must have Name, Street, City, CountryCode.
          required: true
      Party/subClass DeliveryParty:
          description: Details of recipient. Must have Name, Street, City, CountryCode.
          required: true
      Party/subClass Supplier:
          description: Details of supplier. Must have Name, Street, City, CountryCode if used.
          required: false
      Party/subClass PerformingUnit partyId:
          description: Warehouse id for order. Required if order to Warehousing system.
          type: string
          required: false
          example: BERGER
      OrderLineSet:
          description: Set of order items.
          type: sequence
          required: true
      OrderItem articleLineId:
          description: Line id for this order line.
          type: integer
          required: true
          example: 10
      ArticleId:
          description: Article number or id.
          type: sequence
          required: true
          example: 123-4000
      ArticleId codeListAgencyIdentifier:
          description: Sets type of ArticleId.
"CustomerItemNo"
"VendorItemNo"
"EAN"
If not used ArticleId default is CustomerItemNo.
          type: string
          required: false
          example: VendorItemNo
      ArticleQuantity unitCode:
          description: Unit code for quantity ordered.
          type: string
          required: true
          example: STK
      ArticleQuantity:
          description: Quantity ordered.
          type: float
          required: true
          example: 2.0
      Description usageCode:
          description: Article description type. If description used set to AAA.
          type: string
          required: false
          example: AAA
      Description:
          description: Article description.
          type: string
          required: false
          example: Spear parts with all parts
      ArticleName:
          description: Article name.
          type: string
          required: false
          example: Spear parts
      DateAndTimes subClass DeliveryDateRequested:
          description: The date on which order is requested delivered.
          type: dateTime
          required: true
          example: 22.01.2017 11:36:22

    body:
        application/xml:
          example: !include examples/create_order.xml
        application/json:
          example: !include examples/create_order.json
    responses:
      200:
        displayName: Success
        description: |
          Successfully created a order.

/omorder/{customerId}/{orderId}:
  displayName: List order information
  description: |
      Get all information on a given order.
  get:
    description: List order information
    responses:
      200:
        displayName: Success
        description: |
          Complete order information including order items.
        body:
          application/xml:
            example: !include examples/retrieve_order.xml
          application/json:
            example: !include examples/retrieve_order.json

/items/{customerId}/{orderId}:
  displayName: List order items
  description: |
      List all item lines on an order.
  get:
    description: List order items
    responses:
      200:
        displayName: Success
        description: |
          List of order items.
        body:
          application/xml:
            example: !include examples/retrieve_orderitems.xml
          application/json:
            example: !include examples/retrieve_orderitems.json

/articlebalance:
  displayName: Create or update article balance list
  post:
    description: Create or update article balance list
    body:
      application/xml:
        example: !include examples/create_articlebalance.xml
    responses:
      200:
        displayName: Success
        description: |
          Successfully created balance list

/articlebalance/{customerId}:
  displayName: Get stock balance and info for all articles
  get:
    description: Get stock balance and info for all articles
    responses:
      200:
        displayName: Success
        description: |
        body:
          application/xml:
            example: !include examples/retrieve_articlebalance_all.xml
          application/json:
            example: !include examples/retrieve_articlebalance_all.json

/articlebalance/{customerId}/{articleNo}:
  displayName: Get stock balance and info for one article
  get:
    description: Get stock balance and info for one article
    responses:
      200:
        displayName: Success
        description: |
        body:
          application/xml:
            example: !include examples/retrieve_articlebalance_one.xml
          application/json:
            example: !include examples/retrieve_articlebalance_one.json

/articlebalance/info/{customerId}/{articleSearchString}:
  displayName: Get stock balance and info for all articles matching search string
  get:
    description: Get stock balance and info for all articles matching search string
    responses:
      200:
        displayName: Success
        description: |
        body:
          application/xml:
            example: !include examples/retrieve_articlebalance_search.xml
          application/json:
            example: !include examples/retrieve_articlebalance_search.json

/errorCodes:
  displayName: List error codes
  get:
    description: List error codes
    responses:
      200:
        displayName: Success
        description: |
          Dynamic list of error codes used in the solution.
        body:
          application/xml:
            example: !include examples/error_codes.xml
          application/json:
            example: !include examples/error_codes.json

#%RAML 0.8
---
title: Warehousing API
baseUri: https://api.bring.com/po/api/v1

documentation:
- title: Introduction
  content: |
    A typical usage pattern for an Warehousing customer type is to create an order in Order Management that will go to the correct warehouse for picking, packing and sending. Then follow up with creating a packing list from the warehouse with transport information. All steps can be followed in Mybring Order Management.

    Warehousing API has several interfaces (SOAP and XML/JSON). Choose the option that fits your needs best (see table below). The XML/JSON interface is the core interface with complete functionality.

    Please note that this API currently doesn't support json on all of its methods yet. Look in the example section to see which are supported.

    ## SOAP

    ### Versioning

    Warehousing API makes an effort to always be backwards compatible regarding data format for requests and responses of the Web Service. To achieve this, a SchemaVersion element is used in the request, indicating which version the client is on and what data-format the client expects in the result.

    We make an effort not to return new elements in the response when an old schema version is specified. When changes in the schema are made, the SchemaVersion is incremented by one. The new schema is used at the same endpoint URL as before and uses the same namespace for its XML elements. A TraceMessage element (info message) in the response is added to inform the client that its schema should be updated. Old schema versions might in the future be unsupported.

    Regarding the XML API (not Web Services), an XML Schema is not used at all. Therefore, clients of the XML API are expected to handle new elements that appear. Nevertheless, the response will be backwards compatible in the sense that elements are not renamed or deleted.

    ### WSDL

    [https://api.bring.com/po/api/ws/purchaseorder-v1.wsdl](https://api.bring.com/po/api/ws/purchaseorder-v1.wsdl)

    [https://api.bring.com/po/api/ws/om-order-v1.wsdl](https://api.bring.com/po/api/ws/om-order-v1.wsdl)

    ## Error handling

    When using the Warehousing API, errors or service unavailability can occur, although we do our utmost to prevent any downtime. Thus it is important to use timeouts and other error handling techniques when making requests to the service.

    How you handle errors depends on the nature of your application, but one strategy for handling such situations is by providing a failover if the shipping guide responds with an error or does not respond at all (timeout).

    See [the list of error codes](#list-error-codes) for hints on how to implement error handling.

- title: Authentication
  content: |
    The Warehousing API requires authentication for all its endpoints. See the [getting started guide on authentication](/api/#authentication) if you're not sure what this means.

    | Header | Example | Comment |
    |:-------|:--------|:--------|
    | `X-MyBring-API-Uid` | `john.doe@example.com` | Mybring login ID |
    | `X-MyBring-API-Key` | `1234abc-abcd-1234-5678-abcd1234abcd ` | Mybring login's API key |
    | `X-Bring-Client-URL` | `https://example.com/ ` | A URL that sort of identifies where you're using the APIs. |

    Those headers must be set for all endpoints documented below.

/omorder:
  displayName: Send an order
  description: |
      Send an order to Warehousing system. There are different types of order supported in Warehousing system.

       - Order / SalesOrder (as an pickorder for Warehousing)
            - Warehousing functionality sends it to Warhousing system for picking and delivery.
  post:
    description: Send an order
    queryParameters:
      CreateOrderRequest messageFunction:
          description: Type of order.
"Order"
"OrderResponse"
"SalesOrder"
"NotifyTransport"
"PurchaseOrder"
"ArticleBalance"
"DespatchAdvice"
"ReceivingAdvice"
"PackageList"
          type: string
          required: true
          example: Order
      MessageSender partyId:
          description: Customer Number which Bring has provided. It cannot be demo customer number.
          type: string
          required: true
          example: 10000000000
      MessageRecipient partyId:
          description: Receiving Bring system. Constant value.
          type: string
          required: true
          example: NO98466118506
      MessageDate:
          description: The date on which message is sent.
          type: dateTime
          required: true
          example: 22.01.2017 11:36:22
      OrderSet updateIndicator:
          description: Type of order data. Original, Update or Deletion
          type: string
          required: true
          example: Original
      Order orderId:
          description: Ordernumber.
          type: dateTime
          required: true
          example: 101010
      Reference:
          description: Set of references.
          type: sequence
          required: false
      Reference referenceType:
          description: Type of reference coded. https://www.stylusstudio.com/edifact/D04A/1153.htm
          type: String
          required: true
          example: CMR
      Reference ReferenceNo:
          description: Reference.
          type: String
          required: true
          example: 10003455TT
      DateAndTimes subClass DocumentDate:
          description: The date on which order is booked.
          type: dateTime
          required: true
          example: 22.01.2017 11:36:22
      TransportService BasicServiceCode:
          description: Transport product for shipment to customer. http://developer.bring.com/api/products/
          type: String
          required: true
          example: SERVICEPAKKE
      TransportService AdditionalService AdditionalServiceCode:
          description: Transport services for shipment to customer. http://developer.bring.com/api/products/
          type: String
          required: true
          example: EVARSLING
      TransportLeg TransportLegType:
          description: TransportLegType id. Default value 30.
          type: String
          required: true
          example: 30
      TransportLeg ModeOfTransport:
          description: Type of transport.
1 = Sea
2 = Train
3 = Road
4 = Air.
          type: String
          required: true
          example: 3
      Party/subClass OrderingParty:
          description: Details of sender. Must have Name, Street, City, CountryCode.
          required: true
      Party/subClass DeliveryParty:
          description: Details of recipient. Must have Name, Street, City, CountryCode.
          required: true
      Party/subClass Supplier:
          description: Details of supplier. Must have Name, Street, City, CountryCode if used.
          required: false
      Party/subClass PerformingUnit partyId:
          description: Warehouse id for order. Required if order to Warehousing system.
          type: string
          required: false
          example: BERGER
      OrderLineSet:
          description: Set of order items.
          type: sequence
          required: true
      OrderItem articleLineId:
          description: Line id for this order line.
          type: integer
          required: true
          example: 10
      ArticleId:
          description: Article number or id.
          type: sequence
          required: true
          example: 123-4000
      ArticleId codeListAgencyIdentifier:
          description: Sets type of ArticleId.
"CustomerItemNo"
"VendorItemNo"
"EAN"
If not used ArticleId default is CustomerItemNo.
          type: string
          required: false
          example: VendorItemNo
      ArticleQuantity unitCode:
          description: Unit code for quantity ordered.
          type: string
          required: true
          example: STK
      ArticleQuantity:
          description: Quantity ordered.
          type: float
          required: true
          example: 2.0
      Description usageCode:
          description: Article description type. If description used set to AAA.
          type: string
          required: false
          example: AAA
      Description:
          description: Article description.
          type: string
          required: false
          example: Spear parts with all parts
      ArticleName:
          description: Article name.
          type: string
          required: false
          example: Spear parts
      DateAndTimes subClass DeliveryDateRequested:
          description: The date on which order is requested delivered.
          type: dateTime
          required: true
          example: 22.01.2017 11:36:22

    body:
        application/xml:
          example: !include examples/create_order.xml
        application/json:
          example: !include examples/create_order.json
    responses:
      200:
        displayName: Success
        description: |
          Successfully created a order.

/omorder/{customerId}/{orderId}:
  displayName: List order information
  description: |
      Get all information on a given order.
  get:
    description: List order information
    responses:
      200:
        displayName: Success
        description: |
          Complete order information including order items.
        body:
          application/xml:
            example: !include examples/retrieve_order.xml
          application/json:
            example: !include examples/retrieve_order.json

/items/{customerId}/{orderId}:
  displayName: List order items
  description: |
      List all item lines on an order.
  get:
    description: List order items
    responses:
      200:
        displayName: Success
        description: |
          List of order items.
        body:
          application/xml:
            example: !include examples/retrieve_orderitems.xml
          application/json:
            example: !include examples/retrieve_orderitems.json

/articlebalance:
  displayName: Create or update article balance list
  post:
    description: Create or update article balance list
    body:
      application/xml:
        example: !include examples/create_articlebalance.xml
    responses:
      200:
        displayName: Success
        description: |
          Successfully created balance list

/articlebalance/{customerId}:
  displayName: Get stock balance and info for all articles
  get:
    description: Get stock balance and info for all articles
    responses:
      200:
        displayName: Success
        description: |
        body:
          application/xml:
            example: !include examples/retrieve_articlebalance_all.xml
          application/json:
            example: !include examples/retrieve_articlebalance_all.json

/articlebalance/{customerId}/{articleNo}:
  displayName: Get stock balance and info for one article
  get:
    description: Get stock balance and info for one article
    responses:
      200:
        displayName: Success
        description: |
        body:
          application/xml:
            example: !include examples/retrieve_articlebalance_one.xml
          application/json:
            example: !include examples/retrieve_articlebalance_one.json

/articlebalance/info/{customerId}/{articleSearchString}:
  displayName: Get stock balance and info for all articles matching search string
  get:
    description: Get stock balance and info for all articles matching search string
    responses:
      200:
        displayName: Success
        description: |
        body:
          application/xml:
            example: !include examples/retrieve_articlebalance_search.xml
          application/json:
            example: !include examples/retrieve_articlebalance_search.json

/errorCodes:
  displayName: List error codes
  get:
    description: List error codes
    responses:
      200:
        displayName: Success
        description: |
          Dynamic list of error codes used in the solution.
        body:
          application/xml:
            example: !include examples/error_codes.xml
          application/json:
            example: !include examples/error_codes.json