diff --git a/Common/Models/IccidTableEntity.cs b/Common/Models/IccidTableEntity.cs index e3d93918..4d606741 100644 --- a/Common/Models/IccidTableEntity.cs +++ b/Common/Models/IccidTableEntity.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.WindowsAzure.Storage.Table; +using Microsoft.WindowsAzure.Storage.Table; namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.Common.Models { @@ -22,7 +17,7 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.Common.Models public string Iccid { get; set; } public string ProviderName { get; set; } - + public string LastSetLocaleServiceRequestId { get; set; } } public enum IccidRegistrationKey diff --git a/DeviceAdministration/CellularConnectivity/Clients/EricssonCellularClient.cs b/DeviceAdministration/CellularConnectivity/Clients/EricssonCellularClient.cs index ebc85fa4..661c7e15 100644 --- a/DeviceAdministration/CellularConnectivity/Clients/EricssonCellularClient.cs +++ b/DeviceAdministration/CellularConnectivity/Clients/EricssonCellularClient.cs @@ -2,22 +2,23 @@ using System.Collections.Generic; using System.Linq; using System.Net; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Text; using System.Threading.Tasks; +using System.Web.Script.Serialization; +using DCP_eUICC_V2; using DeviceManagement.Infrustructure.Connectivity.Builders; using DeviceManagement.Infrustructure.Connectivity.DeviceReconnect; using DeviceManagement.Infrustructure.Connectivity.EricssonApiService; using DeviceManagement.Infrustructure.Connectivity.EricssonSubscriptionService; using DeviceManagement.Infrustructure.Connectivity.EricssonTrafficManagment; +using DeviceManagement.Infrustructure.Connectivity.Exceptions; +using DeviceManagement.Infrustructure.Connectivity.Models.Jasper; using DeviceManagement.Infrustructure.Connectivity.Models.Other; using DeviceManagement.Infrustructure.Connectivity.Models.Security; using DeviceManagement.Infrustructure.Connectivity.Models.TerminalDevice; using resource = DeviceManagement.Infrustructure.Connectivity.EricssonSubscriptionService.resource; -using System.Net.Http; -using System.Text; -using DeviceManagement.Infrustructure.Connectivity.Models.Jasper; -using System.Web.Script.Serialization; -using System.Net.Http.Headers; -using DeviceManagement.Infrustructure.Connectivity.Exceptions; namespace DeviceManagement.Infrustructure.Connectivity.Clients { @@ -99,7 +100,7 @@ namespace DeviceManagement.Infrustructure.Connectivity.Clients } } - catch (Exception exception) + catch { return terminal; } @@ -284,6 +285,70 @@ namespace DeviceManagement.Infrustructure.Connectivity.Clients return true; } + /// + /// Get current locale name and available locale names + /// + /// ICCID + /// Available locale names + /// Current locale name + public string GetLocale(string iccid, out IEnumerable availableLocaleNames) + { + var euicc = GetEuicc(iccid); + + string localeTableId = euicc.LocalizationTableId.ToString(); + availableLocaleNames = new EuiccLocalesApiHandler().getLocales(localeTableId).Select(l => l.Name); + + return euicc.LocaleName ?? string.Empty; + } + + /// + /// Set locale + /// + /// ICCID + /// Desired locale name + /// True if succeeded, otherwise false + public string SetLocale(string iccid, string localeName) + { + var euicc = GetEuicc(iccid); + + string localeTableId = euicc.LocalizationTableId.ToString(); + var locales = new EuiccLocalesApiHandler().getLocales(localeTableId); + var locale = locales.First(l => l.Name == localeName); + + var request = new EuiccLocalizationApiHandler().localize(euicc.EuiccId, locale.Id, localeTableId); + return request?.ServiceRequestId; + } + + private EuiccV1 GetEuicc(string iccid) + { + var credential = _credentialProvider.Provide(); + var loginCredentials = new LoginApiHandler( + credential.BaseUrl + "/dcpapi/rest", + "06000147", // Hard-coded companyId. To be replaced by the real ID provided by mobile operator + credential.Username, + credential.Password, + false); + + var client = EricssonServiceBuilder.GetSubscriptionManagementClient(credential); + var response = client.QuerySimResource_v2(new QuerySimResource_v2 + { + resource = new resource + { + id = iccid, + type = "icc" + } + }); + + var subscription = new SubscriptionApiHandler().get(response.simResource.First().imsi); + + return new EuiccApiHandler().get(subscription.EuiccId); + } + + public string GetLastSetLocaleServiceRequestState(string serviceRequestId) + { + return new ServiceRequestApiHandler().get(serviceRequestId)?.ServiceRequestState; + } + private bool isAnActiveState(subscriptionStatus status) { switch (status) diff --git a/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/ApiHandlers/ApiHandler.cs b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/ApiHandlers/ApiHandler.cs new file mode 100644 index 00000000..9ab8bf0d --- /dev/null +++ b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/ApiHandlers/ApiHandler.cs @@ -0,0 +1,137 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using RestSharp; +using RestSharp.Authenticators; +using Newtonsoft.Json; +using System.Net; + +namespace DCP_eUICC_V2 +{ + // Each action need to inherith + public abstract class ApiHandler + { + // Properties + protected static string userName = string.Empty; + protected static string passWord = string.Empty; + protected static string baseAddress = string.Empty; + protected static string companyId = string.Empty; + public static bool simulatedApiCalls = false; + protected static RestClient ApiRestClient; + protected IRestResponse response = null; + protected static LoginV1 LoginCredentials; + public Error Error = null; + protected static DateTime loginTokenExpirationTime = DateTime.MinValue.AddYears(2); + + // Constructors + public ApiHandler() { } + public ApiHandler(string baseaddress, string companyid, string username, string password, bool simulateApiCalls) : this() + { + ApiHandler.baseAddress = baseaddress; + ApiHandler.companyId = companyid; + ApiHandler.userName = username; + ApiHandler.passWord = password; + ApiHandler.ApiRestClient = new RestClient(baseaddress); + ApiHandler.simulatedApiCalls = simulateApiCalls; + } + + //Sends an API request and checks for errors + protected virtual bool send(RestRequest request) + { + // Make sure that we have logincredentials + if (ApiHandler.LoginCredentials == null) + ApiHandler.LoginCredentials = new LoginV1(); + + // Check if we are logged in, try to login or renew if needed - if failure then exit + LoginApiHandler myLoginApiHandler = new LoginApiHandler(ApiHandler.baseAddress, ApiHandler.companyId, ApiHandler.userName, ApiHandler.passWord, ApiHandler.simulatedApiCalls); + if (!myLoginApiHandler.isLoggedIn()) + return this.isApiError(); + else + return this.sendWithoutLogin(request); + } + + //Sends an API request and checks for errors + protected virtual bool sendWithoutLogin(RestRequest request) + { + // Initialize default values prior to the API call + this.Error = null; + this.response = null; + + // Add header parameters + if ((LoginCredentials != null) && (LoginCredentials.Token != null) && (LoginCredentials.Token.Length > 0)) + request.AddHeader("X-Access-Token", ApiHandler.LoginCredentials.Token); + + // Send an API request and check the response for success + //- if not successful then the property 'Error' contains info + try + { + //this.response = this.ApiRestClient.Execute(request); + this.response = ApiHandler.ApiRestClient.Execute(request); + } + catch (Exception ex) + { + this.Error = new Error() { Code = 0, HttpStatus = 0, Message = string.Format("Exception:\t{0}", ex.Message) }; + return false; + } + + return this.isApiError(); + } + + // Checks for API errors - provide error message in 'Error' property + protected bool isApiError() + { + // Check if we have a response value + if (this.response != null) + { + // Check for success or different kinds of errors + switch (this.response.ResponseStatus) + { + case ResponseStatus.Completed: + { + switch (this.response.StatusCode) + { + case HttpStatusCode.OK: + return true; + case HttpStatusCode.BadRequest: + case HttpStatusCode.InternalServerError: + case HttpStatusCode.ServiceUnavailable: + case HttpStatusCode.Unauthorized: + this.Error = new Error(); + Error = JsonConvert.DeserializeObject(response.Content); + break; + default: + this.Error = new Error() { Code = 0, HttpStatus = (int)response.StatusCode, Message = System.Enum.GetName(typeof(System.Net.HttpStatusCode), response.StatusCode) }; + break; + } + } + break; + case ResponseStatus.Aborted: + this.Error = new Error() { Code = 0, HttpStatus = 0, Message = "API call aborted" }; + break; + case ResponseStatus.TimedOut: + this.Error = new Error() { Code = 0, HttpStatus = 0, Message = "API call timeout" }; + break; + case ResponseStatus.Error: + case ResponseStatus.None: + default: + this.Error = new Error() { Code = 0, HttpStatus = 0, Message = "Connectivity fault" }; + break; + } + } + else + this.Error = new Error() { Code = 0, HttpStatus = 0, Message = "No content" }; + + // Return the result value + return false; + + } + + // Maybe later re-define the standard 'ToString() method + public override string ToString() + { + return base.ToString(); + } + } +} diff --git a/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/ApiHandlers/CompanyApiHandler.cs b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/ApiHandlers/CompanyApiHandler.cs new file mode 100644 index 00000000..8caa22c5 --- /dev/null +++ b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/ApiHandlers/CompanyApiHandler.cs @@ -0,0 +1,46 @@ +using System; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using RestSharp; + +namespace DCP_eUICC_V2 +{ + // Implements an API call + public class CompanyApiHandler : ApiHandler + { + // Api Action + public List getCompanies() + { + // Check if simulated environment or real API + if (ApiHandler.simulatedApiCalls) + { + // Simulated API call + List myList = new List(); + myList.Add(new CompanyV1() { Id = "Id1", Name = "Company 1" }); + myList.Add(new CompanyV1() { Id = "Id2", Name = "Company 2" }); + myList.Add(new CompanyV1() { Id = "Id3", Name = "Company 3" }); + return myList; + } + else + { + // Real API call + + // Prepare the API request + RestRequest request = new RestRequest("/allowedCompanies", Method.GET); + request.AddHeader("Accept", "application/vnd.dcp-v1+json"); + request.AddQueryParameter("companyId", ApiHandler.companyId); + + // Call the API and take care of the response + if (this.send(request)) + // Successful API request + return JsonConvert.DeserializeObject>(response.Content); + else + // API call failed, error info found in the Error object + return null; + } + } + } +} diff --git a/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/ApiHandlers/EchoApiHandler.cs b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/ApiHandlers/EchoApiHandler.cs new file mode 100644 index 00000000..74b85aca --- /dev/null +++ b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/ApiHandlers/EchoApiHandler.cs @@ -0,0 +1,41 @@ +using RestSharp; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DCP_eUICC_V2 +{ + class EchoApiHandler : ApiHandler + { + // Constructor + public EchoApiHandler(string baseaddress) : base(baseaddress, string.Empty, string.Empty, string.Empty, ApiHandler.simulatedApiCalls) { } + + // Api Action + public string echo(string echomessage) + { + // Check if simulated environment or real API + if (ApiHandler.simulatedApiCalls) + // Simulated API call + return echomessage; + else + { + // Real API call + + // Prepare the API request + RestRequest request = new RestRequest("/monitor/echo/{msg}", Method.GET); + request.AddUrlSegment("msg", echomessage); + request.AddHeader("Accept", "text/plain"); + + // Call the API and take care of the response + if (this.sendWithoutLogin(request)) + // Successful API request + return this.response.Content; + else + // API call failed, error info found in the Error object + return string.Empty; + } + } + } +} diff --git a/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/ApiHandlers/EuiccAgreementsApiHandler.cs b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/ApiHandlers/EuiccAgreementsApiHandler.cs new file mode 100644 index 00000000..eab0c294 --- /dev/null +++ b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/ApiHandlers/EuiccAgreementsApiHandler.cs @@ -0,0 +1,50 @@ +using System; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using RestSharp; + +namespace DCP_eUICC_V2 +{ + // Implements an API call + public class EuiccAgreementsApiHandler : ApiHandler + { + // Properties + //public EuiccAgreementList euiccAgreements = null; // Populated after a successful API call + + // Api Action + public EuiccAgreementListV1 getAgreements() + { + // Check if simulated environment or real API + if (ApiHandler.simulatedApiCalls) + { + // Simulated API call + EuiccAgreementListV1 myList = new EuiccAgreementListV1(); + myList.EuiccAgreements = new List(); + myList.EuiccAgreements.Add(new EuiccAgreementV1() { FormSpecification = new FormSpecificationV1(), Id = "Id1", LeadOperator = "Telia", Name = "Telia", ProfileSpecifications = new List() }); + myList.ServiceContracts = new List(); + myList.ServiceContracts.Add(new ServiceContractV1() { Id = "Id1", Description = "ServiceContract01", Name = "SC 01", SubscriptionPackages = new List() }); + return myList; + } + else + { + // Real API call + + // Prepare the API request + RestRequest request = new RestRequest("/euiccAgreements", Method.GET); + request.AddHeader("Accept", "application/vnd.dcp-v1+json"); + request.AddQueryParameter("companyId", ApiHandler.companyId); + + // Call the API and take care of the response + if (this.send(request)) + // Successful API request + return JsonConvert.DeserializeObject(response.Content); + else + // API call failed, error info found in the Error object + return null; + } + } + } +} diff --git a/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/ApiHandlers/EuiccApiHandler.cs b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/ApiHandlers/EuiccApiHandler.cs new file mode 100644 index 00000000..db713e61 --- /dev/null +++ b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/ApiHandlers/EuiccApiHandler.cs @@ -0,0 +1,77 @@ +using System.Collections.Generic; +using Newtonsoft.Json; +using RestSharp; + +namespace DCP_eUICC_V2 +{ + // Implements an API call that retrieves Login Credentials etc. + public class EuiccApiHandler : ApiHandler + { + // Mock data: Current locale setting + static public Dictionary _localeBinds = new Dictionary(); + + // Api Action + public EuiccV1 get(string eUICCid) + { + // Check if simulated environment or real API + if (ApiHandler.simulatedApiCalls) + { + // Simulated API call + EuiccV1 myEuicc = new EuiccV1() + { + EuiccId = "999870A0B0C0D0E0F100973000012678", + CompanyId = "97000002", + CompanyName = "Grundfos", + State = "LOCALIZED", + Label = null, + LocaleName = "France", + BootstrapIcc = "99987100973000012678", + EnabledIcc = "99987100973000012678", + BootstrapCompanyId = "97000002", + LocalizationTableId = 10040 + }; + List myEuiccSubscriptions = new List(); + List myLocales = new List(); + myLocales.Add(new EuiccLocaleV1() { Id = "FR01", Name = "France" }); + myLocales.Add(new EuiccLocaleV1() { Id = "FR02", Name = "France2" }); + myEuiccSubscriptions.Add(new EuiccSubscriptionV1() + { + Imsi = "100973000012678", + State = "ACTIVE", + OperatorId = "97000001", + OperatorName = "Telia", + Msisdn = "200973000012678", + Iccid = "99987100973000012678", + LocaleList = myLocales, + }); + myEuicc.Subscriptions = myEuiccSubscriptions; + + // Mock code: use mocked locale + string localeName; + if (_localeBinds.TryGetValue(eUICCid, out localeName)) + { + myEuicc.LocaleName = localeName; + } + + return myEuicc; + } + else + { + // Real API call + + // Prepare the API request + RestRequest request = new RestRequest("/euiccs/{id}", Method.GET); + request.AddUrlSegment("id", eUICCid); + request.AddHeader("Accept", "application/vnd.dcp-v1+json"); + + // Call the API and take care of the response + if (this.send(request)) + // Successful API request + return JsonConvert.DeserializeObject(this.response.Content); + else + // API call failed, error info found in the Error object + return null; + } + } + } +} diff --git a/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/ApiHandlers/EuiccLocalesApiHandler.cs b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/ApiHandlers/EuiccLocalesApiHandler.cs new file mode 100644 index 00000000..c29cf2ac --- /dev/null +++ b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/ApiHandlers/EuiccLocalesApiHandler.cs @@ -0,0 +1,49 @@ +using System; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using RestSharp; + +namespace DCP_eUICC_V2 +{ + // Implements an API call + public class EuiccLocalesApiHandler : ApiHandler + { + // Api Action + public List getLocales(string localizationTableId) + { + // Check if simulated environment or real API + if (ApiHandler.simulatedApiCalls) + { + // Simulated API call + List myLocaleList = new List(); + myLocaleList.Add(new EuiccLocaleV1() { Id = "FR01", Name = "France" }); + myLocaleList.Add(new EuiccLocaleV1() { Id = "FR02", Name = "France2" }); + myLocaleList.Add(new EuiccLocaleV1() { Id = "SE01", Name = "Sweden" }); + myLocaleList.Add(new EuiccLocaleV1() { Id = "DK01", Name = "Denmark" }); + myLocaleList.Add(new EuiccLocaleV1() { Id = "CH01", Name = "China" }); + myLocaleList.Add(new EuiccLocaleV1() { Id = "SP01", Name = "Spain" }); + return myLocaleList; + } + else + { + // Real API call + + // Prepare the API request + RestRequest request = new RestRequest("/locales", Method.GET); + request.AddHeader("Accept", "application/vnd.dcp-v1+json"); + request.AddQueryParameter("localizationTableId", localizationTableId); + + // Call the API and take care of the response + if (this.send(request)) + // Successful API request + return JsonConvert.DeserializeObject>(response.Content); + else + // API call failed, error info found in the Error object + return null; + } + } + } +} diff --git a/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/ApiHandlers/EuiccLocalizationApiHandler.cs b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/ApiHandlers/EuiccLocalizationApiHandler.cs new file mode 100644 index 00000000..a015a32c --- /dev/null +++ b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/ApiHandlers/EuiccLocalizationApiHandler.cs @@ -0,0 +1,57 @@ +using System.Linq; +using Newtonsoft.Json; +using RestSharp; + +namespace DCP_eUICC_V2 +{ + // Implements an API call that retrieves Login Credentials etc. + public class EuiccLocalizationApiHandler : ApiHandler + { + // Api Action + public ServiceRequestV1 localize(string eUICCid, string localeId, string localizationTableId) + { + // Check if simulated environment or real API + if (ApiHandler.simulatedApiCalls) + { + // Mock code: save locale setting + var locales = new EuiccLocalesApiHandler().getLocales(localizationTableId); + var localeName = locales.FirstOrDefault(l => l.Id == localeId)?.Name ?? string.Empty; + EuiccApiHandler._localeBinds[eUICCid] = localeName; + + // Simulated API call + return new ServiceRequestV1() + { + CompanyId = "97000002", + CompanyName = "Grundfos", + CreatedBy = "user@grundfos.com", + LastUpdated = new Instant() { Nano = 779000000, EpochSecond = 1480599693 }, + ServiceRequestId = "REQ0001", + ServiceRequestState = "In progress", + ServiceRequestType = string.Empty, + Size = 0, + TimeCreated = new Instant() { Nano = 779000000, EpochSecond = 1480599693 } + }; + } + else + { + // Real API call + + // Prepare the API request + RestRequest request = new RestRequest("/euiccs/{id}/localization", Method.POST); + request.AddUrlSegment("id", eUICCid); + request.AddQueryParameter("localeId", localeId); + request.AddQueryParameter("localizationTableId", localizationTableId); + request.AddQueryParameter("companyId", ApiHandler.companyId); + request.AddHeader("Accept", "application/vnd.dcp-v1+json"); + + // Call the API and take care of the response + if (this.send(request)) + // Successful API request + return JsonConvert.DeserializeObject(response.Content); + else + // API call failed, error info found in the Error object + return null; + } + } + } +} diff --git a/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/ApiHandlers/LoginApiHandler.cs b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/ApiHandlers/LoginApiHandler.cs new file mode 100644 index 00000000..b2c76a9c --- /dev/null +++ b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/ApiHandlers/LoginApiHandler.cs @@ -0,0 +1,166 @@ +using System; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using RestSharp; +using System.Threading.Tasks; +using System.Threading; + +namespace DCP_eUICC_V2 +{ + // Implements an API call + public class LoginApiHandler : ApiHandler + { + // Some constants for the keepAliveTask + const int DefaultDelay = 1; // Seconds + const int MaxDelay = 5 * 60; // Seconds + const int TokenExpirationTimeMargin = 5; // Seconds + const int TokenReissueTimeMargin = TokenExpirationTimeMargin + 5; // Seconds + + // Constructors + public LoginApiHandler(string baseaddress, string companyid, string username, string password, bool simulateApi) : base(baseaddress, companyid, username, password, simulateApi) { } + + // This task tries to login to API and then regularly keep it alive + private Task KeepAliveTask() + { + // Set a start delay value + int backoffdelay = 1; + + // Loop forever, i.e. until calling process goes out of scope + while (true) + { + // Try to login + if (!this.login()) + { // Login failed, back-off and wait and then try again + + Console.WriteLine("Loging failed!"); + + // Calculate a delay value + if (backoffdelay < MaxDelay) + backoffdelay *= 2; + + // Sleep (milliseconds) + Thread.Sleep(backoffdelay * 1000); + } + else + { // Login succeeded + + + Console.WriteLine("Loging Succeded!"); + + // Reset the backoff delay value + backoffdelay = 1; + + // Wait almost the timeout value + long myExpirationtime = 0; + if (ApiHandler.LoginCredentials.ExpirationTime != null) + { + // Calcualte a value to use + myExpirationtime = (long)ApiHandler.LoginCredentials.ExpirationTime - (1000 * TokenExpirationTimeMargin); + + // Handle the case that 'Sleep' only takes 'int' and not long + while (myExpirationtime > 0) + { + // Check for valid 'int' value for the sleep function + if (myExpirationtime > int.MaxValue) + { + // Sleep (milliseconds) + Thread.Sleep(int.MaxValue); + + // Subtract the delay value + myExpirationtime -= int.MaxValue; + } + else + { + // Sleep (milliseconds) + Thread.Sleep((int)myExpirationtime); + + // We are done - Reset the delay value + myExpirationtime = 0; + } + } + } + } + } + } + + // Checks if we are logged, in otherwise tries to login + public bool isLoggedIn() + { + // Keep track of the time now + DateTime timestampNow = DateTime.UtcNow; + + // Check if we need to login, if so try to login + if (timestampNow > ApiHandler.loginTokenExpirationTime.AddSeconds(-TokenExpirationTimeMargin)) + return this.login(); + + // Check if we need to reisse a new token + if (timestampNow > ApiHandler.loginTokenExpirationTime.AddSeconds(-TokenReissueTimeMargin)) + return this.tokenReissue(); + + // Token is still valid, return + return true; + } + + // Api Action + private bool login() + { + // Prepare the API request + RestRequest request = new RestRequest("/login", Method.POST); + request.RequestFormat = DataFormat.Json; + request.AddBody(new LoginSendBody() { email = ApiHandler.userName, password = ApiHandler.passWord }); + request.AddHeader("Accept", "application/vnd.dcp-v1+json"); + + // Call the API and take care of the response + if (this.sendWithoutLogin(request)) + { + // Successful API request + ApiHandler.LoginCredentials = JsonConvert.DeserializeObject(response.Content); + ApiHandler.loginTokenExpirationTime = DateTime.UtcNow.AddMilliseconds((long)ApiHandler.LoginCredentials.ExpirationTime); + return true; + } + else + // API call failed, error info found in the Error object + return false; + } + + // Api Action + private bool tokenReissue() + { + // Prepare the API request + RestRequest request = new RestRequest("/token-reissue", Method.POST); + request.AddHeader("Accept", "application/vnd.dcp-v1+json"); + //request.RequestFormat = DataFormat.Json; + //request.AddBody(new LoginSendBody()); + + // Call the API and take care of the response + if (this.sendWithoutLogin(request)) + { + // Successful API request + ApiHandler.LoginCredentials = JsonConvert.DeserializeObject(response.Content); + ApiHandler.loginTokenExpirationTime = DateTime.UtcNow.AddMilliseconds((long)ApiHandler.LoginCredentials.ExpirationTime); + return true; + } + else + // API call failed, error info found in the Error object + return false; + } + + // Class that models a POST BODY for login + private class LoginSendBody + { + // Properties + public string email; + public string password; + + // Constructor + public LoginSendBody() + { + this.email = ApiHandler.userName; + this.password = ApiHandler.passWord; + } + } + } +} diff --git a/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/ApiHandlers/ServiceRequestApiHandler.cs b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/ApiHandlers/ServiceRequestApiHandler.cs new file mode 100644 index 00000000..db12b097 --- /dev/null +++ b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/ApiHandlers/ServiceRequestApiHandler.cs @@ -0,0 +1,31 @@ +using System; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using RestSharp; + +namespace DCP_eUICC_V2 +{ + // Implements an API call that retrieves Login Credentials etc. + public class ServiceRequestApiHandler : ApiHandler + { + // Api Action + public ServiceRequestV1 get(string servicerequestid) + { + // Prepare the API request + RestRequest request = new RestRequest("/serviceRequests/{id}", Method.GET); + request.AddUrlSegment("id", servicerequestid); + request.AddHeader("Accept", "application/vnd.dcp-v1+json"); + + // Call the API and take care of the response + if (this.send(request)) + // Successful API request + return JsonConvert.DeserializeObject(this.response.Content); + else + // API call failed, error info found in the Error object + return null; + } + } +} diff --git a/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/ApiHandlers/SubscriptionsApiHandler.cs b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/ApiHandlers/SubscriptionsApiHandler.cs new file mode 100644 index 00000000..f2531c53 --- /dev/null +++ b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/ApiHandlers/SubscriptionsApiHandler.cs @@ -0,0 +1,69 @@ +using System; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using RestSharp; + +namespace DCP_eUICC_V2 +{ + // Implements an API call that retrieves Login Credentials etc. + public class SubscriptionApiHandler : ApiHandler + { + // Api Action + public SubscriptionV1 get(string imsi) + { + // Check if simulated environment or real API + if (ApiHandler.simulatedApiCalls) + // Simulated API call + return new SubscriptionV1() + { + Imsi = "100973000012678", + State = "ACTIVE", + OperatorId = "97000001", + OperatorName = "Telia", + Msisdn = "200973000012678", + Iccid = "99987100973000012678", + LocaleList = null, + Label = null, + CompanyId = "97000002", + CompanyName = "Grundfos", + Pin1 = "1234", + Pin2 = "4321", + Puk1 = "12345678", + Puk2 = "87654321", + Region = null, + PbrExitDate = null, + InstallationDate = new Instant() { Nano = 779000000, EpochSecond = 1480599693 }, + Specification = "Specification 01", + SpecificationType = "PROFILE_SPECIFICATION", + ArpAssignMentDate = null, + ArpName = null, + EuiccId = "999870A0B0C0D0E0F100973000012678" + }; + else + { + // Real API call + + + + + + + // Prepare the API request + RestRequest request = new RestRequest("/subscriptions/{id}", Method.GET); + request.AddUrlSegment("id", imsi); + request.AddHeader("Accept", "application/vnd.dcp-v1+json"); + + // Call the API and take care of the response + if (this.send(request)) + // Successful API request + return JsonConvert.DeserializeObject(this.response.Content); + else + // API call failed, error info found in the Error object + return null; + } + } + } +} diff --git a/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/ModelExtensions/SubscriptionExtension.cs b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/ModelExtensions/SubscriptionExtension.cs new file mode 100644 index 00000000..9070fa1e --- /dev/null +++ b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/ModelExtensions/SubscriptionExtension.cs @@ -0,0 +1,21 @@ +using System; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace DCP_eUICC_V2 +{ + // Model Class Extensions + public partial class SubscriptionV1 + { + public bool isEuicc() + { + if (ApiHandler.simulatedApiCalls) + return true; + else + return (this.EuiccId != null); + } + } +} diff --git a/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/ModelExtensions/SubscriptionV1.cs b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/ModelExtensions/SubscriptionV1.cs new file mode 100644 index 00000000..b7804a59 --- /dev/null +++ b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/ModelExtensions/SubscriptionV1.cs @@ -0,0 +1,217 @@ +using System; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace DCP_eUICC_V2 +{ + + /// + /// Model for subscription + /// + [DataContract] + //public class SubscriptionV1 { + public partial class SubscriptionV1 + { + /// + /// Gets or Sets Imsi + /// + [DataMember(Name = "imsi", EmitDefaultValue = false)] + [JsonProperty(PropertyName = "imsi")] + public string Imsi { get; set; } + + /// + /// Gets or Sets State + /// + [DataMember(Name = "state", EmitDefaultValue = false)] + [JsonProperty(PropertyName = "state")] + public string State { get; set; } + + /// + /// Gets or Sets OperatorId + /// + [DataMember(Name = "operatorId", EmitDefaultValue = false)] + [JsonProperty(PropertyName = "operatorId")] + public string OperatorId { get; set; } + + /// + /// Gets or Sets OperatorName + /// + [DataMember(Name = "operatorName", EmitDefaultValue = false)] + [JsonProperty(PropertyName = "operatorName")] + public string OperatorName { get; set; } + + /// + /// Gets or Sets Msisdn + /// + [DataMember(Name = "msisdn", EmitDefaultValue = false)] + [JsonProperty(PropertyName = "msisdn")] + public string Msisdn { get; set; } + + /// + /// Gets or Sets Iccid + /// + [DataMember(Name = "iccid", EmitDefaultValue = false)] + [JsonProperty(PropertyName = "iccid")] + public string Iccid { get; set; } + + /// + /// Gets or Sets LocaleList + /// + [DataMember(Name = "localeList", EmitDefaultValue = false)] + [JsonProperty(PropertyName = "localeList")] + public List LocaleList { get; set; } + + /// + /// Gets or Sets Label + /// + [DataMember(Name = "label", EmitDefaultValue = false)] + [JsonProperty(PropertyName = "label")] + public string Label { get; set; } + + /// + /// Gets or Sets CompanyId + /// + [DataMember(Name = "companyId", EmitDefaultValue = false)] + [JsonProperty(PropertyName = "companyId")] + public string CompanyId { get; set; } + + /// + /// Gets or Sets CompanyName + /// + [DataMember(Name = "companyName", EmitDefaultValue = false)] + [JsonProperty(PropertyName = "companyName")] + public string CompanyName { get; set; } + + /// + /// Gets or Sets Pin1 + /// + [DataMember(Name = "pin1", EmitDefaultValue = false)] + [JsonProperty(PropertyName = "pin1")] + public string Pin1 { get; set; } + + /// + /// Gets or Sets Pin2 + /// + [DataMember(Name = "pin2", EmitDefaultValue = false)] + [JsonProperty(PropertyName = "pin2")] + public string Pin2 { get; set; } + + /// + /// Gets or Sets Puk1 + /// + [DataMember(Name = "puk1", EmitDefaultValue = false)] + [JsonProperty(PropertyName = "puk1")] + public string Puk1 { get; set; } + + /// + /// Gets or Sets Puk2 + /// + [DataMember(Name = "puk2", EmitDefaultValue = false)] + [JsonProperty(PropertyName = "puk2")] + public string Puk2 { get; set; } + + /// + /// Gets or Sets Region + /// + [DataMember(Name = "region", EmitDefaultValue = false)] + [JsonProperty(PropertyName = "region")] + public string Region { get; set; } + + /// + /// Gets or Sets PbrExitDate + /// + [DataMember(Name = "pbrExitDate", EmitDefaultValue = false)] + [JsonProperty(PropertyName = "pbrExitDate")] + public Instant PbrExitDate { get; set; } + + /// + /// Gets or Sets InstallationDate + /// + [DataMember(Name = "installationDate", EmitDefaultValue = false)] + [JsonProperty(PropertyName = "installationDate")] + public Instant InstallationDate { get; set; } + + /// + /// Gets or Sets Specification + /// + [DataMember(Name = "specification", EmitDefaultValue = false)] + [JsonProperty(PropertyName = "specification")] + public string Specification { get; set; } + + /// + /// Gets or Sets SpecificationType + /// + [DataMember(Name = "specificationType", EmitDefaultValue = false)] + [JsonProperty(PropertyName = "specificationType")] + public string SpecificationType { get; set; } + + /// + /// Gets or Sets ArpAssignMentDate + /// + [DataMember(Name = "arpAssignMentDate", EmitDefaultValue = false)] + [JsonProperty(PropertyName = "arpAssignMentDate")] + public Instant ArpAssignMentDate { get; set; } + + /// + /// Gets or Sets ArpName + /// + [DataMember(Name = "arpName", EmitDefaultValue = false)] + [JsonProperty(PropertyName = "arpName")] + public string ArpName { get; set; } + + /// + /// Gets or Sets EuiccId + /// + [DataMember(Name = "euiccId", EmitDefaultValue = false)] + [JsonProperty(PropertyName = "euiccId")] + public string EuiccId { get; set; } + + + /// + /// Get the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class SubscriptionV1 {\n"); + sb.Append(" Imsi: ").Append(Imsi).Append("\n"); + sb.Append(" State: ").Append(State).Append("\n"); + sb.Append(" OperatorId: ").Append(OperatorId).Append("\n"); + sb.Append(" OperatorName: ").Append(OperatorName).Append("\n"); + sb.Append(" Msisdn: ").Append(Msisdn).Append("\n"); + sb.Append(" Iccid: ").Append(Iccid).Append("\n"); + sb.Append(" LocaleList: ").Append(LocaleList).Append("\n"); + sb.Append(" Label: ").Append(Label).Append("\n"); + sb.Append(" CompanyId: ").Append(CompanyId).Append("\n"); + sb.Append(" CompanyName: ").Append(CompanyName).Append("\n"); + sb.Append(" Pin1: ").Append(Pin1).Append("\n"); + sb.Append(" Pin2: ").Append(Pin2).Append("\n"); + sb.Append(" Puk1: ").Append(Puk1).Append("\n"); + sb.Append(" Puk2: ").Append(Puk2).Append("\n"); + sb.Append(" Region: ").Append(Region).Append("\n"); + sb.Append(" PbrExitDate: ").Append(PbrExitDate).Append("\n"); + sb.Append(" InstallationDate: ").Append(InstallationDate).Append("\n"); + sb.Append(" Specification: ").Append(Specification).Append("\n"); + sb.Append(" SpecificationType: ").Append(SpecificationType).Append("\n"); + sb.Append(" ArpAssignMentDate: ").Append(ArpAssignMentDate).Append("\n"); + sb.Append(" ArpName: ").Append(ArpName).Append("\n"); + sb.Append(" EuiccId: ").Append(EuiccId).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Get the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + } +} diff --git a/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/CompanyV1.cs b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/CompanyV1.cs new file mode 100644 index 00000000..6f7dac54 --- /dev/null +++ b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/CompanyV1.cs @@ -0,0 +1,52 @@ +using System; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace DCP_eUICC_V2 { + + /// + /// Company model + /// + [DataContract] + public class CompanyV1 { + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or Sets Name + /// + [DataMember(Name="name", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + + /// + /// Get the string presentation of the object + /// + /// String presentation of the object + public override string ToString() { + var sb = new StringBuilder(); + sb.Append("class CompanyV1 {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Get the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + +} +} diff --git a/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/CredentialsV1.cs b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/CredentialsV1.cs new file mode 100644 index 00000000..1ad94ff0 --- /dev/null +++ b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/CredentialsV1.cs @@ -0,0 +1,54 @@ +using System; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace DCP_eUICC_V2 { + + /// + /// Login request model + /// + [DataContract] + public class CredentialsV1 { + /// + /// User email + /// + /// User email + [DataMember(Name="email", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "email")] + public string Email { get; set; } + + /// + /// User password + /// + /// User password + [DataMember(Name="password", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "password")] + public string Password { get; set; } + + + /// + /// Get the string presentation of the object + /// + /// String presentation of the object + public override string ToString() { + var sb = new StringBuilder(); + sb.Append("class CredentialsV1 {\n"); + sb.Append(" Email: ").Append(Email).Append("\n"); + sb.Append(" Password: ").Append(Password).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Get the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + +} +} diff --git a/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/Error.cs b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/Error.cs new file mode 100644 index 00000000..ddd54879 --- /dev/null +++ b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/Error.cs @@ -0,0 +1,63 @@ +using System; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace DCP_eUICC_V2 { + + /// + /// Error response model + /// + [DataContract] + public class Error { + /// + /// Error code + /// + /// Error code + [DataMember(Name="code", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "code")] + public int? Code { get; set; } + + /// + /// Response HTTP status + /// + /// Response HTTP status + [DataMember(Name="httpStatus", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "httpStatus")] + public int? HttpStatus { get; set; } + + /// + /// Error message + /// + /// Error message + [DataMember(Name="message", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } + + + /// + /// Get the string presentation of the object + /// + /// String presentation of the object + public override string ToString() { + var sb = new StringBuilder(); + sb.Append("class Error {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" HttpStatus: ").Append(HttpStatus).Append("\n"); + sb.Append(" Message: ").Append(Message).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Get the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + +} +} diff --git a/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/EuiccAgreementListV1.cs b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/EuiccAgreementListV1.cs new file mode 100644 index 00000000..f7280a59 --- /dev/null +++ b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/EuiccAgreementListV1.cs @@ -0,0 +1,52 @@ +using System; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace DCP_eUICC_V2 { + + /// + /// Euicc agreement list response model + /// + [DataContract] + public class EuiccAgreementListV1 { + /// + /// Gets or Sets EuiccAgreements + /// + [DataMember(Name="euiccAgreements", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "euiccAgreements")] + public List EuiccAgreements { get; set; } + + /// + /// Gets or Sets ServiceContracts + /// + [DataMember(Name="serviceContracts", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "serviceContracts")] + public List ServiceContracts { get; set; } + + + /// + /// Get the string presentation of the object + /// + /// String presentation of the object + public override string ToString() { + var sb = new StringBuilder(); + sb.Append("class EuiccAgreementListV1 {\n"); + sb.Append(" EuiccAgreements: ").Append(EuiccAgreements).Append("\n"); + sb.Append(" ServiceContracts: ").Append(ServiceContracts).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Get the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + +} +} diff --git a/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/EuiccAgreementV1.cs b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/EuiccAgreementV1.cs new file mode 100644 index 00000000..ed8b3ef3 --- /dev/null +++ b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/EuiccAgreementV1.cs @@ -0,0 +1,76 @@ +using System; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace DCP_eUICC_V2 { + + /// + /// EuiccAgreement response model + /// + [DataContract] + public class EuiccAgreementV1 { + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or Sets Name + /// + [DataMember(Name="name", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or Sets FormSpecification + /// + [DataMember(Name="formSpecification", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "formSpecification")] + public FormSpecificationV1 FormSpecification { get; set; } + + /// + /// Gets or Sets LeadOperator + /// + [DataMember(Name="leadOperator", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "leadOperator")] + public string LeadOperator { get; set; } + + /// + /// Gets or Sets ProfileSpecifications + /// + [DataMember(Name="profileSpecifications", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "profileSpecifications")] + public List ProfileSpecifications { get; set; } + + + /// + /// Get the string presentation of the object + /// + /// String presentation of the object + public override string ToString() { + var sb = new StringBuilder(); + sb.Append("class EuiccAgreementV1 {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append(" FormSpecification: ").Append(FormSpecification).Append("\n"); + sb.Append(" LeadOperator: ").Append(LeadOperator).Append("\n"); + sb.Append(" ProfileSpecifications: ").Append(ProfileSpecifications).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Get the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + +} +} diff --git a/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/EuiccLocaleV1.cs b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/EuiccLocaleV1.cs new file mode 100644 index 00000000..f4daa23a --- /dev/null +++ b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/EuiccLocaleV1.cs @@ -0,0 +1,52 @@ +using System; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace DCP_eUICC_V2 { + + /// + /// Euicc locale response model + /// + [DataContract] + public class EuiccLocaleV1 { + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or Sets Name + /// + [DataMember(Name="name", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + + /// + /// Get the string presentation of the object + /// + /// String presentation of the object + public override string ToString() { + var sb = new StringBuilder(); + sb.Append("class EuiccLocaleV1 {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Get the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + +} +} diff --git a/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/EuiccSubscriptionV1.cs b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/EuiccSubscriptionV1.cs new file mode 100644 index 00000000..bfbbec74 --- /dev/null +++ b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/EuiccSubscriptionV1.cs @@ -0,0 +1,92 @@ +using System; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace DCP_eUICC_V2 { + + /// + /// Model for minimal subscription information when fetching euicc information + /// + [DataContract] + public class EuiccSubscriptionV1 { + /// + /// Gets or Sets Imsi + /// + [DataMember(Name="imsi", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "imsi")] + public string Imsi { get; set; } + + /// + /// Gets or Sets State + /// + [DataMember(Name="state", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "state")] + public string State { get; set; } + + /// + /// Gets or Sets OperatorId + /// + [DataMember(Name="operatorId", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "operatorId")] + public string OperatorId { get; set; } + + /// + /// Gets or Sets OperatorName + /// + [DataMember(Name="operatorName", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "operatorName")] + public string OperatorName { get; set; } + + /// + /// Gets or Sets Msisdn + /// + [DataMember(Name="msisdn", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "msisdn")] + public string Msisdn { get; set; } + + /// + /// Gets or Sets Iccid + /// + [DataMember(Name="iccid", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "iccid")] + public string Iccid { get; set; } + + /// + /// Gets or Sets LocaleList + /// + [DataMember(Name="localeList", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "localeList")] + public List LocaleList { get; set; } + + + /// + /// Get the string presentation of the object + /// + /// String presentation of the object + public override string ToString() { + var sb = new StringBuilder(); + sb.Append("class EuiccSubscriptionV1 {\n"); + sb.Append(" Imsi: ").Append(Imsi).Append("\n"); + sb.Append(" State: ").Append(State).Append("\n"); + sb.Append(" OperatorId: ").Append(OperatorId).Append("\n"); + sb.Append(" OperatorName: ").Append(OperatorName).Append("\n"); + sb.Append(" Msisdn: ").Append(Msisdn).Append("\n"); + sb.Append(" Iccid: ").Append(Iccid).Append("\n"); + sb.Append(" LocaleList: ").Append(LocaleList).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Get the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + +} +} diff --git a/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/EuiccV1.cs b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/EuiccV1.cs new file mode 100644 index 00000000..9b49fa1b --- /dev/null +++ b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/EuiccV1.cs @@ -0,0 +1,124 @@ +using System; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace DCP_eUICC_V2 { + + /// + /// Euicc response model + /// + [DataContract] + public class EuiccV1 { + /// + /// Gets or Sets Subscriptions + /// + [DataMember(Name="subscriptions", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "subscriptions")] + public List Subscriptions { get; set; } + + /// + /// Gets or Sets EuiccId + /// + [DataMember(Name="euiccId", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "euiccId")] + public string EuiccId { get; set; } + + /// + /// Gets or Sets CompanyId + /// + [DataMember(Name="companyId", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "companyId")] + public string CompanyId { get; set; } + + /// + /// Gets or Sets CompanyName + /// + [DataMember(Name="companyName", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "companyName")] + public string CompanyName { get; set; } + + /// + /// Gets or Sets State + /// + [DataMember(Name="state", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "state")] + public string State { get; set; } + + /// + /// Gets or Sets Label + /// + [DataMember(Name="label", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "label")] + public string Label { get; set; } + + /// + /// Gets or Sets LocaleName + /// + [DataMember(Name="localeName", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "localeName")] + public string LocaleName { get; set; } + + /// + /// Gets or Sets BootstrapIcc + /// + [DataMember(Name="bootstrapIcc", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "bootstrapIcc")] + public string BootstrapIcc { get; set; } + + /// + /// Gets or Sets EnabledIcc + /// + [DataMember(Name="enabledIcc", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "enabledIcc")] + public string EnabledIcc { get; set; } + + /// + /// Gets or Sets BootstrapCompanyId + /// + [DataMember(Name="bootstrapCompanyId", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "bootstrapCompanyId")] + public string BootstrapCompanyId { get; set; } + + /// + /// Gets or Sets LocalizationTableId + /// + [DataMember(Name="localizationTableId", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "localizationTableId")] + public long? LocalizationTableId { get; set; } + + + /// + /// Get the string presentation of the object + /// + /// String presentation of the object + public override string ToString() { + var sb = new StringBuilder(); + sb.Append("class EuiccV1 {\n"); + sb.Append(" Subscriptions: ").Append(Subscriptions).Append("\n"); + sb.Append(" EuiccId: ").Append(EuiccId).Append("\n"); + sb.Append(" CompanyId: ").Append(CompanyId).Append("\n"); + sb.Append(" CompanyName: ").Append(CompanyName).Append("\n"); + sb.Append(" State: ").Append(State).Append("\n"); + sb.Append(" Label: ").Append(Label).Append("\n"); + sb.Append(" LocaleName: ").Append(LocaleName).Append("\n"); + sb.Append(" BootstrapIcc: ").Append(BootstrapIcc).Append("\n"); + sb.Append(" EnabledIcc: ").Append(EnabledIcc).Append("\n"); + sb.Append(" BootstrapCompanyId: ").Append(BootstrapCompanyId).Append("\n"); + sb.Append(" LocalizationTableId: ").Append(LocalizationTableId).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Get the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + +} +} diff --git a/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/FormSpecificationV1.cs b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/FormSpecificationV1.cs new file mode 100644 index 00000000..114c1e47 --- /dev/null +++ b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/FormSpecificationV1.cs @@ -0,0 +1,76 @@ +using System; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace DCP_eUICC_V2 { + + /// + /// FormSpecification response model + /// + [DataContract] + public class FormSpecificationV1 { + /// + /// Gets or Sets Description + /// + [DataMember(Name="description", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "description")] + public string Description { get; set; } + + /// + /// Gets or Sets EarliestDeliveryDate + /// + [DataMember(Name="earliestDeliveryDate", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "earliestDeliveryDate")] + public int? EarliestDeliveryDate { get; set; } + + /// + /// Gets or Sets LowOrderThreshold + /// + [DataMember(Name="lowOrderThreshold", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "lowOrderThreshold")] + public int? LowOrderThreshold { get; set; } + + /// + /// Gets or Sets MinimumOrderVolume + /// + [DataMember(Name="minimumOrderVolume", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "minimumOrderVolume")] + public int? MinimumOrderVolume { get; set; } + + /// + /// Gets or Sets OrderIncrement + /// + [DataMember(Name="orderIncrement", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "orderIncrement")] + public int? OrderIncrement { get; set; } + + + /// + /// Get the string presentation of the object + /// + /// String presentation of the object + public override string ToString() { + var sb = new StringBuilder(); + sb.Append("class FormSpecificationV1 {\n"); + sb.Append(" Description: ").Append(Description).Append("\n"); + sb.Append(" EarliestDeliveryDate: ").Append(EarliestDeliveryDate).Append("\n"); + sb.Append(" LowOrderThreshold: ").Append(LowOrderThreshold).Append("\n"); + sb.Append(" MinimumOrderVolume: ").Append(MinimumOrderVolume).Append("\n"); + sb.Append(" OrderIncrement: ").Append(OrderIncrement).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Get the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + +} +} diff --git a/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/Instant.cs b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/Instant.cs new file mode 100644 index 00000000..a392a7e0 --- /dev/null +++ b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/Instant.cs @@ -0,0 +1,52 @@ +using System; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace DCP_eUICC_V2 { + + /// + /// + /// + [DataContract] + public class Instant { + /// + /// Gets or Sets Nano + /// + [DataMember(Name="nano", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "nano")] + public int? Nano { get; set; } + + /// + /// Gets or Sets EpochSecond + /// + [DataMember(Name="epochSecond", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "epochSecond")] + public long? EpochSecond { get; set; } + + + /// + /// Get the string presentation of the object + /// + /// String presentation of the object + public override string ToString() { + var sb = new StringBuilder(); + sb.Append("class Instant {\n"); + sb.Append(" Nano: ").Append(Nano).Append("\n"); + sb.Append(" EpochSecond: ").Append(EpochSecond).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Get the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + +} +} diff --git a/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/LabelUpdateV1.cs b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/LabelUpdateV1.cs new file mode 100644 index 00000000..0b44849f --- /dev/null +++ b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/LabelUpdateV1.cs @@ -0,0 +1,63 @@ +using System; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace DCP_eUICC_V2 { + + /// + /// eUICC label update request model + /// + [DataContract] + public class LabelUpdateV1 { + /// + /// Company id of the requester + /// + /// Company id of the requester + [DataMember(Name="companyId", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "companyId")] + public string CompanyId { get; set; } + + /// + /// Updated label or omitted for clearing the label + /// + /// Updated label or omitted for clearing the label + [DataMember(Name="label", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "label")] + public string Label { get; set; } + + /// + /// One or more 32 hexadecimal digit eUICC IDs + /// + /// One or more 32 hexadecimal digit eUICC IDs + [DataMember(Name="euiccIds", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "euiccIds")] + public List EuiccIds { get; set; } + + + /// + /// Get the string presentation of the object + /// + /// String presentation of the object + public override string ToString() { + var sb = new StringBuilder(); + sb.Append("class LabelUpdateV1 {\n"); + sb.Append(" CompanyId: ").Append(CompanyId).Append("\n"); + sb.Append(" Label: ").Append(Label).Append("\n"); + sb.Append(" EuiccIds: ").Append(EuiccIds).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Get the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + +} +} diff --git a/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/LoginV1.cs b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/LoginV1.cs new file mode 100644 index 00000000..1f2c9217 --- /dev/null +++ b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/LoginV1.cs @@ -0,0 +1,68 @@ +using System; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace DCP_eUICC_V2 { + + /// + /// Login response model + /// + [DataContract] + public class LoginV1 { + /// + /// Gets or Sets Message + /// + [DataMember(Name="message", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } + + /// + /// Gets or Sets ExpirationTime + /// + [DataMember(Name="expirationTime", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "expirationTime")] + public long? ExpirationTime { get; set; } + + /// + /// Gets or Sets UserId + /// + [DataMember(Name="userId", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "userId")] + public string UserId { get; set; } + + /// + /// Gets or Sets Token + /// + [DataMember(Name="token", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "token")] + public string Token { get; set; } + + + /// + /// Get the string presentation of the object + /// + /// String presentation of the object + public override string ToString() { + var sb = new StringBuilder(); + sb.Append("class LoginV1 {\n"); + sb.Append(" Message: ").Append(Message).Append("\n"); + sb.Append(" ExpirationTime: ").Append(ExpirationTime).Append("\n"); + sb.Append(" UserId: ").Append(UserId).Append("\n"); + sb.Append(" Token: ").Append(Token).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Get the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + +} +} diff --git a/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/ProfileSpecification.cs b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/ProfileSpecification.cs new file mode 100644 index 00000000..0cfda414 --- /dev/null +++ b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/ProfileSpecification.cs @@ -0,0 +1,52 @@ +using System; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace DCP_eUICC_V2 { + + /// + /// ProfileSpecification response model + /// + [DataContract] + public class ProfileSpecification { + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or Sets Description + /// + [DataMember(Name="description", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "description")] + public string Description { get; set; } + + + /// + /// Get the string presentation of the object + /// + /// String presentation of the object + public override string ToString() { + var sb = new StringBuilder(); + sb.Append("class ProfileSpecification {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Description: ").Append(Description).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Get the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + +} +} diff --git a/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/ServiceContractV1.cs b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/ServiceContractV1.cs new file mode 100644 index 00000000..d981567f --- /dev/null +++ b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/ServiceContractV1.cs @@ -0,0 +1,68 @@ +using System; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace DCP_eUICC_V2 { + + /// + /// ServiceContract response model + /// + [DataContract] + public class ServiceContractV1 { + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or Sets Description + /// + [DataMember(Name="description", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "description")] + public string Description { get; set; } + + /// + /// Gets or Sets Name + /// + [DataMember(Name="name", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or Sets SubscriptionPackages + /// + [DataMember(Name="subscriptionPackages", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "subscriptionPackages")] + public List SubscriptionPackages { get; set; } + + + /// + /// Get the string presentation of the object + /// + /// String presentation of the object + public override string ToString() { + var sb = new StringBuilder(); + sb.Append("class ServiceContractV1 {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Description: ").Append(Description).Append("\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append(" SubscriptionPackages: ").Append(SubscriptionPackages).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Get the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + +} +} diff --git a/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/ServiceRequestResponseV1.cs b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/ServiceRequestResponseV1.cs new file mode 100644 index 00000000..5b841570 --- /dev/null +++ b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/ServiceRequestResponseV1.cs @@ -0,0 +1,61 @@ +using System; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace DCP_eUICC_V2 { + + /// + /// Service request response model + /// + [DataContract] + public class ServiceRequestResponseV1 { + /// + /// Gets or Sets ServiceRequestId + /// + [DataMember(Name="serviceRequestId", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "serviceRequestId")] + public string ServiceRequestId { get; set; } + + /// + /// Gets or Sets Success + /// + [DataMember(Name="success", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "success")] + public bool? Success { get; set; } + + /// + /// Error message in case of unsuccesfull service request + /// + /// Error message in case of unsuccesfull service request + [DataMember(Name="errorMessage", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "errorMessage")] + public string ErrorMessage { get; set; } + + + /// + /// Get the string presentation of the object + /// + /// String presentation of the object + public override string ToString() { + var sb = new StringBuilder(); + sb.Append("class ServiceRequestResponseV1 {\n"); + sb.Append(" ServiceRequestId: ").Append(ServiceRequestId).Append("\n"); + sb.Append(" Success: ").Append(Success).Append("\n"); + sb.Append(" ErrorMessage: ").Append(ErrorMessage).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Get the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + +} +} diff --git a/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/ServiceRequestV1.cs b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/ServiceRequestV1.cs new file mode 100644 index 00000000..65dbc9ab --- /dev/null +++ b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/ServiceRequestV1.cs @@ -0,0 +1,108 @@ +using System; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace DCP_eUICC_V2 { + + /// + /// ServiceRequest response model + /// + [DataContract] + public class ServiceRequestV1 { + /// + /// Gets or Sets ServiceRequestId + /// + [DataMember(Name="serviceRequestId", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "serviceRequestId")] + public string ServiceRequestId { get; set; } + + /// + /// Gets or Sets ServiceRequestType + /// + [DataMember(Name="serviceRequestType", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "serviceRequestType")] + public string ServiceRequestType { get; set; } + + /// + /// Gets or Sets ServiceRequestState + /// + [DataMember(Name="serviceRequestState", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "serviceRequestState")] + public string ServiceRequestState { get; set; } + + /// + /// Gets or Sets CreatedBy + /// + [DataMember(Name="createdBy", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "createdBy")] + public string CreatedBy { get; set; } + + /// + /// Gets or Sets CompanyId + /// + [DataMember(Name="companyId", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "companyId")] + public string CompanyId { get; set; } + + /// + /// Gets or Sets CompanyName + /// + [DataMember(Name="companyName", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "companyName")] + public string CompanyName { get; set; } + + /// + /// Gets or Sets TimeCreated + /// + [DataMember(Name="timeCreated", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "timeCreated")] + public Instant TimeCreated { get; set; } + + /// + /// Gets or Sets LastUpdated + /// + [DataMember(Name="lastUpdated", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "lastUpdated")] + public Instant LastUpdated { get; set; } + + /// + /// Gets or Sets Size + /// + [DataMember(Name="size", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "size")] + public int? Size { get; set; } + + + /// + /// Get the string presentation of the object + /// + /// String presentation of the object + public override string ToString() { + var sb = new StringBuilder(); + sb.Append("class ServiceRequestV1 {\n"); + sb.Append(" ServiceRequestId: ").Append(ServiceRequestId).Append("\n"); + sb.Append(" ServiceRequestType: ").Append(ServiceRequestType).Append("\n"); + sb.Append(" ServiceRequestState: ").Append(ServiceRequestState).Append("\n"); + sb.Append(" CreatedBy: ").Append(CreatedBy).Append("\n"); + sb.Append(" CompanyId: ").Append(CompanyId).Append("\n"); + sb.Append(" CompanyName: ").Append(CompanyName).Append("\n"); + sb.Append(" TimeCreated: ").Append(TimeCreated).Append("\n"); + sb.Append(" LastUpdated: ").Append(LastUpdated).Append("\n"); + sb.Append(" Size: ").Append(Size).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Get the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + +} +} diff --git a/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/SubscriptionPackageV1.cs b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/SubscriptionPackageV1.cs new file mode 100644 index 00000000..94589c7b --- /dev/null +++ b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/SubscriptionPackageV1.cs @@ -0,0 +1,60 @@ +using System; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace DCP_eUICC_V2 { + + /// + /// SubscriptionPackage response model + /// + [DataContract] + public class SubscriptionPackageV1 { + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or Sets Description + /// + [DataMember(Name="description", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "description")] + public string Description { get; set; } + + /// + /// Gets or Sets Name + /// + [DataMember(Name="name", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + + /// + /// Get the string presentation of the object + /// + /// String presentation of the object + public override string ToString() { + var sb = new StringBuilder(); + sb.Append("class SubscriptionPackageV1 {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Description: ").Append(Description).Append("\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Get the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + +} +} diff --git a/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/TokenReissueV1.cs b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/TokenReissueV1.cs new file mode 100644 index 00000000..998ae090 --- /dev/null +++ b/DeviceAdministration/CellularConnectivity/DCP_eUICC_V2/Models/TokenReissueV1.cs @@ -0,0 +1,68 @@ +using System; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace DCP_eUICC_V2 { + + /// + /// Token reissue response model + /// + [DataContract] + public class TokenReissueV1 { + /// + /// Gets or Sets Message + /// + [DataMember(Name="message", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } + + /// + /// Gets or Sets ExpirationTime + /// + [DataMember(Name="expirationTime", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "expirationTime")] + public long? ExpirationTime { get; set; } + + /// + /// Gets or Sets UserId + /// + [DataMember(Name="userId", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "userId")] + public string UserId { get; set; } + + /// + /// Gets or Sets Token + /// + [DataMember(Name="token", EmitDefaultValue=false)] + [JsonProperty(PropertyName = "token")] + public string Token { get; set; } + + + /// + /// Get the string presentation of the object + /// + /// String presentation of the object + public override string ToString() { + var sb = new StringBuilder(); + sb.Append("class TokenReissueV1 {\n"); + sb.Append(" Message: ").Append(Message).Append("\n"); + sb.Append(" ExpirationTime: ").Append(ExpirationTime).Append("\n"); + sb.Append(" UserId: ").Append(UserId).Append("\n"); + sb.Append(" Token: ").Append(Token).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Get the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + +} +} diff --git a/DeviceAdministration/CellularConnectivity/DeviceManagement.Infrastructure.Connectivity.csproj b/DeviceAdministration/CellularConnectivity/DeviceManagement.Infrastructure.Connectivity.csproj index c64530a1..6911dd8e 100644 --- a/DeviceAdministration/CellularConnectivity/DeviceManagement.Infrastructure.Connectivity.csproj +++ b/DeviceAdministration/CellularConnectivity/DeviceManagement.Infrastructure.Connectivity.csproj @@ -33,13 +33,44 @@ 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -477,6 +508,14 @@ + + ..\..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll + True + + + ..\..\packages\RestSharp.105.2.3\lib\net451\RestSharp.dll + True + diff --git a/DeviceAdministration/CellularConnectivity/Models/Other/LocalizationModel.cs b/DeviceAdministration/CellularConnectivity/Models/Other/LocalizationModel.cs new file mode 100644 index 00000000..50a3abb7 --- /dev/null +++ b/DeviceAdministration/CellularConnectivity/Models/Other/LocalizationModel.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace DeviceManagement.Infrustructure.Connectivity.Models.Other +{ + public class LocalizationModel + { + public string Context { get; set; } + public string CurrentLocale { get; set; } + public IEnumerable AvailableLocales { get; set; } + } +} diff --git a/DeviceAdministration/CellularConnectivity/Services/ExternalCellularService.cs b/DeviceAdministration/CellularConnectivity/Services/ExternalCellularService.cs index d62e9651..d0f9410f 100644 --- a/DeviceAdministration/CellularConnectivity/Services/ExternalCellularService.cs +++ b/DeviceAdministration/CellularConnectivity/Services/ExternalCellularService.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Threading.Tasks; using DeviceManagement.Infrustructure.Connectivity.Clients; using DeviceManagement.Infrustructure.Connectivity.Models.Constants; @@ -260,6 +259,72 @@ namespace DeviceManagement.Infrustructure.Connectivity.Services return isValid; } + /// + /// Get current locale name and available locale names + /// + /// ICCID + /// Available locale names + /// Current locale name + public string GetLocale(string iccid, out IEnumerable availableLocaleNames) + { + var registrationProvider = _credentialProvider.Provide().ApiRegistrationProvider; + + switch (registrationProvider) + { + case ApiRegistrationProviderTypes.Jasper: + throw new NotSupportedException(); + + case ApiRegistrationProviderTypes.Ericsson: + var client = new EricssonCellularClient(_credentialProvider); + return client.GetLocale(iccid, out availableLocaleNames); + + default: + throw new IndexOutOfRangeException($"Could not find a service for '{registrationProvider.ToString()}' provider"); + } + } + + /// + /// Set locale + /// + /// ICCID + /// Desired locale name + /// True if succeeded, otherwise false + public string SetLocale(string iccid, string localeName) + { + var registrationProvider = _credentialProvider.Provide().ApiRegistrationProvider; + + switch (registrationProvider) + { + case ApiRegistrationProviderTypes.Jasper: + throw new NotSupportedException(); + + case ApiRegistrationProviderTypes.Ericsson: + var client = new EricssonCellularClient(_credentialProvider); + return client.SetLocale(iccid, localeName); + + default: + throw new IndexOutOfRangeException($"Could not find a service for '{registrationProvider.ToString()}' provider"); + } + } + + public string GetLastSetLocaleServiceRequestState(string serviceRequestId) + { + var registrationProvider = _credentialProvider.Provide().ApiRegistrationProvider; + + switch (registrationProvider) + { + case ApiRegistrationProviderTypes.Jasper: + throw new NotSupportedException(); + + case ApiRegistrationProviderTypes.Ericsson: + var client = new EricssonCellularClient(_credentialProvider); + return client.GetLastSetLocaleServiceRequestState(serviceRequestId); + + default: + throw new IndexOutOfRangeException($"Could not find a service for '{registrationProvider.ToString()}' provider"); + } + } + private List getAvailableSimStates() { return new List() @@ -293,6 +358,5 @@ namespace DeviceManagement.Infrustructure.Connectivity.Services } }; } - } } diff --git a/DeviceAdministration/CellularConnectivity/Services/IExternalCellularService.cs b/DeviceAdministration/CellularConnectivity/Services/IExternalCellularService.cs index 51cb2a40..97b6391d 100644 --- a/DeviceAdministration/CellularConnectivity/Services/IExternalCellularService.cs +++ b/DeviceAdministration/CellularConnectivity/Services/IExternalCellularService.cs @@ -21,5 +21,8 @@ namespace DeviceManagement.Infrustructure.Connectivity.Services bool UpdateSubscriptionPackage(string iccid, string updatedPackage); bool ReconnectTerminal(string iccid); Task SendSms(string iccid, string msisdn, string smsText); + string GetLocale(string iccid, out IEnumerable availableLocaleNames); + string SetLocale(string iccid, string localeName); + string GetLastSetLocaleServiceRequestState(string serviceRequestId); } } \ No newline at end of file diff --git a/DeviceAdministration/CellularConnectivity/packages.config b/DeviceAdministration/CellularConnectivity/packages.config index 6b8deb9c..af8a8c69 100644 --- a/DeviceAdministration/CellularConnectivity/packages.config +++ b/DeviceAdministration/CellularConnectivity/packages.config @@ -1,3 +1,5 @@  + + \ No newline at end of file diff --git a/DeviceAdministration/Infrastructure/Repository/IIccidRepository.cs b/DeviceAdministration/Infrastructure/Repository/IIccidRepository.cs index 992d9089..cdd6be3d 100644 --- a/DeviceAdministration/Infrastructure/Repository/IIccidRepository.cs +++ b/DeviceAdministration/Infrastructure/Repository/IIccidRepository.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; using DeviceManagement.Infrustructure.Connectivity.Models.TerminalDevice; using Microsoft.Azure.Devices.Applications.RemoteMonitoring.Common.Models; @@ -15,5 +11,7 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr bool DeleteIccidTableEntity(IccidTableEntity iccidTableEntity); bool DeleteAllIccids(); IList GetIccids(); + string GetLastSetLocaleServiceRequestId(string iccid); + void SetLastSetLocaleServiceRequestId(string iccid, string serviceRequestId); } } diff --git a/DeviceAdministration/Infrastructure/Repository/IccidRepository.cs b/DeviceAdministration/Infrastructure/Repository/IccidRepository.cs index 60f38b03..b29028fc 100644 --- a/DeviceAdministration/Infrastructure/Repository/IccidRepository.cs +++ b/DeviceAdministration/Infrastructure/Repository/IccidRepository.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; using DeviceManagement.Infrustructure.Connectivity.Models.TerminalDevice; using Microsoft.Azure.Devices.Applications.RemoteMonitoring.Common.Configurations; using Microsoft.Azure.Devices.Applications.RemoteMonitoring.Common.Helpers; @@ -12,7 +10,7 @@ using Microsoft.WindowsAzure.Storage.Table; namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infrastructure.Repository { - public class IccidRepository: IIccidRepository + public class IccidRepository : IIccidRepository { private const string ICCID_TABLE_NAME = "IccidTable"; private readonly IAzureTableStorageClient _azureTableStorageClient; @@ -78,5 +76,30 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr var queryResponse = _azureTableStorageClient.ExecuteQuery(query); return (from iccid in queryResponse select new Iccid(iccid.Iccid)).ToList(); } + + public string GetLastSetLocaleServiceRequestId(string iccid) + { + return Find(iccid)?.LastSetLocaleServiceRequestId; + } + + public void SetLastSetLocaleServiceRequestId(string iccid, string serviceRequestId) + { + var entity = Find(iccid); + if (entity != null) + { + entity.LastSetLocaleServiceRequestId = serviceRequestId; + _azureTableStorageClient.Execute(TableOperation.InsertOrReplace(entity)); + } + } + + private IccidTableEntity Find(string iccid) + { + var query = new TableQuery().Where(TableQuery.CombineFilters( + TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, IccidRegistrationKey.Default.ToString()), + TableOperators.And, + TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.Equal, iccid))); + + return _azureTableStorageClient.ExecuteQuery(query).SingleOrDefault(); + } } } diff --git a/DeviceAdministration/Web/App_GlobalResources/Strings.resx b/DeviceAdministration/Web/App_GlobalResources/Strings.resx index 293203c1..4535c05b 100644 --- a/DeviceAdministration/Web/App_GlobalResources/Strings.resx +++ b/DeviceAdministration/Web/App_GlobalResources/Strings.resx @@ -1810,4 +1810,12 @@ To activate the integration to view and control your Ericsson IoT account devices through IoT Suite please enter the following credentials: + + Locale + Label + + + -- select a locale -- + Dropdown label. + \ No newline at end of file diff --git a/DeviceAdministration/Web/App_GlobalResources/Strings1.Designer.cs b/DeviceAdministration/Web/App_GlobalResources/Strings1.Designer.cs index 9c52cb54..8752c5c3 100644 --- a/DeviceAdministration/Web/App_GlobalResources/Strings1.Designer.cs +++ b/DeviceAdministration/Web/App_GlobalResources/Strings1.Designer.cs @@ -637,6 +637,24 @@ namespace GlobalResources { } } + /// + /// Looks up a localized string similar to Locale. + /// + public static string CellularInformationLocaleLabel { + get { + return ResourceManager.GetString("CellularInformationLocaleLabel", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to -- select a locale --. + /// + public static string CellularInformationNotLocaledOption { + get { + return ResourceManager.GetString("CellularInformationNotLocaledOption", resourceCulture); + } + } + /// /// Looks up a localized string similar to Rate Plan. /// diff --git a/DeviceAdministration/Web/Controllers/DeviceController.cs b/DeviceAdministration/Web/Controllers/DeviceController.cs index 4bef55a9..599982be 100644 --- a/DeviceAdministration/Web/Controllers/DeviceController.cs +++ b/DeviceAdministration/Web/Controllers/DeviceController.cs @@ -2,11 +2,8 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; -using System.Net; -using System.Net.Http; using System.Threading.Tasks; using System.Web.Mvc; -using DeviceManagement.Infrustructure.Connectivity; using DeviceManagement.Infrustructure.Connectivity.Exceptions; using DeviceManagement.Infrustructure.Connectivity.Models.TerminalDevice; using GlobalResources; @@ -21,7 +18,6 @@ using Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infrastr using Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Web.Helpers; using Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Web.Models; using Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Web.Security; -using Newtonsoft.Json; namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Web.Controllers { @@ -398,7 +394,7 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Web. private async Task processActionRequests(DeviceModel device, List actions) { var iccid = device.SystemProperties.ICCID; - var terminal = _cellularExtensions.GetSingleTerminalDetails(new Iccid(iccid)); + var terminal = _cellularExtensions.GetSingleTerminalDetails(new Iccid(iccid)); var completedActions = new List(); var failedActions = new List(); var exceptions = new List(); @@ -410,30 +406,28 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Web. switch (action.Type) { case CellularActionType.UpdateStatus: - { success = _cellularExtensions.UpdateSimState(iccid, action.Value); break; - } + case CellularActionType.UpdateSubscriptionPackage: - { success = _cellularExtensions.UpdateSubscriptionPackage(iccid, action.Value); break; - } + + case CellularActionType.UpdateLocale: + success = _cellularExtensions.SetLocale(iccid, action.Value); + break; + case CellularActionType.ReconnectDevice: - { success = _cellularExtensions.ReconnectDevice(iccid); break; - } + case CellularActionType.SendSms: - { success = await _cellularExtensions.SendSms(iccid, action.Value); break; - } + default: - { failedActions.Add(action); break; - } } } catch (Exception exception) @@ -456,20 +450,46 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Web. FailedActions = failedActions, Exceptions = exceptions }; - } private SimInformationViewModel generateSimInformationViewModel(string iccid, CellularActionUpdateResponseModel actionResponstModel = null) { var viewModel = new SimInformationViewModel(); viewModel.TerminalDevice = _cellularExtensions.GetSingleTerminalDetails(new Iccid(iccid)); - viewModel.SessionInfo = _cellularExtensions.GetSingleSessionInfo(new Iccid(iccid)).LastOrDefault() ?? - new SessionInfo(); + viewModel.SessionInfo = _cellularExtensions.GetSingleSessionInfo(new Iccid(iccid)).LastOrDefault() ?? new SessionInfo(); + var apiProviderDetails = _apiRegistrationRepository.RecieveDetails(); viewModel.ApiRegistrationProvider = Convert.ToString(apiProviderDetails.ApiRegistrationProvider); viewModel.AvailableSimStates = _cellularExtensions.GetValidTargetSimStates(iccid, viewModel.TerminalDevice.Status); - viewModel.AvailableSubscriptionPackages = _cellularExtensions.GetAvailableSubscriptionPackages(iccid, viewModel.TerminalDevice.RatePlan); + + try + { + viewModel.AvailableSubscriptionPackages = _cellularExtensions.GetAvailableSubscriptionPackages(iccid, viewModel.TerminalDevice.RatePlan); + } + catch + { + // [WORKAROUND] GetAvailableSubscriptionPackages does not work + viewModel.AvailableSubscriptionPackages = new List(); + } + viewModel.CellularActionUpdateResponse = actionResponstModel; + + try + { + IEnumerable availableLocaleNames; + string lastServiceRequestState; + string currentLocaleName = _cellularExtensions.GetLocale(iccid, out availableLocaleNames); + + viewModel.CurrentLocaleName = currentLocaleName; + viewModel.AvailableLocaleNames = availableLocaleNames; + } + catch + { + viewModel.CurrentLocaleName = string.Empty; + viewModel.AvailableLocaleNames = new List(); + } + viewModel.LastServiceRequestState = _cellularExtensions.GetLastSetLocaleServiceRequestState(iccid); + return viewModel; } } diff --git a/DeviceAdministration/Web/Helpers/CellularExtensions.cs b/DeviceAdministration/Web/Helpers/CellularExtensions.cs index 9cbd1a15..48ae078a 100644 --- a/DeviceAdministration/Web/Helpers/CellularExtensions.cs +++ b/DeviceAdministration/Web/Helpers/CellularExtensions.cs @@ -8,7 +8,6 @@ using DeviceManagement.Infrustructure.Connectivity.Models.TerminalDevice; using DeviceManagement.Infrustructure.Connectivity.Services; using Microsoft.Azure.Devices.Applications.RemoteMonitoring.Common.Models; using Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infrastructure.Repository; -using Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Web.Models; namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Web.Helpers { @@ -21,7 +20,7 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Web. { if (cellularService == null) { - throw new ArgumentNullException(nameof(cellularService)); + throw new ArgumentNullException(nameof(cellularService)); } _cellularService = cellularService; _iccidRepository = iccidRepository; @@ -44,8 +43,8 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Web. public IEnumerable GetListOfAvailableIccids(IList devices, string providerName) { - var fullIccidList = providerName == ApiRegistrationProviderTypes.Ericsson ? - _iccidRepository.GetIccids().Select(e => e.Id) : + var fullIccidList = providerName == ApiRegistrationProviderTypes.Ericsson ? + _iccidRepository.GetIccids().Select(e => e.Id) : _cellularService.GetTerminals().Select(i => i.Id); var usedIccidList = GetUsedIccidList(devices).Select(i => i.Id); @@ -114,10 +113,44 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Web. return await _cellularService.SendSms(iccid, terminal.Msisdn.Id, smsText); } + public string GetLocale(string iccid, out IEnumerable availableLocaleNames) + { + return _cellularService.GetLocale(iccid, out availableLocaleNames); + } + + public bool SetLocale(string iccid, string localeName) + { + var serviceRequestId = _cellularService.SetLocale(iccid, localeName); + + if (!string.IsNullOrWhiteSpace(serviceRequestId)) + { + _iccidRepository.SetLastSetLocaleServiceRequestId(iccid, serviceRequestId); + return true; + } + else + { + return false; + } + } + + public string GetLastSetLocaleServiceRequestState(string iccid) + { + var serviceRequestId = _iccidRepository.GetLastSetLocaleServiceRequestId(iccid); + + if (!string.IsNullOrWhiteSpace(serviceRequestId)) + { + return _cellularService.GetLastSetLocaleServiceRequestState(serviceRequestId); + } + else + { + return null; + } + } + private IEnumerable GetUsedIccidList(IList devices) { return (from device in devices - where device.DeviceProperties?.DeviceID != null && + where device.DeviceProperties?.DeviceID != null && device.SystemProperties?.ICCID != null select new Iccid(device.SystemProperties.ICCID) ).ToList(); diff --git a/DeviceAdministration/Web/Helpers/ICellularExtensions.cs b/DeviceAdministration/Web/Helpers/ICellularExtensions.cs index 58ad2f40..c7e75dd5 100644 --- a/DeviceAdministration/Web/Helpers/ICellularExtensions.cs +++ b/DeviceAdministration/Web/Helpers/ICellularExtensions.cs @@ -3,7 +3,6 @@ using System.Threading.Tasks; using DeviceManagement.Infrustructure.Connectivity.Models.Other; using DeviceManagement.Infrustructure.Connectivity.Models.TerminalDevice; using Microsoft.Azure.Devices.Applications.RemoteMonitoring.Common.Models; -using Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Web.Models; namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Web.Helpers { @@ -23,5 +22,8 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Web. bool UpdateSubscriptionPackage(string iccid, string updatedPackage); bool ReconnectDevice(string iccid); Task SendSms(string iccid, string smsText); + string GetLocale(string iccid, out IEnumerable availableLocaleNames); + bool SetLocale(string iccid, string localeName); + string GetLastSetLocaleServiceRequestState(string iccid); } } \ No newline at end of file diff --git a/DeviceAdministration/Web/Models/CellularActionModel.cs b/DeviceAdministration/Web/Models/CellularActionModel.cs index a3801583..edd0f68a 100644 --- a/DeviceAdministration/Web/Models/CellularActionModel.cs +++ b/DeviceAdministration/Web/Models/CellularActionModel.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Web.Models { @@ -15,9 +12,10 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Web. public enum CellularActionType { - UpdateStatus=1, - UpdateSubscriptionPackage=2, - ReconnectDevice=3, - SendSms=4 + UpdateStatus = 1, + UpdateSubscriptionPackage = 2, + ReconnectDevice = 3, + SendSms = 4, + UpdateLocale = 5 } } \ No newline at end of file diff --git a/DeviceAdministration/Web/Models/SimInformationViewModel.cs b/DeviceAdministration/Web/Models/SimInformationViewModel.cs index 46efa3f2..7565a59e 100644 --- a/DeviceAdministration/Web/Models/SimInformationViewModel.cs +++ b/DeviceAdministration/Web/Models/SimInformationViewModel.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using DeviceManagement.Infrustructure.Connectivity.Models.Other; using DeviceManagement.Infrustructure.Connectivity.Models.TerminalDevice; -using Microsoft.Azure.Devices.Applications.RemoteMonitoring.Common.Models; namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Web.Models { @@ -10,9 +9,12 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Web. public string DeviceId { get; set; } public Terminal TerminalDevice { get; set; } public SessionInfo SessionInfo { get; set; } - public string ApiRegistrationProvider { get; set;} + public string ApiRegistrationProvider { get; set; } public List AvailableSimStates { get; set; } public List AvailableSubscriptionPackages { get; set; } public CellularActionUpdateResponseModel CellularActionUpdateResponse { get; set; } + public string CurrentLocaleName { get; set; } + public IEnumerable AvailableLocaleNames { get; set; } + public string LastServiceRequestState { get; set; } } } \ No newline at end of file diff --git a/DeviceAdministration/Web/Scripts/Views/Device/CellularActions.js b/DeviceAdministration/Web/Scripts/Views/Device/CellularActions.js index eb261a73..ac166480 100644 --- a/DeviceAdministration/Web/Scripts/Views/Device/CellularActions.js +++ b/DeviceAdministration/Web/Scripts/Views/Device/CellularActions.js @@ -14,7 +14,8 @@ IoTApp.createModule("IoTApp.CellularActions", function () { reconnectDevice: "ReconnectDevice", sendSms: "SendSms", updateStatus: "UpdateStatus", - updateSubscriptionPackage: "UpdateSubscriptionPackage" + updateSubscriptionPackage: "UpdateSubscriptionPackage", + updateLocale: "UpdateLocale" } self.htmlElementIds = { reconnectDevice: "#reconnectDevice", diff --git a/DeviceAdministration/Web/Scripts/Views/Device/CellularInformation.js b/DeviceAdministration/Web/Scripts/Views/Device/CellularInformation.js index f2a52da9..10ce6abe 100644 --- a/DeviceAdministration/Web/Scripts/Views/Device/CellularInformation.js +++ b/DeviceAdministration/Web/Scripts/Views/Device/CellularInformation.js @@ -14,6 +14,7 @@ IoTApp.createModule("IoTApp.CellularInformation", function () { self.htmlElementIds = { simStateSelect: "#simStateSelect", subscriptionPackageSelect: "#subscriptionPackageSelect", + localeSelect: "#localeSelect", saveCellularInformation: "#saveCellularInformation", editCellularInformation: "#editCellularInformation", cancelEditCellularInformation: "#cancelEditCellularInformation", @@ -29,6 +30,7 @@ IoTApp.createModule("IoTApp.CellularInformation", function () { var resetInputsToInitial = function() { $(self.htmlElementIds.simStateSelect).val(self.initialCellActionSettings.simStatus); $(self.htmlElementIds.subscriptionPackageSelect).val(self.initialCellActionSettings.subscriptionPackage); + $(self.htmlElementIds.localeSelect).val(self.initialCellActionSettings.locale); } /** @@ -40,6 +42,7 @@ IoTApp.createModule("IoTApp.CellularInformation", function () { if (disabled) { $(self.htmlElementIds.simStateSelect).attr("disabled", "disabled"); $(self.htmlElementIds.subscriptionPackageSelect).attr("disabled", "disabled"); + $(self.htmlElementIds.localeSelect).attr("disabled", "disabled"); $(self.htmlElementIds.saveCellularInformation).hide(); $(self.htmlElementIds.cancelEditCellularInformation).hide(); $(self.htmlElementIds.editCellularInformation).show(); @@ -47,6 +50,7 @@ IoTApp.createModule("IoTApp.CellularInformation", function () { } else { $(self.htmlElementIds.simStateSelect).removeAttr("disabled"); $(self.htmlElementIds.subscriptionPackageSelect).removeAttr("disabled"); + $(self.htmlElementIds.localeSelect).removeAttr("disabled"); $(self.htmlElementIds.saveCellularInformation).show(); $(self.htmlElementIds.cancelEditCellularInformation).show(); $(self.htmlElementIds.editCellularInformation).hide(); @@ -62,10 +66,12 @@ IoTApp.createModule("IoTApp.CellularInformation", function () { var retrieveActionFormValues = function () { var simStatus = $(self.htmlElementIds.simStateSelect).val(); var subscriptionPackage = $(self.htmlElementIds.subscriptionPackageSelect).val(); - debugger + var locale = $(self.htmlElementIds.localeSelect).val(); + return { subscriptionPackage: subscriptionPackage, - simStatus: simStatus + simStatus: simStatus, + locale: locale } } @@ -93,6 +99,13 @@ IoTApp.createModule("IoTApp.CellularInformation", function () { value: currentFormValues.simStatus }); } + if (currentFormValues.locale != self.initialCellActionSettings.locale) { + cellularCellularActionRequestModel.cellularActions.push({ + type: self.actionTypes.updateLocale, + previousValue: self.initialCellActionSettings.locale, + value: currentFormValues.locale + }); + } cellularCellularActionRequestModel.deviceId = self.deviceId; return cellularCellularActionRequestModel; } diff --git a/DeviceAdministration/Web/Views/Device/_CellularInformationEricsson.cshtml b/DeviceAdministration/Web/Views/Device/_CellularInformationEricsson.cshtml index 8a96f7c6..c87df8ae 100644 --- a/DeviceAdministration/Web/Views/Device/_CellularInformationEricsson.cshtml +++ b/DeviceAdministration/Web/Views/Device/_CellularInformationEricsson.cshtml @@ -27,6 +27,25 @@ } +

+ @Strings.CellularInformationLocaleLabel +

+ +
@if (Model.CellularActionUpdateResponse != null) {