public async void TestCreateSubscriberAsync(CreateSubscriberRequestModel requestModel) { var responseModel = await service.CreateSubscriberAsync(requestModel); Assert.NotNull(responseModel.HttpResponse); Assert.Equal(HttpStatusCode.OK, responseModel.HttpResponse.StatusCode); Assert.IsType <int>(responseModel.Data.SubscriberId); Assert.NotNull(responseModel.Data); var expectedLink = $"/api/account/{ACCOUNT_CODE}/subscribers/{responseModel.Data.SubscriberId}"; Assert.Equal(expectedLink, responseModel.Data.SubscriberInfoLink.Href); }
// Subscriber public abstract Task <GovDeliveryResponseModel <CreateSubscriberResponseModel> > CreateSubscriberAsync(CreateSubscriberRequestModel requestModel);
// Subscriber public override async Task <GovDeliveryResponseModel <CreateSubscriberResponseModel> > CreateSubscriberAsync(CreateSubscriberRequestModel requestModel) { var subscriberId = 555; var responseModel = new CreateSubscriberResponseModel { SubscriberId = subscriberId, SubscriberInfoLink = new LinkModel { Rel = "self", Href = $"/api/account/{accountCode}/subscribers/{subscriberId}" } }; var httpResponse = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = SerializationUtils.ModelToStringContent(responseModel) }; var responseData = await SerializationUtils.ResponseContentToModel <CreateSubscriberResponseModel>(httpResponse.Content); return(new GovDeliveryResponseModel <CreateSubscriberResponseModel> { HttpResponse = httpResponse, Data = responseData }); }
public override async Task <GovDeliveryResponseModel <CreateSubscriberResponseModel> > CreateSubscriberAsync(CreateSubscriberRequestModel model) { var res = await client.PutAsync("subscriptions.xml", SerializationUtils.ModelToStringContent(model)); InterceptHttpError(res); return(new GovDeliveryResponseModel <CreateSubscriberResponseModel> { HttpResponse = res, Data = null, }); }