-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathRestLabelClient.cs
More file actions
65 lines (56 loc) · 2.33 KB
/
Copy pathRestLabelClient.cs
File metadata and controls
65 lines (56 loc) · 2.33 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System.Linq;
using CallFire_csharp_sdk.API.Rest.Data;
using CallFire_csharp_sdk.API.Soap;
using CallFire_csharp_sdk.Common;
using CallFire_csharp_sdk.Common.Resource;
using CallFire_csharp_sdk.Common.Result;
using CallFire_csharp_sdk.Common.Result.Mappers;
namespace CallFire_csharp_sdk.API.Rest.Clients
{
public class RestLabelClient : BaseRestClient<Label>, ILabelClient
{
public RestLabelClient(string username, string password)
: base(username, password)
{
}
internal RestLabelClient(IHttpClient xmlClient)
: base(xmlClient)
{
}
public void DeleteLabel(string labelName)
{
BaseRequest<string>(HttpMethod.Delete, new DeleteLabel(labelName), new CallfireRestRoute<Label>());
}
public CfLabelQueryResult QueryLabels(CfQuery queryLabels)
{
var resource = BaseRequest<ResourceList>(HttpMethod.Get, new Query(queryLabels),
new CallfireRestRoute<Label>());
return LabelQueryResultMapper.FromSoapLabelQueryResult(
new LabelQueryResult
{
TotalResults = resource.TotalResults,
Label = resource.Resource.Select(r => (r as Label)).ToArray()
});
}
public void LabelBroadcast(long id, string labelName)
{
BaseRequest<string>(HttpMethod.Post, new IdLabelRequest(id, labelName),
new CallfireRestRoute<Label>(id, LabelRestRouteObjects.Broadcast, null));
}
public void UnlabelBroadcast(long id, string labelName)
{
BaseRequest<string>(HttpMethod.Delete, new IdLabelRequest(id, labelName),
new CallfireRestRoute<Label>(id, LabelRestRouteObjects.Broadcast, null));
}
public void LabelNumber(string number, string labelName)
{
BaseRequest<string>(HttpMethod.Post, new NumberLabelRequest(number, labelName),
new CallfireRestRoute<Label>(null, LabelRestRouteObjects.Number, number));
}
public void UnlabelNumber(string number, string labelName)
{
BaseRequest<string>(HttpMethod.Delete, new NumberLabelRequest(number, labelName),
new CallfireRestRoute<Label>(null, LabelRestRouteObjects.Number, number));
}
}
}