-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
773a3ea
commit c83aaa2
Showing
39 changed files
with
2,158 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace IRTrainDotNet.Helpers | ||
{ | ||
public static class ApiUrl | ||
{ | ||
public const string FadakBaseUrl = "https://api.fadaktrains.com/rpTicketing"; | ||
//Raja Still Under Dev | ||
public const string RajaBaseUrl = "https://hostservice.raja.ir/Api/WebSiteService"; | ||
//Safir Completely Under Dev | ||
public const string SafirBaseUrl = "http://www.safirrail.ir"; | ||
|
||
public const string Login = "/Login"; | ||
public const string Stations = "/Station"; | ||
public const string Station = "/Station/"; // + "{StationId}" | ||
public const string GetLastVersion = "/GetLastVersion"; | ||
public const string GetWagonAvailableSeatCount = "/GetWagonAvailableSeatCount"; | ||
public const string LockSeat = "/LockSeat"; | ||
public const string LockSeatBulk = "/LockSeatBulk"; | ||
public const string UnlockSeat = "/UnlockSeat"; | ||
public const string SaveTicketsInfo = "/SaveTicketsInfo"; | ||
public const string RegisterTickets = "/RegisterTickets"; | ||
public const string TicketReportA = "/TicketReportA"; | ||
public const string RefundTicketInfo = "/RefundTicketInfo"; | ||
public const string RefundTicket = "/RefundTicket"; | ||
public const string UserSales = "/UserSales"; | ||
public const string AgentCredit = "/AgentCredit"; | ||
|
||
public const string GetTrainWagonMessage = "/GetTrainWagonMessage"; | ||
public const string StationTimeLine = "/StationTimeLine"; | ||
public const string GetWagonImage = "/GetWagonImage"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace IRTrainDotNet.Helpers | ||
{ | ||
public static class Constants | ||
{ | ||
public const string PreToken = "bmhh "; | ||
public static readonly List<int> SystemErrorCodes = new List<int> { | ||
100, 103, 110, 111, 118, 123, 200, 201, 202, | ||
203, 204, 205, 206, 207, 208, 209, | ||
210, 211,212, 213, 221, 226}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace IRTrainDotNet.Helpers | ||
{ | ||
public enum TarrifCodes | ||
{ | ||
Full = 1, | ||
Child = 2, | ||
Shahed = 3, | ||
Janbaz = 4, | ||
CompartmentFiller = 5, | ||
Infant = 6 | ||
} | ||
public enum Gender | ||
{ | ||
Men = 1, | ||
Wemen = 2, | ||
Family = 3 | ||
} | ||
public enum OffTime | ||
{ | ||
First = 00000015, // 00:00 ---> 00:15 | ||
Second = 06300645, // 06:30 ---> 06:45 | ||
Third = 13301345, // 13:30 ---> 13:45 | ||
Forth = 19301945 // 19:30 ---> 19:45 | ||
} | ||
public enum Company | ||
{ | ||
Raja = 1, | ||
Fadak = 2, | ||
Safir = 3 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
using IRTrainDotNet.Models; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace IRTrainDotNet.Helpers | ||
{ | ||
public static class Extentions | ||
{ | ||
public static string ToAuthorization(this string token) | ||
{ | ||
return Constants.PreToken + token; | ||
} | ||
public static Uri ToUri(this string url, int id = -1) | ||
{ | ||
if (id != -1) | ||
return new Uri(url + id, UriKind.Absolute); | ||
else | ||
return new Uri(url, UriKind.Absolute); | ||
} | ||
|
||
public static bool IsSystemError(this int code) | ||
{ | ||
return Constants.SystemErrorCodes.Contains(code); | ||
} | ||
public static string GetSystemErrorMessage(this int exceptionId, string exceptionMessage) | ||
{ | ||
if (exceptionId.IsSystemError()) | ||
{ | ||
switch (exceptionId) | ||
{ | ||
case 100: | ||
return "خطای نامشخص"; | ||
case 103: | ||
return "خطا در ارتباط با سیستم فروش"; | ||
case 110: | ||
return "قطار انتخابی امکان انتخاب غذا ندارد."; | ||
case 111: | ||
return "تعداد غذای مورد نظر از تعداد بلیت درخواستی بیشتر است."; | ||
case 118: | ||
return "قطار %1 انتخاب شده کوپه ای نبوده و امکان دربست کردن کوپه وجود ندارد. "; | ||
case 123: | ||
return "اطلاعات تراکنش مورد نظر یافت نشد. "; | ||
case 200: | ||
return "خطا در ارتباط با سرور بانک اطلاعاتی "; | ||
case 201: | ||
return "خطا در عملیات بانک اطلاعاتی "; | ||
case 202: | ||
return "نام کاربری یا کلمه عبور اشتباه است "; | ||
case 203: | ||
return "حساب کاربری شما غیر فعال است "; | ||
case 204: | ||
return "حساب کاربری شما مسدود است "; | ||
case 205: | ||
return "حساب کاربری شما تائید نگردیده است "; | ||
case 206: | ||
return "ممکن است به تعداد درخواستی شما در قطار، صندلی آزاد در کنار هم وجود نداشته باشد "; | ||
case 207: | ||
return "سیستم پایه فروش بلیت قادر به ارائه خدمات نمیباشد، لطفا پس از مدتی دوباره تلاش نمایید "; | ||
case 208: | ||
return "خطا در بازیابی نام و نام خانوادگی مسافر "; | ||
case 209: | ||
return "کد ملی و تاریخ تولد با هم مطابقت ندارند. "; | ||
case 210: | ||
return "خطای نامشخص در گرفتن لیست قطارها "; | ||
case 211: | ||
return "خطای نامشخص در ثبت بلیتها "; | ||
case 212: | ||
return "هیچ بلیتی با این مشخصات یافت نشد. "; | ||
case 213: | ||
return "اعتبار کاربر کافی نیست. "; | ||
case 221: | ||
return "آژانس شما غیر فعال است."; | ||
case 226: | ||
return "سرویس RegisterTickets قبل از سرویس SaveTicketsInfo فراخوانی شده است."; | ||
default: | ||
return "نامشخص"; | ||
} | ||
} | ||
else | ||
{ | ||
return exceptionMessage; | ||
} | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
using IRTrainDotNet.Helpers; | ||
using IRTrainDotNet.Models; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace IRTrainDotNet | ||
{ | ||
public interface IIRTrainApi | ||
{ | ||
#region Synchronous | ||
//------------------------------------------- | ||
#region Auth | ||
ServiceResult<string> Login(LoginModel loginModel, Company company); | ||
bool ValidateTokenWithTime(DateTime addDate); | ||
bool ValidateTokenWithRequest(string token, Company company); | ||
#endregion | ||
#region Stations | ||
ServiceResult<List<Station>> GetStations(string authToken, Company company); | ||
ServiceResult<Station> GetStationById(string authToken, int stationId, Company company); | ||
#endregion | ||
#region Raja | ||
ServiceResult<string> GetLastVersion(string authToken, Company company); | ||
#endregion | ||
#region Wagon | ||
ServiceResult<GetWagonAvailableSeatCountResult> GetWagonAvailableSeatCount(string authToken, GetWagonAvailableSeatCountParams getWagonAvailableSeatCountParams, Company company); | ||
#endregion | ||
#region Seat | ||
ServiceResult<LockSeatResult> LockSeat(string authToken, LockSeatParams lockSeatParams, Company company); | ||
ServiceResult<LockSeatBulkResult> LockSeatBulk(string authToken, LockSeatBulkParams lockSeatBulkParams, Company company); | ||
ServiceResult<EmptyResult> UnlockSeat(string authToken, UnlockSeatParams unlockSeatParams, Company company); | ||
#endregion | ||
#region Ticket | ||
ServiceResult<int> SaveTicketsInfo(string authToken, SaveTicketsInfoParams saveTicketsInfoParams, Company company); | ||
ServiceResult<EmptyResult> RegisterTickets(string authToken, RegisterTicketParams registerTicketParams, Company company); | ||
ServiceResult<TicketReportAResult> TicketReportA(string authToken, TicketReportAParams ticketReportAParams, Company company); | ||
ServiceResult<RefundTicketInfoResult> RefundTicketInfo(string authToken, RefundTicketInfoParams refundTicketInfoParams, Company company); | ||
ServiceResult<int> RefundTicket(string authToken, RefundTicketParams refundTicketParams, Company company); | ||
#endregion | ||
#region Agent | ||
ServiceResult<List<UserSaleMetadata>> UserSales(string authToken, Company company); | ||
ServiceResult<long> AgentCredit(string authToken, Company company); | ||
#endregion | ||
//------------------------------------------- | ||
#endregion | ||
|
||
#region Asynchronous | ||
//------------------------------------------- | ||
#region Auth | ||
Task<ServiceResult<String>> LoginAsync(LoginModel loginModel, Company company); | ||
Task<bool> ValidateTokenWithRequestAsync(string token, Company company); | ||
#endregion | ||
#region Stations | ||
Task<ServiceResult<List<Station>>> GetStationsAsync(string authToken, Company company); | ||
Task<ServiceResult<Station>> GetStationByIdAsync(string authToken, int stationId, Company company); | ||
#endregion | ||
#region Raja | ||
Task<ServiceResult<string>> GetLastVersionAsync(string authToken, Company company); | ||
#endregion | ||
#region Wagon | ||
Task<ServiceResult<GetWagonAvailableSeatCountResult>> GetWagonAvailableSeatCountAsync(string authToken, GetWagonAvailableSeatCountParams getWagonAvailableSeatCountParams, Company company); | ||
#endregion | ||
#region Seat | ||
Task<ServiceResult<LockSeatResult>> LockSeatAsync(string authToken, LockSeatParams lockSeatParams, Company company); | ||
Task<ServiceResult<LockSeatBulkResult>> LockSeatBulkAsync(string authToken, LockSeatBulkParams lockSeatBulkParams, Company company); | ||
Task<ServiceResult<EmptyResult>> UnlockSeatAsync(string authToken, UnlockSeatParams unlockSeatParams, Company company); | ||
#endregion | ||
#region Ticket | ||
Task<ServiceResult<int>> SaveTicketsInfoAsync(string authToken, SaveTicketsInfoParams saveTicketsInfoParams, Company company); | ||
Task<ServiceResult<EmptyResult>> RegisterTicketsAsync(string authToken, RegisterTicketParams registerTicketParams, Company company); | ||
Task<ServiceResult<TicketReportAResult>> TicketReportAAsync(string authToken, TicketReportAParams ticketReportAParams, Company company); | ||
Task<ServiceResult<RefundTicketInfoResult>> RefundTicketInfoAsync(string authToken, RefundTicketInfoParams refundTicketInfoParams, Company company); | ||
Task<ServiceResult<int>> RefundTicketAsync(string authToken, RefundTicketParams refundTicketParams, Company company); | ||
|
||
#endregion | ||
#region Agent | ||
Task<ServiceResult<List<UserSaleMetadata>>> UserSalesAsync(string authToken, Company company); | ||
Task<ServiceResult<long>> AgentCreditAsync(string authToken, Company company); | ||
#endregion | ||
//------------------------------------------- | ||
#endregion | ||
} | ||
} |
Oops, something went wrong.