private async Task Parse(string filePath, Action <ApiDictionary> parseCompleted, Action <int, int, int> parseProgressUpdate) { var reader = new StreamReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, filePath)); var allText = Utility.Trim(reader.ReadToEnd()).Trim('-'); var apis = Regex.Split(allText, "^------------------------------------------------------------------\r\n", RegexOptions.Multiline); var apiDictionary = new ApiDictionary(); var parsedCount = 0; var parsedSuccessCount = 0; foreach (var item in apis) { var apiList = new ApiList(apiDictionary); var api = await Api.ParseFromTextBlockAsync(apiList, Utility.Trim(item)); if (api?.Request?.Address != null && Settings.IsUrlMatched(api.Request.Address.Url)) { var key = new ApiKey { Group = api.Request.Address.Group, Method = api.Request.Address.Method }; if (!apiDictionary.Content.ContainsKey(key)) { apiDictionary.Content.Add(key, apiList); } apiDictionary.Content[key].Content.Add(api); parsedSuccessCount++; } parsedCount++; parseProgressUpdate?.Invoke(apis.Length, parsedCount, parsedSuccessCount); } parseCompleted?.Invoke(apiDictionary); }
/// <summary> /// Used internally to initialize the properties of this class. /// </summary> public MessageResponse(ApiDictionary jso) { foreach (string key in jso.Keys) { switch (key.ToLower()) { case "clientreference": _clientReference = Convert.ToString(jso[key]); break; case "detail": // ??? _detail = null; // Suppress compiler warning. break; case "messageid": _messageId = new Guid(Convert.ToString(jso[key])); break; case "networkid": _networkId = Convert.ToString(jso[key]); break; case "rate": _rate = Convert.ToDouble(jso[key]); break; case "status": _status = Convert.ToInt32(jso[key]); break; } } }
/// <summary> /// Initializes a new instance of the <see cref="Campaign" /> /// </summary> public Campaign(ApiDictionary jso) { _actions = new List<Action>(); _moKeywords = new List<MoKeyWord>(); foreach (string key in jso.Keys) { switch (key.ToLower()) { case "accountid": _accountId = Convert.ToString(jso[key]); break; case "actions": var acs = jso[key] as IEnumerable; if (acs != null) { foreach (JObject o in acs) _actions.Add(new Action(o.ToObject<ApiDictionary>())); } break; case "brief": Brief = Convert.ToString(jso[key]); break; case "campaignid": _campaignId = Convert.ToInt64(jso[key]); break; case "datecreated": if (jso[key].ToString() != "") { DateTime dateCreated; DateCreated = DateTime.TryParseExact(jso[key].ToString(), "yyyy-dd-MM hh:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateCreated) ? dateCreated : (DateTime?) null; } break; case "dateended": if (jso[key].ToString() != "") { DateTime dateEnded; DateEnded = DateTime.TryParseExact(jso[key].ToString(), "yyyy-dd-MM hh:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateEnded) ? dateEnded : (DateTime?) null; } break; case "description": Description = Convert.ToString(jso[key]); break; case "enabled": _enabled = Convert.ToBoolean(jso[key]); break; case "isdefault": _isDefault = Convert.ToBoolean(jso[key]); break; case "mokeywords": var mos = jso[key] as IEnumerable; if (mos != null) foreach (JObject mo in mos) _moKeywords.Add(new MoKeyWord(mo.ToObject<ApiDictionary>())); break; case "pendingapproval": _pendingApproval = Convert.ToBoolean(jso[key]); break; } } }
/// <summary> /// Used internally to initialize the properties of this class. /// </summary> public ServiceType(ApiDictionary jso) { foreach (string key in jso.Keys) { switch (key.ToLower()) { case "descriptor": _descriptor = Convert.ToString(jso[key]); break; case "iscreditbased": _isCreditBased = Convert.ToBoolean(jso[key]); break; case "isprepaid": _isPrepaid = Convert.ToBoolean(jso[key]); break; case "name": _name = Convert.ToString(jso[key]); break; case "rate": _rate = Convert.ToDouble(jso[key]); break; case "requiresactivation": _requiresActivation = Convert.ToBoolean(jso[key]); break; } } }
public MainScreen() { InitializeComponent(); // Setup Api Stuff LoggingApiProvider loggingApiProvider = new LoggingApiProvider(); TextToSpeechApiProvider textToSpeechApiProvider = new TextToSpeechApiProvider(); // Setup Api Stuff that needs Text to speech support ProcessApiProvider processApiProvider = new ProcessApiProvider(textToSpeechApiProvider); RecognizerApiProvider p_Brain = new RecognizerApiProvider(textToSpeechApiProvider); // Setup Language Provider m_Brain = p_Brain; // HAHAHAHA science..... SetupLanguageProvider(); // Setup the Api Listing IDictionary<string, ApiProvider> apiListing = new ApiDictionary<string, ApiProvider>(); apiListing.Add("TextToSpeechApi", textToSpeechApiProvider); apiListing.Add("ProcessApi", processApiProvider); apiListing.Add("LoggingApi", loggingApiProvider); apiListing.Add("LoreiApi", m_Brain); // Setup Scripting Languages m_Brain.LoadScriptProcessor(new LuaScriptProcessor(apiListing)); m_Brain.LoadScriptProcessor(new IronPythonScriptProcessor(apiListing)); }
/// <summary> /// </summary> /// <param name="dix"></param> public TopupLocation(ApiDictionary dix) { foreach (string key in dix.Keys) { switch (key.ToLower()) { case "id": Id = Convert.ToInt64(dix[key]); break; case "city": City = Convert.ToString(dix[key]); break; case "area": Area = Convert.ToString(dix[key]); break; case "region": Region = Convert.ToString(dix[key]); break; case "details": Details = Convert.ToString(dix[key]); break; case "description": Description = Convert.ToString(dix[key]); break; case "latitude": Latitude = Convert.ToDouble(dix[key]); break; case "longitude": Longitute = Convert.ToDouble(dix[key]); break; } } }
/// <summary> /// Used internally to initialize the properties of this class. /// </summary> public Sender(ApiDictionary jso) { foreach (string key in jso.Keys) { switch (key.ToLower()) { case "accountid": AccountId = Convert.ToString(jso[key]); break; case "address": Address = Convert.ToString(jso[key]); break; case "id": Id = Convert.ToInt64(jso[key]); break; case "isdeleted": _isDeleted = Convert.ToBoolean(jso[key]); break; case "timeadded": if (jso[key].ToString() != "") { DateTime dateCreated; _timeAdded = DateTime.TryParseExact(jso[key].ToString(), "yyyy-dd-MM hh:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateCreated) ? dateCreated : (DateTime?) null; } break; case "timedeleted": DateTime td; if (jso[key].ToString() != "") _timeDeleted = DateTime.TryParseExact(jso[key].ToString(), "yyyy-dd-MM hh:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out td) ? td : (DateTime?) null; break; } } }
/// <summary> /// Used internally to initialize the properties of this class. /// </summary> public MessageTemplate(ApiDictionary jso) { foreach (string key in jso.Keys) { switch (key.ToLower()) { case "accountid": AccountId = Convert.ToString(jso[key]); break; case "datecreated": if (jso[key].ToString() != "") { DateTime dateCreated; _dateCreated = DateTime.TryParseExact(jso[key].ToString(), "yyyy-dd-MM hh:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateCreated) ? dateCreated : (DateTime?) null; } break; case "id": Id = Convert.ToInt64(jso[key]); break; case "name": Name = Convert.ToString(jso[key]); break; case "text": Text = Convert.ToString(jso[key]); break; } } }
private async Task Compare() { IList <Task> tasks = new List <Task>(); tasks.Add(ApiDictionary.CompareAsync(ApiDictionary1, ApiDictionary2)); tasks.Add(ApiDictionary.CompareAsync(ApiDictionary2, ApiDictionary1)); await Task.WhenAll(tasks); }
/// <summary> /// Used internally to initialize the properties of this class. /// </summary> /// <param name="jso"></param> public ContentFolder(ApiDictionary jso) { _folders = new List<ContentFolder>(); _medias = new List<ContentMedia>(); foreach (string key in jso.Keys) { switch (key.ToLower()) { case "contentfolderid": _contentFolderId = Convert.ToInt64(jso[key]); break; case "contentlibraryid": ContentLibraryId = new Guid(Convert.ToString(jso[key])); break; case "foldername": FolderName = Convert.ToString(jso[key]); break; case "absolutepath": AbosultePath = Convert.ToString(jso[key]); break; case "datecreated": if (jso[key].ToString() != "") { DateTime dateCreated; DateCreated = DateTime.TryParseExact(jso[key].ToString(), "yyyy-dd-MM hh:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateCreated) ? dateCreated : (DateTime?) null; } break; case "datemodified": if (jso[key].ToString() != "") { DateTime dateModified; DateModified = DateTime.TryParseExact(jso[key].ToString(), "yyyy-dd-MM hh:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateModified) ? dateModified : (DateTime?) null; } break; case "parentid": ParentId = Convert.ToInt64(jso[key]); break; case "subfoldercount": _subFolderCount = Convert.ToInt64(jso[key]); break; case "contentmediacount": _contentMediaCount = Convert.ToInt64(jso[key]); break; case "subfolders": var subfolders = jso[key] as IEnumerable; if (subfolders != null) foreach (JObject mo in subfolders) _folders.Add(new ContentFolder(mo.ToObject<ApiDictionary>())); break; case "contentmedias": var medias = jso[key] as IEnumerable; if (medias != null) foreach (JObject mo in medias) _medias.Add(new ContentMedia(mo.ToObject<ApiDictionary>())); break; } } }
/// <summary> /// Initializes a new instance of the <see cref="ChildAccount" /> class. /// </summary> public ChildAccount(ApiDictionary jso) { foreach (string key in jso.Keys) { switch (key.ToLower()) { case "accountnumber": _accountNumber = Convert.ToInt64(jso[key]); break; case "balance": _balance = Convert.ToDouble(jso[key]); break; case "canimpersonate": _canImpersonate = Convert.ToBoolean(jso[key]); break; case "child": _child = Convert.ToString(jso[key]); break; case "credit": _credit = Convert.ToDouble(jso[key]); break; case "id": _id = Convert.ToInt64(jso[key]); break; case "parent": _parent = Convert.ToString(jso[key]); break; case "productid": _productId = Convert.ToString(jso[key]); break; case "productname": _productName = Convert.ToString(jso[key]); break; case "status": _status = Convert.ToInt32(jso[key]); break; case "timecreated": DateTime dateCreated; if (jso[key].ToString() != "") { _timeCreated = DateTime.TryParseExact(jso[key].ToString(), "yyyy-dd-MM hh:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateCreated) ? dateCreated : (DateTime?) null; } break; case "timeremoved": DateTime tmr; if (jso[key].ToString() != "") _timeRemoved = DateTime.TryParseExact(jso[key].ToString(), "yyyy-dd-MM hh:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out tmr) ? tmr : (DateTime?) null; break; } } }
/// <summary> /// Initializes a new instance of the <see cref="AccountContact" /> class. /// </summary> public AccountContact(ApiDictionary jso) { foreach (string key in jso.Keys) { switch (key.ToLower()) { case "accountcontactid": _accountContactId = Convert.ToInt64(jso[key]); break; case "address1": Address1 = Convert.ToString(jso[key]); break; case "address2": Address2 = Convert.ToString(jso[key]); break; case "city": City = Convert.ToString(jso[key]); break; case "country": Country = Convert.ToString(jso[key]); break; case "firstname": FirstName = Convert.ToString(jso[key]); break; case "lastname": LastName = Convert.ToString(jso[key]); break; case "province": Province = Convert.ToString(jso[key]); break; case "postalcode": PostalCode = Convert.ToString(jso[key]); break; case "primaryemail": PrimaryEmail = Convert.ToString(jso[key]); break; case "primaryphone": PrimaryPhone = Convert.ToString(jso[key]); break; case "privatenote": PrivateNote = Convert.ToString(jso[key]); break; case "publicnote": PublicNote = Convert.ToString(jso[key]); break; case "secondaryemail": SecondaryEmail = Convert.ToString(jso[key]); break; case "secondaryphone": SecondaryPhone = Convert.ToString(jso[key]); break; } } }
/// <summary> /// </summary> /// <param name="jso"></param> public Tag(ApiDictionary jso) { foreach (string key in jso.Keys) { switch (key.ToLower()) { case "key": Key = Convert.ToString(jso[key]); break; case "value": Value = Convert.ToString(jso[key]); break; } } }
/// <summary> /// </summary> /// <param name="dix"></param> public Topup(ApiDictionary dix) { foreach (string key in dix.Keys) { switch (key.ToLower()) { case "purchasedcredit": PurchasedCredit = Convert.ToInt64(dix[key]); break; case "actualcredit": ActualCredit = Convert.ToDouble(dix[key]); break; } } }
/// <summary> /// Used internally to initialize the properties of this class. /// </summary> public Service(ApiDictionary jso) { foreach (string key in jso.Keys) { switch (key.ToLower()) { case "accountid": AccountId = Convert.ToString(jso[key]); break; case "billdate": DateTime billDate; if (jso[key].ToString() != "") _billDate = DateTime.TryParseExact(jso[key].ToString(), "yyyy-dd-MM hh:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out billDate) ? billDate : (DateTime?) null; break; case "billingcycleid": BillingCycleId = Convert.ToInt64(jso[key]); break; case "datecreated": if (jso[key].ToString() != "") { DateTime dateCreated; _dateCreated = DateTime.TryParseExact(jso[key].ToString(), "yyyy-dd-MM hh:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateCreated) ? dateCreated : (DateTime?) null; } break; case "description": Description = Convert.ToString(jso[key]); break; case "iscreditbased": IsCreditBased = Convert.ToBoolean(jso[key]); break; case "isprepaid": IsPrepaid = Convert.ToBoolean(jso[key]); break; case "rate": Rate = Convert.ToDecimal(jso[key]); break; case "serviceid": ServiceId = Convert.ToInt64(jso[key]); break; case "servicestatustypeid": ServiceStatusTypeId = Convert.ToInt64(jso[key]); break; case "servicetypeid": ServiceTypeId = Convert.ToInt64(jso[key]); break; } } }
/// <summary> /// Initializes a new instance of the <see cref="AccountProfile" /> class. /// </summary> public AccountProfile(ApiDictionary jso) { foreach (string key in jso.Keys) { switch (key.ToLower()) { case "accountid": _accountId = Convert.ToString(jso[key]); break; case "accountmanager": _accountManager = Convert.ToString(jso[key]); break; case "accountnumber": _accountNumber = Convert.ToInt64(jso[key]); break; case "accountstatus": _accountStatus = Convert.ToString(jso[key]); break; case "balance": _balance = Convert.ToDecimal(jso[key]); break; case "company": _company = Convert.ToString(jso[key]); break; case "credit": _credit = Convert.ToDecimal(jso[key]); break; case "emailaddress": _emailAddress = Convert.ToString(jso[key]); break; case "lastaccessed": DateTime lastAccessedDate; if (jso[key].ToString() != "") { _lastAccessed = DateTime.TryParseExact(jso[key].ToString(), "yyyy-dd-MM hh:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out lastAccessedDate) ? lastAccessedDate : (DateTime?) null; } break; case "mobilenumber": _mobileNumber = Convert.ToString(jso[key]); break; case "numberofservices": _numberOfServices = Convert.ToInt32(jso[key]); break; case "primarycontact": _primaryContact = Convert.ToString(jso[key]); break; case "unpostedbalance": _unpostedBalance = Convert.ToDecimal(jso[key]); break; } } }
/// <summary> /// Used internally to initialize the properties of this class. /// </summary> public Settings(ApiDictionary jso) { foreach (string key in jso.Keys) { switch (key.ToLower()) { case "accountid": _accountId = Convert.ToString(jso[key]); break; case "countrycode": CountryCode = Convert.ToString(jso[key]); break; case "deliveryreportnotificationurl": DeliveryReportNotificationUrl = Convert.ToString(jso[key]); break; case "emaildailysummary": EmailDailySummary = Convert.ToBoolean(jso[key]); break; case "emailinvoicereminders": EmailInvoiceReminders = Convert.ToBoolean(jso[key]); break; case "emailmaintenance": EmailMaintenance = Convert.ToBoolean(jso[key]); break; case "emailnewinvoice": EmailNewInvoice = Convert.ToBoolean(jso[key]); break; case "smsfortnightbalance": SmsFortnightBalance = Convert.ToBoolean(jso[key]); break; case "smslowbalancenotification": SmsLowBalanceNotification = Convert.ToBoolean(jso[key]); break; case "smsmaintenance": SmsMaintenance = Convert.ToBoolean(jso[key]); break; case "smspromotionalmessages": SmsPromotionalMessages = Convert.ToBoolean(jso[key]); break; case "smstopupnotification": SmsTopUpNotification = Convert.ToBoolean(jso[key]); break; case "timezone": TimeZone = Convert.ToString(jso[key]); break; } } }
/// <summary> /// Used internally to initialize the properties of this class. /// </summary> public ContactGroup(ApiDictionary jso) { foreach (string key in jso.Keys) { switch (key.ToLower()) { case "accountid": _accountId = Convert.ToString(jso[key]); break; case "contactcount": _contactCount = Convert.ToInt64(jso[key]); break; case "groupid": _groupId = Convert.ToInt64(jso[key]); break; case "name": Name = Convert.ToString(jso[key]); break; } } }
protected virtual void LoadTranslation(object ct) { CancellationToken cancelTok = (CancellationToken)ct; if (this.DictResult != null) { this.DictResult.Clear(); } ApiDictionary apiDict = new ApiDictionary(this.apiKeyDict); this.DictResult = apiDict.GetTranslation(Lang.EnRu, this.wordKey); int loadedFilesCount = 0; for (int i = 0; i < this.DictResult.Count; i++) { if (!cancelTok.IsCancellationRequested) { foreach (YTranslation translation in this.DictResult[i].Translations) { TranslationEventArgs e = new TranslationEventArgs { PartOfSpeach = this.DictResult[i].AttrPartOfSpeech, Transcription = this.DictResult[i].AttrTranscription }; e.Translation = translation.AttrTranslation; this.OnGettingOneTranslationComplete(e); loadedFilesCount++; } } else { cancelTok.ThrowIfCancellationRequested(); } } if (!cancelTok.IsCancellationRequested) { this.OnGettingTranslationComplete(loadedFilesCount); } }
/// <summary> /// Used internally to initialize the properties of this class. /// </summary> public Invoice(ApiDictionary jso) { foreach (string key in jso.Keys) { switch (key.ToLower()) { case "amount": _amount = Convert.ToDouble(jso[key]); break; case "created": DateTime dateCreated; if (jso[key].ToString() != "") { _created = DateTime.TryParseExact(jso[key].ToString(), "yyyy-dd-MM hh:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateCreated) ? dateCreated : (DateTime?) null; } break; case "description": _description = Convert.ToString(jso[key]); break; case "duedate": if (jso[key].ToString() != "") { _dueDate = DateTime.TryParseExact(jso[key].ToString(), "yyyy-dd-MM hh:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateCreated) ? dateCreated : (DateTime?) null; } break; case "ending": _ending = Convert.ToDouble(jso[key]); break; case "id": _id = Convert.ToInt64(jso[key]); break; case "ispaid": _isPaid = Convert.ToBoolean(jso[key]); break; case "type": _type = Convert.ToString(jso[key]); break; } } }
/// <summary> /// Used internally to initialize the instance of this class. /// </summary> public Contact(ApiDictionary jso) { foreach (string key in jso.Keys) { switch (key.ToLower()) { case "contactid": _contactId = Convert.ToInt64(jso[key]); break; case "custom1": Custom1 = Convert.ToString(jso[key]); break; case "custom2": Custom2 = Convert.ToString(jso[key]); break; case "custom3": Custom3 = Convert.ToString(jso[key]); break; case "firstname": FirstName = Convert.ToString(jso[key]); break; case "groupid": GroupId = Convert.ToInt64(jso[key]); break; case "groupname": _groupName = Convert.ToString(jso[key]); break; case "mobilenumber": MobileNumber = Convert.ToString(jso[key]); break; case "owner": _owner = Convert.ToString(jso[key]); break; case "surname": Surname = Convert.ToString(jso[key]); break; case "title": Title = Convert.ToString(jso[key]); break; } } }
/// <summary> /// Used internally to initialize this API number plan item. /// </summary> public NumberPlanItem(ApiDictionary jso) { foreach (string key in jso.Keys) { switch (key.ToLower()) { case "id": _id = Convert.ToInt64(jso[key]); break; case "network": _network = Convert.ToString(jso[key]); break; case "payout": _payout = Convert.ToDouble(jso[key]); break; case "reversepayout": _reversePayout = Convert.ToDouble(jso[key]); break; case "shortcode": _shortCode = Convert.ToString(jso[key]); break; } } }
/// <summary> /// Initializes a new instance of the <see cref="Action" /> class. /// </summary> public Action(ApiDictionary jso) { foreach (string key in jso.Keys) { switch (key.ToLower()) { case "actionmeta": _actionMeta = Convert.ToString(jso[key]); break; case "actiontypeid": _actionTypeId = Convert.ToInt64(jso[key]); break; case "campaignid": _campaignId = Convert.ToInt64(jso[key]); break; case "id": _id = Convert.ToInt64(jso[key]); break; case "isactive": _isActive = Convert.ToBoolean(jso[key]); break; } } }
/// <summary> /// Used internally to initialize the properties of this class. /// </summary> /// <param name="jso"></param> public ContentLibrary(ApiDictionary jso) { foreach (string key in jso.Keys) { switch (key.ToLower()) { case "libraryid": _libraryId = new Guid(Convert.ToString(jso[key])); break; case "accountid": _accountId = Convert.ToString(jso[key]); break; case "name": Name = Convert.ToString(jso[key]); break; case "shortname": ShortName = Convert.ToString(jso[key]); break; case "datecreated": if (jso[key].ToString() != "") { DateTime dateCreated; DateCreated = DateTime.TryParseExact(jso[key].ToString(), "yyyy-dd-MM hh:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateCreated) ? dateCreated : (DateTime?) null; } break; case "datemodified": if (jso[key].ToString() != "") { DateTime dateModified; DateModified = DateTime.TryParseExact(jso[key].ToString(), "yyyy-dd-MM hh:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateModified) ? dateModified : (DateTime?) null; } break; case "folderid": _folderId = Convert.ToInt64(jso[key]); break; } } }
public static async Task LoadAPIKeys(string path = "data/ApiKeys") { API_KEYS = new ApiDictionary(); string[] files = Directory.GetFiles(path); foreach (string file in files) { FileStream fs = new FileStream(file, FileMode.Open); StreamReader sr = new StreamReader(fs); string Key = await sr.ReadToEndAsync(); string Tag = Path.GetFileNameWithoutExtension(file); string[] pathChunks = Tag.Split('/'); Tag = pathChunks[pathChunks.Length - 1]; API_KEYS.Add(Tag, Key); sr.Close(); fs.Close(); } }
/// <summary> /// initializer /// </summary> /// <param name="json">Data dictionary</param> public TicketResponse(ApiDictionary json) : this() { foreach (string key in json.Keys) { switch (key.ToLower()) { case "id": _id = Convert.ToInt64(json[key]); break; case "time": DateTime timeParsed; if (json[key].ToString() != "") Time = DateTime.TryParseExact(json[key].ToString(), "yyyy-dd-MM hh:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out timeParsed) ? timeParsed : (DateTime?) null; break; case "content": Content = Convert.ToString(json[key]); break; case "attachment": _attachment = Convert.ToString(json[key]); break; } } }
/// <summary> /// Used internally to initialize the properties of this class. /// </summary> public MoKeyWord(ApiDictionary jso) { foreach (string key in jso.Keys) { switch (key.ToLower()) { case "alias1": Alias1 = Convert.ToString(jso[key]); break; case "alias2": Alias2 = Convert.ToString(jso[key]); break; case "alias3": Alias3 = Convert.ToString(jso[key]); break; case "alias4": Alias4 = Convert.ToString(jso[key]); break; case "alias5": Alias5 = Convert.ToString(jso[key]); break; case "id": _id = Convert.ToInt64(jso[key]); break; case "isactive": _isActive = Convert.ToBoolean(jso[key]); break; case "isdefault": _isDefault = Convert.ToBoolean(jso[key]); break; case "keyword": Keyword = Convert.ToString(jso[key]); break; case "numberplanid": NumberPlanId = Convert.ToInt64(jso[key]); break; } } }
/// <summary> /// Used internally to initialize the properties of this class. /// </summary> /// <param name="jso"></param> public ContentMedia(ApiDictionary jso) { Tags = new List<Tag>(); foreach (string key in jso.Keys) { switch (key.ToLower()) { case "id": _id = new Guid(Convert.ToString(jso[key])); break; case "accountid": _accountId = Convert.ToString(jso[key]); break; case "name": Name = Convert.ToString(jso[key]); break; case "libraryid": LibraryId = new Guid(Convert.ToString(jso[key])); break; case "locationpath": LocationPath = Convert.ToString(jso[key]); break; case "tags": var tags = jso[key] as IEnumerable; if (tags != null) foreach (JObject mo in tags) Tags.Add(new Tag(mo.ToObject<ApiDictionary>())); break; case "type": Type = Convert.ToString(jso[key]); break; case "preference": Preference = Convert.ToString(jso[key]); break; case "drmprotect": DrmProtect = Convert.ToBoolean(jso[key]); break; case "encodingstatus": EncodingStatus = Convert.ToString(jso[key]); break; case "streamable": Streamable = Convert.ToBoolean(jso[key]); break; case "displaytext": DisplayText = Convert.ToString(jso[key]); break; case "contenttext": ContentText = Convert.ToString(jso[key]); break; case "approved": Approved = Convert.ToBoolean(jso[key]); break; case "deleted": Deleted = Convert.ToBoolean(jso[key]); break; case "datecreated": if (jso[key].ToString() != "") { DateTime dateCreated; DateCreated = DateTime.TryParseExact(jso[key].ToString(), "yyyy-dd-MM hh:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateCreated) ? dateCreated : (DateTime?) null; } break; case "datemodified": if (jso[key].ToString() != "") { DateTime dateModified; DateModified = DateTime.TryParseExact(jso[key].ToString(), "yyyy-dd-MM hh:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateModified) ? dateModified : (DateTime?) null; } break; case "datedeleted": if (jso[key].ToString() != "") { DateTime dateDeleted; DateDeleted = DateTime.TryParseExact(jso[key].ToString(), "yyyy-dd-MM hh:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateDeleted) ? dateDeleted : (DateTime?) null; } break; case "callbackurl": CallbackUrl = Convert.ToString(jso[key]); break; } } }
/// <summary> /// Used internally to initialize a new instance of this class. /// </summary> public NumberPlan(ApiDictionary jso) { _moKeywords = new List<MoKeyWord>(); _numberPlanItems = new List<NumberPlanItem>(); foreach (string key in jso.Keys) { switch (key.ToLower()) { case "accountid": AccountId = Convert.ToString(jso[key]); break; case "dateactivated": if (jso[key].ToString() != "") { DateTime dateActivated; _dateActivated = DateTime.TryParseExact(jso[key].ToString(), "yyyy-dd-MM hh:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateActivated) ? dateActivated : (DateTime?) null; } break; case "datecreated": if (jso[key].ToString() != "") { DateTime dateCreated; _dateCreated = DateTime.TryParseExact(jso[key].ToString(), "yyyy-dd-MM hh:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateCreated) ? dateCreated : (DateTime?) null; } break; case "datedeactivated": DateTime dateDeactivated; if (jso[key].ToString() != "") { _dateDeactivated = DateTime.TryParseExact(jso[key].ToString(), "yyyy-dd-MM hh:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateDeactivated) ? dateDeactivated : (DateTime?) null; } break; case "dateexpiring": DateTime dateExpiring; if (jso[key].ToString() != "") { _dateExpiring = DateTime.TryParseExact(jso[key].ToString(), "yyyy-dd-MM hh:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateExpiring) ? dateExpiring : (DateTime?) null; } break; case "description": Description = Convert.ToString(jso[key]); break; case "id": Id = Convert.ToInt64(jso[key]); break; case "initialcost": _initialCost = Convert.ToDouble(jso[key]); break; case "isactive": _isActive = Convert.ToBoolean(jso[key]); break; case "ispremium": _isPremium = Convert.ToBoolean(jso[key]); break; case "maxallowedkeywords": _maxAllowedKeywords = Convert.ToInt32(jso[key]); break; case "mokeywords": var mos = jso[key] as IEnumerable; if (mos != null) { foreach (JObject o in mos) _moKeywords.Add(new MoKeyWord(o.ToObject<ApiDictionary>())); } break; case "notes": _notes = Convert.ToString(jso[key]); break; case "numberplanitems": var os = jso[key] as IEnumerable; if (os != null) { foreach (JObject o in os) _numberPlanItems.Add(new NumberPlanItem(o.ToObject<ApiDictionary>())); } break; case "periodiccostbasis": _periodicCostBasis = Convert.ToDouble(jso[key]); break; case "servicetype": var svc = jso[key] as JObject; _serviceType = new ServiceType(svc.ToObject<ApiDictionary>()); break; } } }
/// <summary> /// Constructor /// </summary> /// <param name="jso"></param> public Ticket(ApiDictionary jso) { _responses = new List<TicketResponse>(); foreach (string key in jso.Keys) { switch (key.ToLower()) { case "id": _id = Convert.ToInt32(jso[key]); break; case "accountid": _accountId = Convert.ToString(jso[key]); break; case "assignedto": _assignedTo = Convert.ToString(jso[key]); break; case "supportdepartmentid": SupportDepartmentId = Convert.ToInt32(jso[key]); break; case "supportcategoryid": SupportCategoryId = Convert.ToInt32(jso[key]); break; case "supportstatusid": _supporStatusId = Convert.ToInt32(jso[key]); break; case "priority": Priority = Convert.ToInt32(jso[key]); break; case "source": Source = Convert.ToString(jso[key]); break; case "recipients": _recipients = Convert.ToString(jso[key]); break; case "timeadded": if (jso[key].ToString() != "") { DateTime timeParsed; _timeAdded = DateTime.TryParseExact(jso[key].ToString(), "yyyy-dd-MM hh:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out timeParsed) ? timeParsed : (DateTime?) null; } break; case "timeclosed": if (jso[key].ToString() != "") { DateTime timeParsed; _timeClosed = DateTime.TryParseExact(jso[key].ToString(), "yyyy-dd-MM hh:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out timeParsed) ? timeParsed : (DateTime?) null; } break; case "timeassigned": if (jso[key].ToString() != "") { DateTime timeParsed; _timeAssigned = DateTime.TryParseExact(jso[key].ToString(), "yyyy-dd-MM hh:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out timeParsed) ? timeParsed : (DateTime?) null; } break; case "lastupdated": if (jso[key].ToString() != "") { DateTime timeParsed; _lastUpdated = DateTime.TryParseExact(jso[key].ToString(), "yyyy-dd-MM hh:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out timeParsed) ? timeParsed : (DateTime?) null; } break; case "subject": Subject = Convert.ToString(jso[key]); break; case "content": Content = Convert.ToString(jso[key]); break; case "attachment": _attachment = Convert.ToString(jso[key]); break; case "rating": _rating = Convert.ToInt32(jso[key]); break; case "responses": var os = jso[key] as IEnumerable; if (os != null) { foreach (JObject o in os) _responses.Add(new TicketResponse(o.ToObject<ApiDictionary>())); } break; } } }
/// <summary> /// Used internally to initialize the properties of this class. /// </summary> public Message(ApiDictionary jso) { foreach (string key in jso.Keys) { switch (key.ToLower()) { case "type": Type = Convert.ToInt32(jso[key]); break; case "clientreference": ClientReference = Convert.ToString(jso[key]); break; case "content": Content = Convert.ToString(jso[key]); break; case "direction": _direction = Convert.ToString(jso[key]); break; case "flashmessage": FlashMessage = Convert.ToBoolean(jso[key]); break; case "from": From = Convert.ToString(jso[key]); break; case "messageid": _messageId = new Guid(Convert.ToString(jso[key])); break; case "networkid": _networkId = Convert.ToString(jso[key]); break; case "rate": _rate = Convert.ToDouble(jso[key]); break; case "registereddelivery": RegisteredDelivery = Convert.ToBoolean(jso[key]); break; case "status": _status = Convert.ToString(jso[key]); break; case "time": //Time = Convert.ToDateTime(jso[key]); DateTime time; if (jso[key].ToString() != "") Time = DateTime.TryParseExact(jso[key].ToString(), "yyyy-dd-MM hh:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out time) ? time : (DateTime?) null; break; case "to": To = Convert.ToString(jso[key]); break; case "billinginfo": BillingInfo = Convert.ToString(jso[key]); break; case "udh": Udh = Convert.ToString(jso[key]); break; case "units": _units = Convert.ToDouble(jso[key]); break; case "updatetime": //_updateTime = Convert.ToDateTime(jso[key]); DateTime dateCreated; if (jso[key].ToString() != "") { _updateTime = DateTime.TryParseExact(jso[key].ToString(), "yyyy-dd-MM hh:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out dateCreated) ? dateCreated : (DateTime?) null; } break; } } }