Exemple #1
0
        /*
         * Purchase a number, the number should be the full digit string from the .number within the list of numbers returned from
         * Number#search
         */
        public static Number buy(CTM.AuthToken token, string number)
        {
            string url = CTM.Config.Endpoint() + "/accounts/" + token.account_id + "/numbers.json";

              Hashtable parameters = new Hashtable();
              parameters["phone_number"] = number;

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

              if (res.error != null) {
            return ErrorNumber(token, res.error);

              } else{
            return new Number(res.data.number, token);
              }
        }
        public static AuthToken authorize(string api_key, string api_secret)
        {
            string url = CTM.Config.Endpoint() + "/authentication.json";

              // if (api_key == null || api_secret == null){
              //   Console.WriteLine("Error: missing API_KEY, API_SECRET ");
              //   return null;
              // }

              Hashtable options = new Hashtable();

              options["token"]  = api_key;
              options["secret"] = api_secret;

              CTM.Request  req = new CTM.Request(url);
              CTM.Response res = req.post(options);

              return (res.error != null ? new AuthToken(res.error)
                                : new AuthToken((string)res.data.token,
                                                (string)res.data.first_account.id)
              );
        }