Choicely Priorityfront

Microservice and main endpoint for handling all vote, rating, choice messages that happen on the Choicely front-end clients. Also responsible for handling analytic messages and internal control flags between the Choicely backend and Vote Service.

NOTE: Test server address: https://psftest.choicely.com

NOTE2: the content of the request must be in the Body of the request, not in the query parameters! In some languages this would mean a JSON encoding, which is not the same as URL parameter encoding!

Sending votes

Root endpoint

POST https://psf.choicely.com/
RequestsSend vote changeSend rating changeSend subrating changeSend choice change
Headers
Content-Type: application/json
Body
{
    "user_id": "c395d3d4-efe7-11e3-8a15-37f10dec84fa",
    "contest_key": "ag5zfmxvdmVudGVkdGVzdHIlCxIEVXNlchiAgICIk7idCgwLEgdDb250ZXN0GICAgIDAq4YKDA",
    "participant_id: "ag5zfmxvdmVudGVkdGVzdHI9CxIEVXNlchiAgICIk7idCgwLEgdDb250ZXN0GICAgIDAq4YKDAsSC1BhcnRpY2lwYW50GICAgICQtpYJDA",
    "user_token": "6288e7d2-844f-4338-a81e-f878f4525a8d",
    "free_vote": 1,
    "silver_vote": 1,
    "star_vote": 1
}
Responses200422500
Body
"published"
Body
{
    "errors": [
        {"Required property <MANDATORY_FIELD> was not present.": "#"}, // MANDATORY_FIELD can be user_id, contest_id, participant_id accordingly
        {"Type mismatch. Expected TYPE_EXPECTED but got TYPE_RECEIVED.":"#/{ADDITIONAL_FIELD}"}, // ADDITIONAL_FIELD can be free_vote, silver_vote... subratings accordingly; types are array, int, string etc.
        ...
    ],
    "item": {}
}
Body
{
  "errors": [
    {
      "detail": "Internal server error"
    }
  ]
}
Headers
Content-Type: application/json
Body
{
    "user_id": "c395d3d4-efe7-11e3-8a15-37f10dec84fa",
    "contest_key": "ag5zfmxvdmVudGVkdGVzdHIlCxIEVXNlchiAgICIk7idCgwLEgdDb250ZXN0GICAgIDAq4YKDA",
    "participant_id: "ag5zfmxvdmVudGVkdGVzdHI9CxIEVXNlchiAgICIk7idCgwLEgdDb250ZXN0GICAgIDAq4YKDAsSC1BhcnRpY2lwYW50GICAgICQtpYJDA",
    "user_token": "6288e7d2-844f-4338-a81e-f878f4525a8d",
    "rating_value": 5.0
}
Responses200422500
Body
"published"
Body
{
    "errors": [
        {"Required property <MANDATORY_FIELD> was not present.": "#"}, // MANDATORY_FIELD can be user_id, contest_id, participant_id accordingly
        {"Type mismatch. Expected TYPE_EXPECTED but got TYPE_RECEIVED.":"#/{ADDITIONAL_FIELD}"}, // ADDITIONAL_FIELD can be free_vote, silver_vote... subratings accordingly; types are array, int, string etc.
        ...
    ],
    "item": {}
}
Body
{
  "errors": [
    {
      "detail": "Internal server error"
    }
  ]
}
Headers
Content-Type: application/json
Body
{
    "user_id": "c395d3d4-efe7-11e3-8a15-37f10dec84fa",
    "contest_key": "ag5zfmxvdmVudGVkdGVzdHIlCxIEVXNlchiAgICIk7idCgwLEgdDb250ZXN0GICAgIDAq4YKDA",
    "participant_id: "ag5zfmxvdmVudGVkdGVzdHI9CxIEVXNlchiAgICIk7idCgwLEgdDb250ZXN0GICAgIDAq4YKDAsSC1BhcnRpY2lwYW50GICAgICQtpYJDA",
    "user_token": "6288e7d2-844f-4338-a81e-f878f4525a8d",
    "subratings": [
        {
            "subrating_id": "s1",
            "value": 45
        }, {
            "subrating_id": "s2",
            "value": 5
    ]
}
Responses200422500
Body
"published"
Body
{
    "errors": [
        {"Required property <MANDATORY_FIELD> was not present.": "#"}, // MANDATORY_FIELD can be user_id, contest_id, participant_id accordingly
        {"Type mismatch. Expected TYPE_EXPECTED but got TYPE_RECEIVED.":"#/{ADDITIONAL_FIELD}"}, // ADDITIONAL_FIELD can be free_vote, silver_vote... subratings accordingly; types are array, int, string etc.
        ...
    ],
    "item": {}
}
Body
{
  "errors": [
    {
      "detail": "Internal server error"
    }
  ]
}
Headers
Content-Type: application/json
Body
{
  "user_id": "c395d3d4-efe7-11e3-8a15-37f10dec84fa",
  "contest_key": "ag5zfmxvdmVudGVkdGVzdHIlCxIEVXNlchiAgICIk7idCgwLEgdDb250ZXN0GICAgIDAq4YKDA",
  "participant_id": "ag5zfmxvdmVudGVkdGVzdHI9CxIEVXNlchiAgICIk7idCgwLEgdDb250ZXN0GICAgIDAq4YKDAsSC1BhcnRpY2lwYW50GICAgICQtpYJDA",
  "user_token": "6288e7d2-844f-4338-a81e-f878f4525a8d",
  "choices": [
    "2aab19f8-7b84-4c31-88aa-f008d52be8f8",
    "1234-5654645-3425-436546433"
  ]
}
Responses200422500
Body
"published"
Body
{
    "errors": [
        {"Required property <MANDATORY_FIELD> was not present.": "#"}, // MANDATORY_FIELD can be user_id, contest_id, participant_id accordingly
        {"Type mismatch. Expected TYPE_EXPECTED but got TYPE_RECEIVED.":"#/{ADDITIONAL_FIELD}"}, // ADDITIONAL_FIELD can be free_vote, silver_vote... subratings accordingly; types are array, int, string etc.
        ...
    ],
    "item": {}
}
Body
{
  "errors": [
    {
      "detail": "Internal server error"
    }
  ]
}

Post vote message
POST/

Posts a vote, rating or choice change through the priorityfront (votefront) server. The user_id, contest_key and participant_id parameters in the body of the request are mandatory. If any of these are missing or any of the value types are incorrect, an error (422) is returned.

The correct votes retrieved via this endpoint are timestamped and are forwarded to the Google Cloud Pub/Sub topic matching the configuration. By default, that is the ´votes´ topic in the corresponding project the service is connected to.

NOTE: “user_token” field is optional.


Vote messages endpoint

POST https://psf.choicely.com/vote_messages

Post vote message
POST/vote_messages

Identical to root endpoint’s Post vote message [POST].


Sending analytic messages

Analytic messages endpoint

POST https://psf.choicely.com/analytic_messages
RequestsSend analytic messageSend analytic messages
Headers
Content-Type: application/json
Body
{
  "event": "OPENED_CONTEST",
  "timestamp": "2018-07-30T08:00:00Z",
  "data": {
    "user_token": "us3r-t0k3n",
    "contest_key": "c0nt3st-k3y",
    "choicely-platform": "web",
    "browser": "Google Chrome"
  }
}
Responses200500
Body
"published"
Body
{
  "errors": [
    {
      "detail": "Internal server error"
    }
  ]
}
Headers
Content-Type: application/json
Body
[
  {
    "event": "OPENED_CONTEST",
    "timestamp": "2018-07-30T08:00:00Z",
    "data": {
      "user_token": "us3r-t0k3n",
      "contest_key": "c0nt3st-k3y",
      "choicely-platform": "web",
      "browser": "Google Chrome"
    }
  },
  {
    "event": "CLOSED_CONTEST",
    "timestamp": "2018-07-30T08:05:00Z",
    "data": {
      "user_token": "us3r-t0k3n",
      "contest_key": "c0nt3st-k3y",
      "choicely-platform": "web",
      "browser": "Google Chrome",
      "seconds_elapsed": 2.5
    }
  }
]
Responses200500
Body
"published"
Body
{
  "errors": [
    {
      "detail": "Internal server error"
    }
  ]
}

Post analytic message(s)
POST/analytic_messages

Posts an analytic message or a list of analytic messages through the priorityfront server. Messages should contain an event and data fields and an optional timestamp. These messages are not validated in any way on the priorityfront side.

The retrieved messages via this endpoint are timestamped and are forwarded to the Google Cloud Pub/Sub topic matching the configuration. By default, that is the ´analytic_messages´ topic in the corresponding project the service is connected to.

A complete documentation on the supported types of analytic messages can be found here.


Sending control messages

Control messages endpoint

POST https://psf.choicely.com/control_messages
RequestsSend control messageSend contol messages
Headers
Content-Type: application/json
Body
{
    "code": "CONTEST_WAS_DELETED",
    "parameters": {
        "contest_key: "ag51234ds634911e8960efff52d3862e2"
    }
}
Responses200500
Body
"published"
Body
{
  "errors": [
    {
      "detail": "Internal server error"
    }
  ]
}
Headers
Content-Type: application/json
Body
[
    {
        "code": "CONTEST_WAS_DELETED",
        "parameters": {
            "contest_key: "ag51234ds634911e8960efff52d3862e2"
        }
    },
    {
        "code": "FULL_CACHE_RESET",
        "parameters": {}
    }
]
Responses200500
Body
"published"
Body
{
  "errors": [
    {
      "detail": "Internal server error"
    }
  ]
}

Post control message(s)
POST/control_messages

Posts a control message or a list of control messages through the priorityfront server. Messages should contain an code and parameters fields. These messages are not validated in any way on the priorityfront side.

The retrieved messages via this endpoint are timestamped and are forwarded to the Google Cloud Pub/Sub topic matching the configuration. By default, that is the ´voteservice_control_messages topic in the corresponding project the service is connected to.

A complete documentation on the supported types of control messages can be found here.


Generated by aglio on 31 Aug 2018