public async void Handle([FromQuery] String code, [FromQuery] String access_token, [FromQuery] String subscriber_number) { if (Request.QueryString.HasValue) { //TODO: Check request origination //1. Via web form: check if has CODE, then do POST to get access token //2. Via SMS: (requires hosting) check if has access token // access token needs to be stored along phone number bool isRequestValid = false; bool isRegister = false; var queryValues = Microsoft.AspNetCore.WebUtilities.QueryHelpers.ParseQuery(Request.QueryString.Value); if (queryValues.ContainsKey("code")) { GlobeLabsClient globeLabs = new GlobeLabsClient(); var subscriber = await globeLabs.GetAccessToken(code); if (subscriber != null) { access_token = subscriber.access_token; subscriber_number = subscriber.subscriber_number; isRequestValid = true; isRegister = true; } } if (queryValues.ContainsKey("access_token") && queryValues.ContainsKey("subscriber_number")) { isRequestValid = true; isRegister = true; } if (isRequestValid) { if (isRegister) { using nachos.io.Client cli = new Client(base.ConnectionString); var subscriber = ContactIO.Find(cli, mobileNumber: subscriber_number); if (subscriber != null) { ContactIO.Upsert(cli, new io.model.Contact { Id = subscriber.Id, AccessToken = access_token }); } } } } }
static void Main(string[] args) { ParentSensorIOAbstract sio = null; Console.WriteLine("SIMPLE_ARRAY\nNO_ARRAY"); Console.WriteLine("What type of IO class you want to add in: "); string wtoi = Console.ReadLine(); if (wtoi == "SIMPLE_ARRAY") { sio = new ContactIONoLogic(); } else { sio = new ContactIO(); } sio.showDetails(); }
public void Handle([FromBody] UnsubscribedInfo info) { //todo: check origination if (info != null) { if (info.unsubscribed != null) { if (!String.IsNullOrEmpty(info.unsubscribed.subscriber_number)) { using nachos.io.Client cli = new Client(base.ConnectionString); var subscriber = ContactIO.Find(cli, mobileNumber: info.unsubscribed.subscriber_number); if (subscriber != null) { ContactIO.Unregister(cli, subscriber.Id); } } } } }