/********************************************************************** * * * checkForNewExperiment() * * **********************************************************************/ /** <summary> Sends a request to the server if an experiment is queued. </summary> <remarks> insert detailed description for checkForNewExperiment here... @cond INTERNAL documented by t.wilhelmer, 8.11.2015 @endcond </remarks> <param name="restAPI">In: RESTapi object with personalized x-apikey and userID. </param> <returns>New status for state machine. </returns> */ public Status checkForNewExperiment(RestAPI restAPI) { GETStatusResponse expResponse = new GETStatusResponse(); try { expResponse = (GETStatusResponse)restAPI.GETRequest(RequestEndpoint.status); } catch(Exception e) { logger.errorLog("An exception occurred in checkForNewExperiment() using apis/engine/experiment/" + RequestEndpoint.status); logger.errorLog("Exception message:"); logger.errorLog(e.Message); return Status.EXCEPTION; } if (expResponse.success == true) { Console.WriteLine("\nExperiment found!"); logger.log("checkForNewExperiment()"); logger.log("(" + expResponse.timestamp + ") - Experiment found : ExpId = " + expResponse.expId + "\n"); return Status.DEQUEUEEXPERIMENT; } else { Console.WriteLine("No experiment found!"); return Status.CHECKFOREXPERIMENT; } }
public Result UpdateTimesheetRecordIdByEmployeeAndWeekStartDate(TimesheetByEmployeeAndStartDateAndStatusViewModel objTimesheetRecord, string siteUrl) { Result res = new Result(); try { List <TimesheetWithWorkItems> objTimesheetList = GetTimesheetsByEmployeeAndWeekStartDate(objTimesheetRecord, siteUrl); foreach (var _recordIDObj in objTimesheetList) { Timesheet objTimesheet = new Timesheet(); objTimesheet.ID = _recordIDObj.ID; objTimesheet.RecordID = objTimesheetRecord.RecordID; UpdateTimesheet(objTimesheet, siteUrl); } res.StatusCode = StatusCode.Success; res.Message = Messages.MsgSuccessUpdate; return(res); } catch (Exception ex) { string guid = RestAPI.WriteException(ex, MethodBase.GetCurrentMethod().Name, MethodBase.GetCurrentMethod().DeclaringType.Name); res.Message = Messages.MsgSomethingWentWrong; res.StatusCode = StatusCode.Error; return(res); } }
static async Task <int> Main(string[] args) { try { //dapper test var db = new SqlConnection(secrets.ConnectionString); db.Open(); var ddd = db.Query <object>("select * from users"); //woocommerce api test RestAPI rest = new RestAPI(secrets.SiteAddress, secrets.ConsumerKey, secrets.ConsumerPass); WCObject wc = new WCObject(rest); //Get all products var products = await wc.Product.GetAll(); return(0); } catch (Exception ex) { var msg = ex.Message.UnicodeToString(); return(0); } }
static void Main(string[] args) { RestAPI plivo = new RestAPI("Your AUTH_ID", "Your AUTH_TOKEN"); IRestResponse <MessageResponse> resp = plivo.send_message(new Dictionary <string, string>() { { "src", "1111111111" }, // Sender's phone number with country code { "dst", "2222222222" }, // Receiver's phone number wiht country code // Your SMS text message - English { "text", "This randomly generated text can be used in your layout (webdesign , websites, books, posters ... ) for free. This text is entirely free of law. Feel free to link to this site by using the image below or by making a simple text link" } // Send uicode text // Your SMS text message - Japanese // {"text", "このランダムに生成されたテキストは、自由のためのあなたのレイアウト(ウェブデザイン、ウェブサイト、書籍、ポスター...)で使用することができます。このテキストは、法律の完全に無料です。下の画像を使用して、または単純なテキストリンクを作ることで、このサイトへのリンクフリーです"} // Your SMS text message - French // {"text", "Ce texte généré aléatoirement peut-être utilisé dans vos maquettes (webdesign, sites internet,livres, affiches...) gratuitement. Ce texte est entièrement libre de droit. N'hésitez pas à faire un lien sur ce site en utilisant l'image ci-dessous ou en faisant un simple lien texte} }); //Prints the message details Console.Write(resp.Content); // Get the details of the sent message string uuid = resp.Data.message_uuid[0]; RestAPI plivo1 = new RestAPI("Your AUTH_ID", "Your AUTH_TOKEN"); IRestResponse <Message> response = plivo1.get_message(new Dictionary <string, string>() { { "record_id", uuid } // Message UUID }); Console.WriteLine("Number of units : {0}", response.Data.units); Console.ReadLine(); }
public Result UpdateTimesheetRecordId(List <SyncRecordID> objRecordIDs, string siteUrl) { Result res = new Result(); try { Timesheet objTimesheet = new Timesheet(); int recordsUpdatedCounter = 0; foreach (var _recordIDObj in objRecordIDs) { Result updateResult = new Result(); objTimesheet.ID = _recordIDObj.ID; objTimesheet.RecordID = _recordIDObj.RecordID; updateResult = UpdateTimesheet(objTimesheet, siteUrl); if (updateResult.StatusCode.Equals(1)) { recordsUpdatedCounter++; } } res.StatusCode = StatusCode.Success; res.Message = recordsUpdatedCounter + " " + Messages.MsgSuccessRecordsUpdate; return(res); } catch (Exception ex) { string guid = RestAPI.WriteException(ex, MethodBase.GetCurrentMethod().Name, MethodBase.GetCurrentMethod().DeclaringType.Name); res.Message = Messages.MsgSomethingWentWrong; res.StatusCode = StatusCode.Error; return(res); } }
public async Task <List <string> > GetTopSellerReport(Dictionary <string, string> parms = null) { string json = await API.SendHttpClientRequest("reports/sales/top_sellers", RequestMethod.GET, string.Empty, parms); json = json.Substring(json.IndexOf(':') + 1, json.Length - json.IndexOf(':') - 2); return(RestAPI.DeserializeJSon <List <string> >(json)); }
public async Task <WebhookDeliveryList> GetWebhookDeliveries(int webhookid, Dictionary <string, string> parms = null) { string json = await API.SendHttpClientRequest("webhooks/" + webhookid.ToString() + "/deliveries", RequestMethod.GET, string.Empty, parms); json = json.Substring(json.IndexOf(':') + 1, json.Length - json.IndexOf(':') - 2); return(RestAPI.DeserializeJSon <WebhookDeliveryList>(json)); }
public APIController() { // Utilizamos o segredo aqui no caso de exemplo RestAPI rest = new RestAPI("https://mindboggle-257618.easywp.com/wp-json/wc/v3/", "ck_677e2069693b2a64310671ca9de93c1090f7e294", "cs_b1b0300b985fa3ccf3bbdec4f3d57e3734a05837"); wc = new WCObject(rest); }
public async Task <Customer> GetCustomerByEmail(string email, Dictionary <string, string> parms = null) { string json = await API.SendHttpClientRequest("customers/email/" + email, RequestMethod.GET, string.Empty, parms); json = json.Substring(json.IndexOf(':') + 1, json.Length - json.IndexOf(':') - 2); return(RestAPI.DeserializeJSon <Customer>(json)); }
public async Task <WebhookDelivery> GetWebhookDelivery(int webhookid, int deliveryid, Dictionary <string, string> parms = null) { string json = await API.GetRestful("webhooks/" + webhookid.ToString() + "/deliveries/" + deliveryid.ToString(), parms); json = json.Substring(json.IndexOf(':') + 1, json.Length - json.IndexOf(':') - 2); return(RestAPI.DeserializeJSon <WebhookDelivery>(json)); }
public WCOrderItem(RestAPI api) : base(api) { API = api; Notes = new WCSubItem <T7>(api, APIEndpoint); Refunds = new WCSubItem <T8>(api, APIEndpoint); }
public WCProductItem(RestAPI api) : base(api) { API = api; Reviews = new WCSubItem <T4>(api, APIEndpoint); Variations = new WCSubItem <T5>(api, APIEndpoint); }
static void Main(string[] args) { RestAPI plivo = new RestAPI("Your AUTH_ID", "Your AUTH_TOKEN"); // Link an application to a phone number IRestResponse<GenericResponse> resp = plivo.link_application_number(new Dictionary<string,string>() { {"number","1111111111"}, // Number that has to be linked to an application {"app_id","16632742496743552"} // Application ID that has to be linked }); Console.WriteLine(resp.Content); Debug.WriteLine(resp.Content); // Unlink an application from a phone number IRestResponse<GenericResponse> response = plivo.unlink_application_number(new Dictionary<string, string>() { {"number","1111111111"} // Number that has to be unlikned to an application }); Console.WriteLine(response.Content); Debug.WriteLine(response.Content); Console.ReadLine(); }
public WCObject(RestAPI api) { if (api.Version != APIVersion.Version3) { throw new Exception("Please use WooCommerce Restful API Version 3 url for this WCObject. e.g.: http://www.yourstore.co.nz/wp-json/wc/v3/"); } API = api; Coupon = new WCItem <T1>(api); Customer = new WCItem <T2>(api); Product = new WCProductItem(api); Order = new WCOrderItem(api); Attribute = new WCAttributeItem(api); Category = new WCItem <T11>(api); ShippingClass = new WCItem <T12>(api); Tag = new WCItem <T13>(api); Report = new WCItem <Report>(api); TaxRate = new WCItem <T14>(api); TaxClass = new WCItem <T15>(api); Webhook = new WCItem <Webhook>(api); PaymentGateway = new WCItem <PaymentGateway>(api); ShippingZone = new WCShippingZoneItem(api); ShippingMethod = new WCItem <ShippingMethod>(api); SystemStatus = new WCItem <SystemStatus>(api); SystemStatusTool = new WCItem <SystemStatusTool>(api); Setting = new WCItem <Setting>(api); Data = new WCItem <Data>(api); Plugin = new WCItem <Plugins>(api); }
public WCShippingZoneItem(RestAPI api) : base(api) { API = api; Locations = new WCSubItem <ShippingZoneLocation>(api, APIEndpoint); Methods = new WCSubItem <ShippingZoneMethod>(api, APIEndpoint); }
static void Main(string[] args) { RestAPI plivo = new RestAPI("Your AUTH_ID", "Your AUTH_TOKEN"); // Without Filters IRestResponse<CDRList> resp = plivo.get_cdrs(new Dictionary<string, string>() {}); //Prints the message details Console.Write(resp.Content); // Filtering the response IRestResponse<CDRList> resp = plivo.get_cdrs(new Dictionary<string, string>() { { "end_time_gt", "2015-02-10 11:47" }, // Filter out calls according to the time of completion. gte stands for greater than or equal. { "call_direction", "outbound" }, // Filter the results by call direction. The valid inputs are inbound and outbound { "from_number","1111111111"}, // Filter the results by the number from where the call originated { "to_number","2222222222"}, // Filter the results by the number to which the call was made { "limit","2"}, // The number of results per page { "offset","0"} // The number of value items by which the results should be offset }); //Prints the message details Console.Write(resp.Content); Console.ReadLine(); }
static void Main(string[] args) { RestAPI plivo = new RestAPI("Your AUTH_ID", "Your AUTH_TOKEN"); // API ID is returned for every API request. // Request UUID is request id of the call. This ID is returned as soon as the call is fired irrespective of whether the call is answered or not IRestResponse<Call> resp = plivo.make_call(new Dictionary<string, string>() { { "from", "1111111111" }, // The phone number to which the call has to be placed { "to", "2222222222" }, // The phone number to be used as the caller Id { "answer_url", "http://dotnettest.apphb.com/speak" }, // The URL invoked by Plivo when the outbound call is answered { "answer_method","GET"} // The method used to invoke the answer_url }); //Prints the response Console.Write(resp.Content); // Call UUID is th id of a live call. This ID is returned only after the call is answered. IRestResponse<LiveCall> resp = plivo.get_live_call(new Dictionary<string,string>() { { "call_uuid", "cd8fb3a0-b2a6-11e4-9a04-f5504e456438" } // The status of the call }); //Prints the message details Console.Write(resp.Content); Console.ReadLine(); }
public async Task <Order_Refund> GetOrderRefund(int orderid, int refundid, Dictionary <string, string> parms = null) { string json = await API.SendHttpClientRequest("orders/" + orderid.ToString() + "/refunds/" + refundid.ToString(), RequestMethod.GET, string.Empty, parms); json = json.Substring(json.IndexOf(':') + 1, json.Length - json.IndexOf(':') - 2); return(RestAPI.DeserializeJSon <Order_Refund>(json)); }
public async Task <IRestResult <List <CovidUpdatesModel> > > GetCovidUpdates(bool globalData, CancellationTokenSource cancellationTokenSource = default(CancellationTokenSource)) { Dictionary <string, string> param = new Dictionary <string, string>(); param.Add("globalData", globalData.ToString()); return(await RestAPI.GetAsync <List <CovidUpdatesModel> >(APIConstants.CovidUpdates, param, cancellationTokenSource)); }
public async Task <Product_Category> GetProductCategory(int categoryid, Dictionary <string, string> parms = null) { string json = await API.SendHttpClientRequest("products/categories/" + categoryid.ToString(), RequestMethod.GET, string.Empty, parms); json = json.Substring(json.IndexOf(':') + 1, json.Length - json.IndexOf(':') - 2); return(RestAPI.DeserializeJSon <Product_Category>(json)); }
protected void Page_Load(object sender, EventArgs e) { int type = 99; int[] args = new int[10] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; string[] strArgs = new String[3] { "", "", "" }; if (!int.TryParse(Utility.GetQueryString(Request, "type", "99"), out type)) { return; } for (int i = 0; i < 10; ++i) { if (!int.TryParse(Utility.GetQueryString(Request, "Arg" + (i + 1), "99"), out args[i])) { return; } } for (int i = 0; i < 3; ++i) { strArgs[i] = Utility.SecureInput(Utility.GetQueryString(Request, "StrArg" + (i + 1), "")); } Response.Clear(); Response.ContentType = "application/json; charset=utf-8"; Response.Write(RestAPI.Get(type, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9], strArgs[0], strArgs[1], strArgs[2])); Response.End(); }
public RestAPI CheckUser(string username, string password) { RestAPI restAPI = new RestAPI(); UesrInfo userinfo = new UesrInfo(); using (SHA256 sha256Hash = SHA256.Create()) { // ComputeHash - returns byte array byte[] bytes = sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(password)); // Convert byte array to a string StringBuilder builder = new StringBuilder(); for (int i = 0; i < bytes.Length; i++) { builder.Append(bytes[i].ToString("x2")); } User user = new User(); user = _DouligoDbContext.User.Where(x => x.username == username). Where(x => x.password == builder.ToString()).Where(x => x.activated == 1).FirstOrDefault(); if (user != null) { restAPI.StatusCode = 200; userinfo.username = user.username; userinfo.email = user.email; restAPI.Data = userinfo; } else { restAPI.StatusCode = -1; } } return(restAPI); }
static void Main(string[] args) { RestAPI plivo = new RestAPI("Your AUTH_ID", "Your AUTH_TOKEN"); IRestResponse<MessageResponse> resp = plivo.send_message(new Dictionary<string, string>() { { "src", "1111111111" }, // Sender's phone number with country code { "dst", "2222222222" }, // Receiver's phone number wiht country code // Your SMS text message - English { "text", "This randomly generated text can be used in your layout (webdesign , websites, books, posters ... ) for free. This text is entirely free of law. Feel free to link to this site by using the image below or by making a simple text link" } // Send uicode text // Your SMS text message - Japanese // {"text", "このランダムに生成されたテキストは、自由のためのあなたのレイアウト(ウェブデザイン、ウェブサイト、書籍、ポスター...)で使用することができます。このテキストは、法律の完全に無料です。下の画像を使用して、または単純なテキストリンクを作ることで、このサイトへのリンクフリーです"} // Your SMS text message - French // {"text", "Ce texte généré aléatoirement peut-être utilisé dans vos maquettes (webdesign, sites internet,livres, affiches...) gratuitement. Ce texte est entièrement libre de droit. N'hésitez pas à faire un lien sur ce site en utilisant l'image ci-dessous ou en faisant un simple lien texte} }); //Prints the message details Console.Write(resp.Content); // Get the details of the sent message string uuid = resp.Data.message_uuid[0]; RestAPI plivo1 = new RestAPI("Your AUTH_ID", "Your AUTH_TOKEN"); IRestResponse<Message> response = plivo1.get_message(new Dictionary<string, string>() { { "record_id", uuid } // Message UUID }); Console.WriteLine("Number of units : {0}", response.Data.units); Console.ReadLine(); }
private async void InitRemote() { if (_isInitialized.Value) { return; } try { var models = await RestAPI.Get(ApiEndpoint); foreach (var model in models) { var dim = new DataDimension(); dim.Column = model["column"].Value <string>(); dim.DisplayName = model["displayName"].Value <string>(); dim.HideTicks = model["hideTicks"].Value <bool>(); dim.Ticks = model["ticks"].Select(t => new DataDimension.Tick { Name = t["name"].Value <string>(), Value = t["value"].Value <float>() }).ToArray(); _dimensions.Add(dim); } _isInitialized.OnNext(true); } catch (Exception e) { Debug.LogError(e.Message); } }
public async Task <IRestResult <string> > GetOtp(string phoneNumber, CancellationTokenSource cancellationTokenSource = default(CancellationTokenSource)) { Dictionary <string, string> param = new Dictionary <string, string>(); param.Add("PhoneNumber", phoneNumber); return(await RestAPI.PostAsync <string>(APIConstants.GetOTPUrl, param, cancellationTokenSource)); }
public static async void GetAllProduct1() { var key = "ck_11eedd67dd05dadef7e9e3e5142d34536e6b5c4e"; var secret = "cs_bf52a8cf72941b774a9dd3e8ea1ea7314f67324c"; RestAPI rest = new RestAPI("http://jivori.com/wp-json/wc/v3/", key, secret); WCObject wc = new WCObject(rest); var dic = new System.Collections.Generic.Dictionary <string, string>(); dic.Add("per_page", "100"); int pageNumber = 1; dic.Add("page", pageNumber.ToString()); var products = new List <Product>(); bool endWhile = false; while (!endWhile) { var productsTemp = wc.Product.GetAll(dic).Result; if (productsTemp.Count > 0) { products.AddRange(productsTemp); products.ForEach(p => { Console.WriteLine(p.name); }); pageNumber++; dic["page"] = pageNumber.ToString(); } else { endWhile = true; } } Console.WriteLine("products.Count=" + products.Count); }
public async Task <int> GetProductCount() { int _count = 0; RestAPI _RestAPI = _Woo.GetRootRestAPI; try { string Result = await _RestAPI.GetRestful("products/count"); if (Result.Contains("count")) { int _from = Result.IndexOf(":"); int _to = Result.IndexOf("}"); _count = Convert.ToInt32(Result.Substring(_from + 1, _to - _from - 1)); } } catch (Exception ex) { if (_Woo.Logger != null) { _Woo.Logger.LogError("Error calling WOO REST ROOT API: " + ex.Message); } } return(_count); }
static void Main(string[] args) { RestAPI plivo = new RestAPI("Your AUTH_ID", "Your AUTH_TOKEN"); IRestResponse<MessageResponse> resp = plivo.send_message(new Dictionary<string, string>() { { "src", "1111111111" }, // Sender's phone number with country code { "dst", "2222222222" }, // Receiver's phone number wiht country code { "text", "Hi, text from Plivo." } // Your SMS text message // To send Unicode text // {"text", "こんにちは、元気ですか?"} // Your SMS text message - Japanese // {"text", "Ce est texte généré aléatoirement"} // Your SMS text message - French { "url", "http://dotnettest.apphb.com/delivery_report"}, // The URL to which with the status of the message is sent { "method", "POST"} // Method to invoke the url }); //Prints the message details Console.Write(resp.Content); // Print the message_uuid Console.WriteLine(resp.Data.message_uuid[0]) // Print the api_id Console.WriteLine(resp.Data.api_id) Console.ReadLine(); }
private async Task <List <Product> > GetAllWithParams(Dictionary <string, string> pProductParams) { List <Product> _WooProducts = null; int _Page = 1; bool _GetMore = true; // if there is no page setting adding if (pProductParams.ContainsKey("page")) { pProductParams["page"] = "0"; } else { pProductParams.Add("page", "0"); } if (pProductParams.ContainsKey("per_page")) { pProductParams["per_page"] = "20"; } else { pProductParams.Add("per_page", "20"); } // retrieve products until the number of products returned is 0. try { RestAPI _RestAPI = _Woo.GetJSONRestAPI; WCObject _WC = new WCObject(_RestAPI); while (_GetMore) { pProductParams["page"] = _Page.ToString(); List <Product> TwentyProducts = await _WC.Product.GetAll(pProductParams); if (TwentyProducts.Count > 0) { if (_WooProducts == null) { _WooProducts = TwentyProducts; } else { _WooProducts.AddRange(TwentyProducts); } _Page++; } else { _GetMore = false; } } } catch (Exception ex) { if (_Woo.Logger != null) { _Woo.Logger.LogError("Error calling WOO REST API: " + ex.Message); } } return(_WooProducts); }
static void Main(string[] args) { RestAPI plivo = new RestAPI(auth_id, auth_token); // Place a call IRestResponse<Call> resp = plivo.make_call(new dict { { "to", "11111111111" }, { "from", "22222222222" }, { "answer_url", "http://some.domain/answer/" }, { "answer_method", "GET" }, // add sip headers //{ "sip_headers", "sipheader1=value1,sipheader2=value2" }, }); if (resp.Data != null) { PropertyInfo[] proplist = resp.Data.GetType().GetProperties(); foreach (PropertyInfo property in proplist) Console.WriteLine("{0}: {1}", property.Name, property.GetValue(resp.Data, null)); } else Console.WriteLine(resp.ErrorMessage); // Place bulk call with sip headers for each call IRestResponse<BulkCall> resp = plivo.make_bulk_call(new dict { { "from", "22222222222" }, { "answer_url", "http://some.domain/answer/" }, { "answer_method", "GET" }, }},
public async Task <OrderList> GetOrders(Dictionary <string, string> parms = null) { string json = await API.SendHttpClientRequest("orders", RequestMethod.GET, string.Empty, parms); json = json.Substring(json.IndexOf(':') + 1, json.Length - json.IndexOf(':') - 2); return(RestAPI.DeserializeJSon <OrderList>(json)); }
private async void btn_login_Click(object sender, RoutedEventArgs e) { progress_bar.Visibility = Visibility.Visible; btn_login.IsEnabled = false; LoginRequest loginRequest = new LoginRequest { username = txt_username.Text, password = txt_password.Password }; LoginResponse loginResponse = await RestAPI.PostLogin(loginRequest); progress_bar.Visibility = Visibility.Collapsed; if (loginResponse.token != null) { LoginResponse.access_token = loginResponse.token; if (send != null) { send.Invoke(); this.Close(); } } else { MessageBox.Show("Login Fail"); btn_login.IsEnabled = true; } }
public async Task <DownloadList> GetCustomerDownloads(int id, Dictionary <string, string> parms = null) { string json = await API.GetRestful("customers/" + id.ToString() + "/downloads", parms); json = json.Substring(json.IndexOf(':') + 1, json.Length - json.IndexOf(':') - 2); return(RestAPI.DeserializeJSon <DownloadList>(json)); }
public async Task <Coupon> GetCoupon(string code, Dictionary <string, string> parms = null) { string json = await API.SendHttpClientRequest("coupons/code/" + code, RequestMethod.GET, string.Empty, parms); json = json.Substring(json.IndexOf(':') + 1, json.Length - json.IndexOf(':') - 2); return(RestAPI.DeserializeJSon <Coupon>(json)); }
public static Result AddListItem <T>(string listName, T obj) { string id = string.Empty; string itemPostBody = GenerateJsonFromObject.GenerateJson <T>(obj, out id); string DomainName = Convert.ToString(WebConfigurationManager.AppSettings["DomainName"]); string SiteUrl = Convert.ToString(WebConfigurationManager.AppSettings["SiteUrl"]); string accessToken = (HttpContext.Current.Request.Headers["Authorization"]).Split(' ')[1]; string errorLogPath = Convert.ToString(WebConfigurationManager.AppSettings["ErrorLogPath"]); Result res = new Result(); try { RestAPI.AddListItems(SiteUrl, errorLogPath, accessToken, Lists.ListURLs.RestUrlList(listName), Lists.ListURLs.RestUrlListItemWithQuery(listName, false), itemPostBody, Convert.ToString(GetUserInfo.UserID)); res.StatusCode = StatusCode.Success; res.Message = Messages.MsgSuccessAdd; return(res); } catch (Exception ex) { string guid = RestAPI.WriteException(ex, MethodBase.GetCurrentMethod().Name, MethodBase.GetCurrentMethod().DeclaringType.Name); throw new Exception(string.Format(Lists.Messages.MsgExceptionOccured, guid)); } }
public async Task <ProductReviewList> GetProductReviews(int productid, Dictionary <string, string> parms = null) { string json = await API.SendHttpClientRequest("products/" + productid.ToString() + "/reviews", RequestMethod.GET, string.Empty, parms); json = json.Substring(json.IndexOf(':') + 1, json.Length - json.IndexOf(':') - 2); return(RestAPI.DeserializeJSon <ProductReviewList>(json)); }
public Result UpdateTimesheetSyncStatusByRecordID(List <SyncStatusByRecordID> objSyncStatus, string siteUrl) { Result res = new Result(); try { int recordsUpdatedCounter = 0; foreach (var _recordIDObj in objSyncStatus) { List <TimesheetWithWorkItems> objWorkItemList = GetTimesheetByRecordID(_recordIDObj.RecordID, siteUrl); foreach (var timesheetRecord in objWorkItemList) { Timesheet objTimesheetItem = new Timesheet(); Result updateResult = new Result(); objTimesheetItem.ID = timesheetRecord.ID; objTimesheetItem.IsSynced = _recordIDObj.IsSynced; updateResult = UpdateTimesheet(objTimesheetItem, siteUrl); if (updateResult.StatusCode.Equals(1)) { recordsUpdatedCounter++; } } } res.StatusCode = StatusCode.Success; res.Message = recordsUpdatedCounter + " " + Messages.MsgSuccessRecordsUpdate; return(res); } catch (Exception ex) { string guid = RestAPI.WriteException(ex, MethodBase.GetCurrentMethod().Name, MethodBase.GetCurrentMethod().DeclaringType.Name); res.Message = Messages.MsgSomethingWentWrong; res.StatusCode = StatusCode.Error; return(res); } }
public Program() { Get["/record_api"] = x => { Plivo.XML.Response resp = new Plivo.XML.Response(); String getdigits_action_url = "http://dotnettest.apphb.com/recording_action"; GetDigits gd = new GetDigits("", new Dictionary<string, string>() { {"action",getdigits_action_url}, // The URL to which the digits are sent {"method","GET"}, // Submit to action URL using GET or POST. {"timeout","7"}, // Time in seconds to wait to receive the first digit. {"numDigitd","1"}, // Maximum number of digits to be processed in the current operation. {"retries","1"}, // Indicates the number of retries the user is allowed to input the digits {"redirect","false"} // Redirect to action URL if true. If false,only request the URL and continue to next element. }); gd.AddSpeak("Press 1 to record this call", new Dictionary<string, string>()); resp.Add(gd); resp.AddWait(new Dictionary<string, string>() { {"length","10"} // Time to wait in seconds }); Debug.WriteLine(resp.ToString()); var output = resp.ToString(); var res = (Nancy.Response)output; res.ContentType = "text/xml"; return res; }; Get["/recording_action"] = x => { String digits = Request.Query["Digits"]; String uuid = Request.Query["CallUUID"]; Debug.WriteLine("Digit pressed : {0}, Call UUID : {1}", digits, uuid); if (digits == "1") { string auth_id = "Your AUTH_ID"; string auth_token = "Your AUTH_TOKEN"; RestAPI plivo = new RestAPI(auth_id, auth_token); IRestResponse<Plivo.API.Record> resp = plivo.record(new Dictionary<string, string>() { { "call_uuid", uuid } // ID of the call }); Debug.WriteLine(resp.Content); } else { Debug.WriteLine("Invalid"); } return "OK"; }; }
public void SetUp() { api = new RestAPI(NetellerEnvironment.Test); //always use same culture to avoid formatting differences Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); }
static void Main(string[] args) { RestAPI plivo = new RestAPI("Your AUTH_ID", "Your AUTH_TOKEN"); IRestResponse<PlivoPricing> resp = plivo.pricing(new Dictionary<string, string>() { {"country_iso","GB"} }); Console.WriteLine(resp.Content); Console.ReadLine(); }
static void Main(string[] args) { RestAPI plivo = new RestAPI("Your AUTH_ID", "Your AUTH_TOKEN"); IRestResponse<Message> resp = plivo.get_message(new Dictionary<string, string>() { { "record_id", "1aead330-8ff9-11e4-9bd8-22000afa12b9" } // Message UUID }); //Prints the message details Console.Write(resp.Content); Console.ReadLine(); }
public Program() { // Generates a Conference XML Get["/conference"] = x => { Plivo.XML.Response resp = new Plivo.XML.Response(); resp.AddSpeak("You will now be placed into a demo conference. This is brought to you by Plivo. To know more, visit us at Plivo.com", new Dictionary<string, string>() { }); resp.AddConference("demo", new Dictionary<string, string>() { {"enterSound","beep:1"}, // Used to play a sound when a member enters the conference {"callbackUrl","http://dotnettest.apphb.com/conf_callback"}, // If specified, information is sent back to this URL {"callbackMethod","GET"}, // Method used to notify callbackUrl }); Debug.WriteLine(resp.ToString()); var output = resp.ToString(); var res = (Nancy.Response)output; res.ContentType = "text/xml"; return res; }; // Record API is called in the callback URL to record the conference Get["/conf_callback"] = x => { String events = Request.Query["Event"]; String conf_name = Request.Query["ConferenceName"]; // The recording starts when the user enters the conference room if (events == "ConferenceEnter") { string auth_id = "Your AUTH_ID"; string auth_token = "Your AUTH_TOKEN"; RestAPI plivo = new RestAPI(auth_id, auth_token); IRestResponse<Plivo.API.Record> resp = plivo.record_conference(new Dictionary<string, string>() { {"conference_name",conf_name} // Name of the conference }); Debug.WriteLine(resp.Content); } else { Debug.WriteLine("Invalid"); } return "Done"; }; }
static void Main(string[] args) { RestAPI plivo = new RestAPI("Your AUTH_ID", "Your AUTH_TOKEN"); IRestResponse<CDR> resp = plivo.get_cdr(new Dictionary<string, string>() { { "record_id", "064c0e98-b1e2-11e4-989e-c73b3246dc2a" } // The ID of the call }); //Prints the message details Console.Write(resp.Content); Console.ReadLine(); }
static void Main(string[] args) { RestAPI plivo = new RestAPI("Your AUTH_ID", "Your AUTH_TOKEN"); IRestResponse<GenericResponse> resp = plivo.hangup_call(new Dictionary<string, string>() { { "call_uuid", "defb0706-86a6-11e4-b303-498d468c930b" } // UUID of the call to be hung up }); //Prints the response Console.Write(resp.Content); Console.ReadLine(); }
static void Main(string[] args) { RestAPI plivo = new RestAPI("Your AUTH_ID", "Your AUTH_TOKEN"); IRestResponse<LiveCall> resp = plivo.get_live_call(new Dictionary<string,string>() { { "call_uuid", "cd8fb3a0-b2a6-11e4-9a04-f5504e456438" } // The status of the call }); //Prints the message details Console.Write(resp.Content); Console.ReadLine(); }
static void Main(string[] args) { RestAPI plivo = new RestAPI("Your AUTH_ID", "Your AUTH_TOKEN"); IRestResponse<MessageResponse> resp = plivo.send_message(new Dictionary<string, string>() { { "src", "ALPHA" }, // Alphanumeric sender ID { "dst", "1111111111" }, // Receiver's phone number wiht country code { "text", "Hi, text from plivo" } // Your SMS text message }); //Prints the message details Console.Write(resp.Content); Console.ReadLine(); }
/// <summary> /// Initializes a new instance of the <see cref="SmsService" /> class. /// </summary> /// <param name="authToken"> The plivo AuthToken. </param> /// <param name="accountSid"> The plivo Account Sid. </param> /// <param name="fromNumber"> the plivo from number. </param> /// <param name="loggerService"> The logger service</param> /// <param name="mapperFactory">the mapper factory</param> public SmsService(string authToken, string accountSid, string fromNumber, ILoggerService loggerService, IMapperFactory mapperFactory) { try { this.plivo = new RestAPI(accountSid, authToken); } catch (Exception ex) { this.loggerService.LogException(ex.Message); } this.fromNumber = fromNumber; this.loggerService = loggerService; this.mapperFactory = mapperFactory; }
static void Main(string[] args) { RestAPI plivo = new RestAPI("Your AUTH_ID", "Your AUTH_TOKEN"); // To record a call IRestResponse<Plivo.API.Record> resp = plivo.record(new Dictionary<string, string>() { {"call_uuid", "xxxxxxxxxxx" } // ID of the call {"time_limit","40"}, // Max recording duration in seconds {"callback_url","http://dotnettest.apphb.com/record_callback"}, // The URL invoked by the API when the recording ends {"callback_method","GET"}, // The method which is used to invoke the callback_url {"transcriptionType","auto"}, // The type of transcription required {"transcriptionUrl","http://dotnettest.apphb.com/transcription"}, // The URL where the transcription while be sent from Plivo {"transcriptionMethod","GET"}, // The method used to invoke transcriptionUrl }); Debug.WriteLine(resp.Content); // To stop recording a call IRestResponse<Plivo.API.Record> resp = plivo.stop_record(new Dictionary<string, string>() { { "call_uuid", "xxxxxxxxxxx" } // ID of the call }); Debug.WriteLine(resp.Content); // To record a conference call IRestResponse<Plivo.API.Record> resp = plivo.record_conference(new Dictionary<string, string>() { {"conference_name", "demo" } // The conference name {"callback_url","http://dotnettest.apphb.com/record_callback"}, // The URL invoked by the API when the recording ends {"callback_method","GET"}, // The method which is used to invoke the callback_url }); Debug.WriteLine(resp.Content); // To stop recording a conference IRestResponse<Plivo.API.Record> resp = plivo.stop_record_conference(new Dictionary<string, string>() { {"conference_name", "demo" } // The conference name }); Debug.WriteLine(resp.Content); Console.ReadLine(); }
static void Main(string[] args) { RestAPI plivo = new RestAPI("Your AUTH_ID", "Your AUTH_TOKEN"); // Search for a new phone number IRestResponse<PhoneNumberList> resp = plivo.search_phone_numbers(new Dictionary<string,string>() { {"country_iso","US"}, // The ISO code A2 of the country {"type","local"}, // The type of number you are looking for. The possible number types are local, national and tollfree. {"pattern","210"}, // Represents the pattern of the number to be searched. {"region","Texas"} // This filter is only applicable when the number_type is local. Region based filtering can be performed. }); Console.WriteLine(resp.Content); Debug.WriteLine(resp.Content); // Buy a new phone number IRestResponse<PhoneNumberResponse> res = plivo.buy_phone_number(new Dictionary<string, string>() { {"number","12109206499"} // The phone number that has to be rented }); Console.WriteLine(res.Content); Debug.WriteLine(res.Content); //Modify a number IRestResponse<PhoneNumberResponse> res = plivo.modify_number(new Dictionary<string, string>() { {"number","12109206499"}, // The phone number that has to be rented {"alias","Test"}, //The textual name given to the number {"subaccount","Your SUB_AUTH_ID"} //The auth_id of the subaccount to which this number should be added. }); Console.WriteLine(res.Content); Debug.WriteLine(res.Content); // Unrent a number IRestResponse<GenericResponse> response = plivo.unrent_number(new Dictionary<string, string>() { {"number","12109206499"} // Number that has to be unrented }); Console.WriteLine(response.Content); Debug.WriteLine(response.Content); Console.ReadLine(); }
static void Main(string[] args) { RestAPI plivo = new RestAPI("Your AUTH_ID", "Your AUTH_TOKEN"); IRestResponse<Call> resp = plivo.make_call(new Dictionary<string,string>() { { "to", "2222222222<3333333333" }, // The phone number to which the call has to be placed {"from", "1111111111"}, // The phone number to be used as the caller id {"answer_url","http://dotnettest.apphb.com/response/conference"}, // The URL invoked by Plivo when the outbound call is answered {"answer_method","GET"} // The method used to call the answer_url }); //Prints the message details Console.Write(resp.Content); Console.ReadLine(); }
static void Main(string[] args) { RestAPI plivo = new RestAPI("Your AUTH_ID", "Your AUTH_TOKEN"); IRestResponse<Call> resp = plivo.make_call(new Dictionary<string, string>() { { "from", "1111111111" }, // The phone number to which the call has to be placed { "to", "sip:[email protected]" }, // The phone number to be used as the caller Id { "answer_url", "http://dotnettest.apphb.com/speak" }, // The URL invoked by Plivo when the outbound call is answered {"answer_method","GET"}, // The method used to invoke the answer_url {"sip_headers","Test=Sample"} // List of SIP Headers in the form of 'key=value' pairs, separated by commas }); //Prints the response Console.Write(resp.Content); Console.ReadLine(); }
public void GetAllSubscriptions() { //note: throws an exception if no subscriptions exist, by design of Neteller. NetellerEnvironment[] environments = new[] { NetellerEnvironment.Test, NetellerEnvironment.Production }; foreach (var environment in environments) { api = new RestAPI(environment); Console.WriteLine("Subscriptions in " + environment); Console.WriteLine("==============================="); var subs = api.GetSubscriptions(); foreach (var subscription in subs.list.ToList()) { //with resource expansion (not supported by Neteller on this function yet!) //string customerId = subscription.Customer.id; //string planId = subscription.Plan.planId; //wihtout resource expansion string customerId = subscription.Customer.link.url.Substring(subscription.Customer.link.url.LastIndexOf("/") + 1); string planId = subscription.Plan.link.url.Substring(subscription.Plan.link.url.LastIndexOf("/") + 1); //Customer customer = api.GetCustomerFromCustomerId(customerId); //string customerInfo = string.Format("Email {0} Name {1} {2}", customer.accountProfile.email, customer.accountProfile.firstName, customer.accountProfile.lastName); string customerInfo = string.Format("ID {0}", customerId); Console.WriteLine("Subscription ID {0,-3} Status {1} Start {2} End {3} Customer {4} PlanID: {5}", subscription.SubscriptionId, subscription.Status, subscription.StartDate, subscription.EndDate, customerInfo, planId ); } Assert.That(subs.list, Is.Not.Empty); } }
static void Main(string[] args) { RestAPI plivo = new RestAPI("Your AUTH_ID", "Your AUTH_TOKEN"); IRestResponse<Call> resp = plivo.make_call(new Dictionary<string, string>() { { "from", "1111111111" }, // The phone number to which the call has to be placed { "to", "2222222222" }, // The phone number to be used as the caller Id { "answer_url", "http://dotnettest.apphb.com/speak" }, // The URL invoked by Plivo when the outbound call is answered { "answer_method","GET"}, // The method used to invoke the answer_url // Example for Asynchronous request // {"callback_url","http://dotnettest.apphb.com/callback"}, // {"callback_method","GET"} }); //Prints the response Console.Write(resp.Content); Console.ReadLine(); }
static void Main(string[] args) { RestAPI plivo = new RestAPI("XXXXXXXXXXXXXXXXXXXXXXX", "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY"); IRestResponse<MessageResponse> resp = plivo.send_message(new Dictionary<string, string>() { { "src", "11212121211" }, { "dst", "12212121211" }, { "text", "Hi, text from Plivo." }, { "url", "http://some.domain/receivestatus/" }, { "method", "GET" } }); if (resp.Data != null) { PropertyInfo[] proplist = resp.Data.GetType().GetProperties(); foreach (PropertyInfo property in proplist) Console.WriteLine("{0}: {1}", property.Name, property.GetValue(resp.Data, null)); } else Console.WriteLine(resp.ErrorMessage); }
static void Main(string[] args) { RestAPI plivo = new RestAPI("Your AUTH_ID", "Your AUTH_TOKEN"); // Get all numbers IRestResponse<NumberList> resp = plivo.get_numbers(); Console.WriteLine(resp.Content); Debug.WriteLine(resp.Content); // Get a particular number IRestResponse<Number> res = plivo.get_number(new Dictionary<string, string>() { {"number","1111111111"} // Phone number for which the details have to be retrieved }); Console.WriteLine(res.Content); Debug.WriteLine(res.Content); Console.ReadLine(); }
static void Main(string[] args) { RestAPI plivo = new RestAPI("Your AUTH_ID", "Your AUTH_TOKEN"); // Make an outbound call IRestResponse<Call> resp = plivo.make_call(new Dictionary<string,string>() { { "to", "2222222222" }, // The phone number to which the call has to be placed {"from", "1111111111"}, // The phone number to be used as the caller id {"answer_url","http://dotnettest.apphb.com/detect"}, // The URL invoked by Plivo when the outbound call is answered {"answer_method","GET"}, // Method to invoke the answer_url {"machine_detection","true"}, // Used to detect if the call has been answered by a machine. The valid values are true and hangup. {"machine_detection_time","10000"}, // Time allotted to analyze if the call has been answered by a machine. The default value is 5000 ms. {"machine_detection_url","http://dotnettest.apphb.com/machine_detection"}, // A URL where machine detection parameters will be sent by Plivo. {"machine_detection_method","GET"} // Method used to invoke machine_detection_url }); //Prints the message details Console.Write(resp.Content); Console.ReadLine(); }
static void Main(string[] args) { RestAPI plivo = new RestAPI("Your AUTH_ID", "Your AUTH_TOKEN"); IRestResponse<MessageResponse> resp = plivo.send_message(new Dictionary<string, string>() { { "src", "1111111111" }, // Sender's phone number with country code { "dst", "2222222222<3333333333" }, // Receiver's phone number wiht country code { "text", "Hi, text from Plivo." } // Your SMS text message }); //Prints the message details Console.Write(resp.Content); // Loop through the message_uuid int count = resp.Data.message_uuid.Count; for (int i = 0; i < count; i++) { Console.WriteLine("Message UUID : {0}", resp.Data.message_uuid[i]); } // Print the api_id Console.WriteLine("Api ID : {0}", resp.Data.api_id); // When an invalid number is given as a dst parameter, an error will be thrown and the message will not be sent IRestResponse<MessageResponse> response = plivo.send_message(new Dictionary<string, string>() { { "src", "1111111111" }, // Sender's phone number with country code { "dst", "111111<2222222222" }, // Receiver's phone number wiht country code { "text", "Hi, text from Plivo." } // Your SMS text message }); //Prints the message details Console.Write(response.Content); Console.ReadLine(); }
static void Main(string[] args) { RestAPI plivo = new RestAPI("Your AUTH_ID", "Your AUTH_TOKEN"); IRestResponse<MessageList> resp = plivo.get_messages(); //Prints the message details Console.Write(resp.Content); // Filter the response IRestResponse<MessageList> response = plivo.get_messages(new Dictionary<string, string>() { { "limit", "2" }, // Number of results per page { "offset", "0" }, // The number of value items by which the results should be offset { "message_state", "delivered" }, // The state of the essage to be filtered { "message_direction", "inbound"}, // The direction of the message to be filtered { "subaccount", "SubAccount_AUTH_ID"} // The id of the subaccount, if SMS details of the subaccount is needed. }); // Print the response Console.WriteLine(response.Content); Console.ReadLine(); }
static void Main(string[] args) { string auth_id = "<your_auth_id>"; string auth_token = "<your_auth_token>"; RestAPI plivo = new RestAPI(auth_id, auth_token); string call_uuid = // get the live call's uuid // Record a live call IRestResponse<Record> resp = plivo.record(new dict { { "call_uuid", call_uuid }, { "transcription_url", "http://some.server/url/" }, { "transcription_method", "GET" }, { "transcription_type", "auto" }, }); if (resp.Data != null) { PropertyInfo[] proplist = resp.Data.GetType().GetProperties(); foreach (PropertyInfo property in proplist) Console.WriteLine("{0}: {1}", property.Name, property.GetValue(resp.Data, null)); } else Console.WriteLine(resp.ErrorMessage); }
static void Main(string[] args) { RestAPI plivo = new RestAPI("Your AUTH_ID", "Your AUTH_TOKEN"); // Create an endpoint IRestResponse<Endpoint> resp = plivo.create_endpoint(new Dictionary<string,string>() { {"username", "testuser"}, // The username for the endpoint to be created {"password", "testt"}, // The password for your endpoint username {"alias", "Test"} // Alias for this endpoint }); //Prints the response Console.Write(resp.Content); /* Sample Output { "alias": "Test", "api_id": "db41f044-b5cb-11e4-b423-22000ac8a2f8", "endpoint_id": "29147375335448", "message": "created", "username": "******" } */ // Get details of all existing applications IRestResponse<EndpointList> res = plivo.get_endpoints(new Dictionary<string, string>() { {"limit","2"}, // The number of results per page {"offset","0"} // The number of value items by which the results should be offset }); //Prints the response Console.Write(res.Content); // Prints the total number of apps Console.WriteLine("Total count : " + res.Data.meta.total_count); /* { "api_id": "f09822ba-b5cb-11e4-ac1f-22000ac51de6", "meta": { "limit": 2, "next": "/v1/Account/XXXXXXXXXXXXXXXXX/Endpoint/?limit=2&offset=2", "offset": 0, "previous": null, "total_count": 3 }, "objects": [ { "alias": "Test", "application": "/v1/Account/XXXXXXXXXXXXXXXXX/Application/16982793927977910/", "endpoint_id": "29147375335448", "password": "******", "resource_uri": "/v1/Account/XXXXXXXXXXXXXXXXX/Endpoint/29147375335448/", "sip_registered": "false", "sip_uri": "sip:[email protected]", "sub_account": null, "username": "******" }, { "alias": "TestSample", "application": "/v1/Account/XXXXXXXXXXXXXXXXX/Application/16632742496743552/", "endpoint_id": "24753112937214", "password": "******", "resource_uri": "/v1/Account/XXXXXXXXXXXXXXXXX/Endpoint/24753112937214/", "sip_registered": "false", "sip_uri": "sip:[email protected]", "sub_account": null, "username": "******" } ] } Total count : 3 */ // Get details of a single application IRestResponse<Endpoint> res1 = plivo.get_endpoint(new Dictionary<string, string>() { {"endpoint_id","29147375335448"} // ID of the endpoint for which the details have to be retrieved }); //Prints the response Console.Write(res1.Content); /* Sample Output { "alias": "Test", "api_id": "798973ee-b5cc-11e4-b423-22000ac8a2f8", "application": "/v1/Account/XXXXXXXXXXXXXXXXX/Application/16982793927977910/", "endpoint_id": "29147375335448", "password": "******", "resource_uri": "/v1/Account/XXXXXXXXXXXXXXXXX/Endpoint/29147375335448/", "sip_registered": "false", "sip_uri": "sip:[email protected]", "sub_account": null, "username": "******" } */ // Modify an application IRestResponse<GenericResponse> res2 = plivo.modify_endpoint(new Dictionary<string, string>() { {"endpoint_id","29147375335448"}, // ID of the endpoint that has to be modified {"alias","Testing"} // Values that have to be updated }); //Prints the response Console.Write(res2.Content); /* Sample Output { "api_id": "97305b10-b5cc-11e4-b423-22000ac8a2f8", "message": "changed" } */ // Delete an application IRestResponse<GenericResponse> res3 = plivo.delete_endpoint(new Dictionary<string,string>() { {"endpoint_id","29147375335448"} // ID of the endpoint that as to be deleted }); //Prints the response Console.Write(res3.Content); Console.ReadLine(); /* Successful Output " " Unsuccessful output { "api_id": "be4512a4-b5cc-11e4-9107-22000afaaa90", "error": "not found" } */ }