Added action target template filtered by name

is: [ auth ]
type:
  collection:
    humanName: action target template
    schemaBaseName: actionTargetTemplate
    exampleGetResponse: !include ../examples/actionTargetTemplates/response-array-get.json
    examplePostRequest: !include ../examples/actionTargetTemplates/request-post.json
    examplePostError: !include ../examples/actionTargetTemplates/response-post-error.json
get:
  securedBy: [ test ]
  description: |
    By default, retrieve all the public action target template that a user can visualize.

    - If an `organizationId` is provided, then all the action target templates of the organization are
    retrieved. The user must be a member of the organization, otherwise, he will get a `403`.

    - If `allOrganizations` is used, therfore, all the action target templates for all the organizations where the user
    is member are retrived.

    - If `organizationId` and `allOrganizations` are specified together, then only `organizationId` take effect.
  queryParameters:
    organizationId:
      description: Filter the action target template by organization. The user **MUST** be member of the organization.
      type: integer
      required: false
      example: |
        `organizationId=1`
    allOrganizations:
      description: Filter the action target template to retrieve all of them accross all the organizations where the user is member of.
      type: integer
      required: false
      example: |
        `allOrganizations` or `allOrganizations=true`
    name:
      type: string
      required: false
      description: Use this parameter to apply a filter on the name. Can be combined with other parameters.
      example: |
        `name=iFlu%`

  responses:
    403:
      description: If the user is not a member of the organization that owns the action target template.
post:
  securedBy: [ jwt: { type: 'owner' }, test ]

/{actionTargetId}:
  is: [ auth ]
  type:
    member:
      humanName: action target template
      schemaBaseName: actionTargetTemplate
      identifierName: actionTargetTemplateId
      exampleGetResponse: !include ../examples/actionTargetTemplates/response-get.json
      examplePatchRequest: !include ../examples/actionTargetTemplates/request-patch.json
      examplePatchError: !include ../examples/actionTargetTemplates/response-patch-error.json
  get:
    securedBy: [ jwt: { type: 'owner' }, test ]
  patch:
    securedBy: [ jwt: { type: 'owner' }, test ]

is: [ auth ]
type:
  collection:
    humanName: action target template
    schemaBaseName: actionTargetTemplate
    exampleGetResponse: !include ../examples/actionTargetTemplates/response-array-get.json
    examplePostRequest: !include ../examples/actionTargetTemplates/request-post.json
    examplePostError: !include ../examples/actionTargetTemplates/response-post-error.json
get:
  securedBy: [ test ]
  description: |
    By default, retrieve all the public action target template that a user can visualize.

    - If an `organizationId` is provided, then all the action target templates of the organization are
    retrieved. The user must be a member of the organization, otherwise, he will get a `403`.

    - If `allOrganizations` is used, therfore, all the action target templates for all the organizations where the user
    is member are retrived.

    - If `organizationId` and `allOrganizations` are specified together, then only `organizationId` take effect.
  queryParameters:
    organizationId:
      description: Filter the action target template by organization. The user **MUST** be member of the organization.
      type: integer
      required: false
      example: |
        `organizationId=1`
    allOrganizations:
      description: Filter the action target template to retrieve all of them accross all the organizations where the user is member of.
      type: integer
      required: false
      example: |
        `allOrganizations` or `allOrganizations=true`

  responses:
    403:
      description: If the user is not a member of the organization that owns the action target template.
post:
  securedBy: [ jwt: { type: 'owner' }, test ]

/{actionTargetId}:
  is: [ auth ]
  type:
    member:
      humanName: action target template
      schemaBaseName: actionTargetTemplate
      identifierName: actionTargetTemplateId
      exampleGetResponse: !include ../examples/actionTargetTemplates/response-get.json
      examplePatchRequest: !include ../examples/actionTargetTemplates/request-patch.json
      examplePatchError: !include ../examples/actionTargetTemplates/response-patch-error.json
  get:
    securedBy: [ jwt: { type: 'owner' }, test ]
  patch:
    securedBy: [ jwt: { type: 'owner' }, test ]


Fix button link that is not displayed correctly

#%RAML 1.0
---
title: Shipping Guide API 2.0
baseUri: https://api.bring.com/shippingguide

documentation:
- title: Introduction
  content: |
      The Shipping Guide API 2.0 (Fraktguiden) for provides you with different shipping alternatives for your shipments. If you request applicable shipping alternatives with all relevant details you will receive an object with the following data:

      - Prices
      - Estimated delivery times
      - GUI information

      The API returns the recommended way to present these shipping alternatives, meaning that the actual response can easily be shown in a web-shop checkout without any sorting or filtering and with human readable service texts.

      The Shipping Guide API 2.0 has both a REST and a SOAP interface. The REST interface only supports single consignments, while the SOAP interface can be used for multiple consignments.

      ### Why upgrade?

      * [Unified request and response model](/api/shipping-guide_2/#getting-started): Due to backward compatibility, existing SOAP API versions had too many ways of requesting to Shipping Guide could be always confusing for clients. This has been simplified in the new version with one unified way of requesting to Shipping Guide.
      * [Better error handling for both SOAP and REST](/api/shipping-guide_2/#handle-api-errors): The new version of API gives ability to handle error in a much simpler way.
      * [Ability to fetch agreement prices specific to a service on REST](/api/shipping-guide_2/#get-shipment-prices-and-estimated-delivery): Now you can specify multiple services and along with multiple customer number in a single REST request. [How?](/api/shipping-guide_2/#get-shipment-prices-and-estimated-delivery)
      *  Some improvements to our service offering are planned for 2018-19. More info about upcoming changes will follow to all our partners. Future services will be supported by this new API-version in addition to other improvements. Note that our old versions of API’s will not support future changes in our service offering.

      ### How to upgrade
      Now that Shipping Guide API 2.0 is out you might be wondering how to upgrade to it. The [Upgrade to version 2.0](/api/shipping-guide_2/upgrade-to-version-2) will help you on your way to version 2.0 of the Shipping Guide API.

- title: Getting started
  content: |
      This guide will walk you through getting shipment alternatives for your first consignment using Shipping Guide API. In this example we will be calling the SOAP interface with a HTTP client and query for the service `SERVICEPAKKE` and `PA_DOREN` for two packages.

      ### Before you start
      Before you can begin using the new API you'll have to do the following:

      * [Sign up for a Mybring account](https://www.mybring.com/signup/register/user) if you do not already have one. If you're already registered in Mybring, head to the [settings and API](https://www.mybring.com/useradmin/account/settings/) page to get your API key.
      * [Generate an API key](/api/#authentication) for your user

      ### 1. Get your API key from Mybring
      To make API requests you will need an API key. Click the link below, which sends you to your "Settings and API" page in Mybring profile administration. Scroll down to the "API key" section. Your generated API key which you will use to authenticate your requests can be found here.

      Get API key

      ### 2. Add authentication headers
      A description of the headers can be found in [Getting Started / Authentication](/api/#authentication).

      ### 3. Add additional headers
      Since we're using the SOAP (1.1) interface we'll have to add the following header:

      - `Content-type: text/xml`

      Most SOAP libraries will do this for you.

      ### 4. Add the body to the request
      In this request we will query prices and expected delivery time for the service `SERVICEPAKKE` for a single package being sent from the postal code 0015 to 5518 in Norway.

      ```
      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                        xmlns:ns="http://www.bring.no/logistics/shippingguide/2.0">
          <soapenv:Header/>
          <soapenv:Body>
              <ns:ShippingGuideRequest xmlns:ns="http://www.bring.no/logistics/shippingguide/2.0">
                  <ns:Language>no</ns:Language>
                  <ns:WithPrice>true</ns:WithPrice>
                  <ns:WithExpectedDelivery>false</ns:WithExpectedDelivery>
                  <ns:WithGuiInformation>true</ns:WithGuiInformation>
                  <ns:NumberOfAlternativeDeliveryDates>0</ns:NumberOfAlternativeDeliveryDates>
                  <ns:EDI>true</ns:EDI>
                  <ns:PostingAtPostoffice>true</ns:PostingAtPostoffice>
                  <ns:Trace>true</ns:Trace>
                  <ns:Consignments>
                    <ns:Consignment id="101">
                        <ns:Products>
                            <ns:Product>
                                <ns:Id>SERVICEPAKKE</ns:Id>
                            </ns:Product>
                        </ns:Products>
                        <ns:FromCountryCode>NO</ns:FromCountryCode>
                        <ns:FromPostalCode>0015</ns:FromPostalCode>
                        <ns:ToCountryCode>NO</ns:ToCountryCode>
                        <ns:ToPostalCode>5518</ns:ToPostalCode>
                        <ns:ShippingDate>
                            <ns:Year>2016</ns:Year>
                            <ns:Month>10</ns:Month>
                            <ns:Day>10</ns:Day>
                            <ns:Hour>10</ns:Hour>
                            <ns:Minute>0</ns:Minute>
                        </ns:ShippingDate>
                        <ns:AdditionalServices>
                            <ns:AdditionalService>
                                <ns:Id>EVARSLING</ns:Id>
                            </ns:AdditionalService>
                            <ns:AdditionalService>
                                <ns:Id>POSTOPPKRAV</ns:Id>
                            </ns:AdditionalService>
                        </ns:AdditionalServices>
                        <ns:Packages>
                            <ns:Package id="10">
                                <ns:Height>10</ns:Height>
                                <ns:Width>10</ns:Width>
                                <ns:Length>10</ns:Length>
                                <ns:GrossWeight>50</ns:GrossWeight>
                            </ns:Package>
                            <ns:Package id="11">
                                <ns:Height>10</ns:Height>
                                <ns:Width>10</ns:Width>
                                <ns:Length>10</ns:Length>
                                <ns:GrossWeight>50</ns:GrossWeight>
                            </ns:Package>
                            <ns:Package id="12">
                                <ns:Height>11</ns:Height>
                                <ns:Width>10</ns:Width>
                                <ns:Length>10</ns:Length>
                                <ns:GrossWeight>50</ns:GrossWeight>
                            </ns:Package>
                        </ns:Packages>
                    </ns:Consignment>
                  </ns:Consignments>
              </ns:ShippingGuideRequest>
          </soapenv:Body>
      </soapenv:Envelope>
      ```

      ### 5. Submit the request

      Post your request to

      ```

        https://api.bring.com/shippingguide/api/ws

      ```

      The response may have changed since it was documented but you will get a response that looks something like this:

      ```
      <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
          <SOAP-ENV:Header/>
          <SOAP-ENV:Body>
              <ns2:ShippingGuideResponse xmlns:ns2="http://www.bring.no/logistics/shippingguide/2.0">
                  <ns2:Consignments>
                      <ns2:Consignment consignmentId="101">
                          <ns2:Products>
                              <ns2:Product>
                                  <ns2:Id>SERVICEPAKKE</ns2:Id>
                                  <ns2:ProductionCode>1202</ns2:ProductionCode>
                                  <ns2:GuiInformation>
                                      <ns2:SortOrder>11</ns2:SortOrder>
                                      <ns2:MainDisplayCategory>Pakke</ns2:MainDisplayCategory>
                                      <ns2:SubDisplayCategory>Til private</ns2:SubDisplayCategory>
                                      <ns2:DisplayName>Klimanøytral Servicepakke</ns2:DisplayName>
                                      <ns2:ProductName>Klimanøytral Servicepakke</ns2:ProductName>
                                      <ns2:DescriptionText>Pakken kan spores og utleveres på ditt lokale hentested.</ns2:DescriptionText>
                                      <ns2:HelpText>Klimanøytral Servicepakke leveres til mottakers lokale hentested (postkontor eller Post i Butikk). Mottaker kan velge å hente sendingen på et annet hentested enn sitt lokale. Mottaker varsles om at sendingen er ankommet via SMS, e-post eller hentemelding i postkassen. Sendingen kan spores ved hjelp av sporingsnummeret.</ns2:HelpText>
                                      <ns2:ShortName>Klimanøytral Servicepakke</ns2:ShortName>
                                      <ns2:ProductURL>http://www.bring.no/sende/pakker/private-i-norge/hentes-pa-posten</ns2:ProductURL>
                                      <ns2:DeliveryType>Hentested</ns2:DeliveryType>
                                      <ns2:MaxWeightInKgs>35</ns2:MaxWeightInKgs>
                                  </ns2:GuiInformation>
                                  <ns2:Price>
                                      <ns2:ListPrice currencyCode="NOK">
                                          <ns2:PriceWithoutAdditionalServices>
                                              <ns2:AmountWithoutVAT>239.00</ns2:AmountWithoutVAT>
                                              <ns2:VAT>59.75</ns2:VAT>
                                              <ns2:AmountWithVAT>298.75</ns2:AmountWithVAT>
                                          </ns2:PriceWithoutAdditionalServices>
                                          <ns2:PriceWithAdditionalServices>
                                              <ns2:AmountWithoutVAT>239.00</ns2:AmountWithoutVAT>
                                              <ns2:VAT>59.75</ns2:VAT>
                                              <ns2:AmountWithVAT>298.75</ns2:AmountWithVAT>
                                          </ns2:PriceWithAdditionalServices>
                                      </ns2:ListPrice>
                                  </ns2:Price>
                                  <ns2:ExpectedDelivery>
                                      <ns2:WorkingDays>2</ns2:WorkingDays>
                                      <ns2:UserMessage/>
                                      <ns2:FormattedExpectedDeliveryDate>12.10.2018</ns2:FormattedExpectedDeliveryDate>
                                      <ns2:ExpectedDeliveryDate>
                                          <ns2:Year>2018</ns2:Year>
                                          <ns2:Month>10</ns2:Month>
                                          <ns2:Day>12</ns2:Day>
                                      </ns2:ExpectedDeliveryDate>
                                      <ns2:AlternativeDeliveryDates/>
                                  </ns2:ExpectedDelivery>
                              </ns2:Product>
                              <ns2:Product>
                                  <ns2:Id>PA_DOREN</ns2:Id>
                                  <ns2:ProductionCode>1736</ns2:ProductionCode>
                                  <ns2:GuiInformation>
                                      <ns2:SortOrder>41</ns2:SortOrder>
                                      <ns2:MainDisplayCategory>Pakke</ns2:MainDisplayCategory>
                                      <ns2:SubDisplayCategory>Til private</ns2:SubDisplayCategory>
                                      <ns2:DisplayName>På Døren</ns2:DisplayName>
                                      <ns2:ProductName>På Døren</ns2:ProductName>
                                      <ns2:DescriptionText>Pakken kan spores og leveres hjem til deg mellom kl. 17-21. Sjåføren ringer 30-60 min før ankomst.</ns2:DescriptionText>
                                      <ns2:HelpText>På Døren leveres hjem til mottaker mellom kl. 17 og 21. Mottaker varsles i god tid om forventet utleveringsdag via SMS eller e-post, i tillegg til nytt varsel når sendingen er lastet på bil for utkjøring samme kveld. Sjåføren ringer mottaker 30-60 minutter før ankomst. Mottaker kan endre leveringsdag når pakken spores (gjelder ikke lokalpakker). Dersom sendingen ikke kan leveres, blir den sendt til mottakers lokale hentested (postkontor eller Post i Butikk). Sendingen kan spores ved hjelp av sporingsnummeret.</ns2:HelpText>
                                      <ns2:ShortName>På Døren</ns2:ShortName>
                                      <ns2:ProductURL>http://www.bring.no/sende/pakker/private-i-norge/hjemlevering</ns2:ProductURL>
                                      <ns2:DeliveryType>Dør</ns2:DeliveryType>
                                      <ns2:MaxWeightInKgs>35</ns2:MaxWeightInKgs>
                                  </ns2:GuiInformation>
                                  <ns2:Price>
                                      <ns2:ListPrice currencyCode="NOK">
                                          <ns2:PriceWithoutAdditionalServices>
                                              <ns2:AmountWithoutVAT>270.00</ns2:AmountWithoutVAT>
                                              <ns2:VAT>67.50</ns2:VAT>
                                              <ns2:AmountWithVAT>337.50</ns2:AmountWithVAT>
                                          </ns2:PriceWithoutAdditionalServices>
                                          <ns2:PriceWithAdditionalServices>
                                              <ns2:AmountWithoutVAT>270.00</ns2:AmountWithoutVAT>
                                              <ns2:VAT>67.50</ns2:VAT>
                                              <ns2:AmountWithVAT>337.50</ns2:AmountWithVAT>
                                          </ns2:PriceWithAdditionalServices>
                                      </ns2:ListPrice>
                                  </ns2:Price>
                                  <ns2:Warnings>
                                      <ns2:Warning>
                                          <ns2:code>NO_EXPECTED_DELIVERY</ns2:code>
                                          <ns2:description>Expected delivery date is not available</ns2:description>
                                      </ns2:Warning>
                                  </ns2:Warnings>
                              </ns2:Product>
                          </ns2:Products>
                      </ns2:Consignment>
                  </ns2:Consignments>
              </ns2:ShippingGuideResponse>
          </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>
      ```

      If you want to know more about the fields you can have a look at the XSD linked from the section [Request and response structure](/api/shipping-guide_2/#request-and-response-structure)

- title: Shipping Guide topics
  content: |
      If you want to know more about corner cases/topics/etc, then [Let's talk about Shipping Guide](/api/shipping-guide_2/topics)

- title: Handle API errors
  content: |
      When using the Shipping Guide it is important to handle errors gracefully. Your users should still be able to order even if the Shipping Guide API returns an error or if there is an error establishing a connection to the API.

      The Shipping Guide API return two levels of error information:

      * HTTP error codes or SOAP fault with a message in the body

        For REST we follow general convention of HTTP status codes.
        For SOAP we give out detailed error decription along with an error code which can be parsed programmatically.

        ```
        <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
            <SOAP-ENV:Header/>
            <SOAP-ENV:Body>
                <SOAP-ENV:Fault>
                    <faultcode>SOAP-ENV:Client</faultcode>
                    <faultstring>FG_INPUT_010 Number of alternative delivery dates must be numeric and less than 10 [errorId 2806bbda-1df0-4b1b-b008-1068f5c57f06]
                    </faultstring>
                    <detail>
                        <code>FG_INPUT_010</code>
                        <description>Error number of alternative deliverydates</description>
                    </detail>
                </SOAP-ENV:Fault>
            </SOAP-ENV:Body>
        </SOAP-ENV:Envelope>
        ```

        Possible error codes can be found [here](https://api.bring.com/shippingguide/api/errors?clientUrl=developer.bring.com)

      * An error object in the response that is on service level

        When we are not able to process one of the service requested, we will respond with a error on service level. Details of possible error codes are documented in [XSD](https://api.bring.com/shippingguide/api/ws/shipping-guide-20.xsd) and [WDSL](https://api.bring.com/shippingguide/api/ws/shippingguide-20.wsdl) itself, making it easier for clients to parse it.

- title: Request and response structure
  content: |
      If you request shipping alternatives via the API your request and response will have to comply with the following schemas:

      #### SOAP

      [https://api.bring.com/shippingguide/api/ws/shipping-guide-20.xsd](https://api.bring.com/shippingguide/api/ws/shipping-guide-20.xsd)

      [https://api.bring.com/shippingguide/api/ws/shippingguide-20.wsdl](https://api.bring.com/shippingguide/api/ws/shippingguide-20.wsdl)

- title: Versioning
  content: |
       The Shipping Guide makes an effort to always be backwards compatible regarding data format for requests and responses. To achieve this, namespace schema versioning is used in the request for webservices, indicating which version the client is on and what data-format the client expects in the result. For REST, versioning is defined as part of endpoint itself.

       **Important**: All clients must accept **new (unknown) elements** in the response. E.g. unknown elements should be ignored. Also, **new error codes and warning codes** could be added as well. The client framework used by client must not crash when **unknown elements or new code values** are are encountered.

       When incompatible changes in the schema are made (other than addition of new elements), the namespace versioning will be updated accordingly. The new schema is used at the *same endpoint URL* as before for webservices. Old schema versions will be shut down some time in the future, so its recommended always updating to the latest version.

- title: Improve performance
  content: |
      To have better performance of the api

      * Request can be limited to have only the services needed since the response time of some services can be slow as compared to others
      * If the request is only to find the lead time / prices of different service, the flag for withExpectedDelivery / withPrices should be set to true and others can be set to false. In case of REST these are different endpoints.
      * For net prices requests should include customer number and correct package details
      * Request can include limited number of consignments in each request for quick response.
      * New shipments request can be part of separate request

/v2/products:
  displayName: Get shipment prices and estimated delivery
  description: Use this endpoint to get expected delivery, service categories and additional information.
  get:
    description: Get shipment prices
    headers:
      X-MyBring-API-Uid:
        description: Your Mybring login ID
      X-MyBring-API-Key:
        description: Your user's API key
      Accept:
        description: Specify request format (application/json, application/xml)
    queryParameters:
      fromcountry:
        description: Sender country code
        type: string
      tocountry:
        description: Receiver country code
        type: string
      frompostalcode:
        description: Sender postal code
        type: string
      topostalcode:
        description: Receiver postal code
        type: string
      product:
        description: List of services requested. Multiple services can be requested in a single request. Requested service can also be specified with a customer number separated with delimiter (**:**). For example CARGO**:**CARGO-123456
        type: string
      date:
        description: Shipping date
        type: date
        example: 2018-11-18
        required: false
      time:
        description: Shipping time
        type: date
        example: 12:30
        required: false
      weight:
        description: Package weight in grams
        type: integer
        required: false
      volumeindm3:
        description: Package volume in dm3
        type: integer
        required: false
      loadingmeter:
        description: Package loading meters
        type: double
        required: false
      width:
        description: Package width in cm
        type: integer
        required: false
      length:
        description: Package length in cm
        type: integer
        required: false
      height:
        description: Package height in cm
        type: integer
        required: false
      numberofpallets:
        displayName: Number of pallets
        type: integer
        required: false
      nonstackable:
        description: Set to true if you know that pallet would be non-stackable
        type: boolean
        required: false
        default: false
      edi:
        description: Tells if the parcel will be registered using EDI when being booked. It may affect price and which services are available
        type: boolean
        required: false
        default: true
      postingatpostoffice:
        description: |
          Tells whether the parcel is delivered at a post office when it is shipped. A surcharge will be applied for SERVICEPAKKE and BPAKKE_DOR-DOR
        type: boolean
        required: false
        default: false
      additionalservice:
        displayName: Additional service
        description: Multiple value added services can be requested by repeating this parameter
        required: false
        type: string
      customernumber:
        description: Lets you specify which customer number to use in the request. If specified and service is not supplied with delimited customer number, then it will be applied on all request services
        type: string
        example: CARGO-123456
        required: false
      language:
        description: Language used for the service texts
        type: string
        default: no
        required: false
      volumeSpecial:
        description: True if the package has a shape that requires special handling
        type: boolean
        default: false
        required: false
      incoterms:
        description: Terms of delivery
        type: string
        required: false
      unnumber:
        description: Code for dangerous goods
        type: integer
        required: false
      payer:
        description: Payer type. Possible values are SENDER, RECEIVER or THIRD_PARTY
        type: string
        required: false
      numberofdeliverydates:
        description: Number of alternative delivery dates to be suggested by API for request
        type: integer
        required: false

    responses:
      200:
        displayName: Successful response
        description: |
          A successful response
      400:
        displayName: User error
        description: |
          This can mean that a required field or parameter has not been provided, the value supplied is invalid, or the combination of provided fields is invalid.
      401:
        displayName: Unauthorized
        description: |
          A failed response when the request is unauthenticated

/v2/products/price:
  displayName: Get shipment prices
  description: |
      Use this endpoint to get prices. The request parameters are the same as for [Get shipment prices and estimated delivery](/api/shipping-guide_2/#get-shipment-prices-and-estimated-delivery)
  get:
    description: Use this endpoint to get price. The request parameters are the same as for [Get shipment prices and estimated delivery](/api/shipping-guide_v2/#get-shipment-prices-and-estimated-delivery)

/v2/products/expectedDelivery:
  displayName: Get expected delivery times
  description: |
      Use this endpoint to get expected delivery. The request parameters are the same as for [Get shipment prices and estimated delivery](/api/shipping-guide_2/#get-shipment-prices-and-estimated-delivery)
  get:
    description: Get estimated delivery time

/api/ws:
  displayName: Get shipment prices and estimated delivery
  description: Use this endpoint to get expected delivery, service categories and additional information.
  post:
    description: Use this endpoint to get expected delivery, service categories and additional information.
    headers:
      X-MyBring-API-Uid:
        description: Your Mybring login ID
      X-MyBring-API-Key:
        description: Your user's API key
      Accept:
        description: Specify request format (application/json, application/xml)

#%RAML 1.0
---
title: Shipping Guide API 2.0
baseUri: https://api.bring.com/shippingguide

documentation:
- title: Introduction
  content: |
      The Shipping Guide API 2.0 (Fraktguiden) for provides you with different shipping alternatives for your shipments. If you request applicable shipping alternatives with all relevant details you will receive an object with the following data:

      - Prices
      - Estimated delivery times
      - GUI information

      The API returns the recommended way to present these shipping alternatives, meaning that the actual response can easily be shown in a web-shop checkout without any sorting or filtering and with human readable service texts.

      The Shipping Guide API 2.0 has both a REST and a SOAP interface. The REST interface only supports single consignments, while the SOAP interface can be used for multiple consignments.

      ### Why upgrade?

      * [Unified request and response model](/api/shipping-guide_2/#getting-started): Due to backward compatibility, existing SOAP API versions had too many ways of requesting to Shipping Guide could be always confusing for clients. This has been simplified in the new version with one unified way of requesting to Shipping Guide.
      * [Better error handling for both SOAP and REST](/api/shipping-guide_2/#handle-api-errors): The new version of API gives ability to handle error in a much simpler way.
      * [Ability to fetch agreement prices specific to a service on REST](/api/shipping-guide_2/#get-shipment-prices-and-estimated-delivery): Now you can specify multiple services and along with multiple customer number in a single REST request. [How?](/api/shipping-guide_2/#get-shipment-prices-and-estimated-delivery)
      *  Some improvements to our service offering are planned for 2018-19. More info about upcoming changes will follow to all our partners. Future services will be supported by this new API-version in addition to other improvements. Note that our old versions of API’s will not support future changes in our service offering.

      ### How to upgrade
      Now that Shipping Guide API 2.0 is out you might be wondering how to upgrade to it. The [Upgrade to version 2.0](/api/shipping-guide_2/upgrade-to-version-2) will help you on your way to version 2.0 of the Shipping Guide API.

- title: Getting started
  content: |
      This guide will walk you through getting shipment alternatives for your first consignment using Shipping Guide API. In this example we will be calling the SOAP interface with a HTTP client and query for the service `SERVICEPAKKE` and `PA_DOREN` for two packages.

      ### Before you start
      Before you can begin using the new API you'll have to do the following:

      * [Sign up for a Mybring account](https://www.mybring.com/signup/register/user) if you do not already have one. If you're already registered in Mybring, head to the [settings and API](https://www.mybring.com/useradmin/account/settings/) page to get your API key.
      * [Generate an API key](/api/#authentication) for your user

      ### 1. Get your API key from Mybring
      To make API requests you will need an API key.

      To do this click the button below, which sends you to your "Settings and API" page in Mybring profile administration. Scroll down to the "API key" section. Your generated API key which you will use to authenticate your requests can be found here.

      Get API key

      ### 2. Add authentication headers
      A description of the headers can be found in [Getting Started / Authentication](/api/#authentication).

      ### 3. Add additional headers
      Since we're using the SOAP (1.1) interface we'll have to add the following header:

      - `Content-type: text/xml`

      Most SOAP libraries will do this for you.

      ### 4. Add the body to the request
      In this request we will query prices and expected delivery time for the service `SERVICEPAKKE` for a single package being sent from the postal code 0015 to 5518 in Norway.

      ```
      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                        xmlns:ns="http://www.bring.no/logistics/shippingguide/2.0">
          <soapenv:Header/>
          <soapenv:Body>
              <ns:ShippingGuideRequest xmlns:ns="http://www.bring.no/logistics/shippingguide/2.0">
                  <ns:Language>no</ns:Language>
                  <ns:WithPrice>true</ns:WithPrice>
                  <ns:WithExpectedDelivery>false</ns:WithExpectedDelivery>
                  <ns:WithGuiInformation>true</ns:WithGuiInformation>
                  <ns:NumberOfAlternativeDeliveryDates>0</ns:NumberOfAlternativeDeliveryDates>
                  <ns:EDI>true</ns:EDI>
                  <ns:PostingAtPostoffice>true</ns:PostingAtPostoffice>
                  <ns:Trace>true</ns:Trace>
                  <ns:Consignments>
                    <ns:Consignment id="101">
                        <ns:Products>
                            <ns:Product>
                                <ns:Id>SERVICEPAKKE</ns:Id>
                            </ns:Product>
                        </ns:Products>
                        <ns:FromCountryCode>NO</ns:FromCountryCode>
                        <ns:FromPostalCode>0015</ns:FromPostalCode>
                        <ns:ToCountryCode>NO</ns:ToCountryCode>
                        <ns:ToPostalCode>5518</ns:ToPostalCode>
                        <ns:ShippingDate>
                            <ns:Year>2016</ns:Year>
                            <ns:Month>10</ns:Month>
                            <ns:Day>10</ns:Day>
                            <ns:Hour>10</ns:Hour>
                            <ns:Minute>0</ns:Minute>
                        </ns:ShippingDate>
                        <ns:AdditionalServices>
                            <ns:AdditionalService>
                                <ns:Id>EVARSLING</ns:Id>
                            </ns:AdditionalService>
                            <ns:AdditionalService>
                                <ns:Id>POSTOPPKRAV</ns:Id>
                            </ns:AdditionalService>
                        </ns:AdditionalServices>
                        <ns:Packages>
                            <ns:Package id="10">
                                <ns:Height>10</ns:Height>
                                <ns:Width>10</ns:Width>
                                <ns:Length>10</ns:Length>
                                <ns:GrossWeight>50</ns:GrossWeight>
                            </ns:Package>
                            <ns:Package id="11">
                                <ns:Height>10</ns:Height>
                                <ns:Width>10</ns:Width>
                                <ns:Length>10</ns:Length>
                                <ns:GrossWeight>50</ns:GrossWeight>
                            </ns:Package>
                            <ns:Package id="12">
                                <ns:Height>11</ns:Height>
                                <ns:Width>10</ns:Width>
                                <ns:Length>10</ns:Length>
                                <ns:GrossWeight>50</ns:GrossWeight>
                            </ns:Package>
                        </ns:Packages>
                    </ns:Consignment>
                  </ns:Consignments>
              </ns:ShippingGuideRequest>
          </soapenv:Body>
      </soapenv:Envelope>
      ```

      ### 5. Submit the request

      Post your request to

      ```

        https://api.bring.com/shippingguide/api/ws

      ```

      The response may have changed since it was documented but you will get a response that looks something like this:

      ```
      <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
          <SOAP-ENV:Header/>
          <SOAP-ENV:Body>
              <ns2:ShippingGuideResponse xmlns:ns2="http://www.bring.no/logistics/shippingguide/2.0">
                  <ns2:Consignments>
                      <ns2:Consignment consignmentId="101">
                          <ns2:Products>
                              <ns2:Product>
                                  <ns2:Id>SERVICEPAKKE</ns2:Id>
                                  <ns2:ProductionCode>1202</ns2:ProductionCode>
                                  <ns2:GuiInformation>
                                      <ns2:SortOrder>11</ns2:SortOrder>
                                      <ns2:MainDisplayCategory>Pakke</ns2:MainDisplayCategory>
                                      <ns2:SubDisplayCategory>Til private</ns2:SubDisplayCategory>
                                      <ns2:DisplayName>Klimanøytral Servicepakke</ns2:DisplayName>
                                      <ns2:ProductName>Klimanøytral Servicepakke</ns2:ProductName>
                                      <ns2:DescriptionText>Pakken kan spores og utleveres på ditt lokale hentested.</ns2:DescriptionText>
                                      <ns2:HelpText>Klimanøytral Servicepakke leveres til mottakers lokale hentested (postkontor eller Post i Butikk). Mottaker kan velge å hente sendingen på et annet hentested enn sitt lokale. Mottaker varsles om at sendingen er ankommet via SMS, e-post eller hentemelding i postkassen. Sendingen kan spores ved hjelp av sporingsnummeret.</ns2:HelpText>
                                      <ns2:ShortName>Klimanøytral Servicepakke</ns2:ShortName>
                                      <ns2:ProductURL>http://www.bring.no/sende/pakker/private-i-norge/hentes-pa-posten</ns2:ProductURL>
                                      <ns2:DeliveryType>Hentested</ns2:DeliveryType>
                                      <ns2:MaxWeightInKgs>35</ns2:MaxWeightInKgs>
                                  </ns2:GuiInformation>
                                  <ns2:Price>
                                      <ns2:ListPrice currencyCode="NOK">
                                          <ns2:PriceWithoutAdditionalServices>
                                              <ns2:AmountWithoutVAT>239.00</ns2:AmountWithoutVAT>
                                              <ns2:VAT>59.75</ns2:VAT>
                                              <ns2:AmountWithVAT>298.75</ns2:AmountWithVAT>
                                          </ns2:PriceWithoutAdditionalServices>
                                          <ns2:PriceWithAdditionalServices>
                                              <ns2:AmountWithoutVAT>239.00</ns2:AmountWithoutVAT>
                                              <ns2:VAT>59.75</ns2:VAT>
                                              <ns2:AmountWithVAT>298.75</ns2:AmountWithVAT>
                                          </ns2:PriceWithAdditionalServices>
                                      </ns2:ListPrice>
                                  </ns2:Price>
                                  <ns2:ExpectedDelivery>
                                      <ns2:WorkingDays>2</ns2:WorkingDays>
                                      <ns2:UserMessage/>
                                      <ns2:FormattedExpectedDeliveryDate>12.10.2018</ns2:FormattedExpectedDeliveryDate>
                                      <ns2:ExpectedDeliveryDate>
                                          <ns2:Year>2018</ns2:Year>
                                          <ns2:Month>10</ns2:Month>
                                          <ns2:Day>12</ns2:Day>
                                      </ns2:ExpectedDeliveryDate>
                                      <ns2:AlternativeDeliveryDates/>
                                  </ns2:ExpectedDelivery>
                              </ns2:Product>
                              <ns2:Product>
                                  <ns2:Id>PA_DOREN</ns2:Id>
                                  <ns2:ProductionCode>1736</ns2:ProductionCode>
                                  <ns2:GuiInformation>
                                      <ns2:SortOrder>41</ns2:SortOrder>
                                      <ns2:MainDisplayCategory>Pakke</ns2:MainDisplayCategory>
                                      <ns2:SubDisplayCategory>Til private</ns2:SubDisplayCategory>
                                      <ns2:DisplayName>På Døren</ns2:DisplayName>
                                      <ns2:ProductName>På Døren</ns2:ProductName>
                                      <ns2:DescriptionText>Pakken kan spores og leveres hjem til deg mellom kl. 17-21. Sjåføren ringer 30-60 min før ankomst.</ns2:DescriptionText>
                                      <ns2:HelpText>På Døren leveres hjem til mottaker mellom kl. 17 og 21. Mottaker varsles i god tid om forventet utleveringsdag via SMS eller e-post, i tillegg til nytt varsel når sendingen er lastet på bil for utkjøring samme kveld. Sjåføren ringer mottaker 30-60 minutter før ankomst. Mottaker kan endre leveringsdag når pakken spores (gjelder ikke lokalpakker). Dersom sendingen ikke kan leveres, blir den sendt til mottakers lokale hentested (postkontor eller Post i Butikk). Sendingen kan spores ved hjelp av sporingsnummeret.</ns2:HelpText>
                                      <ns2:ShortName>På Døren</ns2:ShortName>
                                      <ns2:ProductURL>http://www.bring.no/sende/pakker/private-i-norge/hjemlevering</ns2:ProductURL>
                                      <ns2:DeliveryType>Dør</ns2:DeliveryType>
                                      <ns2:MaxWeightInKgs>35</ns2:MaxWeightInKgs>
                                  </ns2:GuiInformation>
                                  <ns2:Price>
                                      <ns2:ListPrice currencyCode="NOK">
                                          <ns2:PriceWithoutAdditionalServices>
                                              <ns2:AmountWithoutVAT>270.00</ns2:AmountWithoutVAT>
                                              <ns2:VAT>67.50</ns2:VAT>
                                              <ns2:AmountWithVAT>337.50</ns2:AmountWithVAT>
                                          </ns2:PriceWithoutAdditionalServices>
                                          <ns2:PriceWithAdditionalServices>
                                              <ns2:AmountWithoutVAT>270.00</ns2:AmountWithoutVAT>
                                              <ns2:VAT>67.50</ns2:VAT>
                                              <ns2:AmountWithVAT>337.50</ns2:AmountWithVAT>
                                          </ns2:PriceWithAdditionalServices>
                                      </ns2:ListPrice>
                                  </ns2:Price>
                                  <ns2:Warnings>
                                      <ns2:Warning>
                                          <ns2:code>NO_EXPECTED_DELIVERY</ns2:code>
                                          <ns2:description>Expected delivery date is not available</ns2:description>
                                      </ns2:Warning>
                                  </ns2:Warnings>
                              </ns2:Product>
                          </ns2:Products>
                      </ns2:Consignment>
                  </ns2:Consignments>
              </ns2:ShippingGuideResponse>
          </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>
      ```

      If you want to know more about the fields you can have a look at the XSD linked from the section [Request and response structure](/api/shipping-guide_2/#request-and-response-structure)

- title: Shipping Guide topics
  content: |
      If you want to know more about corner cases/topics/etc, then [Let's talk about Shipping Guide](/api/shipping-guide_2/topics)

- title: Handle API errors
  content: |
      When using the Shipping Guide it is important to handle errors gracefully. Your users should still be able to order even if the Shipping Guide API returns an error or if there is an error establishing a connection to the API.

      The Shipping Guide API return two levels of error information:

      * HTTP error codes or SOAP fault with a message in the body

        For REST we follow general convention of HTTP status codes.
        For SOAP we give out detailed error decription along with an error code which can be parsed programmatically.

        ```
        <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
            <SOAP-ENV:Header/>
            <SOAP-ENV:Body>
                <SOAP-ENV:Fault>
                    <faultcode>SOAP-ENV:Client</faultcode>
                    <faultstring>FG_INPUT_010 Number of alternative delivery dates must be numeric and less than 10 [errorId 2806bbda-1df0-4b1b-b008-1068f5c57f06]
                    </faultstring>
                    <detail>
                        <code>FG_INPUT_010</code>
                        <description>Error number of alternative deliverydates</description>
                    </detail>
                </SOAP-ENV:Fault>
            </SOAP-ENV:Body>
        </SOAP-ENV:Envelope>
        ```

        Possible error codes can be found [here](https://api.bring.com/shippingguide/api/errors?clientUrl=developer.bring.com)

      * An error object in the response that is on service level

        When we are not able to process one of the service requested, we will respond with a error on service level. Details of possible error codes are documented in [XSD](https://api.bring.com/shippingguide/api/ws/shipping-guide-20.xsd) and [WDSL](https://api.bring.com/shippingguide/api/ws/shippingguide-20.wsdl) itself, making it easier for clients to parse it.

- title: Request and response structure
  content: |
      If you request shipping alternatives via the API your request and response will have to comply with the following schemas:

      #### SOAP

      [https://api.bring.com/shippingguide/api/ws/shipping-guide-20.xsd](https://api.bring.com/shippingguide/api/ws/shipping-guide-20.xsd)

      [https://api.bring.com/shippingguide/api/ws/shippingguide-20.wsdl](https://api.bring.com/shippingguide/api/ws/shippingguide-20.wsdl)

- title: Versioning
  content: |
       The Shipping Guide makes an effort to always be backwards compatible regarding data format for requests and responses. To achieve this, namespace schema versioning is used in the request for webservices, indicating which version the client is on and what data-format the client expects in the result. For REST, versioning is defined as part of endpoint itself.

       **Important**: All clients must accept **new (unknown) elements** in the response. E.g. unknown elements should be ignored. Also, **new error codes and warning codes** could be added as well. The client framework used by client must not crash when **unknown elements or new code values** are are encountered.

       When incompatible changes in the schema are made (other than addition of new elements), the namespace versioning will be updated accordingly. The new schema is used at the *same endpoint URL* as before for webservices. Old schema versions will be shut down some time in the future, so its recommended always updating to the latest version.

- title: Improve performance
  content: |
      To have better performance of the api

      * Request can be limited to have only the services needed since the response time of some services can be slow as compared to others
      * If the request is only to find the lead time / prices of different service, the flag for withExpectedDelivery / withPrices should be set to true and others can be set to false. In case of REST these are different endpoints.
      * For net prices requests should include customer number and correct package details
      * Request can include limited number of consignments in each request for quick response.
      * New shipments request can be part of separate request

/v2/products:
  displayName: Get shipment prices and estimated delivery
  description: Use this endpoint to get expected delivery, service categories and additional information.
  get:
    description: Get shipment prices
    headers:
      X-MyBring-API-Uid:
        description: Your Mybring login ID
      X-MyBring-API-Key:
        description: Your user's API key
      Accept:
        description: Specify request format (application/json, application/xml)
    queryParameters:
      fromcountry:
        description: Sender country code
        type: string
      tocountry:
        description: Receiver country code
        type: string
      frompostalcode:
        description: Sender postal code
        type: string
      topostalcode:
        description: Receiver postal code
        type: string
      product:
        description: List of services requested. Multiple services can be requested in a single request. Requested service can also be specified with a customer number separated with delimiter (**:**). For example CARGO**:**CARGO-123456
        type: string
      date:
        description: Shipping date
        type: date
        example: 2018-11-18
        required: false
      time:
        description: Shipping time
        type: date
        example: 12:30
        required: false
      weight:
        description: Package weight in grams
        type: integer
        required: false
      volumeindm3:
        description: Package volume in dm3
        type: integer
        required: false
      loadingmeter:
        description: Package loading meters
        type: double
        required: false
      width:
        description: Package width in cm
        type: integer
        required: false
      length:
        description: Package length in cm
        type: integer
        required: false
      height:
        description: Package height in cm
        type: integer
        required: false
      numberofpallets:
        displayName: Number of pallets
        type: integer
        required: false
      nonstackable:
        description: Set to true if you know that pallet would be non-stackable
        type: boolean
        required: false
        default: false
      edi:
        description: Tells if the parcel will be registered using EDI when being booked. It may affect price and which services are available
        type: boolean
        required: false
        default: true
      postingatpostoffice:
        description: |
          Tells whether the parcel is delivered at a post office when it is shipped. A surcharge will be applied for SERVICEPAKKE and BPAKKE_DOR-DOR
        type: boolean
        required: false
        default: false
      additionalservice:
        displayName: Additional service
        description: Multiple value added services can be requested by repeating this parameter
        required: false
        type: string
      customernumber:
        description: Lets you specify which customer number to use in the request. If specified and service is not supplied with delimited customer number, then it will be applied on all request services
        type: string
        example: CARGO-123456
        required: false
      language:
        description: Language used for the service texts
        type: string
        default: no
        required: false
      volumeSpecial:
        description: True if the package has a shape that requires special handling
        type: boolean
        default: false
        required: false
      incoterms:
        description: Terms of delivery
        type: string
        required: false
      unnumber:
        description: Code for dangerous goods
        type: integer
        required: false
      payer:
        description: Payer type. Possible values are SENDER, RECEIVER or THIRD_PARTY
        type: string
        required: false
      numberofdeliverydates:
        description: Number of alternative delivery dates to be suggested by API for request
        type: integer
        required: false

    responses:
      200:
        displayName: Successful response
        description: |
          A successful response
      400:
        displayName: User error
        description: |
          This can mean that a required field or parameter has not been provided, the value supplied is invalid, or the combination of provided fields is invalid.
      401:
        displayName: Unauthorized
        description: |
          A failed response when the request is unauthenticated

/v2/products/price:
  displayName: Get shipment prices
  description: |
      Use this endpoint to get prices. The request parameters are the same as for [Get shipment prices and estimated delivery](/api/shipping-guide_2/#get-shipment-prices-and-estimated-delivery)
  get:
    description: Use this endpoint to get price. The request parameters are the same as for [Get shipment prices and estimated delivery](/api/shipping-guide_v2/#get-shipment-prices-and-estimated-delivery)

/v2/products/expectedDelivery:
  displayName: Get expected delivery times
  description: |
      Use this endpoint to get expected delivery. The request parameters are the same as for [Get shipment prices and estimated delivery](/api/shipping-guide_2/#get-shipment-prices-and-estimated-delivery)
  get:
    description: Get estimated delivery time

/api/ws:
  displayName: Get shipment prices and estimated delivery
  description: Use this endpoint to get expected delivery, service categories and additional information.
  post:
    description: Use this endpoint to get expected delivery, service categories and additional information.
    headers:
      X-MyBring-API-Uid:
        description: Your Mybring login ID
      X-MyBring-API-Key:
        description: Your user's API key
      Accept:
        description: Specify request format (application/json, application/xml)


Update currency.raml

Update currency.raml

#%RAML 1.0
---
title: Currency API
baseUri: http://localhost:8081/api/

/currencies:
  get:
    responses:
      200:
        description: Retrieve the list of currencies and their USD to conversion rate.
        body:
          application/json:
            schema: !include currency-schema.json

#%RAML 0.8
---
title: Currency API
baseUri: http://localhost:8081/api/

/currencies:
  get:
    responses:
      200:
        description: Retrieve the list of currencies and their USD to conversion rate.
        body:
          application/json:
            schema: !include currency-schema.json


Added tested flag

Added tested flag

is: [ auth ]
type:
  collection:
    humanName: event type
    schemaBaseName: eventType
    exampleGetResponse: !include ../examples/eventTypes/response-array-get.json
    examplePostRequest: !include ../examples/eventTypes/request-post.json
    examplePostError: !include ../examples/eventTypes/response-post-error.json
get:
  securedBy: [ jwt: { type: 'owner' }, test ]
  description: |
    You cannot retrieve all the event types accross all the event source templates. You **MUST** provide
    the `eventSourceTemplateId` to get all the event types from it.
  queryParameters:
    eventSourceTemplateId:
      description: |
        Filter the event type by event source template.

        The user **MUST** be a member of the organization where the event source template is defined.
      type: integer
      required: true
      example: |
        `eventSourceTemplateId=1`
  responses:
    200:
      description: List of event types or empty list `[]`.
    422:
      description: If the `eventSourceTemplateId` is not provided.
    403:
      description: If the user is not a member of the organization that owns the event source template or not found.
post:
  securedBy: [ jwt: { type: 'owner' }, test ]
  responses:
    403:
      description: If the user is not a member of the organization that owns the event source template.

/{eventTypeId}:
  is: [ auth ]
  type:
    member:
      humanName: event types
      schemaBaseName: eventType
      identifierName: eventTypeId
      exampleGetResponse: !include ../examples/eventTypes/response-get.json
      examplePatchRequest: !include ../examples/eventTypes/request-patch.json
      examplePatchError: !include ../examples/eventTypes/response-patch-error.json
  get:
    securedBy: [ jwt: { type: 'owner' }, test ]
    responses:
      403:
        description: If the user is not a member of the organization that owns the event source template.
  patch:
    securedBy: [ jwt: { type: 'owner' }, test ]
    responses:
      403:
        description: If the user is not a member of the organization that owns the event source template.

is: [ auth ]
type:
  collection:
    humanName: event type
    schemaBaseName: eventType
    exampleGetResponse: !include ../examples/eventTypes/response-array-get.json
    examplePostRequest: !include ../examples/eventTypes/request-post.json
    examplePostError: !include ../examples/eventTypes/response-post-error.json
get:
  securedBy: [ jwt: { type: 'owner' } ]
  description: |
    You cannot retrieve all the event types accross all the event source templates. You **MUST** provide
    the `eventSourceTemplateId` to get all the event types from it.
  queryParameters:
    eventSourceTemplateId:
      description: |
        Filter the event type by event source template.

        The user **MUST** be a member of the organization where the event source template is defined.
      type: integer
      required: true
      example: |
        `eventSourceTemplateId=1`
  responses:
    200:
      description: List of event types or empty list `[]`.
    422:
      description: If the `eventSourceTemplateId` is not provided.
    403:
      description: If the user is not a member of the organization that owns the event source template or not found.
post:
  securedBy: [ jwt: { type: 'owner' } ]
  responses:
    403:
      description: If the user is not a member of the organization that owns the event source template.

/{eventTypeId}:
  is: [ auth ]
  type:
    member:
      humanName: event types
      schemaBaseName: eventType
      identifierName: eventTypeId
      exampleGetResponse: !include ../examples/eventTypes/response-get.json
      examplePatchRequest: !include ../examples/eventTypes/request-patch.json
      examplePatchError: !include ../examples/eventTypes/response-patch-error.json
  get:
    securedBy: [ jwt: { type: 'owner' } ]
    responses:
      403:
        description: If the user is not a member of the organization that owns the event source template.
  patch:
    securedBy: [ jwt: { type: 'owner' } ]
    responses:
      403:
        description: If the user is not a member of the organization that owns the event source template.


fixing syntax

fixing syntax

#%RAML 1.0
title: Jetlag Articles API
version: v0.1
baseUri: /api/0.1/
mediaType:  application/json

types:
  Article : !include articles.raml
/articles:
  get:
    description: Get all articles authored (owned or writable) by the logged in user. Limited to 20 results (to be configurable). The content should be enough to display a list of articles (not their full content).
    responses:
      200:
        body:
          application/json:
            type: Article
  post:
    description: Creates a new article as logged in user
    body:
      application/json:
        type: Article
    responses:
      201:
        body:
          application/json:
            properties:
              id: number
              url: string
  /{articleId}:
    get:
      description: Return JSON description of the article
      responses:
        200:
          body:
            application/json:
              type: Article
    put:
      description: Update the entire article and its components
      body:
        application/json:
          type: Article
      responses:
        200:
          body:
            application/json:
              properties:
                id: number
    patch:
      description: Update partially the article and its components
      body:
        application/json:
          type: Article
      responses:
        200:
          body:
            application/json:
              properties:
                id: number
    delete:
      description: Delete (soft) article. The logged in user must be the article's owner.
      responses:
        200:
          body:
            application/json:
              properties:
                id: number

#%RAML 1.0
title: Jetlag Articles API
version: v0.1
baseUri: /api/0.1/
mediaType:  application/json
types:
resourceTypes:
traits:
/articles:
  get:
    description: Get all articles authored (owned or writable) by the logged in user. Limited to 20 results (to be configurable). The content should be enough to display a list of articles (not their full content).
    responses:
      200:
        body:
          application/json:
            schema: article
  post:
    description: Creates a new article as logged in user
    body:
      application/json
        schema: article
    responses:
      201:
        body:
          application/json:
            id: number
            url: string
  /{articleId}:
    get:
      description: Return JSON description of the article
      responses:
        200:
          body:
            application/json:
              schema: article
    put:
      description: Update the entire article and its components
      body:
        application/json
          schema: article
      responses:
        200:
          body:
            application/json:
              id: number
    patch:
      description: Update partially the article and its components
      body:
        application/json
          schema: article
      responses:
        200:
          body:
            application/json:
              id: number
    delete:
      description: Delete (soft) article. The logged in user must be the article's owner.
      responses:
        200:
          body:
            application/json:
              id: number


Updating list of invoice issuers, types applicable

#%RAML 1.0
---
title: Invoice API
baseUri: https://www.mybring.com/invoicearchive
types:
  Invoices:
    type: object
    properties:
      customerNumber:
        type: string
        required: false
        description: Represents a customerNumber
      invoiceNumber:
        type: string
        required: true
        description: Represents a invoiceNumber
      invoiceDate:
        type: string
        required: true
        description: Represents a invoice date
      invoiceIssuer:
        type: string
        required: false
        description: Represents the invoice issuer
      status:
        type: string
        required: false
        description: Represents the invoice status
      totalAmount:
        type: string
        required: false
        description: Represents the invoice total amount
      currency:
        type: string
        required: false
        description: Represents the currency used in invoice
      type:
        type: string
        required: false
        description: Represents the invoice or credit note
      dueDate:
        type: string
        required: false
        description: Represents the invoice due date
      attachmentCount:
        type: number
        required: false
        description: Represents the number of attachments associated with invoice number
      batchSource:
        type: string
        required: true
        description: Represents the invoice generated source
      invoiceSpecificationAvailable:
        type: boolean
        required: false
        description: Represents the invoice specification report available or not
      parentInvoiceNumber:
        type: string
        required: false
        description: Represents the parent invoice number

documentation:
- title: Introduction
  content: |
      The invoice API is used to list invoices and download the invoice pdfs same as in Mybring.

      ### Before you start
      Before you can begin using the new API you'll have to do the following:

      * [Sign up for a Mybring account](https://www.mybring.com/signup/register/user) if you do not already have one. If you're already registered in Mybring, head to the [settings and API](https://www.mybring.com/useradmin/account/settings/api) page to get your API key.
      * [Generate an API key](/api/#authentication) for your user

      ### Get your API key from Mybring
      To make API requests you will need an API key. Click the link below, which sends you to your "Settings and API" page in Mybring profile administration. Scroll down to the "API key" section. Your generated API key which you will use to authenticate your requests can be found here.

      Get API key

      ### Add authentication headers
      A description of the headers can be found in [Getting Started / Authentication](/api/#authentication).

/invoicearchive/api/invoices/{apiCustomerNumber}{mediaTypeExtension}:
  displayName: List of all Invoices
  description: Gets the list of invoices corresponding to the given customer number.
               By default it shows last 65 days of invoices, with the possibilty to access last 365 days by providing "fromDate" and "toDate".
               This endpoint supports Parcel Domestic, Parcel International and Cargo customers.
  uriParameters:
    apiCustomerNumber:
      enum: [ Main customer number, PARCELS_NORWAY_INTERNATIONAL-xxxxx,PARCELS_SWEDEN-xxxxx,PARCELS_DENMARK-xxxxx,PARCELS_FINLAND-xxxxx,EXPRESS_SWEDEN-xxxxx,EXPRESS_NORWAY-xxxxx,EXPRESS_DENMARK-xxxxx,EXPRESS_FINLAND-xxxxx]
      description: Unique API Customer Number.
    mediaTypeExtension:
      enum: [ .json, .xml ]
      description: Use .json to specify application/json or .xml to specify application/xml
  get:
    description: List of invoices
    headers:
      X-MyBring-API-Uid:
        description: Your Mybring login ID
      X-MyBring-API-Key:
        description: Your user's API key
      X-Bring-Client-URL:
        description: A URL that sort of identifies where you're using the APIs.
    queryParameters:
      fromDate:
        description: Start date for fetching invoices in format dd.mm.yyyy.
        type: string
        required: false
        example: 15.01.2020
      toDate:
        description: End date for fetching invoices in format dd.mm.yyyy.
        type: string
        required: false
        example: 25.01.2020
    responses:
      200:
        displayName: Successful response
        description: |
          The shipment is invoiced based on invoice source and issuer. Here are a list of supported invoice issuers that can be returned.

          | Invoice issuer | Description |
          |:-------|:--------|
          | `BRING_CARGO_AS` | `Bring Cargo AS` |
          | `BRING_LINEHAUL_AS` | `Bring Linehaul AS` |
          | `BRING_FRIGO_AS` | `Bring Frigo AS` |
          | `BRING_POLARBASE_AS` | `Bring Polarbase AS` |
          | `BRING_WAREHOUSING_AS` | `Bring Warehousing AS` |
          | `BRING_CARGO_INTERNATIONAL_NORGE_AS` | `Bring Cargo International Norge AS` |
          | `BRING_TRANSPORTLØSNINGER_AS` | `Bring Transportløsninger AS` |
          | `POSTEN_EIENDOM_ROBSRUD_AS` | `Posten Eiendom Robsrud AS` |
          | `POSTEN_EIENDOM_ALNABRU_AS` | `Posten Eiendom Alnabru AS` |
          | `POSTEN_EIENDOM_VESTFOLD_AS` | `Posten Eiendom Vestfold AS` |
          | `POSTEN_EIENDOM_BERGEN_AS` | `Posten Eiendom Bergen AS` |
          | `POSTEN_EIENDOM_AS` | `Posten Eiendom AS` |
          | `POSTEN_EIENDOM_ALNABRU_UTVIKLING_AS` | `Posten Eiendom Alnabru Utvikling AS` |
          | `POSTEN_EIENDOM_BODØ_AS` | `Posten Eiendom Bodø AS` |
          | `POSTEN_EIENDOM_SVANHOLMEN_AS` | `Posten Eiendom Svanholmen AS` |
          | `POSTEN_EIENDOM_MOLDE_AS` | `Posten Eiendom Molde AS` |
          | `POSTEN_EIENDOM_TROMSØ_AS` | `Posten Eiendom Tromsø AS` |
          | `POSTEN_EIENDOM_NARVIK_AS` | `Posten Eiendom Narvik AS` |
          | `POSTEN_EIENDOM_STAVANGER_AS` | `Posten Eiendom Stavanger AS` |
          | `POSTEN_EIENDOM_TRONDHEIM_AS` | `Posten Eiendom Trondheim AS` |
          | `BRING_EIENDOM_HAUGESUND_AS` | `Bring Eiendom Haugesund AS` |
          | `POSTEN_NORGE_AS` | `Posten Norge AS` |
          | `POSTEN_NORGE_AS_FOR_CARGO_SEA` | `Posten Norge AS` |
          | `OTHER` | `Other` |

          Here are a list of invoice types that can be returned.

          | Invoice Source |
          |:-------|
          | `INVOICE` |
          | `CREDIT_NOTE` |
          | `DEBIT_NOTE` |
          | `DEPOSIT` |
          | `OTHER` |

        body:
          application/json:
            type: Invoices
            examples:
              successful:
                displayName: Successful
                description: The example below shows an list of invoices
                value: !include example/list_invoices.json
          application/xml:
            type: Invoices
            examples:
              successful:
                displayName: Successful
                description: The example below shows an list of invoices
                value: !include example/list_invoices.xml

/invoicearchive/pdf/{apiCustomerNumber}/{invoiceNumber}.pdf:
  displayName: Invoice PDF download endpoint
  description: This link is used to download the invoice pdf for the customers by providing API customer number and invoice number in URI params.
  uriParameters:
    apiCustomerNumber:
      description: Unique API Customer Number for each customer.
    invoiceNumber:
      description: Invoice number of the particular invoice to be downloaded.
  get:
    description: Download pdf for invoice

#%RAML 1.0
---
title: Invoice API
baseUri: https://www.mybring.com/invoicearchive
types:
  Invoices:
    type: object
    properties:
      customerNumber:
        type: string
        required: false
        description: Represents a customerNumber
      invoiceNumber:
        type: string
        required: true
        description: Represents a invoiceNumber
      invoiceDate:
        type: string
        required: true
        description: Represents a invoice date
      invoiceIssuer:
        type: string
        required: false
        description: Represents the invoice issuer
      status:
        type: string
        required: false
        description: Represents the invoice status
      totalAmount:
        type: string
        required: false
        description: Represents the invoice total amount
      currency:
        type: string
        required: false
        description: Represents the currency used in invoice
      type:
        type: string
        required: false
        description: Represents the invoice or credit note
      dueDate:
        type: string
        required: false
        description: Represents the invoice due date
      attachmentCount:
        type: number
        required: false
        description: Represents the number of attachments associated with invoice number
      batchSource:
        type: string
        required: true
        description: Represents the invoice generated source
      invoiceSpecificationAvailable:
        type: boolean
        required: false
        description: Represents the invoice specification report available or not
      parentInvoiceNumber:
        type: string
        required: false
        description: Represents the parent invoice number

documentation:
- title: Introduction
  content: |
      The invoice API is used to list invoices and download the invoice pdfs same as in Mybring.

      ### Before you start
      Before you can begin using the new API you'll have to do the following:

      * [Sign up for a Mybring account](https://www.mybring.com/signup/register/user) if you do not already have one. If you're already registered in Mybring, head to the [settings and API](https://www.mybring.com/useradmin/account/settings/api) page to get your API key.
      * [Generate an API key](/api/#authentication) for your user

      ### Get your API key from Mybring
      To make API requests you will need an API key. Click the link below, which sends you to your "Settings and API" page in Mybring profile administration. Scroll down to the "API key" section. Your generated API key which you will use to authenticate your requests can be found here.

      Get API key

      ### Add authentication headers
      A description of the headers can be found in [Getting Started / Authentication](/api/#authentication).

/invoicearchive/pdf/{customerNumberUnique}/{invoiceNumber}.pdf:
  displayName: Invoice PDF download endpoint
  description: This link is used to download the invoice pdf for the customers by providing API Customer Id and invoice number in URI params.
  uriParameters:
    customerNumberUnique:
      description: Unique API Customer Number for each customer.
    invoiceNumber:
      description: Invoice number of the particular invoice to be downloaded.
  get:
    description: Download pdf for invoice

/invoicearchive/api/invoices/{customerNumberUnique}{mediaTypeExtension}:
  displayName: List of all Invoices
  description: Gets the list of invoices corresponding to the given customer number.
               By default it shows last 65 days of invoices, with the possibilty to access last 365 days by providing "fromDate" and "toDate".
               This endpoint supports Parcel Domestic, Parcel International and Cargo customers.
  uriParameters:
    customerNumberUnique:
      enum: [ Main customer number, PARCELS_NORWAY_INTERNATIONAL-xxxxx,PARCELS_SWEDEN-xxxxx,PARCELS_DENMARK-xxxxx,PARCELS_FINLAND-xxxxx,EXPRESS_SWEDEN-xxxxx,EXPRESS_NORWAY-xxxxx,EXPRESS_DENMARK-xxxxx,EXPRESS_FINLAND-xxxxx]
      description: Unique API Customer Number.
    mediaTypeExtension:
      enum: [ .json, .xml ]
      description: Use .json to specify application/json or .xml to specify application/xml
  get:
    description: List of invoices
    headers:
      X-MyBring-API-Uid:
        description: Your Mybring login ID
      X-MyBring-API-Key:
        description: Your user's API key
      X-Bring-Client-URL:
        description: A URL that sort of identifies where you're using the APIs.
    queryParameters:
      fromDate:
        description: Start date for fetching invoices in format dd.mm.yyyy.
        type: string
        required: false
        example: 15.01.2019
      toDate:
        description: End date for fetching invoices in format dd.mm.yyyy.
        type: string
        required: false
        example: 25.01.2019
    responses:
      200:
        displayName: Successful response
        description: |
        body:
          application/json:
            type: Invoices
            examples:
              successful:
                displayName: Successful
                description: The example below shows an list of invoices
                value: !include example/list_invoices.json
          application/xml:
            type: Invoices
            examples:
              successful:
                displayName: Successful
                description: The example below shows an list of invoices
                value: !include example/list_invoices.xml


Updated correct url reports -> report

Updated correct url reports -> report

#%RAML 0.8
---
title: Reports API
baseUri: https://www.mybring.com/reports/api

documentation:
- title: Introduction
  content: |
    The Reports API is used to generate shipment reports, the same set of reports that are available in mybring.

    Each Mybring user is associated with a set of customers and has access to specific set of report types for which they can generate a report.

    The following steps (which will be API calls) enables you to generate a report:

    1. Get the customers associated with the mybring user.
    2. Get the report types allowed for a customer.
    3. Initiate report creation and get report ID. The Report ID is initially used to monitor reports creation progress, later to get the actual report (XML or Excel file).
    4. After initiating report creation, you can check the status if the job. I.e. if it is in progress, completed or failed. When status is completed, a URL for fetching the actual report is returned.
    5. The report can then be downloaded.

    For all the above APIs we need to identify and authenticate the user. This is done by passing the following header information. These are described in Reference section:

    - Mybring username (email address)
    - API Key

    All these APIs are available in json and xml formats.

- title: How to use
  content: |
    The Reports API is a logged-in service and you need to get an API-key and authenticate before being able to use the API.

    The two first steps in the process is only necessary to find customer numbers and report types for the user. You can save these IDs, and perform the generation-step without verifying the IDs. The response may get added information, so implementation should ignore new elements added to the response.

    1. Get customer IDs
    2. Get list of available reports
    3. Generate report
    4. Check status of report
    5. Download report
    6. Get list of invoice numbers for given customer or group

- title: Authentication
  content: |
    The Reports 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.

/generate{mediaTypeExtension}:
  displayName: List available customers
  description: |
    List available customers for the provided API credentials.
  uriParameters:
    mediaTypeExtension:
      enum: [ .json, .xml ]
      description: Use .json to specify application/json or .xml to specify application/xml
  get:
    description: List available customers
    headers:
      Accept-Language:
        description: A comma-separated list of language codes, `no` for Norwegian, `en` for English, etc.
        type: string
        required: false
    responses:
      200:
        displayName: Successful response
        body:
          application/json:
            example: !include examples/list_customers.json
          application/xml:
            example: !include examples/list_customers.xml

/generate/{customerId}{mediaTypeExtension}:
  displayName: List available reports for a customer
  description: |
    Each customer has a set of reports available. This endpoint lists all available reports for a given customer.
  uriParameters:
    customerId:
      description: A customer ID from the 'list of available customers' call.
      type: string
      required: true
    mediaTypeExtension:
      enum: [ .json, .xml ]
      description: Use .json to specify application/json or .xml to specify application/xml
  get:
    description: List available reports for a customer
    headers:
      Accept-Language:
        description: A comma-separated list of language codes, `no` for Norwegian, `en` for English, etc.
        type: string
        required: false
    responses:
      200:
        displayName: Successful response
        body:
          application/json:
            example: !include examples/list_reports.json
          application/xml:
            example: !include examples/list_reports.xml

/generate/{customerId}/{reportTypeId}{mediaTypeExtension}:
  displayName: Generate a report
  description: |
    To generate a report do a GET to the supplied URL, and include the parameters described in the previous response. You need not invoke the two first steps for every report generation if customer id and report type are known.

    This is asynchronous request. So the GET-call will return 202, telling the caller the that the request for a report is put on the queue. The URL to query to get the status for the request if provided as an HTTP header and also in the response.

    The example below shows how to generate a PARCELS-DELIVERED report for PARCELS_NORWAY-00012341234 in the period 01.07.2014 to 01.08.2014.
  uriParameters:
    customerId:
      description: A customer ID from the 'list of available customers' call.
      type: string
      required: true
    reportTypeId:
      description: A report type ID from the 'list of available reports' call.
      type: string
      required: true
    mediaTypeExtension:
      enum: [ .json, .xml ]
      description: Use .json to specify application/json or .xml to specify application/xml
  get:
    description: Generate a report
    queryParameters:
      parameterName:
        description: The different report types have different params. The params are doucmented in the list of available reports, for example `fromDate` and `toDate`.
        type: string
        required: true
    headers:
      Accept-Language:
        description: A comma-separated list of language codes, `no` for Norwegian, `en` for English, etc.
        type: string
        required: false
    responses:
      202:
        displayName: Successful response
        headers:
          Location:
            description: URL to get status of the generated report
            required: true
            type: string
            example: https://www.mybring.com/reports/api/report/db285042-6e8d-4563-94ca-eb1100706a73/status/
        body:
          application/json:
            example: !include examples/generate_report.json
          application/xml:
            example: !include examples/generate_report.xml

/report/{reportId}/status{mediaTypeExtension}:
  displayName: Check the status of a report
  description: |
    Since the generation of reports may take several minutes, we supply a status address to check the status of the report generation. The status page will display `NOT_DONE`, until the report is ready to be downloaded. When the report is ready, URLs to download the report will be in the response
  uriParameters:
    reportId:
      description: A report ID from a 'generate a report' call.
      type: string
      required: true
    mediaTypeExtension:
      enum: [ .json, .xml ]
      description: Use .json to specify application/json or .xml to specify application/xml
  get:
    description: Check the status of a report
    headers:
      Accept-Language:
        description: A comma-separated list of language codes, `no` for Norwegian, `en` for English, etc.
        type: string
        required: false
    responses:
      200:
        displayName: Report status
        description: Examples show different statuses.
        body:
          application/json+notdone:
            example: !include examples/status_not_done.json
          application/json+done:
            example: !include examples/status_done.json
          application/json+failed:
            example: !include examples/status_failed.json
          application/xml+notdone:
            example: !include examples/status_not_done.xml
          application/xml+done:
            example: !include examples/status_done.xml
          application/xml+failed:
            example: !include examples/status_failed.xml

/report/{reportId}{mediaTypeExtension}:
  displayName: Get report
  description: |
    Returns the generated report.
  uriParameters:
    reportId:
      description: A report ID from a 'generate a report' call.
      type: string
      required: true
    mediaTypeExtension:
      enum: [ .xls, .xml ]
      description: Use .xls to get Excel file or .xml to get XML file.
  get:
    headers:
      Accept-Language:
        description: A comma-separated list of language codes, `no` for Norwegian, `en` for English, etc.
        type: string
        required: false
    responses:
      200:
        displayName: Report
        description: Examples show different statuses.
        body:
          application/xml:
            example: !include examples/empty_report.xml

/invoices/{customerOrGroupId}{mediaTypeExtension}:
  displayName: List invoice numbers
  description: |
    Gets the list of invoice numbers for a customer id or a customer group. By default it shows last 65 days of invoices, with the possibilty to access 365 days data by providing from date and to date.
  uriParameters:
    customerOrGroupId:
      description: Id for customer or customer group. Customer group id should have the prefix `GROUP_`.
      type: string
      required: true
    mediaTypeExtension:
      enum: [ .json, .xml ]
      description: Use .json to specify application/json or .xml to specify application/xml
  get:
    headers:
      Accept-Language:
        description: A comma-separated list of language codes, `no` for Norwegian, `en` for English, etc.
        type: string
        required: false
    queryParameters:
            fromDate:
              description: Start date for fetching invoices in format dd.mm.yyyy.
              required: false
              example: 01.01.2019
            toDate:
              description: End date for fetching invoices in format dd.mm.yyyy.
              type: string
              required: false
              example: 30.06.2019
    responses:
      200:
        displayName: Successful response
        body:
          application/json:
            example: !include examples/list_invoices.json
          application/xml:
            example: !include examples/list_invoices.xml

#%RAML 0.8
---
title: Reports API
baseUri: https://www.mybring.com/reports/api

documentation:
- title: Introduction
  content: |
    The Reports API is used to generate shipment reports, the same set of reports that are available in mybring.

    Each Mybring user is associated with a set of customers and has access to specific set of report types for which they can generate a report.

    The following steps (which will be API calls) enables you to generate a report:

    1. Get the customers associated with the mybring user.
    2. Get the report types allowed for a customer.
    3. Initiate report creation and get report ID. The Report ID is initially used to monitor reports creation progress, later to get the actual report (XML or Excel file).
    4. After initiating report creation, you can check the status if the job. I.e. if it is in progress, completed or failed. When status is completed, a URL for fetching the actual report is returned.
    5. The report can then be downloaded.

    For all the above APIs we need to identify and authenticate the user. This is done by passing the following header information. These are described in Reference section:

    - Mybring username (email address)
    - API Key

    All these APIs are available in json and xml formats.

- title: How to use
  content: |
    The Reports API is a logged-in service and you need to get an API-key and authenticate before being able to use the API.

    The two first steps in the process is only necessary to find customer numbers and report types for the user. You can save these IDs, and perform the generation-step without verifying the IDs. The response may get added information, so implementation should ignore new elements added to the response.

    1. Get customer IDs
    2. Get list of available reports
    3. Generate report
    4. Check status of report
    5. Download report
    6. Get list of invoice numbers for given customer or group

- title: Authentication
  content: |
    The Reports 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.

/generate{mediaTypeExtension}:
  displayName: List available customers
  description: |
    List available customers for the provided API credentials.
  uriParameters:
    mediaTypeExtension:
      enum: [ .json, .xml ]
      description: Use .json to specify application/json or .xml to specify application/xml
  get:
    description: List available customers
    headers:
      Accept-Language:
        description: A comma-separated list of language codes, `no` for Norwegian, `en` for English, etc.
        type: string
        required: false
    responses:
      200:
        displayName: Successful response
        body:
          application/json:
            example: !include examples/list_customers.json
          application/xml:
            example: !include examples/list_customers.xml

/generate/{customerId}{mediaTypeExtension}:
  displayName: List available reports for a customer
  description: |
    Each customer has a set of reports available. This endpoint lists all available reports for a given customer.
  uriParameters:
    customerId:
      description: A customer ID from the 'list of available customers' call.
      type: string
      required: true
    mediaTypeExtension:
      enum: [ .json, .xml ]
      description: Use .json to specify application/json or .xml to specify application/xml
  get:
    description: List available reports for a customer
    headers:
      Accept-Language:
        description: A comma-separated list of language codes, `no` for Norwegian, `en` for English, etc.
        type: string
        required: false
    responses:
      200:
        displayName: Successful response
        body:
          application/json:
            example: !include examples/list_reports.json
          application/xml:
            example: !include examples/list_reports.xml

/generate/{customerId}/{reportTypeId}{mediaTypeExtension}:
  displayName: Generate a report
  description: |
    To generate a report do a GET to the supplied URL, and include the parameters described in the previous response. You need not invoke the two first steps for every report generation if customer id and report type are known.

    This is asynchronous request. So the GET-call will return 202, telling the caller the that the request for a report is put on the queue. The URL to query to get the status for the request if provided as an HTTP header and also in the response.

    The example below shows how to generate a PARCELS-DELIVERED report for PARCELS_NORWAY-00012341234 in the period 01.07.2014 to 01.08.2014.
  uriParameters:
    customerId:
      description: A customer ID from the 'list of available customers' call.
      type: string
      required: true
    reportTypeId:
      description: A report type ID from the 'list of available reports' call.
      type: string
      required: true
    mediaTypeExtension:
      enum: [ .json, .xml ]
      description: Use .json to specify application/json or .xml to specify application/xml
  get:
    description: Generate a report
    queryParameters:
      parameterName:
        description: The different report types have different params. The params are doucmented in the list of available reports, for example `fromDate` and `toDate`.
        type: string
        required: true
    headers:
      Accept-Language:
        description: A comma-separated list of language codes, `no` for Norwegian, `en` for English, etc.
        type: string
        required: false
    responses:
      202:
        displayName: Successful response
        headers:
          Location:
            description: URL to get status of the generated report
            required: true
            type: string
            example: https://www.mybring.com/reports/api/report/db285042-6e8d-4563-94ca-eb1100706a73/status/
        body:
          application/json:
            example: !include examples/generate_report.json
          application/xml:
            example: !include examples/generate_report.xml

/reports/{reportId}/status{mediaTypeExtension}:
  displayName: Check the status of a report
  description: |
    Since the generation of reports may take several minutes, we supply a status address to check the status of the report generation. The status page will display `NOT_DONE`, until the report is ready to be downloaded. When the report is ready, URLs to download the report will be in the response
  uriParameters:
    reportId:
      description: A report ID from a 'generate a report' call.
      type: string
      required: true
    mediaTypeExtension:
      enum: [ .json, .xml ]
      description: Use .json to specify application/json or .xml to specify application/xml
  get:
    description: Check the status of a report
    headers:
      Accept-Language:
        description: A comma-separated list of language codes, `no` for Norwegian, `en` for English, etc.
        type: string
        required: false
    responses:
      200:
        displayName: Report status
        description: Examples show different statuses.
        body:
          application/json+notdone:
            example: !include examples/status_not_done.json
          application/json+done:
            example: !include examples/status_done.json
          application/json+failed:
            example: !include examples/status_failed.json
          application/xml+notdone:
            example: !include examples/status_not_done.xml
          application/xml+done:
            example: !include examples/status_done.xml
          application/xml+failed:
            example: !include examples/status_failed.xml

/reports/{reportId}{mediaTypeExtension}:
  displayName: Get report
  description: |
    Returns the generated report.
  uriParameters:
    reportId:
      description: A report ID from a 'generate a report' call.
      type: string
      required: true
    mediaTypeExtension:
      enum: [ .xls, .xml ]
      description: Use .xls to get Excel file or .xml to get XML file.
  get:
    headers:
      Accept-Language:
        description: A comma-separated list of language codes, `no` for Norwegian, `en` for English, etc.
        type: string
        required: false
    responses:
      200:
        displayName: Report
        description: Examples show different statuses.
        body:
          application/xml:
            example: !include examples/empty_report.xml

/invoices/{customerOrGroupId}{mediaTypeExtension}:
  displayName: List invoice numbers
  description: |
    Gets the list of invoice numbers for a customer id or a customer group. By default it shows last 65 days of invoices, with the possibilty to access 365 days data by providing from date and to date.
  uriParameters:
    customerOrGroupId:
      description: Id for customer or customer group. Customer group id should have the prefix `GROUP_`.
      type: string
      required: true
    mediaTypeExtension:
      enum: [ .json, .xml ]
      description: Use .json to specify application/json or .xml to specify application/xml
  get:
    headers:
      Accept-Language:
        description: A comma-separated list of language codes, `no` for Norwegian, `en` for English, etc.
        type: string
        required: false
    queryParameters:
            fromDate:
              description: Start date for fetching invoices in format dd.mm.yyyy.
              required: false
              example: 01.01.2019
            toDate:
              description: End date for fetching invoices in format dd.mm.yyyy.
              type: string
              required: false
              example: 30.06.2019
    responses:
      200:
        displayName: Successful response
        body:
          application/json:
            example: !include examples/list_invoices.json
          application/xml:
            example: !include examples/list_invoices.xml