0% found this document useful (0 votes)
14 views15 pages

IryoConnector HTTP Wrapper Code

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views15 pages

IryoConnector HTTP Wrapper Code

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

24/10/24, 8:05 Correo de EMOVEERE CONSULTING - (sin asunto)

Enric Jimenez <ejimenez@[Link]>

(sin asunto)
Enric Jimenez <ejimenez@[Link]> 24 de octubre de 2024, 8:04
Borrador

using System;
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];

namespace [Link]
{
public class HttpWrapper
{
public JourneySearchRS Search(JourneySearchRQ query)
{
HttpClient client = new HttpClient();
try
{
[Link](new MediaTypeWithQualityHeaderValue("application/json"));
[Link]("Content-Type", "application/json");
[Link]("Ocp-Apim-Subscription-Key", IryoCredentials.
SubscriptionKey);
//[Link]("Accept-Language", "es-ES");
[Link] = new AuthenticationHeaderValue("Bearer", IryoCredentials.
AuthorisationToken.access_token);

var content = query as JourneySearchRQ;

[Link] = [Link];

var strContent = [Link]();

var uri = [Link] + "/conecta/availability/search";

HttpRequestMessage message = new HttpRequestMessage([Link], uri)


{
Content = new StringContent(strContent, Encoding.UTF8, "application/json"),
};

using (HttpResponseMessage response = [Link](message).Result)


{
[Link]([Link], "Search", uri, strContent);
var strResponse = [Link]().Result;
[Link]([Link], "Search", "", strResponse);

if ([Link])
{
var resp = [Link]<JourneySearchRS>(strResponse);
return resp;
}
else

[Link] 1/15
24/10/24, 8:05 Correo de EMOVEERE CONSULTING - (sin asunto)
{
throw new Exception("Error HTTP- Code: " + [Link] + " Message: " + strResponse);
}
};
}
finally
{
[Link]();
};
}

public CreateBookingRS CreateBooking(CreateBookingRQ query)


{
HttpClient client = new HttpClient();
try
{
[Link](new MediaTypeWithQualityHeaderValue("application/json"));
[Link]("Content-Type", "application/json");
[Link]("Ocp-Apim-Subscription-Key", IryoCredentials.
SubscriptionKey);
[Link]("Accept-Language", "es-ES");
[Link] = new AuthenticationHeaderValue("Bearer", IryoCredentials.
AuthorisationToken.access_token);

var strContent = [Link]();


var uri = [Link] + "/conecta/build/bookings";

HttpRequestMessage message = new HttpRequestMessage([Link], uri)


{
Content = new StringContent(strContent, Encoding.UTF8, "application/json"),
};

using (HttpResponseMessage response = [Link](message).Result)


{
[Link]([Link], "CreateBooking", uri, strContent);
var strResponse = [Link]().Result;
[Link]([Link], "CreateBooking", "", strResponse);

if ([Link])
{
var resp = [Link]<CreateBookingRS>(strResponse);

return resp;
}
else
{
throw new Exception("Error HTTP- Code: " + [Link] + " Message: " + strResponse);
}
};
}
finally
{
[Link]();
};
}

public SearchBookingsRS SearchBookings(SearchBookingsRQ query)


{
HttpClient client = new HttpClient();
try
{
[Link](new MediaTypeWithQualityHeaderValue("application/json"));
[Link]("Content-Type", "application/json");
[Link]("Ocp-Apim-Subscription-Key", IryoCredentials.
SubscriptionKey);
[Link]("Accept-Language", "es-ES");
[Link] = new AuthenticationHeaderValue("Bearer", IryoCredentials.
AuthorisationToken.access_token);

[Link] 2/15
24/10/24, 8:05 Correo de EMOVEERE CONSULTING - (sin asunto)
var strContent = [Link]();
var uri = [Link] + "/conecta/manage/bookings/search";

HttpRequestMessage message = new HttpRequestMessage([Link], uri)


{
Content = new StringContent(strContent, Encoding.UTF8, "application/json"),
};

using (HttpResponseMessage response = [Link](message).Result)


{
[Link]([Link], "SearchBookings", uri, strContent);
var strResponse = [Link]().Result;
[Link]([Link], "SearchBookings", "", strResponse);

if ([Link])
{
var resp = [Link]<SearchBookingsRS>(strResponse);
return resp;
}
else
{
throw new Exception("Error HTTP- Code: " + [Link] + " Message: " +
[Link]().Result);
}
};
}
finally
{
[Link]();
};
}

public UpdatePassengerRS UpdatePassenger(UpdatePassengersRQ query)


{
HttpClient client = new HttpClient();
try
{
[Link](new MediaTypeWithQualityHeaderValue("application/json"));
[Link]("Content-Type", "application/json");
[Link]("Ocp-Apim-Subscription-Key", IryoCredentials.
SubscriptionKey);
[Link] = new AuthenticationHeaderValue("Bearer", IryoCredentials.
AuthorisationToken.access_token);

var result = new UpdatePassengerRS();


foreach (var passenger in [Link])
{
var strContent = [Link]();
var uri = [Link] + "/conecta/manage/bookings/" + [Link] +
"/passengers/" + passenger.passenger_id;

HttpRequestMessage message = new HttpRequestMessage(new HttpMethod("PATCH"), uri)


{
Content = new StringContent(strContent, Encoding.UTF8, "application/json"),
};

using (HttpResponseMessage response = [Link](message).Result)


{
[Link]([Link], "UpdatePassenger", uri, strContent);
var strResponse = [Link]().Result;
[Link]([Link], "UpdatePassenger", "", strResponse);

if ([Link])
{
var resp = [Link]<UpdatePassengerRS>(strResponse);
result = resp;
}
else
{

[Link] 3/15
24/10/24, 8:05 Correo de EMOVEERE CONSULTING - (sin asunto)
throw new Exception("Error HTTP- Code: " + [Link] + " Message: " +
[Link]().Result);
}
};
};

return result;
}
finally
{
[Link]();
};
}

public PaymentMethodsRS PaymentMethods(string bookingNumber)


{
HttpClient client = new HttpClient();
try
{
[Link](new MediaTypeWithQualityHeaderValue("application/json"));
[Link]("Content-Type", "application/json");
[Link]("Ocp-Apim-Subscription-Key", IryoCredentials.
SubscriptionKey);
[Link] = new AuthenticationHeaderValue("Bearer", IryoCredentials.
AuthorisationToken.access_token);

var uri = [Link] + "/conecta/gateway/payments/methods?bookingNumber=" +


bookingNumber;

HttpRequestMessage message = new HttpRequestMessage([Link], uri);

using (HttpResponseMessage response = [Link](message).Result)


{
[Link]([Link], "PaymentMethods", uri, "");
var strResponse = [Link]().Result;
[Link]([Link], "PaymentMethods", "", strResponse);

if ([Link])
{
var methodsArray = [Link]<PaymenMethod[]>(strResponse);

var resp = new PaymentMethodsRS


{
Methods = methodsArray
};

return resp;
}
else
{
throw new Exception("Error HTTP- Code: " + [Link] + " Message: " +
[Link]().Result);
}
};
}
finally
{
[Link]();
};
}

public PaymentAccountRS PaymentAccount(PaymentAccountRQ query)


{
HttpClient client = new HttpClient();
try
{
[Link](new MediaTypeWithQualityHeaderValue("application/json"));

[Link] 4/15
24/10/24, 8:05 Correo de EMOVEERE CONSULTING - (sin asunto)
[Link]("Content-Type", "application/json");
[Link]("Ocp-Apim-Subscription-Key", IryoCredentials.
SubscriptionKey);
[Link] = new AuthenticationHeaderValue("Bearer", IryoCredentials.
AuthorisationToken.access_token);

var strContent = [Link]();


var uri = [Link] + "/conecta/gateway/payments/account";

HttpRequestMessage message = new HttpRequestMessage([Link], uri)


{
Content = new StringContent(strContent, Encoding.UTF8, "application/json"),
};

using (HttpResponseMessage response = [Link](message).Result)


{

[Link]([Link], "PaymentAccount", uri, strContent);


var strResponse = [Link]().Result;
[Link]([Link], "PaymentAccount", "", strResponse);

if ([Link])
{
var resp = [Link]<PaymentAccountRS>(strResponse);
return resp;
}
else
{
throw new Exception("Error HTTP- Code: " + [Link] + " Message: " +
[Link]().Result);
}
};
}
finally
{
[Link]();
};
}

public Card3DsPaymentRS Card3DsPayment(Card3DsPaymentRQ query)


{
HttpClient client = new HttpClient();
try
{
[Link](new MediaTypeWithQualityHeaderValue("application/json"));
[Link]("Content-Type", "application/json");
[Link]("Ocp-Apim-Subscription-Key", IryoCredentials.
SubscriptionKey);
[Link] = new AuthenticationHeaderValue("Bearer", IryoCredentials.
AuthorisationToken.access_token);

var strContent = [Link]();


var uri = [Link] + "/conecta/gateway/payments/3ds/api";

HttpRequestMessage message = new HttpRequestMessage([Link], uri)


{
Content = new StringContent(strContent, Encoding.UTF8, "application/json"),
};

using (HttpResponseMessage response = [Link](message).Result)


{
[Link]([Link], "Card3DsPayment", uri, strContent);
var strResponse = [Link]().Result;
[Link]([Link], "Card3DsPayment", "", strResponse);

if ([Link])
{
var resp = [Link]<Card3DsPaymentRS>(strResponse);

[Link] 5/15
24/10/24, 8:05 Correo de EMOVEERE CONSULTING - (sin asunto)
return resp;
}
else
{
throw new Exception("Error HTTP- Code: " + [Link] + " Message: " +
[Link]().Result);
}
};
}
finally
{
[Link]();
};
}

public ProcessPaymentRS ProcessPayment(ProcessPaymentRQ query)


{
HttpClient client = new HttpClient();
try
{
[Link](new MediaTypeWithQualityHeaderValue("application/json"));
[Link]("Content-Type", "application/json");
[Link]("Ocp-Apim-Subscription-Key", IryoCredentials.
SubscriptionKey);
[Link] = new AuthenticationHeaderValue("Bearer", IryoCredentials.
AuthorisationToken.access_token);

var strContent = [Link]();


var uri = [Link] + "/conecta/gateway/payments/process";

HttpRequestMessage message = new HttpRequestMessage([Link], uri)


{
Content = new StringContent(strContent, Encoding.UTF8, "application/json"),
};

using (HttpResponseMessage response = [Link](message).Result)


{
[Link]([Link], "ProcessPayment", uri, strContent);
var strResponse = [Link]().Result;
[Link]([Link], "ProcessPayment", "", strResponse);

if ([Link])
{
var resp = [Link]<ProcessPaymentRS>(strResponse);
return resp;
}
else
{
throw new Exception("Error HTTP- Code: " + [Link] + " Message: " +
[Link]().Result);
}
};
}
finally
{
[Link]();
};
}

public VoucherPaymentRS VoucherPayment(VoucherPaymentRQ query)


{
HttpClient client = new HttpClient();
try
{
[Link](new MediaTypeWithQualityHeaderValue("application/json"));
[Link]("Content-Type", "application/json");
[Link]("Ocp-Apim-Subscription-Key", IryoCredentials.

[Link] 6/15
24/10/24, 8:05 Correo de EMOVEERE CONSULTING - (sin asunto)
SubscriptionKey);
[Link] = new AuthenticationHeaderValue("Bearer", IryoCredentials.
AuthorisationToken.access_token);

var strContent = [Link]();


var uri = [Link] + "/conecta/gateway/payments/voucher";

HttpRequestMessage message = new([Link], uri)


{
Content = new StringContent(strContent, Encoding.UTF8, "application/json"),
};

using (HttpResponseMessage response = [Link](message).Result)


{
[Link]([Link], "VoucherPayment", uri, strContent);
var strResponse = [Link]().Result;
[Link]([Link], "VoucherPayment", "", strResponse);

if ([Link])
{
var resp = [Link]<VoucherPaymentRS>(strResponse);
return resp;
}
else
{
throw new Exception("Error HTTP- Code: " + [Link] + " Message: " +
[Link]().Result);
}
};
}
finally
{
[Link]();
};
}

public ConfirmBookingRS ConfirmBooking(string bookingNumber)


{
HttpClient client = new();
try
{
[Link](new MediaTypeWithQualityHeaderValue("application/json"));
[Link]("Content-Type", "application/json");
[Link]("Ocp-Apim-Subscription-Key", IryoCredentials.
SubscriptionKey);
[Link] = new AuthenticationHeaderValue("Bearer", IryoCredentials.
AuthorisationToken.access_token);

var uri = [Link] + "/conecta/manage/bookings/" + bookingNumber + "/confirm";

HttpRequestMessage message = new([Link], uri);

using (HttpResponseMessage response = [Link](message).Result)


{
[Link]([Link], "ConfirmBooking", uri, "");
var strResponse = [Link]().Result;
[Link]([Link], "ConfirmBooking", "", strResponse);

if ([Link])
{
var resp = [Link]<ConfirmBookingRS>(strResponse);
return resp;
}
else
{
throw new Exception("Error HTTP- Code: " + [Link] + " Message: " +
[Link]().Result);
}
};

[Link] 7/15
24/10/24, 8:05 Correo de EMOVEERE CONSULTING - (sin asunto)
}
finally
{
[Link]();
};
}

public RetrieveBookingRS RetrieveBooking(string bookingNumber)


{
HttpClient client = new();
try
{
[Link](new MediaTypeWithQualityHeaderValue("application/json"));
[Link]("Content-Type", "application/json");
[Link]("Ocp-Apim-Subscription-Key", IryoCredentials.
SubscriptionKey);
[Link]("Accept-Language", "es-ES");
[Link] = new AuthenticationHeaderValue("Bearer", IryoCredentials.
AuthorisationToken.access_token);

var uri = [Link] + "/conecta/manage/bookings/" + bookingNumber;

HttpRequestMessage message = new HttpRequestMessage([Link], uri);

using (HttpResponseMessage response = [Link](message).Result)


{
[Link]([Link], "RetrieveBooking", uri, "");
var strResponse = [Link]().Result;
[Link]([Link], "RetrieveBooking", "", strResponse);

if ([Link])
{
var resp = [Link]<RetrieveBookingRS>(strResponse);
return resp;
}
else
{
throw new Exception("Error HTTP- Code: " + [Link] + " Message: " +
[Link]().Result);
}
};
}
finally
{
[Link]();
};
}

public CancelBookingRS CancelBooking(string bookingNumber, bool twoStep)


{
HttpClient client = new HttpClient();

try
{
[Link](new MediaTypeWithQualityHeaderValue("application/json"));
[Link]("Content-Type", "application/json");
[Link]("Ocp-Apim-Subscription-Key", IryoCredentials.
SubscriptionKey);
[Link] = new AuthenticationHeaderValue("Bearer", IryoCredentials.
AuthorisationToken.access_token);

var cancelRQ = new CancelBookingRQ()


{
twoStepsAction = true
};

string strContent = "";

if (twoStep)

[Link] 8/15
24/10/24, 8:05 Correo de EMOVEERE CONSULTING - (sin asunto)
{
strContent = [Link]();
};

var uri = [Link] + "/conecta/manage/bookings/" + bookingNumber + "/cancel";

HttpRequestMessage message = new HttpRequestMessage([Link], uri)


{
Content = new StringContent(strContent, Encoding.UTF8, "application/json"),
};

using (HttpResponseMessage response = [Link](message).Result)


{
[Link]([Link], "CancelBooking", uri, strContent);
var strResponse = [Link]().Result;
[Link]([Link], "CancelBooking", "", strResponse);

if ([Link])
{
var resp = [Link]<CancelBookingRS>(strResponse);
return resp;
}
else
{
throw new Exception("Error HTTP- Code: " + [Link] + " Message: " +
[Link]().Result);
}
};
}
finally
{
[Link]();
};
}

public RefundMethodsRS RefundMethods(string bookingNumber)


{
HttpClient client = new HttpClient();
try
{
[Link](new MediaTypeWithQualityHeaderValue("application/json"));
[Link]("Content-Type", "application/json");
[Link]("Ocp-Apim-Subscription-Key", IryoCredentials.
SubscriptionKey);
[Link]("Accept-Language", "es-ES");
[Link] = new AuthenticationHeaderValue("Bearer", IryoCredentials.
AuthorisationToken.access_token);

var uri = [Link] + "/conecta/gateway/payments/methods?bookingNumber=" +


bookingNumber;

HttpRequestMessage message = new HttpRequestMessage([Link], uri);

using (HttpResponseMessage response = [Link](message).Result)


{
[Link]([Link], "RefundMethods", uri, "");
var strResponse = [Link]().Result;
[Link]([Link], "RefundMethods", "", strResponse);

if ([Link])
{
var methodsArray = [Link]<RefundMethod[]>(strResponse);

var resp = new RefundMethodsRS


{
RefundMethods = methodsArray
};

[Link] 9/15
24/10/24, 8:05 Correo de EMOVEERE CONSULTING - (sin asunto)
return resp;
}
else
{
throw new Exception("Error HTTP- Code: " + [Link] + " Message: " +
[Link]().Result);
}
};
}
finally
{
[Link]();
};
}

public void RefundPSP(string bookingNumber)


{
HttpClient client = new HttpClient();

try
{
[Link](new MediaTypeWithQualityHeaderValue("application/json"));
[Link]("Content-Type", "application/json");
[Link]("Ocp-Apim-Subscription-Key", IryoCredentials.
SubscriptionKey);
[Link] = new AuthenticationHeaderValue("Bearer", IryoCredentials.
AuthorisationToken.access_token);

var refundRQ = new RefundPspRQ()


{
bookingNumber = bookingNumber
};

var strContent = [Link]();


var uri = [Link] + "/conecta/gateway/refunds/psp";

HttpRequestMessage message = new HttpRequestMessage([Link], uri)


{
Content = new StringContent(strContent, Encoding.UTF8, "application/json"),
};

using (HttpResponseMessage response = [Link](message).Result)


{
[Link]([Link], "Refund", uri, "");
var strResponse = [Link]().Result;
[Link]([Link], "Refund", "", strResponse);

if (![Link])
{
throw new Exception("Error HTTP- Code: " + [Link] + " Message: " +
[Link]().Result);
}
};
}
finally
{
[Link]();
};
}

public List<Products> GetProducts()


{
HttpClient client = new HttpClient();
try
{
[Link](new MediaTypeWithQualityHeaderValue("application/json"));
[Link]("Content-Type", "application/json");

[Link] 10/15
24/10/24, 8:05 Correo de EMOVEERE CONSULTING - (sin asunto)
[Link]("Ocp-Apim-Subscription-Key", IryoCredentials.
SubscriptionKey);
[Link]("Accept-Language", "es-ES");
[Link] = new AuthenticationHeaderValue("Bearer", IryoCredentials.
AuthorisationToken.access_token);

HttpRequestMessage message = new HttpRequestMessage([Link],


[Link] + "/conecta/support/products");

using (HttpResponseMessage response = [Link](message).Result)


{
if ([Link])
{
var strResponse = [Link]().Result;
var resp = [Link]<IryoProductRS>(strResponse);
return [Link]();
}
else
{
throw new Exception("Error HTTP- Code: " + [Link] + " Message: " +
[Link]().Result);
}
};
}
finally
{
[Link]();
};
}

public List<T> GetGeneric<T>(string uri)


{
HttpClient client = new HttpClient();
try
{
[Link](new MediaTypeWithQualityHeaderValue("application/json"));
[Link]("Content-Type", "application/json");
[Link]("Accept-Language", "es-ES");
[Link]("Ocp-Apim-Subscription-Key", IryoCredentials.
SubscriptionKey);
[Link] = new AuthenticationHeaderValue("Bearer", IryoCredentials.
AuthorisationToken.access_token);

HttpRequestMessage message = new HttpRequestMessage([Link],


[Link] + uri);

using (HttpResponseMessage response = [Link](message).Result)


{
if ([Link])
{
var strResponse = [Link]().Result;
var resp = [Link]<IryoGenericTypesRs<T>>(strResponse);
return [Link]();
}
else
{
throw new Exception("Error HTTP- Code: " + [Link] + " Message: " +
[Link]().Result);
}
};
}
finally
{
[Link]();
};
}

public SalesChannelRS SalesChannel()


{

[Link] 11/15
24/10/24, 8:05 Correo de EMOVEERE CONSULTING - (sin asunto)

HttpClient client = new HttpClient();


try
{
[Link](new MediaTypeWithQualityHeaderValue("application/json"));
[Link]("Content-Type", "application/json");
[Link]("Ocp-Apim-Subscription-Key", IryoCredentials.
SubscriptionKey);
[Link]("Accept-Language", "es-ES");
[Link] = new AuthenticationHeaderValue("Bearer", IryoCredentials.
AuthorisationToken.access_token);

var uri = [Link] + "/conecta/config/sales-channel";

HttpRequestMessage message = new HttpRequestMessage([Link], uri);

using (HttpResponseMessage response = [Link](message).Result)


{
//[Link]([Link], "SalesChannel", uri, "");
var strResponse = [Link]().Result;
//[Link]([Link], "SalesChannel", "", strResponse);

if ([Link])
{
var resp = [Link]<SalesChannelRS>(strResponse);
return resp;
}
else
{
throw new Exception("Error HTTP- Code: " + [Link] + " Message: " +
[Link]().Result);
}
};
}
finally
{
[Link]();
}
}

public PassengerRulesRS PassengerRules()


{
HttpClient client = new HttpClient();
try
{
[Link](new MediaTypeWithQualityHeaderValue("application/json"));
[Link]("Content-Type", "application/json");
[Link]("Ocp-Apim-Subscription-Key", IryoCredentials.
SubscriptionKey);
[Link]("Accept-Language", "es-ES");
[Link] = new AuthenticationHeaderValue("Bearer", IryoCredentials.
AuthorisationToken.access_token);

var uri = [Link] + "/conecta/build/bookings/passenger-rules";

HttpRequestMessage message = new HttpRequestMessage([Link], uri);

using (HttpResponseMessage response = [Link](message).Result)


{
[Link]([Link], "PassengerRules", uri, "");
var strResponse = [Link]().Result;
[Link]([Link], "PassengerRules", "", strResponse);

if ([Link])
{
var resp = [Link]<PassengerRulesRS>(strResponse);
return resp;
}

[Link] 12/15
24/10/24, 8:05 Correo de EMOVEERE CONSULTING - (sin asunto)
else
{
throw new Exception("Error HTTP- Code: " + [Link] + " Message: " +
[Link]().Result);
}
};
}
finally
{
[Link]();
};
}

public List<RouteInfo> GetRoutes()


{
HttpClient client = new HttpClient();
try
{
[Link](new MediaTypeWithQualityHeaderValue("application/json"));
[Link]("Content-Type", "application/json");
[Link]("Ocp-Apim-Subscription-Key", IryoCredentials.
SubscriptionKey);
[Link]("Accept-Language", "es-ES");
[Link] = new AuthenticationHeaderValue("Bearer", IryoCredentials.
AuthorisationToken.access_token);

var uri = [Link] + "/conecta/support/routes";

HttpRequestMessage message = new HttpRequestMessage([Link], uri);

using (HttpResponseMessage response = [Link](message).Result)


{
// [Link]([Link], "RetrieveBooking", uri, "");
var strResponse = [Link]().Result;
// [Link]([Link], "RetrieveBooking", "",
strResponse);

if ([Link])
{
var resp = [Link]<RoutesRS>(strResponse);
return [Link]();
}
else
{
throw new Exception("Error HTTP- Code: " + [Link] + " Message: " +
[Link]().Result);
}
};
}
finally
{
[Link]();
};
}

public AuthenticationTokenRS GetAuthenticationToken(string apiKey, string userName)


{
HttpClient client = new HttpClient();

try
{
[Link](new MediaTypeWithQualityHeaderValue("application/json"));
[Link]("Content-Type", "application/json");

var nvc = new List<KeyValuePair<string, string>>();


[Link](new KeyValuePair<string, string>("client_id", "api"));
[Link](new KeyValuePair<string, string>("grant_type", "password"));
[Link](new KeyValuePair<string, string>("api_key", apiKey)); //password

[Link] 13/15
24/10/24, 8:05 Correo de EMOVEERE CONSULTING - (sin asunto)
[Link](new KeyValuePair<string, string>("scope", "openid"));
[Link](new KeyValuePair<string, string>("username", userName)); //username

HttpRequestMessage message = new HttpRequestMessage([Link],


[Link] + "/auth/realms/ilsa/protocol/openid-connect/token")
{
Content = new FormUrlEncodedContent(nvc)
};

using (HttpResponseMessage response = [Link](message).Result)


{
if ([Link])
{
var strResponse = [Link]().Result;
var resp = [Link]<AuthenticationTokenRS>(strResponse);
return resp;
}
else
{
throw new Exception("Error HTTP- Code: " + [Link] + " Message: " +
[Link]().Result);
}
};
}
finally
{
[Link]();
}
}

public AuthorisationTokenRS GetAuthorisationToken(string authenToken)


{
HttpClient client = new HttpClient();
try
{
[Link](new MediaTypeWithQualityHeaderValue("application/json"));
[Link]("Content-Type", "application/json");

var nvc = new List<KeyValuePair<string, string>>();


[Link](new KeyValuePair<string, string>("audience", "internal-api"));
[Link](new KeyValuePair<string, string>("grant_type", "urn:ietf:params:oauth:grant-type:uma-ticket"));

[Link] = new AuthenticationHeaderValue("Bearer", authenToken);

HttpRequestMessage message = new HttpRequestMessage([Link],


[Link] + "/auth/realms/ilsa/protocol/openid-connect/token")
{
Content = new FormUrlEncodedContent(nvc)
};

using (HttpResponseMessage response = [Link](message).Result)


{
if ([Link])
{
var strResponse = [Link]().Result;
var resp = [Link]<AuthorisationTokenRS>(strResponse);
return resp;
}
else
{
throw new Exception("Error HTTP- Code: " + [Link] + " Message: " +
[Link]().Result);
}
};
}
finally
{
[Link]();
}

[Link] 14/15
24/10/24, 8:05 Correo de EMOVEERE CONSULTING - (sin asunto)
}

public RefreshAuthorisationTokenRS RefreshAuthorisationToken(string authenToken, string refreshToken)


{
HttpClient client = new HttpClient();
try
{
[Link](new MediaTypeWithQualityHeaderValue("application/json"));
[Link]("Content-Type", "application/json");

var nvc = new List<KeyValuePair<string, string>>();


[Link](new KeyValuePair<string, string>("client_id", "api"));
[Link](new KeyValuePair<string, string>("grant_type", "refresh_token"));
[Link](new KeyValuePair<string, string>("refresh_token", refreshToken));

[Link] = new AuthenticationHeaderValue("Bearer", authenToken);

HttpRequestMessage message = new HttpRequestMessage([Link],


[Link] + "/auth/realms/ilsa/protocol/openid-connect/token")
{
Content = new FormUrlEncodedContent(nvc)
};

using (HttpResponseMessage response = [Link](message).Result)


{
if ([Link])
{
var strResponse = [Link]().Result;
var resp = [Link]<RefreshAuthorisationTokenRS>(strResponse);
return resp;
}
else
{
throw new Exception("Error HTTP- Code: " + [Link] + " Message: " +
[Link]().Result);
}
};
}
finally
{
[Link]();
}
}
}

[Link] 15/15

You might also like