From 3883be55c0ffb5c2b97fcfaf72a81a57d46ba5d8 Mon Sep 17 00:00:00 2001 From: Khalil Mohammad Mirza Date: Thu, 22 Jun 2023 17:06:25 +0500 Subject: [PATCH] updates --- .../AccessIPAddresses/AccessIPAddress.cs | 60 +++++ .../AccessIPAddressCreateOption.cs | 23 ++ .../AccessIPAddressListOptions.cs | 42 +++ .../Entities/AccessIPRanges/AccessIPRanges.cs | 53 ++++ .../AccessIPRangesCreateOption.cs | 25 ++ .../AccessIPRangesListOption.cs | 53 ++++ .../Entities/AccessToken/AccessToken.cs | 17 ++ .../AuthenticationProviderCreateOption.cs | 41 +++ .../AuthenticationProviderListOption.cs | 15 ++ .../AuthenticationProviders.cs | 52 ++++ .../AuthenticationProviders/NameObject.cs | 27 ++ .../AuthenticationProviders/SettingsObject.cs | 34 +++ .../SettingsRequestObject.cs | 31 +++ .../CallControl/ClientState/ClientState.cs | 17 ++ .../AccessIPAddresses/CloudflareSyncStatus.cs | 19 ++ .../AccessIPRanges/CloudflareSyncStatus.cs | 19 ++ .../FingerprintAlgorithm.cs | 28 ++ .../Enum/AuthenticationProviders/Sort.cs | 28 ++ src/Telnyx.net/Infrastructure/Requestor.cs | 2 +- .../AccessIPAddressService.cs | 57 ++++ .../AccessIPRanges/AcessIPRangesService.cs | 52 ++++ .../AccessToken/AccessTokenService.cs | 32 +++ .../AuthenticationProviderServices.cs | 70 +++++ .../Calls/CallControl/CallControlService.cs | 12 + .../ClientState/ClientStateService.cs | 35 +++ .../CallControlApplicationService.cs | 7 +- src/Telnyx.net/Services/Service.cs | 143 ++++++---- src/Telnyx.net/Services/ServiceNested.cs | 8 +- .../Wireless/WDRReports/WDRReportsService.cs | 8 +- src/Telnyx.net/Telnyx.net.csproj | 1 + src/Telnyx.net/stylecop3.json | 14 + .../AccessIPAddressListOptionsTest.cs | 124 +++++++++ .../AccessIpAddressCreateOptionTest.cs | 113 ++++++++ .../AccessIPRangesCreateTest.cs | 107 ++++++++ .../AccessIPRanges/AccessIPRangesListTest.cs | 82 ++++++ .../Services/AccessToken/AccessTokenTest.cs | 50 ++++ .../AuthenticationProviderCreateTest.cs | 244 ++++++++++++++++++ .../AuthenticationProviderListTest.cs | 92 +++++++ .../ClientState/ClientStateTest.cs | 50 ++++ .../DisableManagedAccountsTest.cs | 26 +- .../NotificationProfileTest.cs | 4 +- .../NotificationSettingTest.cs | 3 +- 42 files changed, 1849 insertions(+), 71 deletions(-) create mode 100644 src/Telnyx.net/Entities/AccessIPAddresses/AccessIPAddress.cs create mode 100644 src/Telnyx.net/Entities/AccessIPAddresses/AccessIPAddressCreateOption.cs create mode 100644 src/Telnyx.net/Entities/AccessIPAddresses/AccessIPAddressListOptions.cs create mode 100644 src/Telnyx.net/Entities/AccessIPRanges/AccessIPRanges.cs create mode 100644 src/Telnyx.net/Entities/AccessIPRanges/AccessIPRangesCreateOption.cs create mode 100644 src/Telnyx.net/Entities/AccessIPRanges/AccessIPRangesListOption.cs create mode 100644 src/Telnyx.net/Entities/AccessToken/AccessToken.cs create mode 100644 src/Telnyx.net/Entities/AuthenticationProviders/AuthenticationProviderCreateOption.cs create mode 100644 src/Telnyx.net/Entities/AuthenticationProviders/AuthenticationProviderListOption.cs create mode 100644 src/Telnyx.net/Entities/AuthenticationProviders/AuthenticationProviders.cs create mode 100644 src/Telnyx.net/Entities/AuthenticationProviders/NameObject.cs create mode 100644 src/Telnyx.net/Entities/AuthenticationProviders/SettingsObject.cs create mode 100644 src/Telnyx.net/Entities/AuthenticationProviders/SettingsRequestObject.cs create mode 100644 src/Telnyx.net/Entities/Calls/CallControl/ClientState/ClientState.cs create mode 100644 src/Telnyx.net/Entities/Enum/AccessIPAddresses/CloudflareSyncStatus.cs create mode 100644 src/Telnyx.net/Entities/Enum/AccessIPRanges/CloudflareSyncStatus.cs create mode 100644 src/Telnyx.net/Entities/Enum/AuthenticationProviders/FingerprintAlgorithm.cs create mode 100644 src/Telnyx.net/Entities/Enum/AuthenticationProviders/Sort.cs create mode 100644 src/Telnyx.net/Services/AccessIPAddresses/AccessIPAddressService.cs create mode 100644 src/Telnyx.net/Services/AccessIPRanges/AcessIPRangesService.cs create mode 100644 src/Telnyx.net/Services/AccessToken/AccessTokenService.cs create mode 100644 src/Telnyx.net/Services/AuthenticationProviders/AuthenticationProviderServices.cs create mode 100644 src/Telnyx.net/Services/Calls/CallControl/ClientState/ClientStateService.cs create mode 100644 src/Telnyx.net/stylecop3.json create mode 100644 src/TelnyxTests/Services/AccessIPAddress/AccessIPAddressListOptionsTest.cs create mode 100644 src/TelnyxTests/Services/AccessIPAddress/AccessIpAddressCreateOptionTest.cs create mode 100644 src/TelnyxTests/Services/AccessIPRanges/AccessIPRangesCreateTest.cs create mode 100644 src/TelnyxTests/Services/AccessIPRanges/AccessIPRangesListTest.cs create mode 100644 src/TelnyxTests/Services/AccessToken/AccessTokenTest.cs create mode 100644 src/TelnyxTests/Services/AuthenticationProvider/AuthenticationProviderCreateTest.cs create mode 100644 src/TelnyxTests/Services/AuthenticationProvider/AuthenticationProviderListTest.cs create mode 100644 src/TelnyxTests/Services/Calls/CallControl/ClientState/ClientStateTest.cs diff --git a/src/Telnyx.net/Entities/AccessIPAddresses/AccessIPAddress.cs b/src/Telnyx.net/Entities/AccessIPAddresses/AccessIPAddress.cs new file mode 100644 index 00000000..02f75ff8 --- /dev/null +++ b/src/Telnyx.net/Entities/AccessIPAddresses/AccessIPAddress.cs @@ -0,0 +1,60 @@ + + +using Newtonsoft.Json; +using System; +using Telnyx.net.Entities.Enum.AccessIPAddresses; + +namespace Telnyx.net.Entities.AccessIPAddresses +{ + public class AccessIPAddress : TelnyxEntity + { + /// + /// The ISO 8601 formatted date indicating when the resource was created. + /// + [JsonProperty("created_at")] + public DateTime CreatedAt { get; set; } + + /// + /// The description of the resource. + /// + [JsonProperty("description")] + public string Description { get; set; } + + /// + /// The ID of the resource. + /// + [JsonProperty("id")] + public string Id { get; set; } + + /// + /// The IP address value. + /// + [JsonProperty("ip_address")] + public string IpAddress { get; set; } + + /// + /// The source value. + /// + [JsonProperty("source")] + public string Source { get; set; } + + /// + /// The status of the Cloudflare sync. + /// + [JsonProperty("status")] + public CloudflareSyncStatus Status { get; set; } + + /// + /// The ISO 8601 formatted date indicating when the resource was last updated. + /// + [JsonProperty("updated_at")] + public DateTime UpdatedAt { get; set; } + + /// + /// The ID of the user. + /// + [JsonProperty("user_id")] + public string UserId { get; set; } + + } +} diff --git a/src/Telnyx.net/Entities/AccessIPAddresses/AccessIPAddressCreateOption.cs b/src/Telnyx.net/Entities/AccessIPAddresses/AccessIPAddressCreateOption.cs new file mode 100644 index 00000000..f325115f --- /dev/null +++ b/src/Telnyx.net/Entities/AccessIPAddresses/AccessIPAddressCreateOption.cs @@ -0,0 +1,23 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; +using Telnyx.net.Entities.Enum.AccessIPAddresses; + +namespace Telnyx.net.Entities.AccessIPAddresses +{ + public class AccessIPAddressCreateOptions : BaseOptions + { + /// + /// The description. + /// + [JsonProperty("description")] + public string Description { get; set; } + + /// + /// The IP address. + /// + [JsonProperty("ip_address")] + public string IpAddress { get; set; } + } +} diff --git a/src/Telnyx.net/Entities/AccessIPAddresses/AccessIPAddressListOptions.cs b/src/Telnyx.net/Entities/AccessIPAddresses/AccessIPAddressListOptions.cs new file mode 100644 index 00000000..8400fc9f --- /dev/null +++ b/src/Telnyx.net/Entities/AccessIPAddresses/AccessIPAddressListOptions.cs @@ -0,0 +1,42 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; +using Telnyx.net.Entities.Enum.AccessIPAddresses; + +namespace Telnyx.net.Entities.AccessIPAddresses +{ + public class AccessIPAddressListOptions : ListOptions + { + /// + /// Filter by the IP source. + /// + [JsonProperty("filter[ip_source]")] + public string IpSource { get; set; } + + /// + /// Filter by the IP address. + /// + [JsonProperty("filter[ip_address]")] + public string IpAddress { get; set; } + + /// + /// Filter by the status of the Cloudflare sync. + /// + [JsonProperty("filter[status]")] + public CloudflareSyncStatus Status { get; set; } + + /// + /// Filter by the created date after the specified datetime. + /// + [JsonProperty("filter[created_at][gt]")] + public string CreatedAtGreaterThan { get; set; } + + /// + /// Filter by the created date before the specified datetime. + /// + [JsonProperty("filter[created_at][lt]")] + public string CreatedAtLessThan { get; set; } + + } +} diff --git a/src/Telnyx.net/Entities/AccessIPRanges/AccessIPRanges.cs b/src/Telnyx.net/Entities/AccessIPRanges/AccessIPRanges.cs new file mode 100644 index 00000000..7537a70d --- /dev/null +++ b/src/Telnyx.net/Entities/AccessIPRanges/AccessIPRanges.cs @@ -0,0 +1,53 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; +using Telnyx.net.Entities.Enum.AccessIPRanges; + +namespace Telnyx.net.Entities.AccessIPRanges +{ + public class AccessIPRanges : TelnyxEntity + { + /// + /// The CIDR block. + /// + [JsonProperty("cidr_block")] + public string CidrBlock { get; set; } + + /// + /// The created date. + /// + [JsonProperty("created_at")] + public DateTime CreatedAt { get; set; } + + /// + /// The description. + /// + [JsonProperty("description")] + public string Description { get; set; } + + /// + /// The ID. + /// + [JsonProperty("id")] + public string Id { get; set; } + + /// + /// The status. + /// + [JsonProperty("status")] + public CloudflareSyncStatus Status { get; set; } + + /// + /// The updated date. + /// + [JsonProperty("updated_at")] + public DateTime UpdatedAt { get; set; } + + /// + /// The user ID. + /// + [JsonProperty("user_id")] + public string UserId { get; set; } + } +} diff --git a/src/Telnyx.net/Entities/AccessIPRanges/AccessIPRangesCreateOption.cs b/src/Telnyx.net/Entities/AccessIPRanges/AccessIPRangesCreateOption.cs new file mode 100644 index 00000000..1cceeb6b --- /dev/null +++ b/src/Telnyx.net/Entities/AccessIPRanges/AccessIPRangesCreateOption.cs @@ -0,0 +1,25 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace Telnyx.net.Entities.AccessIPRanges +{ + public class AccessIPRangesCreateOption : BaseOptions + { + /// + /// The CIDR block. + /// + [JsonProperty("cidr_block")] + public string CidrBlock { get; set; } + + /// + /// The description. + /// + [JsonProperty("description")] + public string Description { get; set; } + + + + } +} diff --git a/src/Telnyx.net/Entities/AccessIPRanges/AccessIPRangesListOption.cs b/src/Telnyx.net/Entities/AccessIPRanges/AccessIPRangesListOption.cs new file mode 100644 index 00000000..1d34e4e7 --- /dev/null +++ b/src/Telnyx.net/Entities/AccessIPRanges/AccessIPRangesListOption.cs @@ -0,0 +1,53 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; +using Telnyx.net.Entities.Enum.AccessIPRanges; + +namespace Telnyx.net.Entities.AccessIPRanges +{ + public class AccessIPRangesListOption : ListOptions + { + /// + /// The CIDR block. + /// + [JsonProperty("filter[cidr_block]")] + public string CidrBlock { get; set; } + + /// + /// The CIDR block starts with. + /// + [JsonProperty("filter[cidr_block][startswith]")] + public string CidrBlockStartsWith { get; set; } + + /// + /// The CIDR block ends with. + /// + [JsonProperty("filter[cidr_block][endswith]")] + public string CidrBlockEndsWith { get; set; } + + /// + /// The CIDR block contains. + /// + [JsonProperty("filter[cidr_block][contains]")] + public string CidrBlockContains { get; set; } + + /// + /// The status. + /// + [JsonProperty("filter[status]")] + public CloudflareSyncStatus Status { get; set; } + + /// + /// The created at greater than filter. + /// + [JsonProperty("filter[created_at][gt]")] + public DateTime CreatedAtGreaterThan { get; set; } + + /// + /// The created at less than filter. + /// + [JsonProperty("filter[created_at][lt]")] + public DateTime CreatedAtLessThan { get; set; } + } +} diff --git a/src/Telnyx.net/Entities/AccessToken/AccessToken.cs b/src/Telnyx.net/Entities/AccessToken/AccessToken.cs new file mode 100644 index 00000000..b11b4659 --- /dev/null +++ b/src/Telnyx.net/Entities/AccessToken/AccessToken.cs @@ -0,0 +1,17 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace Telnyx.net.Entities.AccessToken +{ + public class AccessTokenCreate : TelnyxEntity + { + /// + /// Identifies the resource. + /// + public string Response { get; set; } + + + } +} diff --git a/src/Telnyx.net/Entities/AuthenticationProviders/AuthenticationProviderCreateOption.cs b/src/Telnyx.net/Entities/AuthenticationProviders/AuthenticationProviderCreateOption.cs new file mode 100644 index 00000000..2cda02a8 --- /dev/null +++ b/src/Telnyx.net/Entities/AuthenticationProviders/AuthenticationProviderCreateOption.cs @@ -0,0 +1,41 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace Telnyx.net.Entities.AuthenticationProviders +{ + public class AuthenticationProviderCreateOption : BaseOptions + { + /// + /// The active status of the authentication provider. + /// + [JsonProperty("active")] + public bool Active { get; set; } + + /// + /// Full contact name. + /// + [JsonProperty("name")] + public string Name { get; set; } + + /// + /// The settings associated with the authentication provider. + /// + [JsonProperty("settings")] + public SettingsObject Settings { get; set; } + + /// + /// The URL for the identity provider metadata file to populate the settings automatically. If the settings attribute is provided, that will be used instead. + /// + [JsonProperty("settings_url")] + public string SettingsUrl { get; set; } + + /// + /// The short name associated with the authentication provider. This must be unique and URL-friendly, as it's going to be part of the login URL. + /// + [JsonProperty("short_name")] + public string ShortName { get; set; } + + } +} diff --git a/src/Telnyx.net/Entities/AuthenticationProviders/AuthenticationProviderListOption.cs b/src/Telnyx.net/Entities/AuthenticationProviders/AuthenticationProviderListOption.cs new file mode 100644 index 00000000..b2f533be --- /dev/null +++ b/src/Telnyx.net/Entities/AuthenticationProviders/AuthenticationProviderListOption.cs @@ -0,0 +1,15 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; +using Telnyx.net.Entities.Enum.AuthenticationProviders; +using Telnyx.net.Services.PhoneNumbers.Orders.Comments; + +namespace Telnyx.net.Entities.AuthenticationProviders +{ + public class AuthenticationProviderListOption : ListOptions + { + [JsonProperty("sort")] + public Sort Sort { get; set; } = Sort.Name; + } +} diff --git a/src/Telnyx.net/Entities/AuthenticationProviders/AuthenticationProviders.cs b/src/Telnyx.net/Entities/AuthenticationProviders/AuthenticationProviders.cs new file mode 100644 index 00000000..9de3a951 --- /dev/null +++ b/src/Telnyx.net/Entities/AuthenticationProviders/AuthenticationProviders.cs @@ -0,0 +1,52 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Runtime; +using System.Text; +using System.Xml.Linq; + +namespace Telnyx.net.Entities.AuthenticationProviders +{ + public class AuthenticationProviders : TelnyxEntity + { + /// + /// The active status of the authentication provider. + /// + [JsonProperty("active")] + public bool Active { get; set; } + + [JsonProperty("created_at")] + public DateTime CreatedAt { get; set; } + + [JsonProperty("id")] + public Guid Id { get; set; } + + /// + /// Full contact name. + /// + [JsonProperty("name")] + public string Name { get; set; } + + [JsonProperty("organization_id")] + public Guid OrganizationId { get; set; } + + [JsonProperty("record_type")] + public string RecordType { get; set; } + + /// + /// The settings associated with the authentication provider. + /// + [JsonProperty("settings")] + public SettingsObject Settings { get; set; } + + /// + /// The short name associated with the authentication provider. This must be unique and URL-friendly, as it's going to be part of the login URL. + /// + [JsonProperty("short_name")] + public string ShortName { get; set; } + + [JsonProperty("updated_at")] + public DateTime UpdatedAt { get; set; } + + } +} diff --git a/src/Telnyx.net/Entities/AuthenticationProviders/NameObject.cs b/src/Telnyx.net/Entities/AuthenticationProviders/NameObject.cs new file mode 100644 index 00000000..ee6451ff --- /dev/null +++ b/src/Telnyx.net/Entities/AuthenticationProviders/NameObject.cs @@ -0,0 +1,27 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; +using Telnyx.net.Entities.Enum.AuthenticationProviders; +using Telnyx.net.Services.PhoneNumbers.Orders.Comments; + +namespace Telnyx.net.Entities.AuthenticationProviders +{ + public class NameObject + { + [JsonProperty("first_name")] + public string FirstName { get; set; } + + [JsonProperty("formatted_name")] + public string FormattedName { get; set; } + + [JsonProperty("last_name")] + public string LastName { get; set; } + + [JsonProperty("prefix")] + public string Prefix { get; set; } + + [JsonProperty("suffix")] + public string Suffix { get; set; } + } +} diff --git a/src/Telnyx.net/Entities/AuthenticationProviders/SettingsObject.cs b/src/Telnyx.net/Entities/AuthenticationProviders/SettingsObject.cs new file mode 100644 index 00000000..82ec98a4 --- /dev/null +++ b/src/Telnyx.net/Entities/AuthenticationProviders/SettingsObject.cs @@ -0,0 +1,34 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; +using Telnyx.net.Entities.Enum.AuthenticationProviders; +using Telnyx.net.Services.PhoneNumbers.Orders.Comments; + +namespace Telnyx.net.Entities.AuthenticationProviders +{ + public class SettingsObject + { + [JsonProperty("assertion_consumer_service_url")] + public string AssertionConsumerServiceUrl { get; set; } + + [JsonProperty("idp_cert_fingerprint")] + public string IdpCertFingerprint { get; set; } + + [JsonProperty("idp_cert_fingerprint_algorithm")] + public string IdpCertFingerprintAlgorithm { get; set; } = "sha1"; + + [JsonProperty("idp_entity_id")] + public string IdpEntityId { get; set; } + + [JsonProperty("idp_sso_target_url")] + public string IdpSsoTargetUrl { get; set; } + + [JsonProperty("name_identifier_format")] + public string NameIdentifierFormat { get; set; } + + [JsonProperty("service_provider_entity_id")] + public string ServiceProviderEntityId { get; set; } + + } +} diff --git a/src/Telnyx.net/Entities/AuthenticationProviders/SettingsRequestObject.cs b/src/Telnyx.net/Entities/AuthenticationProviders/SettingsRequestObject.cs new file mode 100644 index 00000000..7f7ef592 --- /dev/null +++ b/src/Telnyx.net/Entities/AuthenticationProviders/SettingsRequestObject.cs @@ -0,0 +1,31 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; +using Telnyx.net.Entities.Enum.AuthenticationProviders; +using Telnyx.net.Services.PhoneNumbers.Orders.Comments; + +namespace Telnyx.net.Entities.AuthenticationProviders +{ + public class SettingsRequestObject + { + [JsonProperty("idp_cert_fingerprint")] + public string IdPCertFingerprint { get; set; } + + [JsonProperty("idp_cert_fingerprint_algorithm")] + [JsonConverter(typeof(JsonStringEnumConverter))] + public FingerprintAlgorithm IdPCertFingerprintAlgorithm { get; set; } = FingerprintAlgorithm.Sha1; + + [JsonProperty("idp_entity_id")] + public string IdPEntityId { get; set; } + + [JsonProperty("idp_sso_target_url")] + public string IdPSSOTargetUrl { get; set; } + + /// + /// The URL for the identity provider metadata file to populate the settings automatically. If the settings attribute is provided, that will be used instead. + /// + [JsonProperty("settings_url")] + public string SettingsUrl { get; set; } + } +} diff --git a/src/Telnyx.net/Entities/Calls/CallControl/ClientState/ClientState.cs b/src/Telnyx.net/Entities/Calls/CallControl/ClientState/ClientState.cs new file mode 100644 index 00000000..1b7b180b --- /dev/null +++ b/src/Telnyx.net/Entities/Calls/CallControl/ClientState/ClientState.cs @@ -0,0 +1,17 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace Telnyx.net.Entities.Calls.CallControl.ClientState +{ + public class ClientStateOption : BaseOptions + { + /// + /// Use this field to add state to every subsequent webhook. It must be a valid Base-64 encoded string. + /// + [JsonProperty("client_state")] + public string ClientStates { get; set; } + + } +} diff --git a/src/Telnyx.net/Entities/Enum/AccessIPAddresses/CloudflareSyncStatus.cs b/src/Telnyx.net/Entities/Enum/AccessIPAddresses/CloudflareSyncStatus.cs new file mode 100644 index 00000000..125249f4 --- /dev/null +++ b/src/Telnyx.net/Entities/Enum/AccessIPAddresses/CloudflareSyncStatus.cs @@ -0,0 +1,19 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; + +namespace Telnyx.net.Entities.Enum.AccessIPAddresses +{ + [JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + public enum CloudflareSyncStatus + { + [EnumMember(Value = "pending")] + Pending, + + [EnumMember(Value = "added")] + Added + } +} diff --git a/src/Telnyx.net/Entities/Enum/AccessIPRanges/CloudflareSyncStatus.cs b/src/Telnyx.net/Entities/Enum/AccessIPRanges/CloudflareSyncStatus.cs new file mode 100644 index 00000000..d3d49708 --- /dev/null +++ b/src/Telnyx.net/Entities/Enum/AccessIPRanges/CloudflareSyncStatus.cs @@ -0,0 +1,19 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; + +namespace Telnyx.net.Entities.Enum.AccessIPRanges +{ + [JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + public enum CloudflareSyncStatus + { + [EnumMember(Value = "pending")] + Pending, + + [EnumMember(Value = "added")] + Added + } +} diff --git a/src/Telnyx.net/Entities/Enum/AuthenticationProviders/FingerprintAlgorithm.cs b/src/Telnyx.net/Entities/Enum/AuthenticationProviders/FingerprintAlgorithm.cs new file mode 100644 index 00000000..275d6362 --- /dev/null +++ b/src/Telnyx.net/Entities/Enum/AuthenticationProviders/FingerprintAlgorithm.cs @@ -0,0 +1,28 @@ +using Newtonsoft.Json.Linq; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; + +namespace Telnyx.net.Entities.Enum.AuthenticationProviders +{ + [JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + public enum FingerprintAlgorithm + { + [EnumMember(Value = "sha1")] + Sha1, + + [EnumMember(Value = "sha256")] + Sha256, + + [EnumMember(Value = "sha384")] + sha384, + + [EnumMember(Value = "sha256")] + sha256, + + [EnumMember(Value = "sha512")] + sha512, + } +} diff --git a/src/Telnyx.net/Entities/Enum/AuthenticationProviders/Sort.cs b/src/Telnyx.net/Entities/Enum/AuthenticationProviders/Sort.cs new file mode 100644 index 00000000..3bd030aa --- /dev/null +++ b/src/Telnyx.net/Entities/Enum/AuthenticationProviders/Sort.cs @@ -0,0 +1,28 @@ +using Newtonsoft.Json.Linq; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using System.Text; + +namespace Telnyx.net.Entities.Enum.AuthenticationProviders +{ + [JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + public enum Sort + { + [EnumMember(Value = "name")] + Name, + + [EnumMember(Value = "short_name")] + ShortName, + + [EnumMember(Value = "active")] + Active, + + [EnumMember(Value = "created_at")] + CreatedAt, + + [EnumMember(Value = "updated_at")] + UpdatedAt, + } +} diff --git a/src/Telnyx.net/Infrastructure/Requestor.cs b/src/Telnyx.net/Infrastructure/Requestor.cs index 2cdd56e6..9c8ab684 100644 --- a/src/Telnyx.net/Infrastructure/Requestor.cs +++ b/src/Telnyx.net/Infrastructure/Requestor.cs @@ -185,7 +185,7 @@ public static byte[] ExecuteFileRequest(HttpRequestMessage requestMessage) /// requestOptions. /// cancellationToken. /// telnyxResponse. - public static async Task GetStringAsync(string url, RequestOptions requestOptions, CancellationToken cancellationToken = default(CancellationToken)) + public static async Task GetStringAsync(string url, RequestOptions requestOptions,CancellationToken cancellationToken = default(CancellationToken)) { var wr = GetRequestMessage(url, HttpMethod.Get, requestOptions); diff --git a/src/Telnyx.net/Services/AccessIPAddresses/AccessIPAddressService.cs b/src/Telnyx.net/Services/AccessIPAddresses/AccessIPAddressService.cs new file mode 100644 index 00000000..b9d6db6c --- /dev/null +++ b/src/Telnyx.net/Services/AccessIPAddresses/AccessIPAddressService.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using System.Threading; +using Telnyx.net.Entities.AccessIPAddresses; +using Telnyx.net.Entities; + +namespace Telnyx.net.Services.AccessIPAddresses +{ + public class AccessIPAddressService : Service + { + + public AccessIPAddressService() + : base(null) { } + + public AccessIPAddressService(string apiKey) + : base(apiKey) { } + + public override string BasePath => "/access_ip_address"; + public TelnyxList ListAllAccessIPAddresses(AccessIPAddressListOptions listOptions, RequestOptions reqOpts = null) + { + return this.ListEntities(listOptions, reqOpts); + } + + public async Task> ListAllAccessIPAddressesAsync(AccessIPAddressListOptions listOptions, RequestOptions reqOpts = null, string parentToken = "") + { + return await this.ListEntitiesAsync(listOptions, reqOpts, parentToken); + } + public AccessIPAddress CreateAllAccessIPAddresses(AccessIPAddressCreateOptions createOptions, RequestOptions reqOpts = null) + { + return this.CreateEntity(createOptions, reqOpts); + } + + public async Task CreateAllAccessIPAddressesAsync(AccessIPAddressCreateOptions createOptions, RequestOptions reqOpts = null, CancellationToken ct = default) + { + return await this.CreateEntityAsync(createOptions, reqOpts, ct, parentToken: null); + } + public AccessIPAddress DeleteAllAccessIPAddresses(string id, RequestOptions requestOptions = null) + { + var a= this.DeleteEntity(id, requestOptions); + return a; + } + + public async Task DeleteAllAccessIPAddressesAsync(string id, RequestOptions requestOptions = null, CancellationToken ct = default) + { + return await this.DeleteEntityAsync(id, requestOptions, ct).ConfigureAwait(false); + } + public async Task RetrieveAllAccessIPAddressesAsync(string id, BaseOptions options = null, RequestOptions reqOpts = null, string parentToken = "",CancellationToken ct = default) + { + return await this.GetEntityAsync(id, options, reqOpts, parentToken,ct); + } + public AccessIPAddress RetrieveAllAccessIPAddresses(string id, BaseOptions options = null, RequestOptions reqOpts = null) + { + return this.GetEntity(id, options, reqOpts); + } + } +} diff --git a/src/Telnyx.net/Services/AccessIPRanges/AcessIPRangesService.cs b/src/Telnyx.net/Services/AccessIPRanges/AcessIPRangesService.cs new file mode 100644 index 00000000..5c2fc3db --- /dev/null +++ b/src/Telnyx.net/Services/AccessIPRanges/AcessIPRangesService.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using System.Threading; +using Telnyx.net.Entities.AccessIPRanges; +using Telnyx.net.Entities; + + +namespace Telnyx.net.Services.AccessIPRange +{ + public class AcessIPRangesService : Service + { + private string parentToken; + + public AcessIPRangesService() + : base(null) { } + + public AcessIPRangesService(string apiKey) + : base(apiKey) { } + + public override string BasePath => "/access_ip_ranges"; + public TelnyxList ListAllAccessIPRanges(AccessIPRangesListOption listOptions, RequestOptions reqOpts = null) + { + return this.ListEntities(listOptions, reqOpts); + } + + public async Task> ListAllAccessIPRangesAsync(AccessIPRangesListOption listOptions, RequestOptions reqOpts = null) + { + return await this.ListEntitiesAsync(listOptions, reqOpts, parentToken = ""); + } + public AccessIPRanges CreateAllAccessIPRanges(AccessIPRangesCreateOption createOptions, RequestOptions reqOpts = null) + { + return this.CreateEntity(createOptions, reqOpts); + } + + public async Task CreateAllAccessIPRangesAsync(AccessIPRangesCreateOption createOptions, RequestOptions reqOpts = null, CancellationToken ct = default) + { + return await this.CreateEntityAsync(createOptions, reqOpts, ct); + } + public AccessIPRanges DeleteAllAccessIPRanges(string id, RequestOptions requestOptions = null) + { + return this.DeleteEntity(id, requestOptions); + } + + public async Task DeleteAllAccessIPRangesAsync(string id, RequestOptions requestOptions = null, CancellationToken ct = default) + { + return await this.DeleteEntityAsync(id, requestOptions, ct).ConfigureAwait(false); + } + + } +} diff --git a/src/Telnyx.net/Services/AccessToken/AccessTokenService.cs b/src/Telnyx.net/Services/AccessToken/AccessTokenService.cs new file mode 100644 index 00000000..4b19e816 --- /dev/null +++ b/src/Telnyx.net/Services/AccessToken/AccessTokenService.cs @@ -0,0 +1,32 @@ +//using system; +//using system.collections.generic; +//using system.threading.tasks; +//using system.threading; +//using telnyx.net.entities.accesstoken; +//using telnyx.net.entities; + +//namespace telnyx.net.services.accesstokens +//{ +// public class accesstokensservice : service +// { + +// public accesstokensservice() +// : base(null) { } + +// public accesstokensservice(string apikey) +// : base(apikey) { } + +// public override string basepath => "/telephony_credentials"; +// public override string postpath => "/token"; +// public accesstokencreate createaccesstoken(string id, telnyxentity createoptions, requestoptions reqopts = null) +// { +// return this.createentity(id, this.postpath, createoptions, reqopts); +// } + +// public async task createaccesstokenasync(string id, telnyxentity createoptions, requestoptions reqopts = null, cancellationtoken ct = default) +// { +// return await this.createentityasync(id, this.postpath, createoptions, reqopts, ct); +// } + +// } +//} diff --git a/src/Telnyx.net/Services/AuthenticationProviders/AuthenticationProviderServices.cs b/src/Telnyx.net/Services/AuthenticationProviders/AuthenticationProviderServices.cs new file mode 100644 index 00000000..57fd6cd8 --- /dev/null +++ b/src/Telnyx.net/Services/AuthenticationProviders/AuthenticationProviderServices.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using System.Threading; +using Telnyx.net.Entities.AuthenticationProviders; +using Telnyx.net.Entities; +using Telnyx.net.Entities.AuthenticationProviders; +using Telnyx.net.Services; + +namespace Telnyx.net.Services.AuthentictionProvider +{ + public class AuthenticationProviderService : Service + { + private string parentToken; + + public AuthenticationProviderService() + : base(null) { } + + public AuthenticationProviderService(string apiKey) + : base(apiKey) { } + + public override string BasePath => "/authentication_providers"; + public TelnyxList ListAuthenticationProviders(AuthenticationProviderListOption listOption, RequestOptions reqOpts = null) + { + return this.ListEntities(listOption, reqOpts); + } + + public async Task> ListAuthenticationProvidersAsync(AuthenticationProviderListOption listOption, RequestOptions reqOpts = null) + { + return await this.ListEntitiesAsync(listOption, reqOpts, parentToken = ""); + } + + public AuthenticationProviders CreateAuthenticationProviders(AuthenticationProviderCreateOption createOptions, RequestOptions reqOpts = null) + { + return this.CreateEntity(createOptions, reqOpts); + } + + public async Task CreateAuthenticationProvidersAsync(AuthenticationProviderCreateOption createOptions, RequestOptions reqOpts = null, CancellationToken ct = default) + { + return await this.CreateEntityAsync(createOptions, reqOpts, ct); + } + public AuthenticationProviders DeleteAuthenticationProviders(string id, RequestOptions requestOptions = null) + { + return this.DeleteEntity(id, requestOptions); + } + + public async Task DeleteAuthenticationProvidersAsync(string id, RequestOptions requestOptions = null, CancellationToken ct = default) + { + return await this.DeleteEntityAsync(id, requestOptions, ct).ConfigureAwait(false); + } + public AuthenticationProviders UpdateAuthenticationProviders(string id, AuthenticationProviderCreateOption createOptions, RequestOptions requestOptions = null) + { + return this.UpdateEntity(id, createOptions, requestOptions); + } + + public async Task UpdateAuthenticationProvidersAsync(string id, AuthenticationProviderCreateOption createOptions, RequestOptions requestOptions = null, CancellationToken ct = default) + { + return await this.UpdateEntityAsync(id, createOptions, requestOptions, ct).ConfigureAwait(false); + } + public async Task RetrieveAuthenticationProvidersAsync(string id, RequestOptions reqOpts = null) + { + return await this.GetEntityAsync(id, reqOpts); + } + + public AuthenticationProviders RetrieveAuthenticationProviders(string id, RequestOptions reqOpts = null) + { + return this.GetEntity(id, reqOpts); + } + } +} diff --git a/src/Telnyx.net/Services/Calls/CallControl/CallControlService.cs b/src/Telnyx.net/Services/Calls/CallControl/CallControlService.cs index c63563b9..9fe963de 100644 --- a/src/Telnyx.net/Services/Calls/CallControl/CallControlService.cs +++ b/src/Telnyx.net/Services/Calls/CallControl/CallControlService.cs @@ -4,9 +4,11 @@ using System.Threading; using System.Threading.Tasks; using Telnyx.net.Entities; +using Telnyx.net.Entities.Calls.CallControl.ClientState; using Telnyx.net.Services.Calls.CallControl.GatherStop; using Telnyx.net.Services.Calls.CallControl.RecordActions; using Telnyx.net.Services.Calls.CallControl.Refer; +using Telnyx.net.Services.Calls.CallControl.ClientState; using Telnyx.net.Services.Calls.CallControl.Transcriptions; namespace Telnyx.net.Services.Calls.CallCommands @@ -31,6 +33,7 @@ public class CallControlService private readonly RecordActionService recordActionService; private readonly CallTranscriptionService transcriptionService; private readonly CallControlReferService referService; + private readonly ClientStateService updateClientStateService; public CallControlService() { @@ -285,5 +288,14 @@ public virtual TelnyxApiResponse ReferCall(string id, ReferOptions options, Requ { return this.referService.Refer(id, options, requestOptions); } + public TelnyxApiResponse UpdateClientState(string id, ClientStateOption clientState, RequestOptions requestOptions = null) + { + return this.updateClientStateService.UpdateEntity(id, clientState, requestOptions); + } + + public async Task UpdateClientStateAsync(string id, ClientStateOption clientState, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return await this.updateClientStateService.UpdateEntityAsync(id, clientState, requestOptions, cancellationToken); + } } } diff --git a/src/Telnyx.net/Services/Calls/CallControl/ClientState/ClientStateService.cs b/src/Telnyx.net/Services/Calls/CallControl/ClientState/ClientStateService.cs new file mode 100644 index 00000000..8501b9e0 --- /dev/null +++ b/src/Telnyx.net/Services/Calls/CallControl/ClientState/ClientStateService.cs @@ -0,0 +1,35 @@ +using System.Threading; +using System.Threading.Tasks; +using Telnyx.net.Entities.Calls.CallControl.ClientState; +using Telnyx.net.Entities; +namespace Telnyx.net.Services.Calls.CallControl.ClientState +{ + public class ClientStateService : Service + { + public ClientStateService() + : base(null) + { + + } + + public ClientStateService(string apiKey) + : base(apiKey) + { + + } + + public override string BasePath => "/calls"; + + public override string PostPath => "actions/client_state_update"; + + public TelnyxApiResponse UpdateEntity(string id, ClientStateOption updateOptions, RequestOptions requestOptions = null) + { + return this.UpdateEntity(id, updateOptions, requestOptions); + } + + public async Task UpdateEntityAsync(string id, ClientStateOption updateOptions, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + { + return await this.UpdateEntityAsync(id, updateOptions, requestOptions, cancellationToken); + } + } +} diff --git a/src/Telnyx.net/Services/Calls/CallControlApplications/CallControlApplicationService.cs b/src/Telnyx.net/Services/Calls/CallControlApplications/CallControlApplicationService.cs index 3598c838..2d20ee0c 100644 --- a/src/Telnyx.net/Services/Calls/CallControlApplications/CallControlApplicationService.cs +++ b/src/Telnyx.net/Services/Calls/CallControlApplications/CallControlApplicationService.cs @@ -1,5 +1,6 @@ namespace Telnyx.net.Services.Calls.CallControlApplications { + using Newtonsoft.Json; using System; using System.Threading; using System.Threading.Tasks; @@ -40,9 +41,9 @@ public CallControlApplication Get(string id, RequestOptions requestOptions = nul return this.GetEntity(id, null, requestOptions); } - public async Task GetAsync(string id, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + public async Task GetAsync(string id, RequestOptions requestOptions = null, string parentToken = "", CancellationToken cancellationToken = default) { - return await this.GetEntityAsync(id, null, requestOptions, cancellationToken); + return await this.GetEntityAsync(id, null, requestOptions, parentToken, cancellationToken); } public TelnyxList List(ListCallControlApplicationOptions listOptions = null, RequestOptions requestOptions = null) @@ -52,7 +53,7 @@ public TelnyxList List(ListCallControlApplicationOptions public async Task> ListAsync(ListCallControlApplicationOptions listOptions = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) { - return await this.ListEntitiesAsync(listOptions, requestOptions, cancellationToken); + return await this.ListEntitiesAsync(listOptions, requestOptions, "", cancellationToken); } public CallControlApplication Update(string id, CreateCallControlApplicationOptions updateOptions, RequestOptions requestOptions = null) diff --git a/src/Telnyx.net/Services/Service.cs b/src/Telnyx.net/Services/Service.cs index 816c2ad5..0c592447 100644 --- a/src/Telnyx.net/Services/Service.cs +++ b/src/Telnyx.net/Services/Service.cs @@ -107,9 +107,13 @@ protected async Task CreateEntityAsync(string id, string postFix, BaseOp /// requestOptions. /// /// {EntityReturned}. - protected EntityReturned CreateEntity(BaseOptions options, RequestOptions requestOptions, string postBasePath = "") + protected EntityReturned CreateEntity( + BaseOptions options, + RequestOptions requestOptions, + string postBasePath = "", + string parentToken="") { - return this.PostRequest(this.ClassUrl(postBasePath: postBasePath), options, requestOptions); + return this.PostRequest(this.ClassUrl(postBasePath: postBasePath), options, requestOptions, parentToken: parentToken); } /// @@ -120,9 +124,14 @@ protected EntityReturned CreateEntity(BaseOptions options, RequestOptions reques /// cancellationToken. /// /// {EntityReturned}. - protected async Task CreateEntityAsync(BaseOptions options, RequestOptions requestOptions, CancellationToken cancellationToken, string postBasePath = "") + protected async Task CreateEntityAsync( + BaseOptions options, + RequestOptions requestOptions, + CancellationToken cancellationToken, + string postBasePath = "", + string parentToken = "data") { - return await this.PostRequestAsync(this.ClassUrl(), options, requestOptions, cancellationToken); + return await this.PostRequestAsync(this.ClassUrl(), options, requestOptions, cancellationToken, parentToken: parentToken); } /// @@ -197,9 +206,14 @@ protected EntityReturned GetEntity(string id, BaseOptions options, RequestOption /// requestOptions. /// cancellationToken. /// {EntityReturned}. - protected async Task GetEntityAsync(string id, BaseOptions options, RequestOptions requestOptions, CancellationToken cancellationToken) + protected async Task GetEntityAsync( + string id, + BaseOptions options, + RequestOptions requestOptions, + string parentToken = "", + CancellationToken cancellationToken = default) { - return await this.GetRequestAsync(this.InstanceUrl(id), options, requestOptions, false, cancellationToken); + return await this.GetRequestAsync(this.InstanceUrl(id), options, requestOptions, false, parentToken, cancellationToken); } /// @@ -211,7 +225,7 @@ protected async Task GetEntityAsync(string id, BaseOptions optio /// {EntityReturned}. protected EntityReturned DeleteEntity(string id, RequestOptions requestOptions) { - return this.DeleteRequest(this.InstanceUrl(id), null, requestOptions); + return this.DeleteRequest(this.InstanceUrl(id), null, requestOptions); } /// @@ -247,9 +261,9 @@ protected EntityReturned GetEntity(string id, RequestOptions requestOptions) /// requestOptions. /// cancellationToken. /// {EntityReturned}. - protected async Task GetEntityAsync(string id, RequestOptions requestOptions, CancellationToken cancellationToken) + protected async Task GetEntityAsync(string id, RequestOptions requestOptions, string parentToken = "", CancellationToken cancellationToken = default) { - return await this.GetRequestAsync(this.InstanceUrl(id), null, requestOptions, false, cancellationToken); + return await this.GetRequestAsync(this.InstanceUrl(id), null, requestOptions, false, parentToken, cancellationToken); } /// /// GetEntity @@ -259,9 +273,9 @@ protected async Task GetEntityAsync(string id, RequestOptions re /// requestOptions /// postPath /// {EntityReturned} - protected EntityReturned GetEntity(string id, BaseOptions options, RequestOptions requestOptions, string postPath = null) + protected EntityReturned GetEntity(string id, BaseOptions options, RequestOptions requestOptions, string postPath = null, string parentToken = "") { - return this.GetRequest(this.CallUrl(id, postPath), options, requestOptions, false); + return this.GetRequest(this.CallUrl(id, postPath), options, requestOptions, false, parentToken); } /// @@ -273,9 +287,9 @@ protected EntityReturned GetEntity(string id, BaseOptions options, RequestOption /// cancellationToken /// postPath /// {EntityReturned} - protected async Task GetEntityAsync(string id, BaseOptions options, RequestOptions requestOptions, CancellationToken cancellationToken, string postPath = null) + protected async Task GetEntityAsync(string id, BaseOptions options, RequestOptions requestOptions, string postPath = null, string parentToken = "") { - return await this.GetRequestAsync(this.CallUrl(id, postPath), options, requestOptions, false, cancellationToken); + return await this.GetRequestAsync(this.CallUrl(id, postPath), options, requestOptions, false, parentToken); } /// /// CreateEntity @@ -313,9 +327,9 @@ protected async Task CreateEntityAsync(string id, BaseOptions op /// requestOptions. /// cancellationToken. /// TelnyxList {EntityReturned}. - protected async Task> ListEntitiesAsync(BaseOptions options, RequestOptions requestOptions, CancellationToken cancellationToken) + protected async Task> ListEntitiesAsync(BaseOptions options, RequestOptions requestOptions, string parentToken ="") { - return await this.GetRequestAsync>(this.ClassUrl(), options, requestOptions, true, cancellationToken); + return await this.GetRequestAsync>(this.ClassUrl(), options, requestOptions, true, parentToken); } /// ny6j /// ListEntities. @@ -333,11 +347,12 @@ protected TelnyxList ListEntities(BaseOptions options, RequestOp /// /// options. /// requestOptions. + /// /// cancellationToken. /// TelnyxList {EntityReturned}. - protected async Task> ListEntitiesAsync(ListOptions options, RequestOptions requestOptions, CancellationToken cancellationToken) + protected async Task> ListEntitiesAsync(ListOptions options, RequestOptions requestOptions, string parentToken = "", CancellationToken cancellationToken = default) { - return await this.ListRequestPagingAsync(this.ClassUrl(), options, requestOptions, cancellationToken); + return await this.ListRequestPagingAsync(this.ClassUrl(), options, requestOptions, parentToken, cancellationToken); } /// /// ListEntities. @@ -345,9 +360,9 @@ protected async Task> ListEntitiesAsync(ListOptions o /// options. /// requestOptions. /// TelnyxList {EntityReturned}. - protected TelnyxList ListEntities(ListOptions options, RequestOptions requestOptions) + protected TelnyxList ListEntities(ListOptions options, RequestOptions requestOptions, string parentToken) { - return this.ListRequestPaging(this.ClassUrl(), options, requestOptions); + return this.ListRequestPaging(this.ClassUrl(), options, requestOptions, parentToken = ""); } /// /// ListEntitiesAutoPaging. @@ -355,9 +370,9 @@ protected TelnyxList ListEntities(ListOptions options, RequestOp /// options. /// requestOptions. /// IEnumerable {EntityReturned}. - protected IEnumerable ListEntitiesAutoPaging(ListOptions options, RequestOptions requestOptions) + protected IEnumerable ListEntitiesAutoPaging(ListOptions options, RequestOptions requestOptions, string parentToken) { - return this.ListRequestAutoPaging(this.ClassUrl(), options, requestOptions); + return this.ListRequestAutoPaging(this.ClassUrl(), options, requestOptions, parentToken = ""); } /// /// ListEntitiesAutoPaging. @@ -365,9 +380,9 @@ protected IEnumerable ListEntitiesAutoPaging(ListOptions options /// options. /// requestOptions. /// IEnumerable {EntityReturned}. - protected async Task> ListEntitiesAutoPagingAsync(ListOptions options, RequestOptions requestOptions, CancellationToken ct) + protected async Task> ListEntitiesAutoPagingAsync(ListOptions options, RequestOptions requestOptions, string parentToken) { - return await this.ListRequestAutoPagingAsync(this.ClassUrl(), options, requestOptions, ct); + return await this.ListRequestAutoPagingAsync(this.ClassUrl(), options, requestOptions, parentToken = ""); } /// @@ -377,9 +392,9 @@ protected async Task> ListEntitiesAutoPagingAsync(Li /// options /// requestOptions /// TelnyxList {EntityReturned} - protected TelnyxList ListEntities(string postPath, ListOptions options, RequestOptions requestOptions, string id = null) + protected TelnyxList ListEntities(string postPath, ListOptions options, RequestOptions requestOptions, string parentToken, string id = null) { - return this.ListRequestPaging(this.CallUrl(id, postPath), options, requestOptions); + return this.ListRequestPaging(this.CallUrl(id, postPath), options, requestOptions, parentToken =""); } /// @@ -390,9 +405,9 @@ protected TelnyxList ListEntities(string postPath, ListOptions o /// requestOptions /// cancellationToken /// TelnyxList {EntityReturned} - protected async Task> ListEntitiesAsync(string postPath, ListOptions options, RequestOptions requestOptions, CancellationToken cancellationToken, string id = null) + protected async Task> ListEntitiesAsync(string postPath, ListOptions options, RequestOptions requestOptions, string parentToken, string id = null) { - return await this.ListRequestPagingAsync(this.CallUrl(id, postPath), options, requestOptions, cancellationToken); + return await this.ListRequestPagingAsync(this.CallUrl(id, postPath), options, requestOptions, parentToken = ""); } /// @@ -402,9 +417,9 @@ protected async Task> ListEntitiesAsync(string postPa /// options /// requestOptions /// IEnumerable {EntityReturned} - protected IEnumerable ListEntitiesAutoPaging(string postPath, ListOptions options, RequestOptions requestOptions) + protected IEnumerable ListEntitiesAutoPaging(string postPath, ListOptions options, RequestOptions requestOptions, string parentToken) { - return this.ListRequestAutoPaging(this.CallUrl(null, postPath), options, requestOptions); + return this.ListRequestAutoPaging(this.CallUrl(null, postPath), options, requestOptions, parentToken =""); } /// /// ListEntitiesAutoPaging @@ -413,9 +428,9 @@ protected IEnumerable ListEntitiesAutoPaging(string postPath, Li /// options /// requestOptions /// IEnumerable {EntityReturned} - protected Task> ListEntitiesAutoPagingAsync(string postPath, ListOptions options, RequestOptions requestOptions, CancellationToken ct = default) + protected Task> ListEntitiesAutoPagingAsync(string postPath, ListOptions options, RequestOptions requestOptions, string parentToken) { - return this.ListRequestAutoPagingAsync(this.CallUrl(null, postPath), options, requestOptions, ct); + return this.ListRequestAutoPagingAsync(this.CallUrl(null, postPath), options, requestOptions, parentToken = ""); } /// @@ -535,7 +550,7 @@ protected T DeleteRequest(string url, BaseOptions options, RequestOptions req return Mapper.MapFromJson( Requestor.Delete( this.ApplyAllParameters(options, url), - this.SetupRequestOptions(requestOptions)), "data"); + this.SetupRequestOptions(requestOptions))); } /// @@ -553,7 +568,7 @@ protected async Task DeleteRequestAsync(string url, BaseOptions options, R await Requestor.DeleteAsync( this.ApplyAllParameters(options, url), this.SetupRequestOptions(requestOptions), - cancellationToken).ConfigureAwait(false), "data"); + cancellationToken).ConfigureAwait(false)); } /// @@ -565,9 +580,8 @@ await Requestor.DeleteAsync( /// requestOptions. /// isListMethod. /// {EntityReturned}. - protected T GetRequest(string url, BaseOptions options, RequestOptions requestOptions, bool isListMethod) + protected T GetRequest(string url, BaseOptions options, RequestOptions requestOptions, bool isListMethod, string parentToken = "data") { - var parentToken = (typeof(T) == typeof(TelnyxList)) ? null : "data"; return Mapper.MapFromJson( Requestor.GetString( this.ApplyAllParameters(options, url, isListMethod), @@ -582,11 +596,17 @@ protected T GetRequest(string url, BaseOptions options, RequestOptions reques /// options. /// requestOptions. /// isListMethod. + /// /// cancellationToken. /// {EntityReturned}. - protected async Task GetRequestAsync(string url, BaseOptions options, RequestOptions requestOptions, bool isListMethod, CancellationToken cancellationToken) + protected async Task GetRequestAsync( + string url, + BaseOptions options, + RequestOptions requestOptions, + bool isListMethod, + string parentToken = "data", + CancellationToken cancellationToken = default) { - var parentToken = (typeof(T) == typeof(TelnyxList)) ? null : "data"; return Mapper.MapFromJson( await Requestor.GetStringAsync( this.ApplyAllParameters(options, url, isListMethod), @@ -598,16 +618,16 @@ await Requestor.GetStringAsync( /// /// Request for {EntityReturned}. /// url. + /// /// options. /// requestOptions. /// isListMethod. /// cancellationToken. /// {EntityReturned}. - protected async Task GetRequestAsync(string url, CancellationToken cancellationToken) + protected async Task GetRequestAsync(string url, ListOptions options,RequestOptions requestOptions, bool isListMethod, string parentToken = "data", CancellationToken cancellationToken = default) { - var parentToken = (typeof(T) == typeof(TelnyxList)) ? null : "data"; return Mapper.MapFromJson( - await Requestor.GetStringAsync(url, null, cancellationToken) + await Requestor.GetStringAsync(url,requestOptions, cancellationToken) .ConfigureAwait(false), parentToken); } /// @@ -618,9 +638,9 @@ await Requestor.GetStringAsync(url, null, cancellationToken) /// options. /// requestOptions. /// IEnumerable {EntityReturned}. - protected IEnumerable ListRequestAutoPaging(string url, ListOptions options, RequestOptions requestOptions) + protected IEnumerable ListRequestAutoPaging(string url, ListOptions options, RequestOptions requestOptions, string parentToken = "") { - return this.ListRequestAutoPagingAsync(url, options, requestOptions).GetAwaiter().GetResult(); + return this.ListRequestAutoPagingAsync(url, options, requestOptions, parentToken).GetAwaiter().GetResult(); } /// /// ListRequestAutoPaging. @@ -630,9 +650,9 @@ protected IEnumerable ListRequestAutoPaging(string url, ListOptions option /// options. /// requestOptions. /// IEnumerable {EntityReturned}. - protected async Task> ListRequestAutoPagingAsync(string url, ListOptions options, RequestOptions requestOptions, CancellationToken ct = default) + protected async Task> ListRequestAutoPagingAsync(string url, ListOptions options, RequestOptions requestOptions, string parentToken = "") { - var page = await this.GetRequestAsync>(url, options, requestOptions, true, ct); + var page = await this.GetRequestAsync>(url, options, requestOptions, true, parentToken); if (options == null) { options = new ListOptions(); @@ -644,7 +664,7 @@ protected async Task> ListRequestAutoPagingAsync(string url, L { options.PageNumber = page.PageInfo?.NextPage ?? options?.PageNumber + 1; - page = await this.GetRequestAsync>(url, options, requestOptions, true, ct); + page = await this.GetRequestAsync>(url, options, requestOptions, true, parentToken =""); if (page != null && page.Data != null && page.Data.Any()) { listOfEntities.AddRange(page.Data); @@ -661,9 +681,9 @@ protected async Task> ListRequestAutoPagingAsync(string url, L /// options. /// requestOptions. /// IEnumerable {EntityReturned}. - protected TelnyxList ListRequestPaging(string url, ListOptions options, RequestOptions requestOptions) + protected TelnyxList ListRequestPaging(string url, ListOptions options, RequestOptions requestOptions, string parentToken) { - return this.ListRequestPagingAsync(url, options, requestOptions).GetAwaiter().GetResult(); + return this.ListRequestPagingAsync(url, options, requestOptions, parentToken = "").GetAwaiter().GetResult(); } /// /// ListRequestAutoPaging. @@ -673,9 +693,9 @@ protected TelnyxList ListRequestPaging(string url, ListOptions options, Re /// options. /// requestOptions. /// IEnumerable {EntityReturned}. - protected async Task> ListRequestPagingAsync(string url, ListOptions options, RequestOptions requestOptions, CancellationToken ct = default) + protected async Task> ListRequestPagingAsync(string url, ListOptions options, RequestOptions requestOptions, string parentToken = "", CancellationToken cancellation = default) { - var page = await this.GetRequestAsync>(url, options, requestOptions, true, ct); + var page = await this.GetRequestAsync>(url, options, requestOptions,true, parentToken, cancellation); if (options == null) { options = new ListOptions(); @@ -689,7 +709,7 @@ protected async Task> ListRequestPagingAsync(string url, ListOp do { options.PageNumber = page.PageInfo.NextPage; - page = await this.GetRequestAsync>(url, options, requestOptions, true, ct); + page = await this.GetRequestAsync>(url, options, requestOptions, true, parentToken = ""); if (page != null && page.Data != null && page.Data.Any()) { listOfEntities.AddRange(page.Data); @@ -711,15 +731,22 @@ protected async Task> ListRequestPagingAsync(string url, ListOp /// url. /// options. /// requestOptions. + /// + /// /// {EntityReturned}. - protected T PostRequest(string url, BaseOptions options, RequestOptions requestOptions, bool isJsonResponse = true) + protected T PostRequest( + string url, + BaseOptions options, + RequestOptions requestOptions, + bool isJsonResponse = true, + string parentToken = "") { if (isJsonResponse) { return Mapper.MapFromJson( Requestor.PostString( this.ApplyAllParameters(options, url), - this.SetupRequestOptions(requestOptions)), "data"); + this.SetupRequestOptions(requestOptions)), parentToken); } else { @@ -737,8 +764,16 @@ protected T PostRequest(string url, BaseOptions options, RequestOptions reque /// options. /// requestOptions. /// cancellationToken. + /// Maps as json response + /// Parsing token /// {EntityReturned}. - protected async Task PostRequestAsync(string url, BaseOptions options, RequestOptions requestOptions, CancellationToken cancellationToken, bool isJsonResponse = true) + protected async Task PostRequestAsync( + string url, + BaseOptions options, + RequestOptions requestOptions, + CancellationToken cancellationToken, + bool isJsonResponse = true, + string parentToken = "") { if (isJsonResponse) { @@ -746,7 +781,7 @@ protected async Task PostRequestAsync(string url, BaseOptions options, Req await Requestor.PostStringAsync( this.ApplyAllParameters(options, url), this.SetupRequestOptions(requestOptions), - cancellationToken).ConfigureAwait(false), "data"); + cancellationToken).ConfigureAwait(false), parentToken); } else { diff --git a/src/Telnyx.net/Services/ServiceNested.cs b/src/Telnyx.net/Services/ServiceNested.cs index 73a390a3..3765e619 100644 --- a/src/Telnyx.net/Services/ServiceNested.cs +++ b/src/Telnyx.net/Services/ServiceNested.cs @@ -129,9 +129,9 @@ protected TelnyxList ListNestedEntities(string parentId, ListOpt /// requestOptions. /// cancellationToken. /// TelnyxList {EntityReturned}. - protected async Task> ListNestedEntitiesAsync(string parentId, ListOptions options, RequestOptions requestOptions, CancellationToken cancellationToken) + protected async Task> ListNestedEntitiesAsync(string parentId, ListOptions options, RequestOptions requestOptions, string parentToken = "") { - return await this.ListRequestPagingAsync(this.ClassUrl(parentId), options, requestOptions, cancellationToken); + return await this.ListRequestPagingAsync(this.ClassUrl(parentId), options, requestOptions, parentToken); } /// @@ -152,9 +152,9 @@ protected IEnumerable ListNestedEntitiesAutoPaging(string parent /// options. /// requestOptions. /// Ienumerable {EntityReturned}. - protected async Task > ListNestedEntitiesAutoPagingAsync(string parentId, ListOptions options, RequestOptions requestOptions, CancellationToken ct = default) + protected async Task > ListNestedEntitiesAutoPagingAsync(string parentId, ListOptions options, RequestOptions requestOptions, string parentToken = "") { - return await this.ListRequestAutoPagingAsync(this.ClassUrl(parentId), options, requestOptions, ct); + return await this.ListRequestAutoPagingAsync(this.ClassUrl(parentId), options, requestOptions, parentToken); } /// diff --git a/src/Telnyx.net/Services/Wireless/WDRReports/WDRReportsService.cs b/src/Telnyx.net/Services/Wireless/WDRReports/WDRReportsService.cs index bf6cd80c..b9e54f3b 100644 --- a/src/Telnyx.net/Services/Wireless/WDRReports/WDRReportsService.cs +++ b/src/Telnyx.net/Services/Wireless/WDRReports/WDRReportsService.cs @@ -19,9 +19,9 @@ public TelnyxList List(ListOptions listOptions = null, Request return this.ListEntities(listOptions, requestOptions); } - public Task> ListAsync(ListOptions listOptions = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + public Task> ListAsync(ListOptions listOptions = null, RequestOptions requestOptions = null, string parentToken = "") { - return this.ListEntitiesAsync(listOptions, requestOptions, cancellationToken); + return this.ListEntitiesAsync(listOptions, requestOptions, parentToken); } public WDRReportsRecord Create(CreateWDRReportsOptions createOptions, RequestOptions requestOptions = null) @@ -39,9 +39,9 @@ public WDRReportsRecord Get(string id, RequestOptions requestOptions = null) return this.GetEntity(id, requestOptions); } - public async Task GetAsync(string id, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) + public async Task GetAsync(string id, RequestOptions requestOptions = null, string parentToken = "", CancellationToken cancellationToken = default) { - return await this.GetEntityAsync(id, null, requestOptions, CancellationToken.None); + return await this.GetEntityAsync(id, null, requestOptions, parentToken, CancellationToken.None); } public WDRReportsRecord Delete(string id, RequestOptions requestOptions = null) diff --git a/src/Telnyx.net/Telnyx.net.csproj b/src/Telnyx.net/Telnyx.net.csproj index fb30ec93..c240a8d9 100644 --- a/src/Telnyx.net/Telnyx.net.csproj +++ b/src/Telnyx.net/Telnyx.net.csproj @@ -107,6 +107,7 @@ + diff --git a/src/Telnyx.net/stylecop3.json b/src/Telnyx.net/stylecop3.json new file mode 100644 index 00000000..42fb1f8e --- /dev/null +++ b/src/Telnyx.net/stylecop3.json @@ -0,0 +1,14 @@ +{ + // ACTION REQUIRED: This file was automatically added to your project, but it + // will not take effect until additional steps are taken to enable it. See the + // following page for additional information: + // + // https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/EnableConfiguration.md + + "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json", + "settings": { + "documentationRules": { + "companyName": "PlaceholderCompany" + } + } +} diff --git a/src/TelnyxTests/Services/AccessIPAddress/AccessIPAddressListOptionsTest.cs b/src/TelnyxTests/Services/AccessIPAddress/AccessIPAddressListOptionsTest.cs new file mode 100644 index 00000000..effdd85f --- /dev/null +++ b/src/TelnyxTests/Services/AccessIPAddress/AccessIPAddressListOptionsTest.cs @@ -0,0 +1,124 @@ +using System.Threading.Tasks; +using Telnyx; +using Telnyx.net.Entities; +using Telnyx.net.Services.AccessIPAddresses; + +using Xunit; +using System.Threading; +using Telnyx.net.Entities.AccessIPAddresses; +using Telnyx.net.Entities.Enum.AccessIPAddresses; +using Castle.Core.Resource; +using System; +using Telnyx.net.Entities.AuthenticationProviders; + +namespace TelnyxTests.Services.AccessIPAddressList +{ + /// + /// Test class for AccessIPAddressList. + /// + public class AccessIPAddressListTest : BaseTelnyxTest + { + private readonly AccessIPAddressService service; + private readonly AccessIPAddressListOptions AccessIPAddressListOptions; + private readonly AccessIPAddressCreateOptions AccessIPAddressCreateOptions; + private readonly RequestOptions requestOptions; + private readonly BaseOptions baseOptions; + private const string Id = "6a09cdc3-8948-47f0-aa62-74ac943d6c58"; + + public AccessIPAddressListTest(MockHttpClientFixture mockHttpClientFixture) + : base(mockHttpClientFixture) + { + this.service = new AccessIPAddressService(); + this.baseOptions = new BaseOptions(); + this.requestOptions = new RequestOptions(); + this.AccessIPAddressListOptions = new AccessIPAddressListOptions() + { + IpSource = "string", + IpAddress = "string", + Status = Telnyx.net.Entities.Enum.AccessIPAddresses.CloudflareSyncStatus.Pending, + CreatedAtGreaterThan = "string", + CreatedAtLessThan = "string", + }; + this.AccessIPAddressCreateOptions = new AccessIPAddressCreateOptions(); + } + + [Fact] + public void List() + { + var result = this.service.ListAllAccessIPAddresses(this.AccessIPAddressListOptions, this.requestOptions); + Assert.NotNull(result); + Assert.Equal(typeof(TelnyxList), result.GetType()); + foreach (var item in result.Data) + { + var expectedDateTime = new DateTime(2019, 8, 24, 14, 15, 22); + Assert.Equal(expectedDateTime.ToString("s") + "Z", item.CreatedAt.ToString("s") + "Z"); + Assert.Equal("string", item.Description); + Assert.Equal("string", item.Id); + Assert.Equal("string", item.IpAddress); + Assert.Equal("string", item.Source); + Assert.Equal(new CloudflareSyncStatus(), item.Status); + Assert.Equal(expectedDateTime.ToString("s") + "Z", item.UpdatedAt.ToString("s") + "Z"); + Assert.Equal("string", item.UserId); + } + } + + [Fact] + public async Task ListSync() + { + var cts = new CancellationTokenSource(); + var result = await this.service.ListAllAccessIPAddressesAsync(this.AccessIPAddressListOptions, this.requestOptions, cts.Token); + Assert.NotNull(result); + Assert.Equal(typeof(TelnyxList), result.GetType()); + foreach (var item in result.Data) + { + var expectedDateTime = new DateTime(2019, 8, 24, 14, 15, 22); + Assert.Equal(expectedDateTime.ToString("s") + "Z", item.CreatedAt.ToString("s") + "Z"); + Assert.Equal("string", item.Description); + Assert.Equal("string", item.Id); + Assert.Equal("string", item.IpAddress); + Assert.Equal("string", item.Source); + Assert.Equal(new CloudflareSyncStatus(), item.Status); + Assert.Equal(expectedDateTime.ToString("s") + "Z", item.UpdatedAt.ToString("s") + "Z"); + Assert.Equal("string", item.UserId); + } + } + [Fact] + public void Retrieve() + { + var result = this.service.RetrieveAllAccessIPAddresses(Id, this.baseOptions, this.requestOptions); + Assert.NotNull(result); + Assert.Equal(typeof(AccessIPAddress), result.GetType()); + var expectedDateTime = new DateTime(2019, 8, 24, 14, 15, 22); + var item = result; + Assert.Equal(expectedDateTime.ToString("s") + "Z", item.CreatedAt.ToString("s") + "Z"); + Assert.Equal("string", item.Description); + Assert.Equal("string", item.Id); + Assert.Equal("string", item.IpAddress); + Assert.Equal("string", item.Source); + Assert.Equal(new CloudflareSyncStatus(), item.Status); + Assert.Equal(expectedDateTime.ToString("s") + "Z", item.UpdatedAt.ToString("s") + "Z"); + Assert.Equal("string", item.UserId); + + } + + [Fact] + public async Task RetrieveSync() + { + var cts = new CancellationTokenSource(); + var result = await this.service.RetrieveAllAccessIPAddressesAsync(Id, this.baseOptions, this.requestOptions, cts.Token); + Assert.NotNull(result); + Assert.Equal(typeof(AccessIPAddress), result.GetType()); + var item = result; + var expectedDateTime = new DateTime(2019, 8, 24, 14, 15, 22); + Assert.Equal(expectedDateTime.ToString("s") + "Z", item.CreatedAt.ToString("s") + "Z"); + Assert.Equal("string", item.Description); + Assert.Equal("string", item.Id); + Assert.Equal("string", item.IpAddress); + Assert.Equal("string", item.Source); + Assert.Equal(new CloudflareSyncStatus(), item.Status); + Assert.Equal(expectedDateTime.ToString("s") + "Z", item.UpdatedAt.ToString("s") + "Z"); + Assert.Equal("string", item.UserId); + + } + } +} \ No newline at end of file diff --git a/src/TelnyxTests/Services/AccessIPAddress/AccessIpAddressCreateOptionTest.cs b/src/TelnyxTests/Services/AccessIPAddress/AccessIpAddressCreateOptionTest.cs new file mode 100644 index 00000000..5eed7089 --- /dev/null +++ b/src/TelnyxTests/Services/AccessIPAddress/AccessIpAddressCreateOptionTest.cs @@ -0,0 +1,113 @@ +using System.Threading.Tasks; +using Telnyx; +using Telnyx.net.Entities; +using Telnyx.net.Services.AccessIPAddresses; + +using Xunit; +using System.Threading; +using Telnyx.net.Entities.AccessIPAddresses; +using Telnyx.net.Entities.Enum.AccessIPAddresses; +using Castle.Core.Resource; +using System; +using Newtonsoft.Json; + +namespace TelnyxTests.Services.AccessIPAddressCreate +{ + /// + /// Test class for AccessIPAddressCreate. + /// + public class AccessIPAddressCreateTest : BaseTelnyxTest + { + private readonly AccessIPAddressService service; + private readonly AccessIPAddressCreateOptions AccessIPAddressCreateOptions; + private readonly RequestOptions requestOptions; + private readonly BaseOptions baseOptions; + private readonly string json; + private const string Id = "6a09cdc3-8948-47f0-aa62-74ac943d6c58"; + public AccessIPAddressCreateTest(MockHttpClientFixture mockHttpClientFixture) + : base(mockHttpClientFixture) + { + this.service = new AccessIPAddressService(); + this.baseOptions = new BaseOptions(); + this.requestOptions = new RequestOptions(); + this.AccessIPAddressCreateOptions = new AccessIPAddressCreateOptions() + { + Description = "description", + IpAddress = "string", + }; + } + [Fact] + public void Create() + { + var result = this.service.CreateAllAccessIPAddresses(this.AccessIPAddressCreateOptions, this.requestOptions); + Assert.NotNull(result); + Assert.Equal(typeof(AccessIPAddress), result.GetType()); + var expectedDateTime = new DateTime(2019, 8, 24, 14, 15, 22); + Assert.Equal(expectedDateTime.ToString("s") + "Z", result.UpdatedAt.ToString("s") + "Z"); + Assert.Equal("string", result.Description); + Assert.Equal("string", result.Id); + Assert.Equal("string", result.IpAddress); + Assert.Equal("string", result.Source); + Assert.Equal(new CloudflareSyncStatus(), result.Status); + Assert.Equal(expectedDateTime.ToString("s") + "Z", result.CreatedAt.ToString("s") + "Z"); + Assert.Equal("string", result.UserId); + + } + + [Fact] + public async Task CreateSync() + { + var cts = new CancellationTokenSource(); + var result = await this.service.CreateAllAccessIPAddressesAsync(this.AccessIPAddressCreateOptions, this.requestOptions, cts.Token); + Assert.NotNull(result); + Assert.Equal(typeof(AccessIPAddress), result.GetType()); + var expectedDateTime = new DateTime(2019, 8, 24, 14, 15, 22); + Assert.Equal(expectedDateTime.ToString("s") + "Z", result.UpdatedAt.ToString("s") + "Z"); + Assert.Equal("string", result.Description); + Assert.Equal("string", result.Id); + Assert.Equal("string", result.IpAddress); + Assert.Equal("string", result.Source); + Assert.Equal(new CloudflareSyncStatus(), result.Status); + Assert.Equal(expectedDateTime.ToString("s") + "Z", result.CreatedAt.ToString("s") + "Z"); + Assert.Equal("string", result.UserId); + } + [Fact] + public void Delete() + { + var result = this.service.DeleteAllAccessIPAddresses(Id, this.requestOptions); + Assert.NotNull(result); + Assert.Equal(typeof(AccessIPAddress), result.GetType()); + var expectedDateTime = new DateTime(2019, 8, 24, 14, 15, 22); + var item = result; + Assert.Equal(expectedDateTime.ToString("s") + "Z", item.CreatedAt.ToString("s") + "Z"); + Assert.Equal("string", item.Description); + Assert.Equal("string", item.Id); + Assert.Equal("string", item.IpAddress); + Assert.Equal("string", item.Source); + Assert.Equal(new CloudflareSyncStatus(), item.Status); + Assert.Equal(expectedDateTime.ToString("s") + "Z", item.UpdatedAt.ToString("s") + "Z"); + Assert.Equal("string", item.UserId); + + } + + [Fact] + public async Task DeleteSync() + { + var cts = new CancellationTokenSource(); + var result = await this.service.DeleteAllAccessIPAddressesAsync(Id, this.requestOptions, cts.Token); + Assert.NotNull(result); + Assert.Equal(typeof(AccessIPAddress), result.GetType()); + var item = result; + var expectedDateTime = new DateTime(2019, 8, 24, 14, 15, 22); + Assert.Equal(expectedDateTime.ToString("s") + "Z", item.CreatedAt.ToString("s") + "Z"); + Assert.Equal("string", item.Description); + Assert.Equal("string", item.Id); + Assert.Equal("string", item.IpAddress); + Assert.Equal("string", item.Source); + Assert.Equal(new CloudflareSyncStatus(), item.Status); + Assert.Equal(expectedDateTime.ToString("s") + "Z", item.UpdatedAt.ToString("s") + "Z"); + Assert.Equal("string", item.UserId); + + } + } +} \ No newline at end of file diff --git a/src/TelnyxTests/Services/AccessIPRanges/AccessIPRangesCreateTest.cs b/src/TelnyxTests/Services/AccessIPRanges/AccessIPRangesCreateTest.cs new file mode 100644 index 00000000..4ca0491d --- /dev/null +++ b/src/TelnyxTests/Services/AccessIPRanges/AccessIPRangesCreateTest.cs @@ -0,0 +1,107 @@ +using System.Threading.Tasks; +using Telnyx; +using Telnyx.net.Entities; +using Telnyx.net.Services.AccessIPRange; + +using Xunit; +using System.Threading; +using Telnyx.net.Entities.AccessIPRanges; +using Telnyx.net.Entities.Enum.AccessIPRanges; +using Castle.Core.Resource; +using System; + +namespace TelnyxTests.Services.AccessToken +{ + /// + /// Test class for AccessToken. + /// + public class AccessIPRangesCreateTest : BaseTelnyxTest + { + private readonly AcessIPRangesService service; + private readonly AccessIPRangesCreateOption AccessIPRangesCreateOption; + private readonly RequestOptions requestOptions; + private readonly BaseOptions baseOptions; + private const string Id = "6a09cdc3-8948-47f0-aa62-74ac943d6c58"; + + public AccessIPRangesCreateTest(MockHttpClientFixture mockHttpClientFixture) + : base(mockHttpClientFixture) + { + this.service = new AcessIPRangesService(); + this.baseOptions = new BaseOptions(); + this.requestOptions = new RequestOptions(); + this.AccessIPRangesCreateOption = new AccessIPRangesCreateOption() + { + Description = "description", + CidrBlock = "string", + }; + } + [Fact] + public void Create() + { + var result = this.service.CreateAllAccessIPRanges(this.AccessIPRangesCreateOption, this.requestOptions); + Assert.NotNull(result); + Assert.Equal(typeof(AccessIPRanges), result.GetType()); + var expectedDateTime = new DateTime(2019, 8, 24, 14, 15, 22); + var items = result; + Assert.Equal("string", items.CidrBlock); + Assert.Equal(expectedDateTime.ToString("s") + "Z", items.CreatedAt.ToString("s") + "Z"); + Assert.Equal("string", items.Description); + Assert.Equal("string", items.Id); + Assert.Equal(new CloudflareSyncStatus(), items.Status); + Assert.Equal(expectedDateTime.ToString("s") + "Z", items.UpdatedAt.ToString("s") + "Z"); + Assert.Equal("string", items.UserId); + } + + [Fact] + public async Task CreateSync() + { + var cts = new CancellationTokenSource(); + var result = await this.service.CreateAllAccessIPRangesAsync(this.AccessIPRangesCreateOption, this.requestOptions, cts.Token); + Assert.NotNull(result); + Assert.Equal(typeof(AccessIPRangesCreateOption), result.GetType()); + var expectedDateTime = new DateTime(2019, 8, 24, 14, 15, 22); + var items = result; + Assert.Equal("string", items.CidrBlock); + Assert.Equal(expectedDateTime.ToString("s") + "Z", items.CreatedAt.ToString("s") + "Z"); + Assert.Equal("string", items.Description); + Assert.Equal("string", items.Id); + Assert.Equal(new CloudflareSyncStatus(), items.Status); + Assert.Equal(expectedDateTime.ToString("s") + "Z", items.UpdatedAt.ToString("s") + "Z"); + Assert.Equal("string", items.UserId); + } + [Fact] + public void Delete() + { + var result = this.service.DeleteAllAccessIPRanges(Id, this.requestOptions); + Assert.NotNull(result); + Assert.Equal(typeof(AccessIPRanges), result.GetType()); + var expectedDateTime = new DateTime(2019, 8, 24, 14, 15, 22); + var items = result; + Assert.Equal("string", items.CidrBlock); + Assert.Equal(expectedDateTime.ToString("s") + "Z", items.CreatedAt.ToString("s") + "Z"); + Assert.Equal("string", items.Description); + Assert.Equal("string", items.Id); + Assert.Equal(new CloudflareSyncStatus(), items.Status); + Assert.Equal(expectedDateTime.ToString("s") + "Z", items.UpdatedAt.ToString("s") + "Z"); + Assert.Equal("string", items.UserId); + } + + [Fact] + public async Task DeleteSync() + { + var cts = new CancellationTokenSource(); + var result = await this.service.DeleteAllAccessIPRangesAsync(Id, this.requestOptions, cts.Token); + Assert.NotNull(result); + Assert.Equal(typeof(AccessIPRanges), result.GetType()); + var expectedDateTime = new DateTime(2019, 8, 24, 14, 15, 22); + var items = result; + Assert.Equal("string", items.CidrBlock); + Assert.Equal(expectedDateTime.ToString("s") + "Z", items.CreatedAt.ToString("s") + "Z"); + Assert.Equal("string", items.Description); + Assert.Equal("string", items.Id); + Assert.Equal(new CloudflareSyncStatus(), items.Status); + Assert.Equal(expectedDateTime.ToString("s") + "Z", items.UpdatedAt.ToString("s") + "Z"); + Assert.Equal("string", items.UserId); + } + } +} \ No newline at end of file diff --git a/src/TelnyxTests/Services/AccessIPRanges/AccessIPRangesListTest.cs b/src/TelnyxTests/Services/AccessIPRanges/AccessIPRangesListTest.cs new file mode 100644 index 00000000..bbbf063a --- /dev/null +++ b/src/TelnyxTests/Services/AccessIPRanges/AccessIPRangesListTest.cs @@ -0,0 +1,82 @@ +using System.Threading.Tasks; +using Telnyx; +using Telnyx.net.Entities; +using Telnyx.net.Services.AccessIPRange; + +using Xunit; +using System.Threading; +using Telnyx.net.Entities.AccessIPRanges; +using Telnyx.net.Entities.Enum.AccessIPRanges; +using Castle.Core.Resource; +using System; + +namespace TelnyxTests.Services.AccessToken +{ + /// + /// Test class for AccessToken. + /// + public class AccessIPRangesListTest : BaseTelnyxTest + { + private readonly AcessIPRangesService service; + private readonly AccessIPRangesListOption AccessIPRangesListOption; + private readonly RequestOptions requestOptions; + private readonly BaseOptions baseOptions; + private const string Id = "6a09cdc3-8948-47f0-aa62-74ac943d6c58"; + + public AccessIPRangesListTest(MockHttpClientFixture mockHttpClientFixture) + : base(mockHttpClientFixture) + { + this.service = new AcessIPRangesService(); + this.baseOptions = new BaseOptions(); + this.requestOptions = new RequestOptions(); + this.AccessIPRangesListOption = new AccessIPRangesListOption() + { + CidrBlock = "string", + CidrBlockContains = "string", + Status = Telnyx.net.Entities.Enum.AccessIPRanges.CloudflareSyncStatus.Pending, + CreatedAtGreaterThan = DateTime.UtcNow, + CidrBlockEndsWith = "string", + CidrBlockStartsWith = "string", + CreatedAtLessThan = DateTime.UtcNow, + }; + } + [Fact] + public void List() + { + var result = this.service.ListAllAccessIPRanges(this.AccessIPRangesListOption, this.requestOptions); + Assert.NotNull(result); + Assert.Equal(typeof(TelnyxList), result.GetType()); + foreach(var items in result.Data) + { + var expectedDateTime = new DateTime(2019, 8, 24, 14, 15, 22); + Assert.Equal("string", items.CidrBlock); + Assert.Equal(expectedDateTime.ToString("s") + "Z", items.CreatedAt.ToString("s") + "Z"); + Assert.Equal("string", items.Description); + Assert.Equal("string", items.Id); + Assert.Equal(new CloudflareSyncStatus(), items.Status); + Assert.Equal(expectedDateTime.ToString("s") + "Z", items.UpdatedAt.ToString("s") + "Z"); + Assert.Equal("string", items.UserId); + } + } + + [Fact] + public async Task ListSync() + { + var cts = new CancellationTokenSource(); + var result = await this.service.ListAllAccessIPRangesAsync(this.AccessIPRangesListOption, this.requestOptions, cts.Token); + Assert.NotNull(result); + Assert.Equal(typeof(TelnyxList), result.GetType()); + foreach (var items in result.Data) + { + var expectedDateTime = new DateTime(2019, 8, 24, 14, 15, 22); + Assert.Equal("string", items.CidrBlock); + Assert.Equal(expectedDateTime.ToString("s") + "Z", items.CreatedAt.ToString("s") + "Z"); + Assert.Equal("string", items.Description); + Assert.Equal("string", items.Id); + Assert.Equal(new CloudflareSyncStatus(), items.Status); + Assert.Equal(expectedDateTime.ToString("s") + "Z", items.UpdatedAt.ToString("s") + "Z"); + Assert.Equal("string", items.UserId); + } + } + } +} \ No newline at end of file diff --git a/src/TelnyxTests/Services/AccessToken/AccessTokenTest.cs b/src/TelnyxTests/Services/AccessToken/AccessTokenTest.cs new file mode 100644 index 00000000..af359487 --- /dev/null +++ b/src/TelnyxTests/Services/AccessToken/AccessTokenTest.cs @@ -0,0 +1,50 @@ +//using System.Threading.Tasks; +//using Telnyx; +//using Telnyx.net.Entities; +//using Telnyx.net.Services.AccessTokens; + +//using Xunit; +//using System.Threading; +//using Telnyx.net.Entities.AccessToken; +//using Castle.Core.Resource; +//using System; + +//namespace TelnyxTests.Services.AccessToken +//{ +// /// +// /// Test class for AccessToken. +// /// +// public class AccessTokenTest : BaseTelnyxTest +// { +// private readonly AccessTokensService service; +// private readonly RequestOptions requestOptions; +// private readonly BaseOptions baseOptions; +// private const string Id = "6a09cdc3-8948-47f0-aa62-74ac943d6c58"; + +// public AccessTokenTest(MockHttpClientFixture mockHttpClientFixture) +// : base(mockHttpClientFixture) +// { +// this.service = new AccessTokensService(); +// this.baseOptions = new BaseOptions(); +// this.requestOptions = new RequestOptions(); +// } +// [Fact] +// public void Create() +// { +// var result = this.service.CreateAccessToken(Id, this.requestOptions); +// Assert.NotNull(result); +// Assert.Equal(typeof(AccessTokensService), result.GetType()); +// } + +// [Fact] +// public async Task CreateSync() +// { +// var cts = new CancellationTokenSource(); +// var result = await this.service.CreateAccessTokenAsync(Id, this.requestOptions, cts.Token); +// Assert.NotNull(result); +// Assert.Equal(typeof(AccessTokensService), result.GetType()); + + +// } +// } +//} \ No newline at end of file diff --git a/src/TelnyxTests/Services/AuthenticationProvider/AuthenticationProviderCreateTest.cs b/src/TelnyxTests/Services/AuthenticationProvider/AuthenticationProviderCreateTest.cs new file mode 100644 index 00000000..5705b049 --- /dev/null +++ b/src/TelnyxTests/Services/AuthenticationProvider/AuthenticationProviderCreateTest.cs @@ -0,0 +1,244 @@ +using System.Threading.Tasks; +using Telnyx; +using Telnyx.net.Entities; +using Telnyx.net.Services.AuthentictionProvider; +using Xunit; +using System.Threading; +using Telnyx.net.Entities.AuthenticationProviders; +using Telnyx.net.Entities.Enum.AuthenticationProviders; +using Castle.Core.Resource; +using System; +using Xunit.Abstractions; +using Moq; + +namespace TelnyxTests.Services.AuthenticationProvider +{ + /// + /// Test class for AuthenticationProvider. + /// + public class AuthenticationProviderCreateTest : BaseTelnyxTest + { + private readonly AuthenticationProviderService service; + private readonly AuthenticationProviderCreateOption AuthenticationProviderCreateOption; + private readonly RequestOptions requestOptions; + private readonly BaseOptions baseOptions; + private const string Id = "6a09cdc3-8948-47f0-aa62-74ac943d6c58"; + + public AuthenticationProviderCreateTest(MockHttpClientFixture mockHttpClientFixture) + : base(mockHttpClientFixture) + { + this.service = new AuthenticationProviderService(); + this.baseOptions = new BaseOptions(); + this.requestOptions = new RequestOptions(); + this.AuthenticationProviderCreateOption = new AuthenticationProviderCreateOption() + { + Active = true, + Name = "Okta", + Settings = new SettingsObject + { + AssertionConsumerServiceUrl = "https://api.telnyx.com/sso/saml/auth/myorg", + IdpCertFingerprint = "https://api.telnyx.com/sso/saml/metadata/myorg", + IdpCertFingerprintAlgorithm = "sha1", + IdpEntityId = "https://myorg.myidp.com/saml/metadata", + IdpSsoTargetUrl = "https://myorg.myidp.com/trust/saml2/http-post/sso", + NameIdentifierFormat = "urn:oasis:names:tc:SAML:1.1:nameid-format", + ServiceProviderEntityId = "https://api.telnyx.com/sso/saml/metadata/myorg", + }, + SettingsUrl = "https://myorg.myidp.com/saml/metadata", + ShortName = "myord", + }; + } + [Fact] + public void Create() + { + var result = this.service.CreateAuthenticationProviders(this.AuthenticationProviderCreateOption, this.requestOptions); + Assert.NotNull(result); + Assert.Equal(typeof(AuthenticationProviders), result.GetType()); + var items = result; + var expectedDateTime = new DateTime(2018, 2, 2, 22, 25, 27, 521); + Assert.True(items.Active); + Assert.Equal("https://api.telnyx.com/sso/saml/auth/myorg", items.Settings.AssertionConsumerServiceUrl); + Assert.Equal("urn:oasis:names:tc:SAML:1.1:nameid-format", items.Settings.NameIdentifierFormat); + Assert.Equal("https://api.telnyx.com/sso/saml/metadata/myorg", items.Settings.ServiceProviderEntityId); + Assert.Equal("https://myorg.myidp.com/trust/saml2/http-post/sso", items.Settings.IdpSsoTargetUrl); + Assert.Equal("13:38:C7:BB:C9:FF:4A:70:38:3A:E3:D9:5C:CD:DB:2E:50:1E:80:A7", items.Settings.IdpCertFingerprint); + Assert.Equal("sha1", items.Settings.IdpCertFingerprintAlgorithm); + Assert.Equal("https://myorg.myidp.com/saml/metadata", items.Settings.IdpEntityId); + Assert.Equal("urn:oasis:names:tc:SAML:1.1:nameid-format", items.Settings.NameIdentifierFormat); + Assert.Equal("myorg", items.ShortName); + Assert.Equal("Okta", items.Name); + Assert.Equal(new Guid("35146afd-df93-4963-b1e9-1a085e2ae874"), items.Id); + Assert.Equal(new Guid("24b4a4bb-c4df-46ad-bbcb-23fc741c5ad7"), items.OrganizationId); + Assert.Equal("authentication_provider", items.RecordType); + Assert.Equal(expectedDateTime.ToString("s") + "Z", items.UpdatedAt.ToString("s") + "Z"); + Assert.Equal(expectedDateTime.ToString("s") + "Z", items.CreatedAt.ToString("s") + "Z"); + } + [Fact] + public async Task CreateSync() + { + var cts = new CancellationTokenSource(); + var result = await this.service.CreateAuthenticationProvidersAsync(this.AuthenticationProviderCreateOption, this.requestOptions, cts.Token); + Assert.NotNull(result); + Assert.Equal(typeof(AuthenticationProviders), result.GetType()); + var expectedDateTime = new DateTime(2018, 2, 2, 22, 25, 27, 521); + var items = result; + Assert.True(items.Active); + Assert.Equal("https://api.telnyx.com/sso/saml/auth/myorg", items.Settings.AssertionConsumerServiceUrl); + Assert.Equal("urn:oasis:names:tc:SAML:1.1:nameid-format", items.Settings.NameIdentifierFormat); + Assert.Equal("https://api.telnyx.com/sso/saml/metadata/myorg", items.Settings.ServiceProviderEntityId); + Assert.Equal("https://myorg.myidp.com/trust/saml2/http-post/sso", items.Settings.IdpSsoTargetUrl); + Assert.Equal("13:38:C7:BB:C9:FF:4A:70:38:3A:E3:D9:5C:CD:DB:2E:50:1E:80:A7", items.Settings.IdpCertFingerprint); + Assert.Equal("sha1", items.Settings.IdpCertFingerprintAlgorithm); + Assert.Equal("https://myorg.myidp.com/saml/metadata", items.Settings.IdpEntityId); + Assert.Equal("urn:oasis:names:tc:SAML:1.1:nameid-format", items.Settings.NameIdentifierFormat); + Assert.Equal("myorg", items.ShortName); + Assert.Equal("Okta", items.Name); + Assert.Equal(new Guid("35146afd-df93-4963-b1e9-1a085e2ae874"), items.Id); + Assert.Equal(new Guid("24b4a4bb-c4df-46ad-bbcb-23fc741c5ad7"), items.OrganizationId); + Assert.Equal("authentication_provider", items.RecordType); + Assert.Equal(expectedDateTime.ToString("s") + "Z", items.UpdatedAt.ToString("s") + "Z"); + Assert.Equal(expectedDateTime.ToString("s") + "Z", items.CreatedAt.ToString("s") + "Z"); + } + [Fact] + public void Delete() + { + var result = this.service.DeleteAuthenticationProviders(Id, this.requestOptions); + Assert.NotNull(result); + Assert.Equal(typeof(AuthenticationProviders), result.GetType()); + var items = result; + var expectedDateTime = new DateTime(2018, 2, 2, 22, 25, 27, 521); + Assert.True(items.Active); + Assert.Equal("https://api.telnyx.com/sso/saml/auth/myorg", items.Settings.AssertionConsumerServiceUrl); + Assert.Equal("urn:oasis:names:tc:SAML:1.1:nameid-format", items.Settings.NameIdentifierFormat); + Assert.Equal("https://api.telnyx.com/sso/saml/metadata/myorg", items.Settings.ServiceProviderEntityId); + Assert.Equal("https://myorg.myidp.com/trust/saml2/http-post/sso", items.Settings.IdpSsoTargetUrl); + Assert.Equal("13:38:C7:BB:C9:FF:4A:70:38:3A:E3:D9:5C:CD:DB:2E:50:1E:80:A7", items.Settings.IdpCertFingerprint); + Assert.Equal("sha1", items.Settings.IdpCertFingerprintAlgorithm); + Assert.Equal("https://myorg.myidp.com/saml/metadata", items.Settings.IdpEntityId); + Assert.Equal("urn:oasis:names:tc:SAML:1.1:nameid-format", items.Settings.NameIdentifierFormat); + Assert.Equal("myorg", items.ShortName); + Assert.Equal("Okta", items.Name); + Assert.Equal(new Guid("35146afd-df93-4963-b1e9-1a085e2ae874"), items.Id); + Assert.Equal(new Guid("24b4a4bb-c4df-46ad-bbcb-23fc741c5ad7"), items.OrganizationId); + Assert.Equal("authentication_provider", items.RecordType); + Assert.Equal(expectedDateTime.ToString("s") + "Z", items.UpdatedAt.ToString("s") + "Z"); + Assert.Equal(expectedDateTime.ToString("s") + "Z", items.CreatedAt.ToString("s") + "Z"); + } + [Fact] + public async Task DeleteSync() + { + var cts = new CancellationTokenSource(); + var result = await this.service.DeleteAuthenticationProvidersAsync(Id, this.requestOptions, cts.Token); + Assert.NotNull(result); + Assert.Equal(typeof(AuthenticationProviders), result.GetType()); + var expectedDateTime = new DateTime(2018, 2, 2, 22, 25, 27, 521); + var items = result; + Assert.True(items.Active); + Assert.Equal("https://api.telnyx.com/sso/saml/auth/myorg", items.Settings.AssertionConsumerServiceUrl); + Assert.Equal("urn:oasis:names:tc:SAML:1.1:nameid-format", items.Settings.NameIdentifierFormat); + Assert.Equal("https://api.telnyx.com/sso/saml/metadata/myorg", items.Settings.ServiceProviderEntityId); + Assert.Equal("https://myorg.myidp.com/trust/saml2/http-post/sso", items.Settings.IdpSsoTargetUrl); + Assert.Equal("13:38:C7:BB:C9:FF:4A:70:38:3A:E3:D9:5C:CD:DB:2E:50:1E:80:A7", items.Settings.IdpCertFingerprint); + Assert.Equal("sha1", items.Settings.IdpCertFingerprintAlgorithm); + Assert.Equal("https://myorg.myidp.com/saml/metadata", items.Settings.IdpEntityId); + Assert.Equal("urn:oasis:names:tc:SAML:1.1:nameid-format", items.Settings.NameIdentifierFormat); + Assert.Equal("myorg", items.ShortName); + Assert.Equal("Okta", items.Name); + Assert.Equal(new Guid("35146afd-df93-4963-b1e9-1a085e2ae874"), items.Id); + Assert.Equal(new Guid("24b4a4bb-c4df-46ad-bbcb-23fc741c5ad7"), items.OrganizationId); + Assert.Equal("authentication_provider", items.RecordType); + Assert.Equal(expectedDateTime.ToString("s") + "Z", items.UpdatedAt.ToString("s") + "Z"); + Assert.Equal(expectedDateTime.ToString("s") + "Z", items.CreatedAt.ToString("s") + "Z"); + } + [Fact] + public void Update() + { + var result = this.service.UpdateAuthenticationProviders(Id, this.AuthenticationProviderCreateOption, this.requestOptions); + Assert.NotNull(result); + Assert.Equal(typeof(AuthenticationProviders), result.GetType()); + var items = result; + var expectedDateTime = new DateTime(2018, 2, 2, 22, 25, 27, 521); + Assert.True(items.Active); + Assert.Equal("https://api.telnyx.com/sso/saml/auth/myorg", items.Settings.AssertionConsumerServiceUrl); + Assert.Equal("urn:oasis:names:tc:SAML:1.1:nameid-format", items.Settings.NameIdentifierFormat); + Assert.Equal("https://api.telnyx.com/sso/saml/metadata/myorg", items.Settings.ServiceProviderEntityId); + Assert.Equal("https://myorg.myidp.com/trust/saml2/http-post/sso", items.Settings.IdpSsoTargetUrl); + Assert.Equal("13:38:C7:BB:C9:FF:4A:70:38:3A:E3:D9:5C:CD:DB:2E:50:1E:80:A7", items.Settings.IdpCertFingerprint); + Assert.Equal("sha1", items.Settings.IdpCertFingerprintAlgorithm); + Assert.Equal("https://myorg.myidp.com/saml/metadata", items.Settings.IdpEntityId); + Assert.Equal("urn:oasis:names:tc:SAML:1.1:nameid-format", items.Settings.NameIdentifierFormat); + Assert.Equal("myorg", items.ShortName); + Assert.Equal("Okta", items.Name); + Assert.Equal(new Guid("35146afd-df93-4963-b1e9-1a085e2ae874"), items.Id); + Assert.Equal(new Guid("24b4a4bb-c4df-46ad-bbcb-23fc741c5ad7"), items.OrganizationId); + Assert.Equal("authentication_provider", items.RecordType); + Assert.Equal(expectedDateTime.ToString("s") + "Z", items.UpdatedAt.ToString("s") + "Z"); + Assert.Equal(expectedDateTime.ToString("s") + "Z", items.CreatedAt.ToString("s") + "Z"); + } + [Fact] + public async Task UpdateSync() + { + var cts = new CancellationTokenSource(); + var result = await this.service.UpdateAuthenticationProvidersAsync(Id, this.AuthenticationProviderCreateOption, this.requestOptions,cts.Token); + Assert.NotNull(result); + Assert.Equal(typeof(AuthenticationProviders), result.GetType()); + var expectedDateTime = new DateTime(2018, 2, 2, 22, 25, 27, 521); + var items = result; + Assert.True(items.Active); + Assert.Equal("https://api.telnyx.com/sso/saml/auth/myorg", items.Settings.AssertionConsumerServiceUrl); + Assert.Equal("urn:oasis:names:tc:SAML:1.1:nameid-format", items.Settings.NameIdentifierFormat); + Assert.Equal("https://api.telnyx.com/sso/saml/metadata/myorg", items.Settings.ServiceProviderEntityId); + Assert.Equal("https://myorg.myidp.com/trust/saml2/http-post/sso", items.Settings.IdpSsoTargetUrl); + Assert.Equal("13:38:C7:BB:C9:FF:4A:70:38:3A:E3:D9:5C:CD:DB:2E:50:1E:80:A7", items.Settings.IdpCertFingerprint); + Assert.Equal("sha1", items.Settings.IdpCertFingerprintAlgorithm); + Assert.Equal("https://myorg.myidp.com/saml/metadata", items.Settings.IdpEntityId); + Assert.Equal("urn:oasis:names:tc:SAML:1.1:nameid-format", items.Settings.NameIdentifierFormat); + Assert.Equal("myorg", items.ShortName); + Assert.Equal("Okta", items.Name); + Assert.Equal(new Guid("35146afd-df93-4963-b1e9-1a085e2ae874"), items.Id); + Assert.Equal(new Guid("24b4a4bb-c4df-46ad-bbcb-23fc741c5ad7"), items.OrganizationId); + Assert.Equal("authentication_provider", items.RecordType); + Assert.Equal(expectedDateTime.ToString("s") + "Z", items.UpdatedAt.ToString("s") + "Z"); + Assert.Equal(expectedDateTime.ToString("s") + "Z", items.CreatedAt.ToString("s") + "Z"); + } + + [Fact] + public void Retrieve() + { + var result = this.service.RetrieveAuthenticationProviders(Id, this.requestOptions); + RetrieveAsserts(result); + } + + [Fact] + public async Task RetrieveSync() + { + var cts = new CancellationTokenSource(); + var result = await this.service.RetrieveAuthenticationProvidersAsync(Id, this.requestOptions); + RetrieveAsserts(result); + } + + public void RetrieveAsserts(AuthenticationProviders result) + { + Assert.NotNull(result); + Assert.Equal(typeof(AuthenticationProviders), result.GetType()); + var items = result; + var expectedDateTime = new DateTime(2018, 2, 2, 22, 25, 27, 521); + Assert.False(items.Active); + Assert.Equal("https://api.telnyx.com/sso/saml/auth/myorg", items.Settings.AssertionConsumerServiceUrl); + Assert.Equal("urn:oasis:names:tc:SAML:1.1:nameid-format", items.Settings.NameIdentifierFormat); + Assert.Equal("https://api.telnyx.com/sso/saml/metadata/myorg", items.Settings.ServiceProviderEntityId); + Assert.Equal("https://myorg.myidp.com/trust/saml2/http-post/sso", items.Settings.IdpSsoTargetUrl); + Assert.Equal("13:38:C7:BB:C9:FF:4A:70:38:3A:E3:D9:5C:CD:DB:2E:50:1E:80:A7", items.Settings.IdpCertFingerprint); + Assert.Equal("sha1", items.Settings.IdpCertFingerprintAlgorithm); + Assert.Equal("https://myorg.myidp.com/saml/metadata", items.Settings.IdpEntityId); + Assert.Equal("urn:oasis:names:tc:SAML:1.1:nameid-format", items.Settings.NameIdentifierFormat); + Assert.Equal("myorg", items.ShortName); + Assert.Equal("Okta", items.Name); + Assert.Equal(new Guid("35146afd-df93-4963-b1e9-1a085e2ae874"), items.Id); + Assert.Equal(new Guid("24b4a4bb-c4df-46ad-bbcb-23fc741c5ad7"), items.OrganizationId); + Assert.Equal("authentication_provider", items.RecordType); + Assert.Equal(expectedDateTime.ToString("s") + "Z", items.UpdatedAt.ToString("s") + "Z"); + Assert.Equal(expectedDateTime.ToString("s") + "Z", items.CreatedAt.ToString("s") + "Z"); + } + } +} \ No newline at end of file diff --git a/src/TelnyxTests/Services/AuthenticationProvider/AuthenticationProviderListTest.cs b/src/TelnyxTests/Services/AuthenticationProvider/AuthenticationProviderListTest.cs new file mode 100644 index 00000000..a1a412ed --- /dev/null +++ b/src/TelnyxTests/Services/AuthenticationProvider/AuthenticationProviderListTest.cs @@ -0,0 +1,92 @@ +using System.Threading.Tasks; +using Telnyx; +using Telnyx.net.Entities; +using Telnyx.net.Services.AuthentictionProvider; +using Xunit; +using System.Threading; +using Telnyx.net.Entities.AuthenticationProviders; +using Telnyx.net.Entities.Enum.AuthenticationProviders; +using Castle.Core.Resource; +using System; +using Xunit.Abstractions; + +namespace TelnyxTests.Services.AuthenticationProvider +{ + /// + /// Test class for AuthenticationProvider. + /// + public class AuthenticationProviderListTest : BaseTelnyxTest + { + private readonly AuthenticationProviderService service; + private readonly AuthenticationProviderListOption AuthenticationProviderListOption; + private readonly RequestOptions requestOptions; + private readonly BaseOptions baseOptions; + private const string Id = "6a09cdc3-8948-47f0-aa62-74ac943d6c58"; + + public AuthenticationProviderListTest(MockHttpClientFixture mockHttpClientFixture) + : base(mockHttpClientFixture) + { + this.service = new AuthenticationProviderService(); + this.baseOptions = new BaseOptions(); + this.requestOptions = new RequestOptions(); + this.AuthenticationProviderListOption = new AuthenticationProviderListOption() + { + Sort = Sort.Name, + }; + } + [Fact] + public void List() + { + var result = this.service.ListAuthenticationProviders(this.AuthenticationProviderListOption, this.requestOptions); + Assert.NotNull(result); + Assert.Equal(typeof(TelnyxList), result.GetType()); + foreach (var items in result.Data) + { + var expectedDateTime = new DateTime(2018, 2, 2, 22, 25, 27, 521); + Assert.True(items.Active); + Assert.Equal("https://api.telnyx.com/sso/saml/auth/myorg", items.Settings.AssertionConsumerServiceUrl); + Assert.Equal("urn:oasis:names:tc:SAML:1.1:nameid-format", items.Settings.NameIdentifierFormat); + Assert.Equal("https://api.telnyx.com/sso/saml/metadata/myorg", items.Settings.ServiceProviderEntityId); + Assert.Equal("https://myorg.myidp.com/trust/saml2/http-post/sso", items.Settings.IdpSsoTargetUrl); + Assert.Equal("13:38:C7:BB:C9:FF:4A:70:38:3A:E3:D9:5C:CD:DB:2E:50:1E:80:A7", items.Settings.IdpCertFingerprint); + Assert.Equal("sha1", items.Settings.IdpCertFingerprintAlgorithm); + Assert.Equal("https://myorg.myidp.com/saml/metadata", items.Settings.IdpEntityId); + Assert.Equal("urn:oasis:names:tc:SAML:1.1:nameid-format", items.Settings.NameIdentifierFormat); + Assert.Equal("myorg", items.ShortName); + Assert.Equal("Okta", items.Name); + Assert.Equal(new Guid("35146afd-df93-4963-b1e9-1a085e2ae874"), items.Id); + Assert.Equal(new Guid("24b4a4bb-c4df-46ad-bbcb-23fc741c5ad7"), items.OrganizationId); + Assert.Equal("authentication_provider", items.RecordType); + Assert.Equal(expectedDateTime.ToString("s") + "Z", items.UpdatedAt.ToString("s") + "Z"); + Assert.Equal(expectedDateTime.ToString("s") + "Z", items.CreatedAt.ToString("s") + "Z"); + } + } + [Fact] + public async Task ListSync() + { + var cts = new CancellationTokenSource(); + var result = await this.service.ListAuthenticationProvidersAsync(this.AuthenticationProviderListOption, this.requestOptions, cts.Token); + Assert.NotNull(result); + Assert.Equal(typeof(TelnyxList), result.GetType()); + var expectedDateTime = new DateTime(2018, 2, 2, 22, 25, 27, 521); + foreach (var items in result.Data) { + Assert.True(items.Active); + Assert.Equal("https://api.telnyx.com/sso/saml/auth/myorg", items.Settings.AssertionConsumerServiceUrl); + Assert.Equal("urn:oasis:names:tc:SAML:1.1:nameid-format", items.Settings.NameIdentifierFormat); + Assert.Equal("https://api.telnyx.com/sso/saml/metadata/myorg", items.Settings.ServiceProviderEntityId); + Assert.Equal("https://myorg.myidp.com/trust/saml2/http-post/sso", items.Settings.IdpSsoTargetUrl); + Assert.Equal("13:38:C7:BB:C9:FF:4A:70:38:3A:E3:D9:5C:CD:DB:2E:50:1E:80:A7", items.Settings.IdpCertFingerprint); + Assert.Equal("sha1", items.Settings.IdpCertFingerprintAlgorithm); + Assert.Equal("https://myorg.myidp.com/saml/metadata", items.Settings.IdpEntityId); + Assert.Equal("urn:oasis:names:tc:SAML:1.1:nameid-format", items.Settings.NameIdentifierFormat); + Assert.Equal("myorg", items.ShortName); + Assert.Equal("Okta", items.Name); + Assert.Equal(new Guid("35146afd-df93-4963-b1e9-1a085e2ae874"), items.Id); + Assert.Equal(new Guid("24b4a4bb-c4df-46ad-bbcb-23fc741c5ad7"), items.OrganizationId); + Assert.Equal("authentication_provider", items.RecordType); + Assert.Equal(expectedDateTime.ToString("s") + "Z", items.UpdatedAt.ToString("s") + "Z"); + Assert.Equal(expectedDateTime.ToString("s") + "Z", items.CreatedAt.ToString("s") + "Z"); + } + } + } +} \ No newline at end of file diff --git a/src/TelnyxTests/Services/Calls/CallControl/ClientState/ClientStateTest.cs b/src/TelnyxTests/Services/Calls/CallControl/ClientState/ClientStateTest.cs new file mode 100644 index 00000000..ec36f33a --- /dev/null +++ b/src/TelnyxTests/Services/Calls/CallControl/ClientState/ClientStateTest.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Telnyx.net.Entities.Calls.CallControl.ClientState; +using Telnyx.net.Services.Calls.CallControl.ClientState; +using Xunit; + +namespace TelnyxTests.Services.Calls.CallControl.ClientState +{ + public class CallControlReferServiceTests : BaseTelnyxTest + { + private const string CallControllId = "call_123"; + + private readonly ClientStateService service; + private readonly ClientStateOption options; + + + public CallControlReferServiceTests(MockHttpClientFixture mockHttpClientFixture) + : base(mockHttpClientFixture) + { + this.service = new ClientStateService(); + + this.options = new ClientStateOption + { + ClientStates = "aGF2ZSBhIG5pY2UgZGF5ID1d", + + }; + } + [Fact] + public void Update() + { + var response = this.service.UpdateEntity(CallControllId,this.options); + Assert.NotNull(response); + var result = response.Result; + Assert.Equal(typeof(ClientStateOption), result.GetType()); + Assert.Equal("ok", result); + + } + [Fact] + public async Task UpdateAsync() + { + var response = await this.service.UpdateEntityAsync(CallControllId, this.options); + Assert.NotNull(response); + var result = response.Result; + Assert.Equal(typeof(ClientStateOption), result.GetType()); + } + } +} diff --git a/src/TelnyxTests/Services/ManagedAccounts/DisableManagedAccountsTest.cs b/src/TelnyxTests/Services/ManagedAccounts/DisableManagedAccountsTest.cs index 8583164a..3d14f296 100644 --- a/src/TelnyxTests/Services/ManagedAccounts/DisableManagedAccountsTest.cs +++ b/src/TelnyxTests/Services/ManagedAccounts/DisableManagedAccountsTest.cs @@ -35,7 +35,19 @@ public void Disable() var result = this.service.DisableManagedAccount(Id, this.requestOptions); Assert.NotNull(result); Assert.Equal(typeof(ManagedAccount), result.GetType()); - Assert.Equal("KEY01236170692E74656C6E79782E636F6D_YmlnIGlyb24gaXMgZGVhZA", result.ApiKey); + Assert.Equal("KEY01236170692E74656C6E79782E636F6D_YmlnIGlyb24gaXMgZGVhZA", result .ApiKey); + Assert.Equal("USD", result.Balance.Currency); + Assert.Equal("balance", result.Balance.RecordType); + Assert.Equal(100, result.Balance.CreditLimit); + Assert.Equal(300, result.Balance.AccountBalance); + Assert.Equal(300, result.Balance.AvailableCredit); + Assert.Equal("managed_account", result.RecordType); + Assert.Equal(Id, result.Id); + Assert.Equal("user@example.com", result.Email); + Assert.Equal("managed_account@example.com", result.ApiUser); + Assert.Equal("x6oexQNHTs-fZ7-QsDMOeg", result.ApiToken); + Assert.Equal("Example Company LLC", result.OrganizationName); + Assert.Equal("f65ceda4-6522-4ad6-aede-98de83385123", result.ManagerAccountId); } [Fact] @@ -46,6 +58,18 @@ public async Task DisableAsync() Assert.NotNull(result); Assert.Equal(typeof(ManagedAccount), result.GetType()); Assert.Equal("KEY01236170692E74656C6E79782E636F6D_YmlnIGlyb24gaXMgZGVhZA", result.ApiKey); + Assert.Equal("USD", result.Balance.Currency); + Assert.Equal("balance", result.Balance.RecordType); + Assert.Equal(100, result.Balance.CreditLimit); + Assert.Equal(300, result.Balance.AccountBalance); + Assert.Equal(300, result.Balance.AvailableCredit); + Assert.Equal("managed_account", result.RecordType); + Assert.Equal(Id, result.Id); + Assert.Equal("user@example.com", result.Email); + Assert.Equal("managed_account@example.com", result.ApiUser); + Assert.Equal("x6oexQNHTs-fZ7-QsDMOeg", result.ApiToken); + Assert.Equal("Example Company LLC", result.OrganizationName); + Assert.Equal("f65ceda4-6522-4ad6-aede-98de83385123", result.ManagerAccountId); } } } diff --git a/src/TelnyxTests/Services/Notifications/NotificationProfile/NotificationProfileTest.cs b/src/TelnyxTests/Services/Notifications/NotificationProfile/NotificationProfileTest.cs index d51b2ac9..971d0da2 100644 --- a/src/TelnyxTests/Services/Notifications/NotificationProfile/NotificationProfileTest.cs +++ b/src/TelnyxTests/Services/Notifications/NotificationProfile/NotificationProfileTest.cs @@ -38,7 +38,7 @@ public void List() { var result = this.service.ListNotificationProfiles(this.requestOptions); Assert.NotNull(result); - Assert.Equal(typeof(), result.GetType()); + Assert.Equal(typeof(NotificationProfileOptions), result.GetType()); } [Fact] @@ -47,7 +47,7 @@ public async Task ListSync() var cts = new CancellationTokenSource(); var result = await this.service.ListNotificationProfilesAsync(this.requestOptions, cts.Token); Assert.NotNull(result); - Assert.Equal(typeof(NotificationProfile), result.GetType()); + Assert.Equal(typeof(NotificationProfileOptions), result.GetType()); } } } diff --git a/src/TelnyxTests/Services/Notifications/NotificationSettings/NotificationSettingTest.cs b/src/TelnyxTests/Services/Notifications/NotificationSettings/NotificationSettingTest.cs index 5b49a3ae..fb7bf34d 100644 --- a/src/TelnyxTests/Services/Notifications/NotificationSettings/NotificationSettingTest.cs +++ b/src/TelnyxTests/Services/Notifications/NotificationSettings/NotificationSettingTest.cs @@ -35,8 +35,7 @@ public NotificationSettingTest(MockHttpClientFixture mockHttpClientFixture) NotificationChannelId = "12455643-3cf1-4683-ad23-1cd32f7d5e0a", NotificationEventConditionId = "70c7c5cb-dce2-4124-accb-870d39dbe852", NotificationProfileId = "12455643-3cf1-4683-ad23-1cd32f7d5e0a", - AssociatedRecordType = Telnyx.net.Entities.Enum.Notification.NotificationSettings.AssociatedRecordType.Account, - NotificationStatus = Telnyx.net.Entities.Enum.Notification.NotificationSettings.NotificationStatus.DeletePending, + Parameters = {} }; }