-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathFetchDeleteService.cs
More file actions
47 lines (43 loc) · 1.65 KB
/
FetchDeleteService.cs
File metadata and controls
47 lines (43 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System;
using Contentstack.Management.Core.Queryable;
using Newtonsoft.Json;
using Contentstack.Management.Core.Utils;
namespace Contentstack.Management.Core.Services.Models
{
internal class FetchDeleteService: ContentstackService
{
#region Internal
internal FetchDeleteService(JsonSerializer serializer, Core.Models.Stack stack, string resourcePath, string httpMethod = "GET", ParameterCollection collection = null)
: base(serializer, stack: stack, collection)
{
if (stack.APIKey == null)
{
throw new ArgumentNullException("stack", CSConstants.MissingAPIKey);
}
if (resourcePath == null)
{
throw new ArgumentNullException("resourcePath", CSConstants.ResourcePathRequired);
}
this.ResourcePath = resourcePath;
this.HttpMethod = httpMethod;
if (collection != null && collection.Count > 0)
{
this.UseQueryString = true;
}
}
#endregion
/// <summary>
/// Skip Content-Type for DELETE /releases (single release delete). Keep it for DELETE /releases/{uid}/item and other requests.
/// </summary>
protected override bool ShouldSetContentType()
{
if (HttpMethod != "DELETE" || string.IsNullOrEmpty(ResourcePath))
return true;
if (!ResourcePath.StartsWith("/releases", StringComparison.Ordinal))
return true;
if (ResourcePath.EndsWith("/item", StringComparison.Ordinal))
return true;
return false;
}
}
}