Added xsd, swdl and json schema to the update guide

#%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 will allow you to easily get shipping methods for your new shipments. If you request applicable shipping methods with all 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 methods, meaning that the actual response can be shown in e.g. a web-shop checking without any sorting or filtering and with human readable service texts.

      The Shipping Guide API 2.0 has both a JSON and a SOAP interface. The JSON interface is typically used for a single service or similar services and is only for a single consignment. The SOAP interface can be used for multiple consignments and has the complete functionality of Shipping Guide API.

      ### What's new
      With the major version of 2.0, the Shipping Guide team has taken the opportunity to make changes to clean up the API and fix bugs that may prove to break the previous API.

      * [Authentication](/api/#authentication) is now required
      * [Errors](/api/shipping-guide_v2/#handle-api-errors) are now in a more structured format in the body of the respons and contain error IDs
      TODO: Complete this list

      ### Why upgrade?
      TODO: Create a text that sells this version to the end users

      ### How to upgrade
      Now that Shipping Guide API 2.0 is out, you might be wondering how to upgrade to it. [The upgrade guide](/api/shipping-guide_2/upgrade-guide.html) will walk you through the major steps involved in upgrading, and help you to upgrade from the version you are using.

- title: Getting started
  content: |
      This guide will walk you through getting shipment methods for your first package using Shipping Guide API. In this example, we will be calling the SOAP interface with a HTTP client and query for the services `SERVICEPAKKE` and `PA_DOREN` for two packages.
      TODO: Change to a product that isn't being phased out

      ### Before you start
      Before you can begin integrating with or testing 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
      * [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 will be used when creating you request is available here.

      Get API key

      ### 2. Add authentication headers
      Authenticate your request by adding the three headers: Your Mybring username, API key and a client URL. A description of the headers can be found in [Getting Started / Authentication](/api/#authentication).

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

      - `Content-type: text/xml` TODO: Is this right?

      If you're using a SOAP client it may be that this is done for you, meaning you can skip this step.

      ### 4. Add the body to the request
      In this request we'll be querying 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:RequestProperties>
                      <ns:Language>no</ns:Language>
                  </ns:RequestProperties>
                  <ns:Consignments>
                      <ns:Consignment consignmentId="101">
                          <ns:ProductIds>
                              <ns:ProductId>SERVICEPAKKE</ns:ProductId>
                              <ns:ProductId>PA_DOREN</ns:ProductId>
                          </ns:ProductIds>
                          <ns:FromCountryCode>NO</ns:FromCountryCode>
                          <ns:FromPostalCode>0015</ns:FromPostalCode>
                          <ns:ToCountryCode>NO</ns:ToCountryCode>
                          <ns:ToPostalCode>5518</ns:ToPostalCode>
                          <ns:ShippingDate>
                              <ns:Year>2018</ns:Year>
                              <ns:Month>10</ns:Month>
                              <ns:Day>10</ns:Day>
                          </ns:ShippingDate>
                          <ns:Packages>
                              <ns:Package>
                                  <ns:Height>19</ns:Height>
                                  <ns:Width>12</ns:Width>
                                  <ns:Length>30</ns:Length>
                                  <ns:GrossWeight>120</ns:GrossWeight>
                              </ns:Package>
                              <ns:Package>
                                  <ns:Height>30</ns:Height>
                                  <ns:Width>15</ns:Width>
                                  <ns:Length>22</ns:Length>
                                  <ns:GrossWeight>240</ns:GrossWeight>
                              </ns:Package>
                          </ns:Packages>
                      </ns:Consignment>
                  </ns:Consignments>
              </ns:ShippingGuideRequest>
          </soapenv:Body>
      </soapenv:Envelope>
      ```

      ### 5. Submit the request
      The request should now be complete, so now it is time to submit it.

      TODO: Write better text
      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:TraceMessages>
                      <ns2:Message>Defaulting to current time of day as no hour and minute component present in date time element.</ns2:Message>
                      <ns2:Message>Added fee 'brev-varsling' (NOK 13.00) to base price of SERVICEPAKKE since request did not have additional service 'eVarsling' specified.</ns2:Message>
                  </ns2:TraceMessages>
                  <ns2:Consignments>
                      <ns2:Consignment consignmentId="101">
                          <ns2:Products>
                              <ns2:Product>
                                  <ns2:ProductId>SERVICEPAKKE</ns2:ProductId>
                                  <ns2:ProductCodeInProductionSystem>1202</ns2:ProductCodeInProductionSystem>
                                  <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:Tip/>
                                      <ns2:MaxWeightInKgs>35</ns2:MaxWeightInKgs>
                                  </ns2:GuiInformation>
                                  <ns2:Price currencyIdentificationCode="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: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:ProductId>PA_DOREN</ns2:ProductId>
                                  <ns2:ProductCodeInProductionSystem>1736</ns2:ProductCodeInProductionSystem>
                                  <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:Tip/>
                                      <ns2:MaxWeightInKgs>35</ns2:MaxWeightInKgs>
                                  </ns2:GuiInformation>
                                  <ns2:Price currencyIdentificationCode="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:Price>
                                  <ns2:ExpectedDelivery>
                                      <ns2:WorkingDays/>
                                      <ns2:UserMessage>Ingen fremsendingstidsgaranti for oppgitt tilpostnummer.</ns2:UserMessage>
                                      <ns2:FormattedExpectedDeliveryDate/>
                                      <ns2:AlternativeDeliveryDates/>
                                      <ns2:FormattedEarliestPickupDate/>
                                  </ns2:ExpectedDelivery>
                              </ns2:Product>
                          </ns2:Products>
                      </ns2:Consignment>
                  </ns2:Consignments>
              </ns2:ShippingGuideResponse>
          </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>
      ```

- title: Handle API errors
  content: |
      The Shipping Guide API return two levels of error information:

      * HTTP error codes or SOAP fault with a message in the body
      * An error object in the response that is on a service level

      TODO: Write about the 2 and when they typically occur

      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 e.g. a timeout occurs.

      TODO: Write about error ID (code) and that texts (trace and error descriptions) should not be parsed...blablabla

- title: Response structure
  content: |
      If you request shipping methods via API, you will receive an object which complies to the following schemas:

      #### SOAP

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

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

      #### JSON

      [https://api.bring.com/shippingguide/v2/products/schema](https://api.bring.com/shippingguide/v2/products/schema)

- title: Improve performance
  content: |
      TODO: Write about limiting the request to only the services needed since the respons time on some services are slow compared to others
      TODO: Write about limiting the response by using the prices / leadtime json interfaces or SOAP with flags. lets say u only need prices and do not care about

/v2/services:
  displayName: Get shipment prices and estimated delivery
  description: Use this endpoint to get expected delivery, product 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
      Content-Type:
        description: The API key needed to create a new job

    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
      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
      additional:
        displayName: Additional service
        description: Multiple additional services can be requested by repeating this parameter
        required: false
        type: string
      service:
        description: Multiple services can be requested by repeating this parameter
        type: string
        required: true
      customernumber:
        description: Lets you specify which customer number to use in the request
        type: string
        example: CARGO-123456
      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

    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/services/price:
  displayName: Get shipment prices
  description: |
      Use this endpoint to get prices, product categories and additional information. The request parameters are the same as for [Get shipment prices and estimated delivery](/api/shipping-guide_v2/#get-shipment-prices-and-estimated-delivery)
  get:
    description: Use this endpoint to get price, product categories and additional information such as an indication of which alternative has the least environmental impact. 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/services/expectedDelivery:
  displayName: Get expected delivery times
  description: |
      Use this endpoint to get expected delivery, product categories and additional information. The request parameters are the same as for [Get shipment prices and estimated delivery](/api/shipping-guide_v2/#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, product categories and additional information.
  post:
    description: Use this endpoint to get expected delivery, product categories and additional information.
    headers:
      X-MyBring-API-Uid:
        description: Your Mybring login ID
      X-MyBring-API-Key:
        description: Your user's API key
      Content-Type:
        description: The API key needed to create a new job

#%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 will allow you to easily get shipping methods for your new shipments. If you request applicable shipping methods with all 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 methods, meaning that the actual response can be shown in e.g. a web-shop checking without any sorting or filtering and with human readable service texts.

      The Shipping Guide API 2.0 has both a JSON and a SOAP interface. The JSON interface is typically used for a single service or similar services and is only for a single consignment. The SOAP interface can be used for multiple consignments and has the complete functionality of Shipping Guide API.

      ### What's new
      With the major version of 2.0, the Shipping Guide team has taken the opportunity to make changes to clean up the API and fix bugs that may prove to break the previous API.

      * [Authentication](/api/#authentication) is now required
      * [Errors](/api/shipping-guide_v2/#handle-api-errors) are now in a more structured format in the body of the respons and contain error IDs
      TODO: Complete this list

      ### Why upgrade?
      TODO: Create a text that sells this version to the end users

      ### How to upgrade
      Now that Shipping Guide API 2.0 is out, you might be wondering how to upgrade to it. [The upgrade guide](/api/shipping-guide_2/upgrade-guide.html) will walk you through the major steps involved in upgrading, and help you to upgrade from the version you are using.

- title: Getting started
  content: |
      This guide will walk you through getting shipment methods for your first package using Shipping Guide API. In this example, we will be calling the SOAP interface with a HTTP client and query for the services `SERVICEPAKKE` and `PA_DOREN` for two packages.
      TODO: Change to a product that isn't being phased out

      ### Before you start
      Before you can begin integrating with or testing 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
      * [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 will be used when creating you request is available here.

      Get API key

      ### 2. Add authentication headers
      Authenticate your request by adding the three headers: Your Mybring username, API key and a client URL. A description of the headers can be found in [Getting Started / Authentication](/api/#authentication).

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

      - `Content-type: text/xml` TODO: Is this right?

      If you're using a SOAP client it may be that this is done for you, meaning you can skip this step.

      ### 4. Add the body to the request
      In this request we'll be querying 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:RequestProperties>
                      <ns:Language>no</ns:Language>
                  </ns:RequestProperties>
                  <ns:Consignments>
                      <ns:Consignment consignmentId="101">
                          <ns:ProductIds>
                              <ns:ProductId>SERVICEPAKKE</ns:ProductId>
                              <ns:ProductId>PA_DOREN</ns:ProductId>
                          </ns:ProductIds>
                          <ns:FromCountryCode>NO</ns:FromCountryCode>
                          <ns:FromPostalCode>0015</ns:FromPostalCode>
                          <ns:ToCountryCode>NO</ns:ToCountryCode>
                          <ns:ToPostalCode>5518</ns:ToPostalCode>
                          <ns:ShippingDate>
                              <ns:Year>2018</ns:Year>
                              <ns:Month>10</ns:Month>
                              <ns:Day>10</ns:Day>
                          </ns:ShippingDate>
                          <ns:Packages>
                              <ns:Package>
                                  <ns:Height>19</ns:Height>
                                  <ns:Width>12</ns:Width>
                                  <ns:Length>30</ns:Length>
                                  <ns:GrossWeight>120</ns:GrossWeight>
                              </ns:Package>
                              <ns:Package>
                                  <ns:Height>30</ns:Height>
                                  <ns:Width>15</ns:Width>
                                  <ns:Length>22</ns:Length>
                                  <ns:GrossWeight>240</ns:GrossWeight>
                              </ns:Package>
                          </ns:Packages>
                      </ns:Consignment>
                  </ns:Consignments>
              </ns:ShippingGuideRequest>
          </soapenv:Body>
      </soapenv:Envelope>
      ```

      ### 5. Submit the request
      The request should now be complete, so now it is time to submit it.

      TODO: Write better text
      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:TraceMessages>
                      <ns2:Message>Defaulting to current time of day as no hour and minute component present in date time element.</ns2:Message>
                      <ns2:Message>Added fee 'brev-varsling' (NOK 13.00) to base price of SERVICEPAKKE since request did not have additional service 'eVarsling' specified.</ns2:Message>
                  </ns2:TraceMessages>
                  <ns2:Consignments>
                      <ns2:Consignment consignmentId="101">
                          <ns2:Products>
                              <ns2:Product>
                                  <ns2:ProductId>SERVICEPAKKE</ns2:ProductId>
                                  <ns2:ProductCodeInProductionSystem>1202</ns2:ProductCodeInProductionSystem>
                                  <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:Tip/>
                                      <ns2:MaxWeightInKgs>35</ns2:MaxWeightInKgs>
                                  </ns2:GuiInformation>
                                  <ns2:Price currencyIdentificationCode="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: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:ProductId>PA_DOREN</ns2:ProductId>
                                  <ns2:ProductCodeInProductionSystem>1736</ns2:ProductCodeInProductionSystem>
                                  <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:Tip/>
                                      <ns2:MaxWeightInKgs>35</ns2:MaxWeightInKgs>
                                  </ns2:GuiInformation>
                                  <ns2:Price currencyIdentificationCode="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:Price>
                                  <ns2:ExpectedDelivery>
                                      <ns2:WorkingDays/>
                                      <ns2:UserMessage>Ingen fremsendingstidsgaranti for oppgitt tilpostnummer.</ns2:UserMessage>
                                      <ns2:FormattedExpectedDeliveryDate/>
                                      <ns2:AlternativeDeliveryDates/>
                                      <ns2:FormattedEarliestPickupDate/>
                                  </ns2:ExpectedDelivery>
                              </ns2:Product>
                          </ns2:Products>
                      </ns2:Consignment>
                  </ns2:Consignments>
              </ns2:ShippingGuideResponse>
          </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>
      ```

- title: Handle API errors
  content: |
      The Shipping Guide API return two levels of error information:

      * HTTP error codes or SOAP fault with a message in the body
      * An error object in the response that is on a service level

      TODO: Write about the 2 and when they typically occur

      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 e.g. a timeout occurs.

      TODO: Write about error ID (code) and that texts (trace and error descriptions) should not be parsed...blablabla

- title: Response structure
  content: |
      If you request shipping methods via API, you will receive an object which complies to the following schemas:

      #### SOAP
      TODO: Link to XSD

      #### JSON
      TODO: Link to JSON Schema

- title: Improve performance
  content: |
      TODO: Write about limiting the request to only the services needed since the respons time on some services are slow compared to others
      TODO: Write about limiting the response by using the prices / leadtime json interfaces or SOAP with flags. lets say u only need prices and do not care about

/v2/services:
  displayName: Get shipment prices and estimated delivery
  description: Use this endpoint to get expected delivery, product 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
      Content-Type:
        description: The API key needed to create a new job

    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
      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
      additional:
        displayName: Additional service
        description: Multiple additional services can be requested by repeating this parameter
        required: false
        type: string
      service:
        description: Multiple services can be requested by repeating this parameter
        type: string
        required: true
      customernumber:
        description: Lets you specify which customer number to use in the request
        type: string
        example: CARGO-123456
      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

    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/services/price:
  displayName: Get shipment prices
  description: |
      Use this endpoint to get prices, product categories and additional information. The request parameters are the same as for [Get shipment prices and estimated delivery](/api/shipping-guide_v2/#get-shipment-prices-and-estimated-delivery)
  get:
    description: Use this endpoint to get price, product categories and additional information such as an indication of which alternative has the least environmental impact. 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/services/expectedDelivery:
  displayName: Get expected delivery times
  description: |
      Use this endpoint to get expected delivery, product categories and additional information. The request parameters are the same as for [Get shipment prices and estimated delivery](/api/shipping-guide_v2/#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, product categories and additional information.
  post:
    description: Use this endpoint to get expected delivery, product categories and additional information.
    headers:
      X-MyBring-API-Uid:
        description: Your Mybring login ID
      X-MyBring-API-Key:
        description: Your user's API key
      Content-Type:
        description: The API key needed to create a new job


Updated the RAML file to be more complete.

#%RAML 0.8
title: Test API
version: v1
baseUri: http://localhost:8000/api/{version}
mediaType: application/vnd.api+json

/users:
    get:
        description: Retrieve all application users
        responses:
            200:
    post:
        description: Create one or more application users
        responses:
            201:
    /{user-ids}:
        get:
            description: Fetch one or more users by id.
            responses:
                200:
        put:
            description: Update one or more users by id.
            responses:
                200:
        delete:
            description: Delete one or more users by id.
        /links:
            /{relationship}:
                get:
                    description: Fetch a user-related resource.
                    responses:
                        200:
                post:
                    description: Add one or more user relationships.
                    responses:
                        201:
                put:
                    description: Update a user relationship.
                    responses:
                        204:
                delete:
                    description: Remove a user relationship by id.
            /{relationship-ids}:
                delete:
                    description: Remove multiple user relationships by id.

#%RAML 0.8
title: HATEOAS Inc. Example API
version: v1
baseUri: http://localhost:8000/api/{version}
mediaType: application/vnd.api+json

/users:
    get:
        description: Fetches application users
        responses:
            200


Updating text to explain supported customers

#%RAML 1.0
---
title: Reports API
baseUri: https://www.mybring.com/reports/api
types:
  DashboardData:
    type: object
    properties:
      kolliNumber:
        type: string
        required: true
        description: Represents a package number
      shipmentNumber:
        type: string
        required: true
        description: Represents a shipment number
      recipientName:
        type: string
        required: true
        description: Represents a recipient name
      lastStatus:
        type: string
        required: true
        description: Represents the lastStatus
      lastEvent:
        type: string
        required: false
        description: Represents the lastEvent
      senderReference:
        type: string
        required: false
        description: Represents the senderReference
      recipientMobileNumber:
        type: string
        required: false
        description: Represents the recipient Mobile Number
      productCode:
        type: string
        required: false
        description: Represents the productCode
      productName:
        type: string
        required: true
        description: Represents the productName
      countryCode:
        type: string
        required: true
        enum: [ "DK", "FI","NO", "SE"]
        description: Represents the country code
      shipmentGroupType:
        type: string
        required: true
        enum: [ "REMAINING_FOR_DELIVERY", "LOADED_TO_CAR", "ATTEMPTED_DELIVERY", "AT_PICKUP_POINT", "SUCCESSFULLY_DELIVERED"]
        description: Represents the shipmentGroup by status

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:
  content: |
    #### List of available invoice sources
    For specified invoice report 4 different types of report can be returned depending on the invoice source. Those are

    Cargo Domestic and Sea :
      - AMPHORA_DOMESTIC
      - AMPHORA_SEA

    Cargo International and Sysped :
      - AMPHORA_BCI
      - SYSPED

    Parcels :
      - PARCEL_DOMESTIC

    Frigo :
      - TIMPEX

- title: Authentication
  content: |
    The Reports API requires authentication for all its endpoints.

    ### 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).

    | 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:
            examples:
              successful:
                displayName: Successful
                description: The example below shows list of available customers
                value: !include examples/list_customers.json
          application/xml:
            examples:
              successful:
                displayName: Successful
                description: The example below shows list of available customers
                value: !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:
            examples:
              successful:
                displayName: Successful
                description: The example below shows list of available reports
                value: !include examples/list_reports.json
          application/xml:
            examples:
              successful:
                displayName: Successful
                description: The example below shows list of available reports
                value: !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:
            examples:
              successful:
                displayName: Successful
                description: The example below shows successful reports generation response with URL
                value: !include examples/generate_report.json
          application/xml:
            examples:
              successful:
                displayName: Successful
                description: The example below shows successful reports generation response with URL
                value: !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:
            examples:
              successful:
                displayName: Report status done
                description: The example below shows reports status done
                value: !include examples/status_done.json
              successful_notDone:
                displayName: Report status not done
                description: The example below shows reports generated status
                value: !include examples/status_not_done.json
              successful_failed:
                displayName: Report status failed
                description: The example below shows reports generation failed status
                value: !include examples/status_failed.json
          application/xml:
            examples:
              successful:
                displayName: Report status done
                description: The example below shows reports status not done
                value: !include examples/status_done.xml
              successful_notDone:
                displayName: Report status not done
                description: The example below shows reports generated status
                value: !include examples/status_not_done.xml
              successful_failed:
                displayName: Report status failed
                description: The example below shows reports generation failed status
                value: !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 the MetaData included in successful(200) response for specified invoice report vs other reports.
        body:
          application/xml:
            examples:
              successful_invoice:
                displayName: Successful with invoice details
                description: The example below shows empty report with invoice details under metadata section of Report response
                value: !include examples/empty_invoice_report.xml
              successful:
                displayName: Successful
                description: The example below shows empty report without invoice details
                value: !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
        description:
        body:
          application/json:
            examples:
              successful:
                displayName: Successful
                description: The example below shows an list of invoices
                value: !include examples/list_invoices.json
          application/xml:
            examples:
              successful:
                displayName: Successful
                description: The example below shows an list of invoices
                value: !include examples/list_invoices.xml

/overview/{apiCustomerNumber}/summary{mediaTypeExtension}:
  displayName: Reports overview statistics summary
  description: |
    Gives total cost and volume of shipments from Parcel, Cargo and  Parcel International service customers with reports with financial access.
  uriParameters:
    apiCustomerNumber:
      description: |
             Unique API Customer Number of applicable service categories by considering below rules

* For Non Agreement Converted customer:  use the possible *"API customer number"*

* For Agreement converted customer: *"```ServiceType|Main Customer Number```"*
      type: string
      required: true
      enum: [ Main customer number,
              CARGO-xxxxx,
              PARCELS_NORWAY_INTERNATIONAL-xxxxx,PARCELS_SWEDEN-xxxxx,PARCELS_DENMARK-xxxxx,PARCELS_FINLAND-xxxxx]
      example: CARGO|12345, CARGO_INTERNATIONAL|12345, PARCEL|12345
    mediaTypeExtension:
      enum: [ .json ]
      description: Use .json to specify application/json
  get:
    description: Gives reports overview statistics
    responses:
      200:
        displayName: Successful response
        body:
          application/json:
            examples:
              successful:
                displayName: Successful
                description: The example below shows overview summary
                value: !include examples/overview_summary.json
              successfulNordics:
                displayName: Successful without cost details
                description: The example below shows overview summary for parcel internationals customers which dont have economy details as of now.
                value: !include examples/overview_summary_without_cost.json

/dashboard/{apiCustomerNumber}/count:
  displayName: Provides count of shipments for key events
  description: |
    Gives count of shipment for key event for Parcel, Cargo and  Parcel International service customers with reports access.
  uriParameters:
    apiCustomerNumber:
      description: |
             Unique API Customer Number of applicable service categories by considering below rules

* For Non Agreement Converted customer:  use the possible *"API customer number"*

* For Agreement converted customer: *"```ServiceType|Main Customer Number```"*
      type: string
      required: true
      enum: [ Main customer number,
              CARGO-xxxxx,
              PARCELS_NORWAY_INTERNATIONAL-xxxxx,PARCELS_SWEDEN-xxxxx,PARCELS_DENMARK-xxxxx,PARCELS_FINLAND-xxxxx]
      example: CARGO|12345, CARGO_INTERNATIONAL|12345, PARCEL|12345
  get:
    description: Provides count of shipments for key events
    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:
      requestedForDate:
        description: Date for which shipment count is required in format dd.mm.yyyy.
        required: true
        example: 24.03.2020
    responses:
      200:
        displayName: Successful response
        body:
          application/json:
            examples:
              successful:
                displayName: Successful
                description: The example below shows shipment count for key events
                value: !include examples/dashboard_count.json

/dashboard/{apiCustomerNumber}/dashboardRowData:
  displayName: Provides count of shipments with details for key events.
  description: |
    Gives count of shipment for key event with details for Parcel, Cargo and  Parcel International service customers with reports access.
  uriParameters:
    apiCustomerNumber:
      description: |
             Unique API Customer Number of applicable service categories by considering below rules

* For Non Agreement Converted customer:  use the possible *"API customer number"*

* For Agreement converted customer: *"```ServiceType|Main Customer Number```"*
      type: string
      required: true
      enum: [ Main customer number,
              CARGO-xxxxx,
              PARCELS_NORWAY_INTERNATIONAL-xxxxx,PARCELS_SWEDEN-xxxxx,PARCELS_DENMARK-xxxxx,PARCELS_FINLAND-xxxxx]
      example: CARGO|12345, CARGO_INTERNATIONAL|12345, PARCEL|12345
  get:
    description: Provides shipment counts with details for key events.
    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:
      requestedForDate:
        description: Date for which shipment details is required in format dd.mm.yyyy.
        required: true
        example: 24.03.2020
    responses:
      200:
        displayName: Successful response
        body:
          application/json:
            type: DashboardData
            examples:
              successful:
                displayName: Successful
                description: The example below shows shipment count with details for the key events
                value: !include examples/dashboard_row_details.json

#%RAML 1.0
---
title: Reports API
baseUri: https://www.mybring.com/reports/api
types:
  DashboardData:
    type: object
    properties:
      kolliNumber:
        type: string
        required: true
        description: Represents a package number
      shipmentNumber:
        type: string
        required: true
        description: Represents a shipment number
      recipientName:
        type: string
        required: true
        description: Represents a recipient name
      lastStatus:
        type: string
        required: true
        description: Represents the lastStatus
      lastEvent:
        type: string
        required: false
        description: Represents the lastEvent
      senderReference:
        type: string
        required: false
        description: Represents the senderReference
      recipientMobileNumber:
        type: string
        required: false
        description: Represents the recipient Mobile Number
      productCode:
        type: string
        required: false
        description: Represents the productCode
      productName:
        type: string
        required: true
        description: Represents the productName
      countryCode:
        type: string
        required: true
        enum: [ "DK", "FI","NO", "SE"]
        description: Represents the country code
      shipmentGroupType:
        type: string
        required: true
        enum: [ "REMAINING_FOR_DELIVERY", "LOADED_TO_CAR", "ATTEMPTED_DELIVERY", "AT_PICKUP_POINT", "SUCCESSFULLY_DELIVERED"]
        description: Represents the shipmentGroup by status

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:
  content: |
    #### List of available invoice sources
    For specified invoice report 4 different types of report can be returned depending on the invoice source. Those are

    Cargo Domestic and Sea :
      - AMPHORA_DOMESTIC
      - AMPHORA_SEA

    Cargo International and Sysped :
      - AMPHORA_BCI
      - SYSPED

    Parcels :
      - PARCEL_DOMESTIC

    Frigo :
      - TIMPEX

- title: Authentication
  content: |
    The Reports API requires authentication for all its endpoints.

    ### 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).

    | 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:
            examples:
              successful:
                displayName: Successful
                description: The example below shows list of available customers
                value: !include examples/list_customers.json
          application/xml:
            examples:
              successful:
                displayName: Successful
                description: The example below shows list of available customers
                value: !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:
            examples:
              successful:
                displayName: Successful
                description: The example below shows list of available reports
                value: !include examples/list_reports.json
          application/xml:
            examples:
              successful:
                displayName: Successful
                description: The example below shows list of available reports
                value: !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:
            examples:
              successful:
                displayName: Successful
                description: The example below shows successful reports generation response with URL
                value: !include examples/generate_report.json
          application/xml:
            examples:
              successful:
                displayName: Successful
                description: The example below shows successful reports generation response with URL
                value: !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:
            examples:
              successful:
                displayName: Report status done
                description: The example below shows reports status done
                value: !include examples/status_done.json
              successful_notDone:
                displayName: Report status not done
                description: The example below shows reports generated status
                value: !include examples/status_not_done.json
              successful_failed:
                displayName: Report status failed
                description: The example below shows reports generation failed status
                value: !include examples/status_failed.json
          application/xml:
            examples:
              successful:
                displayName: Report status done
                description: The example below shows reports status not done
                value: !include examples/status_done.xml
              successful_notDone:
                displayName: Report status not done
                description: The example below shows reports generated status
                value: !include examples/status_not_done.xml
              successful_failed:
                displayName: Report status failed
                description: The example below shows reports generation failed status
                value: !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 the MetaData included in successful(200) response for specified invoice report vs other reports.
        body:
          application/xml:
            examples:
              successful_invoice:
                displayName: Successful with invoice details
                description: The example below shows empty report with invoice details under metadata section of Report response
                value: !include examples/empty_invoice_report.xml
              successful:
                displayName: Successful
                description: The example below shows empty report without invoice details
                value: !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
        description:
        body:
          application/json:
            examples:
              successful:
                displayName: Successful
                description: The example below shows an list of invoices
                value: !include examples/list_invoices.json
          application/xml:
            examples:
              successful:
                displayName: Successful
                description: The example below shows an list of invoices
                value: !include examples/list_invoices.xml

/overview/{apiCustomerNumber}/summary{mediaTypeExtension}:
  displayName: Reports overview statistics summary
  description: |
    Gives total cost and volume of shipments from all the products for the given api customer number.
  uriParameters:
    apiCustomerNumber:
      description: |
             Unique API Customer Number which needs to be decided based on below rules

* For Non Agreement Converted customer:  use the possible *"API customer number"*

* For Agreement converted customer: *"```ServiceType|Main Customer Number```"*
      type: string
      required: true
      enum: [ Main customer number,
              CARGO-xxxxx,
              PARCELS_NORWAY_INTERNATIONAL-xxxxx,PARCELS_SWEDEN-xxxxx,PARCELS_DENMARK-xxxxx,PARCELS_FINLAND-xxxxx]
      example: CARGO|12345, CARGO_INTERNATIONAL|12345, PARCEL|12345
    mediaTypeExtension:
      enum: [ .json ]
      description: Use .json to specify application/json
  get:
    description: Gives reports overview statistics
    responses:
      200:
        displayName: Successful response
        body:
          application/json:
            examples:
              successful:
                displayName: Successful
                description: The example below shows overview summary
                value: !include examples/overview_summary.json
              successfulNordics:
                displayName: Successful without cost details
                description: The example below shows overview summary for parcel internationals customers which dont have economy details as of now.
                value: !include examples/overview_summary_without_cost.json

/dashboard/{apiCustomerNumber}/count:
  displayName: Provides count of shipments for key events
  description: |
    Gives count of shipment for key event/status for the given api customer number.
  uriParameters:
    apiCustomerNumber:
      description: |
             Unique API Customer Number which needs to be decided based on below rules

* For Non Agreement Converted customer:  use the possible *"API customer number"*

* For Agreement converted customer: *"```ServiceType|Main Customer Number```"*
      type: string
      required: true
      enum: [ Main customer number,
              CARGO-xxxxx,
              PARCELS_NORWAY_INTERNATIONAL-xxxxx,PARCELS_SWEDEN-xxxxx,PARCELS_DENMARK-xxxxx,PARCELS_FINLAND-xxxxx]
      example: CARGO|12345, CARGO_INTERNATIONAL|12345, PARCEL|12345
  get:
    description: Provides count of shipments for key events
    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:
      requestedForDate:
        description: Date for which shipment count is required in format dd.mm.yyyy.
        required: true
        example: 24.03.2020
    responses:
      200:
        displayName: Successful response
        body:
          application/json:
            examples:
              successful:
                displayName: Successful
                description: The example below shows shipment count for key events
                value: !include examples/dashboard_count.json

/dashboard/{apiCustomerNumber}/dashboardRowData:
  displayName: Provides count of shipments with details for key events.
  description: |
    Gives count of shipment for key event/status with details for the given api customer number.
  uriParameters:
    apiCustomerNumber:
      description: |
             Unique API Customer Number which needs to be decided based on below rules

* For Non Agreement Converted customer:  use the possible *"API customer number"*

* For Agreement converted customer: *"```ServiceType|Main Customer Number```"*
      type: string
      required: true
      enum: [ Main customer number,
              CARGO-xxxxx,
              PARCELS_NORWAY_INTERNATIONAL-xxxxx,PARCELS_SWEDEN-xxxxx,PARCELS_DENMARK-xxxxx,PARCELS_FINLAND-xxxxx]
      example: CARGO|12345, CARGO_INTERNATIONAL|12345, PARCEL|12345
  get:
    description: Provides shipment counts with details for key events.
    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:
      requestedForDate:
        description: Date for which shipment details is required in format dd.mm.yyyy.
        required: true
        example: 24.03.2020
    responses:
      200:
        displayName: Successful response
        body:
          application/json:
            type: DashboardData
            examples:
              successful:
                displayName: Successful
                description: The example below shows shipment count with details for the key events
                value: !include examples/dashboard_row_details.json