# Directly testing ms-auction in devc
Testing ms-auction directly is not straightforward. This is especially true for the HasVast endpoint, which uses HTTP, but with protobuf/querystring input and output.
This simple proxy makes it easier by transforming JSON requests (done via curl or Postman) into matching protobuf ones.

To run the proxy:

`npx ts-node index.ts`

Optional env variables:
- `ENV` (default: `devc`): ms-auction environment targeted by the proxy
- `PORT` (default: `8080`): local port the proxy will be running on

JSON requests can be then made to `http://localhost:$PORT` in the formats specified below, and will be relayed to ms-auction in the target `$ENV`. Currently only the HasVast endpoint data is modified, all others are sent as-is.

## HasVast endpoint
- campaign must have format = `Programmatic Video`
- (non-web) app must be present in `app-infos2-$ENV` under an `$os:$bundle` key

`POST http://localhost:8080/v1/hv?seller_id=a152aed0e6b1cf7faf8d9d790b218c4b&publisher_name=publisher&publisher_is_network_partner=false`
```json
{
  "adcandidates": [],
  "bid_request": {
    "id": "b348fb23-ea2d-4a01-bfda-2a691d927196",
    "device": {
      "ifa": "foo",
      "ua": "Mozilla/5.0 (Linux; Android 8.0.0; SM-G960F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.84 Mobile Safari/537.36",
      "language": "frFR",
      "ip": "127.0.0.1",
      "os": "ANDROID"
    },
    "app": {
      "bundle": "io.presage.test323",
      "name": "AppName",
      "cat": [
        "game"
      ]
    },
    "site": {},
    "imp": [
      {
        "id": "dac04e81-4a61-4d93-957d-ae9f76029996",
        "video": {
          "minduration": 0,
          "maxduration": 90
        }
      }
    ],
    "user": {
      "id": "",
      "buyeruid": "",
      "geo": {
        "ext": {
          ".ogury.country_code": "FR"
        }
      },
      "ext": {
        "consent": "29390961244f4c488d9bc2f954ab4428",
        ".ogury.odid": "7c4516ba-cd8f-4be6-b0b9-ebec710bf5dd",
        ".ogury.data_optin": false,
        ".ogury.tcf_version": 2,
        ".ogury.is_gdpr_applied": true,
        ".ogury.consent_ads": 3
      }
    },
    "ext": {
      ".ogury.advert_id": "8212aafb-5bc3-49f7-9195-fee8c789a2e1",
      ".ogury.ad_unit_id": "269841_default",
      ".ogury.ad_unit_type": "interstitial",
      ".ogury.campaign_ids": [
        "31907",
        "31887"
      ],
      ".ogury.environment_type": "app"
    }
  }
}
```
Example response:
```json
{
  "campaign": "31887",
  "vast_hash": "eu-west-1_8212aafb-5bc3-49f7-9195-fee8c789a2e1"
}
```
<br />

## Marketplace
- campaign must have family = `marketplace`
- app must be present in `app-infos2-$ENV` under an `$os:$bundle` key

`POST http://localhost:8080/mkp/bid`
```json
{
  "advert_id": "8212aafb-5bc3-49f7-9195-fee8c789a2e1",
  "ogury_bidfloor": 1,
  "app": {
    "bundle": "io.presage.test323",
    "name": "AppName",
    "categories": [
      "game"
    ],
    "seller_id": "a152aed0e6b1cf7faf8d9d790b218c4b",
    "publisher_name": "publisher",
    "publisher_is_network_partner": false,
    "ad_unit_id": "269841_default",
    "ad_unit_type": "interstitial"
  },
  "device": {
    "user_agent": "Mozilla/5.0 (Linux; Android 8.0.0; SM-G960F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.84 Mobile Safari/537.36",
    "language": "frFR",
    "os_type": "ANDROID",
    "ip": "127.0.0.1",
    "is_omid_compliant": true
  },
  "campaigns": [
    {
      "id": 32235,
      "deal_id": "38738783",
      "wseat": [
        "1234"
      ],
      "bid_floor": 4
    }
  ],
  "context": {
    "country_code": "FR"
  },
  "user": {
    "aaid": "foo",
    "odid": "7c4516ba-cd8f-4be6-b0b9-ebec710bf5dd",
    "is_data_optin": true,
    "consent": "iabstuff",
    "consent_ads": "TARGETED",
    "tcf_version": 2,
    "is_gdpr_applied": true
  }
}
```
Example response:
```json
{
  "advert_id": "f6257471-c4bd-4eac-a304-12b64e7f7d7a",
  "campaign": 32235,
  "price": 21,
  "advertiser_domain": "example.com",
  "advertiser_name": "",
  "agency_name": "",
  "agency_id": "",
  "seat": "1234",
  "deal_id": "38738783"
}
```
<br />

## GetVast

`GET http://localhost:8080/v1/gv?bid_hash=eu-west-1_8212aafb-5bc3-49f7-9195-fee8c789a2e1&oc_id=31907&u_id=7c4516ba-cd8f-4be6-b0b9-ebec710bf5dd&cached_vast=true`
