Methods for getting and updating survey answer data for a subscription from the Store API.

GET /v1/store/api/subscriptions/{subscription_id}/surveys/
GET /v1/store/api/subscriptions/{subscription_id}/surveys/{product_survey_result_id}
PUT /v1/store/api/subscriptions/{subscription_id}/surveys/{product_survey_result_id}

Get all subscription survey results

$.get('/v1/store/api/subscriptions/{subscription_id}/surveys/');
{
   "count":2,
   "next":null,
   "prev":null,
   "results":[
      {
         "answers":[
            {
               "field":{
                  "id":1618805539,
                  "survey":{
                     "id":1618805536,
                     "type":"product_survey"
                  },
                  "survey_id":1618805536,
                  "type":"product_survey_field"
               },
               "field_id":1618805539,
               "id":1663879030,
               "value":"I like turtles!"
            },
            {
               "field":{
                  "id":1618805540,
                  "survey":{
                     "id":1618805536,
                     "type":"product_survey"
                  },
                  "survey_id":1618805536,
                  "type":"product_survey_field"
               },
               "field_id":1618805540,
               "id":1663879029,
               "value":"2014-07-22"
            }
         ],
         "created_at":"Mon, 23 Jul 2018 10:09:33 GMT",
         "id":1663879024,
         "subscription_id":1663878876,
         "type":"product_survey_result",
         "updated_at":"Mon, 23 Jul 2018 10:09:33 GMT",
         "url":"/v1/store/api/subscriptions/<int:subscription_id>/surveys/1663879024/"
      },
      {
         "answers":[
            {
               "field":{
                  "id":1618805541,
                  "survey":{
                     "id":1618805537,
                     "type":"product_survey"
                  },
                  "survey_id":1618805537,
                  "type":"product_survey_field"
               },
               "field_id":1618805541,
               "id":1663879019,
               "value":"I am a zombie!"
            }
         ],
         "created_at":"Mon, 23 Jul 2018 10:09:32 GMT",
         "id":1663879016,
         "subscription_id":1663878876,
         "type":"product_survey_result",
         "updated_at":"Mon, 23 Jul 2018 10:09:32 GMT",
         "url":"/v1/store/api/subscriptions/<int:subscription_id>/surveys/1663879016/"
      }
   ]
}

Get results for an individual survey:

GET /v1/store/api/subscriptions/{subscription_id}/surveys/{product_survey_result_id}
$.get('/v1/store/api/subscriptions/{subscription_id}/surveys/{product_survey_result_id}')
{
   "answers":[
      {
         "field":{
            "id":1618805539,
            "survey":{
               "id":1618805536,
               "type":"product_survey"
            },
            "survey_id":1618805536,
            "type":"product_survey_field"
         },
         "field_id":1618805539,
         "id":1663879030,
         "value":"I like turtles!"
      },
      {
         "field":{
            "id":1618805540,
            "survey":{
               "id":1618805536,
               "type":"product_survey"
            },
            "survey_id":1618805536,
            "type":"product_survey_field"
         },
         "field_id":1618805540,
         "id":1663879029,
         "value":"2014-07-22"

      }
   ],
   "created_at":"Mon, 23 Jul 2018 10:09:33 GMT",
   "id":1663879024,
   "subscription_id":1663878876,
   "type":"product_survey_result",
   "updated_at":"Mon, 23 Jul 2018 10:09:33 GMT"

}

Update a Survey Response

PUT /v1/store/api/subscriptions/{subscription_id}/surveys/{product_survey_result_id}

Survey responses are immutable. When you make a PUT request to update survey responses, note that the response ID will have changed, as we perform a delete-and-add update rather than an edit in-place update.
The entire survey result needs to be sent. You can't update an individual answer of a multiple-question survey; the entire existing result will be deleted and replaced, so you have to send the full set of field/answers pairs you want.

$.ajax({
	url: '/v1/store/api/subscriptions/{subscription_id}/surveys/{product_survey_result_id}',
	contentType: 'application/json',
	data: JSON.stringify(
		{
		  "answers":
			{
				"{field_id}": "Turtles carry salmonella? Gross!",
				"{field_id": "2014-07-01"
			}
		}
	),
	dataType: 'json',
	type: 'PUT',
})
{
   "answers":[
      {
         "field":{
            "id":1618805539,
            "survey":{
               "id":1618805536,
               "type":"product_survey"
            },
            "survey_id":1618805536,
            "type":"product_survey_field"
         },
         "field_id":1618805539,
         "id":1663936001,
         "value":"Turtles carry salmonella? Gross!"
      },
      {
         "field":{
            "id":1618805540,
            "survey":{
               "id":1618805536,
               "type":"product_survey"
            },
            "survey_id":1618805536,
            "type":"product_survey_field"
         },
         "field_id":1618805540,
         "id":1663936000,
         "value":"2014-07-01"
      }
   ],
   "created_at":"Mon, 23 Jul 2018 10:09:33 GMT",
   "id":1663879024,
   "subscription_id":1663878876,
   "type":"product_survey_result",
   "updated_at":"Mon, 23 Jul 2018 10:09:33 GMT"
}