Guest User

Untitled

a guest
Jan 19th, 2016
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.56 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using VillasDirectAPITests.Helpers;
  4. using VillasDirectAPITests.Helpers.Models;
  5. using VillasDirectAPITests.Models;
  6. using VillasDirectAPITests.Models.Agency;
  7.  
  8. namespace VillasDirectAPITests
  9. {
  10.     public static class Actions
  11.     {
  12.         #region Public Methods
  13.  
  14.         public static Response<AvailabilityResponseParams> CheckAvailability(AvailabilityRequestParams requestData, string system, int agencyId)
  15.         {
  16.             string url = string.Format("/api/availability?system={0}&agencyId={1}", system, agencyId);
  17.             return HttpHelper.Post<AvailabilityRequestParams, AvailabilityResponseParams>(url, requestData);
  18.         }
  19.  
  20.         public static Response<List<AvailabilitiesResponseParams>> CheckAvailabilities(AvailabilitiesRequestParams requestData)
  21.         {
  22.             string url = "/api/properties/availability";
  23.             return HttpHelper.Post<AvailabilitiesRequestParams, List<AvailabilitiesResponseParams>>(url, requestData);
  24.         }
  25.  
  26.         public static Response<PlaceBookingResponseData> PlaceBooking(PlaceBookingModel requestData)
  27.         {
  28.             return HttpHelper.Post<PlaceBookingModel, PlaceBookingResponseData>("/api/b2b/availability/placebooking", requestData);
  29.         }
  30.  
  31.         public static Response<ImportResponseModel> ExecuteImportProcess(ImportRequestModel data)
  32.         {
  33.             string url = string.Format(
  34.                 "/api/import/vendor?process={0}&full={1}&skipInit={2}&isInit={3}&vendor={4}&lastchange={5}&reset={6}",
  35.                 data.Process,
  36.                 data.Full,
  37.                 data.SkipInit,
  38.                 data.IsInit,
  39.                 data.Vendor,
  40.                 data.LastChange,
  41.                 data.Reset);
  42.  
  43.             return HttpHelper.Get<ImportResponseModel>(url);
  44.         }
  45.  
  46.         public static Response<object> PutBooking(UpdateBookingModel updateBookingModel)
  47.         {
  48.             return HttpHelper.Put<UpdateBookingModel, object>("/api/b2b/availability/placebooking", updateBookingModel);
  49.         }
  50.  
  51.         public static Response<GetBookingResponseData> GetBooking(int agentId, int bookingId)
  52.         {
  53.             string url = string.Format("api/b2b/agents/{0}/bookings/{1}", agentId, bookingId);
  54.             return HttpHelper.Get<GetBookingResponseData>(url);
  55.         }
  56.  
  57.         public static Response<bool> CheckTestEnvironment()
  58.         {
  59.             return HttpHelper.Get<bool>("api/b2b/availability/istestenv");
  60.         }
  61.  
  62.         public static Response<CreateUserAgencyResponse> CreateUser(CreateAgencyUserModel data)
  63.         {
  64.             return HttpHelper.Post<CreateAgencyUserModel, CreateUserAgencyResponse>("/api/agency/user", data);
  65.         }
  66.  
  67.         public static Response<UMT> GetUser<UMT>(string username, string password)
  68.             where UMT : new()
  69.         {
  70.             return HttpHelper.Get<UMT>("/api/agency/user?username=" + username + "&password=" + password);
  71.         }
  72.  
  73.         public static Response<UMT> GetUser<UMT>(string username)
  74.             where UMT : new()
  75.         {
  76.             return HttpHelper.Get<UMT>("/api/agency/user/username?value=" + username);
  77.         }
  78.  
  79.         public static Response<object> UpdateUser(UpdateAgencyUserModel data)
  80.         {
  81.             return HttpHelper.Put<UpdateAgencyUserModel, object>("/api/agency/user", data);
  82.         }
  83.  
  84.         public static Response<List<GetAgencyUserModelBase>> ChangeStatus(int userId, bool confirmed)
  85.         {
  86.             string url = string.Format("/api/agency/user/{0}/confirmed", userId);
  87.             return HttpHelper.Put<UpdateConfirmedModel, List<GetAgencyUserModelBase>>(url, new UpdateConfirmedModel(confirmed));
  88.         }
  89.  
  90.         public static Response<object> UpdatePassword(int userId, UpdatePasswordModel data)
  91.         {
  92.             string url = string.Format("/api/agency/user/{0}/password", userId);
  93.             return HttpHelper.Put<UpdatePasswordModel, object>(url, data);
  94.         }
  95.  
  96.         public static Response<object> UpdateAgency(int agencyId, UpdateAgencyModel data)
  97.         {
  98.             string url = string.Format("/api/agency/{0}", agencyId);
  99.             return HttpHelper.Put<UpdateAgencyModel, object>(url, data);
  100.         }
  101.  
  102.         public static Response<AgencyModelGet> GetAgency(string taxNo, string countryOfInc)
  103.         {
  104.             return HttpHelper.Get<AgencyModelGet>("/api/agency?taxNo=" + taxNo + "&countryOfInc=" + countryOfInc);
  105.         }
  106.  
  107.         public static Response<UsersModel> AddUsers(int agencyId, UsersModel usersModel)
  108.         {
  109.             return HttpHelper.Post<UsersModel, UsersModel>("/api/agency/" + agencyId + "/user", usersModel);
  110.         }
  111.  
  112.         public static Response<object> DeleteUsers(int agencyId, UsersModel usersModel)
  113.         {
  114.             return HttpHelper.Put<UsersModel, object>("/api/agency/" + agencyId + "/user", usersModel);
  115.         }
  116.  
  117.         public static Response<UsersModel> GetUsers(int agencyId)
  118.         {
  119.             return HttpHelper.Get<UsersModel>("/api/agency/" + agencyId + "/user");
  120.         }
  121.  
  122.         public static Response<TimeRangeAvailabilityResponse> GetAvailabilities(int propertyId, DateTime startdate, DateTime endDate)
  123.         {
  124.             string url = string.Format("api/availability/property?propertyId={0}&startDateString={1}&endDateString={2}&page=1&pageSize=1", propertyId, String.Format("{0:dd-MM-yyyy}", startdate), String.Format("{0:dd-MM-yyyy}", endDate));
  125.             var ret = HttpHelper.Get<TimeRangeAvailabilityResponse>(url);
  126.             return ret;
  127.         }
  128.  
  129.  
  130.         #endregion Public Methods
  131.     }
  132. }
Add Comment
Please, Sign In to add comment