-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8a39abd
commit fbaa6ec
Showing
14 changed files
with
252 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using Newtonsoft.Json; | ||
using Nexmo.Api.Applications.Capabilities; | ||
|
||
namespace Nexmo.Api.Applications | ||
{ | ||
public class Application | ||
{ | ||
[JsonProperty("id")] | ||
public string Id { get; set; } | ||
|
||
[JsonProperty("name")] | ||
public string Name { get; set; } | ||
|
||
[JsonProperty("capabilities")] | ||
public Capability[] Capabilities { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using Nexmo.Api.Request; | ||
|
||
namespace Nexmo.Api.Applications | ||
{ | ||
public class ApplicationClient : IApplicationClient | ||
{ | ||
public Credentials Credentials { get; set; } | ||
public ApplicationClient(Credentials creds) | ||
{ | ||
Credentials = creds; | ||
} | ||
public Application CreateApplicaiton(CreateApplicationRequest request, Credentials creds = null) | ||
{ | ||
return ApiRequest.DoRequestWithJsonContent<Application>( | ||
"POST", | ||
ApiRequest.GetBaseUriFor(typeof(ApplicationV2), "/v2/applications"), | ||
request, | ||
ApiRequest.AuthType.Basic, | ||
creds ?? Credentials | ||
); | ||
} | ||
|
||
public PaginatedResponse<ApplicationList> ListApplications(ListApplicationsRequest request, Credentials creds = null) | ||
{ | ||
return ApiRequest.DoGetRequestWithUrlContent<PaginatedResponse<Api.Applications.ApplicationList>>( | ||
ApiRequest.GetBaseUriFor(typeof(ApplicationV2), "/v2/applications"), | ||
ApiRequest.AuthType.Basic, | ||
request, | ||
creds ?? Credentials | ||
); | ||
} | ||
|
||
public Application GetApplication(string id, Credentials creds) | ||
{ | ||
return ApiRequest.DoGetRequestWithUrlContent<Application>( | ||
ApiRequest.GetBaseUriFor(typeof(ApplicationV2), $"/v2/applications{id}"), | ||
ApiRequest.AuthType.Basic, | ||
credentials: creds ?? Credentials | ||
); | ||
} | ||
|
||
public Application UpdateApplication(string id, CreateApplicationRequest request, Credentials creds = null) | ||
{ | ||
return ApiRequest.DoRequestWithJsonContent<Application>( | ||
"PUT", | ||
ApiRequest.GetBaseUriFor(typeof(ApplicationV2), $"/v2/applications{id}"), | ||
request, | ||
ApiRequest.AuthType.Basic, | ||
creds ?? Credentials | ||
); | ||
} | ||
|
||
public bool DeleteApplication(string id, Credentials creds) | ||
{ | ||
ApiRequest.DoDeleteRequestWithUrlContent( | ||
ApiRequest.GetBaseUriFor(typeof(ApplicationV2), $"/v2/applications{id}"), | ||
null, | ||
creds ?? Credentials | ||
); | ||
return true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using Newtonsoft.Json; | ||
using System.Collections.Generic; | ||
namespace Nexmo.Api.Applications | ||
{ | ||
public class ApplicationList | ||
{ | ||
[JsonProperty("applications")] | ||
public IList<Application> Applications { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using Nexmo.Api.Common; | ||
using Newtonsoft.Json; | ||
|
||
namespace Nexmo.Api.Applications.Capabilities | ||
{ | ||
public abstract class Capability | ||
{ | ||
[JsonProperty("webhooks")] | ||
public IDictionary<Common.Webhook.Type,Common.Webhook> Webhooks { get; set; } | ||
|
||
[JsonIgnore] | ||
public CapabilityType Type { get; protected set; } | ||
|
||
public enum CapabilityType | ||
{ | ||
[Description("voice")] | ||
Voice, | ||
[Description("rtc")] | ||
Rtc, | ||
[Description("messages")] | ||
Messages, | ||
[Description("vbc")] | ||
Vbc | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Nexmo.Api.Applications.Capabilities | ||
{ | ||
public class Messages : Capability | ||
{ | ||
public Messages(IDictionary<Common.Webhook.Type, Common.Webhook> webhooks) | ||
{ | ||
this.Webhooks = webhooks; | ||
this.Type = CapabilityType.Messages; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Nexmo.Api.Applications.Capabilities | ||
{ | ||
public class Rtc : Capability | ||
{ | ||
public Rtc(IDictionary<Common.Webhook.Type, Common.Webhook> webhooks) | ||
{ | ||
this.Webhooks = webhooks; | ||
this.Type = CapabilityType.Rtc; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace Nexmo.Api.Applications.Capabilities | ||
{ | ||
public class Vbc : Capability | ||
{ | ||
public Vbc() | ||
{ | ||
Type = CapabilityType.Vbc; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Nexmo.Api.Applications.Capabilities | ||
{ | ||
public class Voice : Capability | ||
{ | ||
public Voice(IDictionary<Common.Webhook.Type, Common.Webhook> webhooks) | ||
{ | ||
this.Webhooks = Webhooks; | ||
this.Type = Capability.CapabilityType.Voice; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Newtonsoft.Json; | ||
using Nexmo.Api.Applications.Capabilities; | ||
|
||
namespace Nexmo.Api.Applications | ||
{ | ||
public class CreateApplicationRequest | ||
{ | ||
[JsonProperty("name")] | ||
public string Name { get; set; } | ||
|
||
[JsonProperty("capabilities")] | ||
public Capability[] Capabilities { get; set; } | ||
|
||
[JsonProperty("keys")] | ||
public Keys Keys { get; set; } | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Nexmo.Api.Request; | ||
|
||
namespace Nexmo.Api.Applications | ||
{ | ||
public interface IApplicationClient | ||
{ | ||
Application CreateApplicaiton(CreateApplicationRequest request, Credentials creds = null); | ||
PaginatedResponse<ApplicationList> ListApplications(ListApplicationsRequest request, Credentials creds = null); | ||
Application GetApplication(string id, Credentials creds); | ||
Application UpdateApplication(string id, CreateApplicationRequest request, Credentials creds = null); | ||
bool DeleteApplication(string id, Credentials creds); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace Nexmo.Api.Applications | ||
{ | ||
public class Keys | ||
{ | ||
[JsonProperty("public_key")] | ||
public string PublicKey { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace Nexmo.Api.Applications | ||
{ | ||
public class ListApplicationsRequest | ||
{ | ||
[JsonProperty("page_size")] | ||
public int PageSize { get; set; } | ||
|
||
[JsonProperty("page")] | ||
public int Page { get; set; } | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System.ComponentModel; | ||
using System.Net.Http; | ||
using Newtonsoft.Json; | ||
|
||
namespace Nexmo.Api.Common | ||
{ | ||
public class Webhook | ||
{ | ||
[JsonProperty("http_method")] | ||
public HttpMethod Method { get; set; } | ||
|
||
[JsonProperty("address")] | ||
public string Address { get; set; } | ||
|
||
public enum Type | ||
{ | ||
[Description("answer_url")] | ||
Answer=1, | ||
[Description("event_url")] | ||
Event=2, | ||
[Description("inbound_url")] | ||
Inbound=3, | ||
[Description("status_url")] | ||
Status=4, | ||
[Description("unknown")] | ||
Unknown=5 | ||
} | ||
|
||
} | ||
} |