-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathRestCallClient.cs
More file actions
79 lines (67 loc) · 3.02 KB
/
Copy pathRestCallClient.cs
File metadata and controls
79 lines (67 loc) · 3.02 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using System;
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.DataManagement;
using CallFire_csharp_sdk.Common.Resource;
using CallFire_csharp_sdk.Common.Resource.Mappers;
using CallFire_csharp_sdk.Common.Result;
namespace CallFire_csharp_sdk.API.Rest.Clients
{
public class RestCallClient : BaseRestClient<Call>, ICallClient
{
public RestCallClient(string username, string password)
: base(username, password)
{
}
internal RestCallClient(IHttpClient xmlClient)
: base(xmlClient)
{
}
public long SendCall(CfSendCall cfSendCall)
{
var resource = BaseRequest<ResourceReference>(HttpMethod.Post, new SendCall(cfSendCall), new CallfireRestRoute<Call>());
return resource.Id;
}
public CfCallQueryResult QueryCalls(CfActionQuery cfQueryCalls)
{
var resourceList = BaseRequest<ResourceList>(HttpMethod.Get, new ActionQuery(cfQueryCalls),
new CallfireRestRoute<Call>());
var call = resourceList.Resource == null ? null
: resourceList.Resource.Select(r => CallMapper.FromCall((Call)r)).ToArray();
return new CfCallQueryResult(resourceList.TotalResults, call);
}
public CfCall GetCall(long id)
{
var resource = BaseRequest<Resource>(HttpMethod.Get, null, new CallfireRestRoute<Call>(id));
return CallMapper.FromCall(resource.Resources as Call);
}
public long CreateSound(CfCreateSound cfCreateSound, CfSoundFormat cfSoundFormat)
{
var resource = BaseRequest<ResourceReference>(HttpMethod.Post, new CreateSound(cfCreateSound), new CallfireRestRoute<Call>(null, CallRestRouteObjects.Sound, null), cfSoundFormat);
return resource.Id;
}
public CfSoundMetaQueryResult QuerySoundMeta(CfQuery cfQuerySoundMeta)
{
var resourceList = BaseRequest<ResourceList>(HttpMethod.Get, new Query(cfQuerySoundMeta),
new CallfireRestRoute<Call>(null, CallRestRouteObjects.Sound, null));
var soundMeta = resourceList.Resource == null ? null
: resourceList.Resource.Select(r => SoundMetaMapper.FromSoundMeta((SoundMeta)r)).ToArray();
return new CfSoundMetaQueryResult(resourceList.TotalResults, soundMeta);
}
public CfSoundMeta GetSoundMeta(long id)
{
var resource = BaseRequest<Resource>(HttpMethod.Get, null, new CallfireRestRoute<Call>(id, CallRestRouteObjects.Sound, null));
return SoundMetaMapper.FromSoundMeta(resource.Resources as SoundMeta);
}
public byte[] GetSoundData(CfGetSoundData cfGetSoundData)
{
throw new NotImplementedException();
}
public byte[] GetRecordingData(CfGetRecordingData cfGetRecordingData)
{
throw new NotImplementedException();
}
}
}