Beispiel #1
0
        public bool remReceivingNumber(ReceivingNumber num)
        {
            string url = CTM.Config.Endpoint() + "/accounts/" + this.token.account_id + "/numbers/" + this.id + "/receiving_numbers/" + num.id + "/rem.json";

              CTM.Response res = new CTM.Request(url, this.token).delete();

              if (res.error != null){ this.error = res.error; }
              return res.error == null;
        }
Beispiel #2
0
        static void UpdateReceivingNumber(ReceivingNumber rn)
        {
            if (rn.error != null){
            Console.WriteLine("ReceivingNumber has error: " + rn.error);
            return;
              }

              PrintReceivingNumber(rn);

              string oldname   = rn.name;
              string oldnumber = rn.number;

              rn.name = "Changed the name!";
              rn.number = "+266696687";      //anonymous

              if (!rn.save()){
            Console.WriteLine("Error saving receiving number: " + rn.error);
            rn.reload();
            return;
              }else{
            rn.reload();
              }

              PrintReceivingNumber(rn);

              rn.name   = oldname;
              rn.number = oldnumber;

              if (!rn.save()){
            Console.WriteLine("Error saving receiving number: " + rn.error);
            rn.reload();
            return;
              }else{
            rn.reload();
              }

               PrintReceivingNumber(rn);
        }
Beispiel #3
0
        /*
         * List receiving numbers on a number
         */
        public Page<ReceivingNumber> receiving_numbers(int page = 0)
        {
            string url = CTM.Config.Endpoint() + "/accounts/" + this.token.account_id + "/numbers/" + this.id + "/receiving_numbers.json";

              Hashtable parameters = new Hashtable();
              parameters["page"]   = page.ToString();

              CTM.Response res = new CTM.Request(url, token).get(parameters);

              if (res.error != null){
            return new Page<ReceivingNumber>(res.error);

              } else {
            int index = 0;
            ReceivingNumber[] numbers = new ReceivingNumber[res.data.receiving_numbers.Count];

            foreach (JObject number in res.data.receiving_numbers.Children<JToken>()) {
              numbers[index++] = new ReceivingNumber(number, token);
            }
            return new Page<ReceivingNumber>(numbers, page, (int)res.data.total_entries, (int)res.data.total_pages);
              }
        }
Beispiel #4
0
 static void PrintReceivingNumber(ReceivingNumber rn)
 {
     Console.WriteLine();
       if (rn.error == null){
     Console.WriteLine("ReceivingNumber: " + rn.id);
     Console.WriteLine("     Name: " + rn.name);
     Console.WriteLine("   Number: " + rn.number);
     Console.WriteLine("  Display: " + rn.display_number);
     Console.WriteLine("Formatted: " + rn.formatted);
       } else {
     Console.WriteLine("Error in receiving number: " + rn.error);
       }
 }