public DwollaService(IDwollaClient client) { _headers = new Headers(); _client = client; rootRes = GetRootAsync().GetAwaiter().GetResult(); _httpClient = HttpClientFactory.Create(); }
public static RootResponse <T> CreateRoot <T>(int code) { var response = new RootResponse <T>(); response.Code = code; return(response); }
public async Task <User> GetUser(Login login) { RootResponse responseObj = new RootResponse(); HttpClient client = new HttpClient(); string url = baseUrl + "login" + apiKey; // var jsonObj = JsonConvert.SerializeObject(new { email = login.Email, password = login.Password }); var content = new StringContent(jsonObj, Encoding.UTF8, "application/json"); var response = await client.PostAsync(url, content); var userResponse = await response.Content.ReadAsStringAsync(); responseObj = JsonConvert.DeserializeObject <RootResponse>(userResponse); if (response.IsSuccessStatusCode) { HttpContext.Session.SetString("Token", responseObj.LoginResponse.Token); token = responseObj.LoginResponse.Token; return(responseObj.LoginResponse.User); } return(null); }
public async Task <RootResponse> Post(RootRequest request) { string validationResponse = "UNVERIFIED"; using (var context = new PrincipalContext(ContextType.Domain, _settings.LdapDomain, _settings.ADServiceAccount, _settings.ADServiceAccountPwd)) { if (request == null || request.data == null || request.data.context == null || request.data.context.credential == null || request.data.context.credential.username == null || request.data.context.credential.password == null) { return(new RootResponse()); } _logger.LogInformation("Verifying password for:" + request.data.context.credential.username); if (context.ValidateCredentials(request.data.context.credential.username, request.data.context.credential.password)) { _logger.LogInformation("Verified password successfully for:" + request.data.context.credential.username); validationResponse = "VERIFIED"; } } Command command = new Command() { type = "com.okta.action.update", value = new Value() { credential = validationResponse } }; RootResponse response = new RootResponse(); response.commands = new List <Command>(); response.commands.Add(command); return(response); }
public static void EnsureSuccess(this RootResponse response) { if (!response.Success) { throw new Exception(response.Errors[0]); } }
public static Employee DeserializeCreateUpdate(string content) { Employee employee = new Employee(); try { RootResponse myDeserializedClass = JsonConvert.DeserializeObject <RootResponse>(content); employee = new Employee { Id = myDeserializedClass.data.id, Name = myDeserializedClass.data.name, Email = myDeserializedClass.data.email, Gender = myDeserializedClass.data.gender, Status = myDeserializedClass.data.status, Created_at = myDeserializedClass.data.created_at, Updated_at = myDeserializedClass.data.updated_at }; } catch { try { RootResponseError myDeserializedClassError = JsonConvert.DeserializeObject <RootResponseError>(content); new CustomException("It was not possible to proceed with this operation. \n\n Reason: " + myDeserializedClassError.data[0].field + " " + myDeserializedClassError.data[0].message); } catch (Exception ex) { new CustomException(ex.Message); } } return(employee); }
public Employee Api_Employee_Edit(Employee employee) { RestClient client = new RestClient(BASE_URL + "/" + employee.Id); RestRequest request = new RestRequest(Method.PATCH); request.AddHeader("Authorization", "Bearer " + TOKEN); request.AddHeader("Cache-Control", "no-cache"); request.RequestFormat = DataFormat.Json; request.AddJsonBody(new { name = employee.Name, email = employee.Email, gender = employee.Gender, status = employee.Status }); IRestResponse response = client.Execute(request); var content = response.Content; RootResponse myDeserializedClass = JsonConvert.DeserializeObject <RootResponse>(response.Content); Employee returnEmployee = new Employee { Id = myDeserializedClass.data.id, Name = myDeserializedClass.data.name, Email = myDeserializedClass.data.email, Gender = myDeserializedClass.data.gender, Status = myDeserializedClass.data.status, Created_at = myDeserializedClass.data.created_at, Updated_at = myDeserializedClass.data.updated_at }; return(returnEmployee); }
public static RootResponse <T> CreateRoot <T>(MessageCode code) { var response = new RootResponse <T>(); response.Code = (int)code; return(response); }
public static RootResponse <T> Build <T>(T response) { var responseModel = new RootResponse <T>(); responseModel.Result = response; responseModel.Status = true; return(responseModel); }
public static RootResponse <string> BuildError(Error error) { var responseModel = new RootResponse <string>(); responseModel.Status = false; responseModel.Result = "Произошла ОШИБКА!"; responseModel.Error = error; return(responseModel); }
public IActionResult GetRoot() { var response = new RootResponse { Self = Link.To(nameof(GetRoot)), Meets = Link.To(nameof(MeetsController.GetMeetsAsync)) }; return(Ok(response)); }
private static void AssertTestData(RootResponse root) { Assert.AreEqual(root.HorizonVersion, "snapshot-c5fe0ff"); Assert.AreEqual(root.StellarCoreVersion, "stellar-core 9.2.0 (7561c1d53366ec79b908de533726269e08474f77)"); Assert.AreEqual(root.HistoryLatestLedger, 18369116); Assert.AreEqual(root.HistoryElderLedger, 1); Assert.AreEqual(root.CoreLatestLedger, 18369117); Assert.AreEqual(root.NetworkPassphrase, "Public Global Stellar Network ; September 2015"); Assert.AreEqual(root.ProtocolVersion, 9); }
public IActionResult GetRoot() { var response = new RootResponse { Self = Link.To(nameof(GetRoot)), ToDoItems = Link.ToCollection(nameof(ToDoItemController.GetToDoItems)) }; return(Ok(response)); }
public IActionResult GetRoot() { var response = new RootResponse { Href = null, // TODO - Url.Link(nameof(GetRoot), null), Rooms = Link.To(nameof(RoomsController.GetRooms)), Info = Link.To(nameof(InfoController.GetInfo)), }; return(Ok(response)); }
public IActionResult GetRoot() { var response = new RootResponse { Self = Link.To(nameof(GetRoot)), History = Link.To(nameof(HistoryController.GetAllHistoryAsync)), Image = Link.ToCollection(nameof(ImageController.GetAllImages)) }; return(Ok(response)); }
public IActionResult GetRoot() { var response = new RootResponse { Self = Link.To(nameof(GetRoot)), Rooms = Link.ToCollection(nameof(RoomsController.GetAllRooms)), Info = Link.To(nameof(InfoController.GetInfo)) }; return(Ok(response)); }
public IActionResult GetRoot() { var response = new RootResponse { Self = Link.To(nameof(GetRoot)), Recipes = Link.ToCollection(nameof(RecipesController.ListAllRecipes)), Users = Link.ToCollection(nameof(UsersController.ListAllUsers)), }; return(Ok(response)); }
public ActionResult GetRoot() { var response = new RootResponse { Href = null, Rooms = Link.To(nameof(RoomsController.GetRooms)), Info = Link.To(nameof(InfoController.GetInfo)) }; return(Ok(response)); }
public IActionResult GetRoot() { var response = new RootResponse { Self = Link.To(nameof(GetRoot)), TreasureMaps = Link.To(nameof(TreasureMapsController.Get)), // Link.ToCollection(nameof(TreasureMapsController.GetAllTreasureMaps)), Info = Link.To(nameof(InfoController.GetInfo)) }; return(Ok(response)); }
public IActionResult GetRoot() { var response = new RootResponse { Self = Link.To(nameof(RootController.GetRoot)), // TODO Url.Link(nameof(GetRoot), null) Rooms = Link.To(nameof(RoomsController.GetRoomsAsync)), Info = Link.To(nameof(InfoController.GetInfo)) }; return(Ok(response)); }
public IActionResult GetRoot() { var response = new RootResponse() { // Href = null, Self = Link.To(nameof(GetRoot), null), Users = Link.To(nameof(UserController.GetUsers), null), Info = null // Url.Link(nameof(UserController.GetUsers), null), }; return(Ok(response)); }
public IActionResult GetRoot() { var response = new RootResponse { Self = Link.To(nameof(GetRoot)), Points = Link.To(nameof(PointsController.GetPointsAsync), new { version = "1" }), Routes = Link.To(nameof(RoutesController.GetRoutesAsync), new { version = "1" }), Login = Link.To(nameof(AccountsController.LoginUser)) }; return(Ok(response)); }
public IActionResult GetRoot() { var response = new RootResponse { Self = Link.To(nameof(GetRoot)), Categories = Link.To(nameof(CategoriesController.GetCategoriesAsync)), Tasks = Link.To(nameof(TasksController.GetTasksAsync)), Comments = Link.To(nameof(CommentsController.GetCommentsAsync)) }; return(Ok(response)); }
public IActionResult GetRoot() { var response = new RootResponse { // don't forget update mappiing Self = Link.To(nameof(GetRoot)), Info = Link.To(nameof(InfoController.GetInfo)), Rooms = Link.To(nameof(RoomsController.GetRoomsAsync)) }; return(Ok(response)); }
public IActionResult GetRoot() { var response = new RootResponse { Self = Link.To(nameof(GetRoot)), Info = Link.To(nameof(InfoController.GetInfo)), Businesses = Link.ToCollection(nameof(BusinessesController.GetAllBusinesses)), Users = Link.ToCollection(nameof(UsersController.GetVisibleUsers)) }; return(Ok(response)); }
[ProducesResponseType(200)]//optional - will help open api documentation,attribute specifies that this method could return 200 status public IActionResult GetRoot() { var response = new RootResponse { Self = Link.To(nameof(GetRoot), null), //Link.To(nameof(RoomsController.GetRooms), null), TODO: URL.Link(nameof(GetRoot), null) rooms = Link.ToCollection(nameof(RoomsController.GetAllRooms), null) , info = Link.To(nameof(InfoController.Getinfo), null) }; return(Ok(response)); }
[ProducesResponseType(200)] //nie je potrebny atribut, vhodny ale pre pouzitie pre Swagger public IActionResult GetRoot() { //vyuzivana ION JSON specifikacia (https://ionspec.org/) var response = new RootResponse { //Href = null, //Url.Link(nameof(GetRoot), null), //generovanie absolute path Self = Link.To(nameof(GetRoot)), Rooms = Link.ToCollection(nameof(RoomsController.GetAllRooms)), Info = Link.To(nameof(InfoController.GetInfo)) }; return(Ok(response)); }
public IActionResult GetRoot() { var response = new RootResponse() { Self = LinkGenerator.To(RouteNames.Root), Directions = LinkGenerator.To(RouteNames.DirectionsRoot), Users = LinkGenerator.To(RouteNames.UsersRoot), Tokens = LinkGenerator.To(RouteNames.TokenRoot), BusStops = LinkGenerator.ToCollection(RouteNames.ListBusStops), Buses = LinkGenerator.ToCollection(RouteNames.Buses) }; return(Ok(response)); }
//调用中和接口向ERP系统插入订单 public string AddOrder(Full_order_info_listItem OrderItem) { string HttpResponse = string.Empty; List <GoodsItem> ListGoodsItem = new List <GoodsItem>(); SortedDictionary <string, string> sb = new SortedDictionary <string, string>(); //详细地址 sb.Add("address", OrderItem.full_order_info.address_info.delivery_address); //市 sb.Add("city", OrderItem.full_order_info.address_info.delivery_city); //商品信息 foreach (var item in OrderItem.full_order_info.orders) { //取规格ID ListGoodsItem.Add(new GoodsItem { item_id = orderService.QueryBarcode(item.outer_sku_id), qty = item.num, price = Convert.ToDouble(item.total_fee) / item.num }); } string GoodsJson = JsonConvert.SerializeObject(ListGoodsItem); sb.Add("items", GoodsJson); //买家手机号 sb.Add("mobile", OrderItem.full_order_info.address_info.receiver_tel); //创建时间 sb.Add("order_created", OrderItem.full_order_info.order_info.pay_time); //订单号 sb.Add("order_id", OrderItem.full_order_info.order_info.tid); //省 sb.Add("province", OrderItem.full_order_info.address_info.delivery_province); //备注 sb.Add("remark", OrderItem.full_order_info.remark_info.buyer_message); //收货人名称 sb.Add("recevier", OrderItem.full_order_info.address_info.receiver_name); //收货人手机号 sb.Add("tel", OrderItem.full_order_info.address_info.receiver_tel); //区 sb.Add("town", OrderItem.full_order_info.address_info.delivery_district); string ordersJosonStr = HttpHepler.UrlResponseByPost("add_order", sb, appkey, appsecret); if (!string.IsNullOrEmpty(ordersJosonStr)) { RootResponse rootModel = JsonConvert.DeserializeObject <RootResponse>(ordersJosonStr); if (rootModel.Code == "0") { return(rootModel.AddOrderResponse.ERPORDERID); } logService.AddLog("有赞订单号:" + OrderItem.full_order_info.order_info.tid + " 收件人信息" + OrderItem.full_order_info.address_info.receiver_name + OrderItem.full_order_info.address_info.receiver_tel + " 地址:" + OrderItem.full_order_info.address_info.delivery_province + OrderItem.full_order_info.address_info.delivery_city + OrderItem.full_order_info.address_info.delivery_district + OrderItem.full_order_info.address_info.delivery_address + " 错误信息:" + rootModel.ErrorMessage.Trim()); } return(null); }
public IActionResult GetRoot() { var response = new RootResponse { Self = Link.To(nameof(GetRoot)), Endpoints = Link.To(nameof(EndpointsController.GetEndpointsAsync)) }; if (!Request.GetEtagHandler().NoneMatch(response)) { return(StatusCode(304, response)); } return(Ok(response)); }
public RootResponse Get() { var root = new RootResponse(); RootHyperMediaProvider.Instance.AddHyperMedia(Request, root); return root; }