static void Main(string[] args) { var apiKey = ExampleUtils.GetApiKey(args); var client = new Client(apiKey); var query = new PhoneQuery(PhoneNumber); Response<IPhone> response; try { response = client.FindPhones(query); } catch (FindException) { System.Console.Out.WriteLine("ReversePhone lookup for {0} failed!", PhoneNumber); throw; } if ((response != null) && (response.IsSuccess)) { var results = response.Results; System.Console.Out.WriteLine("ReversePhone lookup for {0} was successful, returning {1} root phone objects.{2}{2}", PhoneNumber, results.Count, System.Environment.NewLine); foreach (var phone in results) { ExampleUtils.DumpPhone(phone, 2); System.Console.Out.WriteLine(); } } #if DEBUG System.Console.Out.WriteLine("Press the ENTER key to quit..."); System.Console.In.ReadLine(); #endif }
public string Format(PhoneQuery.PhoneResponseType? responseType) { if (responseType == null) { return null; } switch (responseType.Value) { case PhoneQuery.PhoneResponseType.Regular: { return ResponseTypeRegularValue; } case PhoneQuery.PhoneResponseType.Lite: { return ResponseTypeLiteValue; } case PhoneQuery.PhoneResponseType.CallerId: { return ResponseTypeCallerIdValue; } default: { return null; } } }
public void ItShouldPrintAHumanReadablePhoneQuery() { var q = new PhoneQuery("2065551234"); var s = q.ToString(); Console.Out.WriteLine(s); Assert.IsTrue(s.StartsWith("PhoneQuery")); Assert.IsTrue(s.Contains("2065551234")); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Result); TextView name = FindViewById<TextView>(Resource.Id.NameLabel); TextView where = FindViewById<TextView>(Resource.Id.WhereLabel); try { string phoneNumber = Intent.GetStringExtra("PhoneNumber") ?? ""; if (string.IsNullOrWhiteSpace(phoneNumber)) { base.Finish(); } var apiKey = Resources.GetString(Resource.String.ApiKey); var client = new Client(apiKey); var phoneQuery = new PhoneQuery(phoneNumber); var response = client.FindPhones(phoneQuery); var phone = response.Results.FirstOrDefault(); if (phone == null) { name.Text = response.ResponseMessages.First().Text; } else { name.Text = phone.PersonAssociations.FirstOrDefault().Person.BestName; where.Text = phone.BestLocation.City + " " + phone.BestLocation.PostalCode; } MainActivity.transitionToast.Cancel(); } catch (Exception exc) { Toast.MakeText(this, exc.Message, ToastLength.Long).Show(); name.Text = exc.Message; } Button button = FindViewById<Button>(Resource.Id.ConfirmButton); button.Click += delegate { Toast.MakeText(this, "You are now signed in.", ToastLength.Long).Show(); }; }
public Response<IPhone> SearchProApi(string phoneNumber) { Response<IPhone> response; var apiKey = ConfigurationManager.AppSettings["api_key"]; var client = new Client(apiKey); var query = new PhoneQuery(phoneNumber); try { response = client.FindPhones(query); } catch (FindException) { throw new Exception(string.Format("ReversePhone lookup for {0} failed!", phoneNumber)); } return response; }
/// <summary> /// Executes the given query and returns the response. /// </summary> /// <param name="query">The query to perform</param> /// <returns>The response object</returns> public virtual Response<IPhone> FindPhones(PhoneQuery query) { return _phoneResultFinder.Find(query, this); }
public override Response<IPhone> FindPhones(PhoneQuery query) { if (this.ForceErrorResult) { throw new FindException("Stubbed client always errors!"); } var results = new List<IPhone>(); if (!this.ForceEmptyResult) { results.Add(_phone); } return new Response<IPhone>(this, results, GetDictionary(this), _emptyMessages); }