public void PatchStoreDescription_Ok_PatchStoreWithJustDescription() { var ps = new PatchStore() { Description = "A new description" }; var store = Patch("abc", ps); Assert.Equal(store.Description, ps.Description); }
/// <summary> /// Patch (Update) a store /// </summary> /// <param name="storeId">ID of store to patch</param> /// <param name="store">Values which should be updated, null are ignored</param> public Store Patch(string storeId, PatchStore store) { if (string.IsNullOrEmpty(storeId)) { throw new Exception("You can't specify an empty storeId"); } var request = new RestRequest("v1/stores/{storeId}", Method.PATCH); request.AddUrlSegment("storeId", storeId); request.RequestFormat = DataFormat.Json; var serializer = new JsonSerializer { NullValueHandling = NullValueHandling.Ignore }; string bodyContent; using (var writer = new StringWriter()) { serializer.Serialize(writer, store); bodyContent = writer.ToString(); } request.AddParameter("application/json", bodyContent, ParameterType.RequestBody); Store patchedStore; try { patchedStore = DeserializeGet(_client.ExecuteRequest(request, HttpStatusCode.OK).Content); } catch (KeyNotFoundException) { throw new Exception("No Store found with ID : " + storeId); } return patchedStore; }
public Store Patch(string resourceId, PatchStore resource) { const string tictailJsonReponse = "{" + "\"description\": \"A new description\"," + "}"; var endpointDummy = new TictailEndpoint(new Uri("https://api.somewhere.com"), "accesstoken_abcdefhiljklmnopqrstuvxuz"); var clientTest = new TictailClientTest(endpointDummy); clientTest.Content = tictailJsonReponse; var repository = new TictailRepository(clientTest); return repository.Stores.Patch(resourceId, resource); }