/// <summary> /// update Profile /// </summary> /// <param name="profile">Profile</param> /// <returns>Profile</returns> public Profile Update(Profile profile) { profile.SetRequiredFields(new List <string> { GlobalConstants.Id }); profile.CheckRequiredFields(); profile.SetRequiredFields(new List <string> { GlobalConstants.MerchantCustomerId, GlobalConstants.Locale }); profile.SetOptionalFields(new List <string> { GlobalConstants.FirstName, GlobalConstants.MiddleName, GlobalConstants.LastName, GlobalConstants.DateOfBirth, GlobalConstants.Ip, GlobalConstants.Gender, GlobalConstants.Nationality, GlobalConstants.Email, GlobalConstants.Phone, GlobalConstants.CellPhone }); Request request = new Request( method: RequestType.Put, uri: PrepareUri("/profiles/" + profile.Id()), body: profile ); dynamic response = _client.ProcessRequest(request); return(new Profile(response)); }
/// <summary> /// delete profile /// </summary> /// <param name="profile">Profile</param> /// <returns>bool</returns> public bool Delete(Profile profile) { profile.SetRequiredFields(new List <string> { GlobalConstants.Id }); profile.CheckRequiredFields(); Request request = new Request( method: RequestType.Delete, uri: PrepareUri("/profiles/" + profile.Id()) ); _client.ProcessRequest(request); return(true); }
/// <summary> /// get profile with subcomponents /// </summary> /// <param name="profile">Profile</param> /// <returns>Profile</returns> public Profile Get(Profile profile, bool includeAddresses = false, bool includeCards = false, bool includeAchBankAccounts = false, bool includeBacsBankAccounts = false, bool includeEftBankAccounts = false, bool includeSepaBankAccounts = false) { profile.SetRequiredFields(new List <string> { GlobalConstants.Id }); profile.CheckRequiredFields(); Dictionary <string, string> queryStr = new Dictionary <string, string>(); StringBuilder toInclude = new StringBuilder(); if (includeAddresses) { toInclude.Append("addresses"); } if (includeCards) { if (toInclude.Length > 0) { toInclude.Append(","); } toInclude.Append("cards"); } if (includeAchBankAccounts) { if (toInclude.Length > 0) { toInclude.Append(","); } toInclude.Append("achbankaccounts"); } if (includeBacsBankAccounts) { if (toInclude.Length > 0) { toInclude.Append(","); } toInclude.Append("bacsbankaccounts"); } if (includeEftBankAccounts) { if (toInclude.Length > 0) { toInclude.Append(","); } toInclude.Append("eftbankaccounts"); } if (includeSepaBankAccounts) { if (toInclude.Length > 0) { toInclude.Append(","); } toInclude.Append("sepabankaccounts"); } queryStr.Add("fields", toInclude.ToString()); Request request = new Request( method: RequestType.Get, uri: PrepareUri("/profiles/" + profile.Id()), queryString: queryStr ); dynamic response = _client.ProcessRequest(request); return(new Profile(response)); }