public FindCustomerViewModel(IEndpointClient endpointClient, DbManager dbManager, IPreferenceManager preferenceManager, IFileClient fileClient) { this.endpointClient = endpointClient; this.dbManager = dbManager; this.preferenceManager = preferenceManager; this.fileClient = fileClient; }
protected virtual void AssertRequest(CallInfo callInfo, IEndpointClient client, string pathAndQuery) { // Format the URI to how it's supposed to be var uri = new Uri(Gw2WebApiV2Client.UrlBase, $"{client.EndpointPath}{pathAndQuery}"); var parameterProperties = client.GetType() .GetProperties(BindingFlags.Public | BindingFlags.Instance) .Where(p => p.GetCustomAttribute <EndpointQueryParameterAttribute>() != null); if (parameterProperties.Any()) { var builder = new UriBuilder(uri); foreach (var parameter in parameterProperties) { var attr = parameter.GetCustomAttribute <EndpointQueryParameterAttribute>(); var value = parameter.GetValue(client); if (value == null) { continue; } string toAppend = $"{attr.ParameterName}={value}"; builder.Query = builder.Query != null && builder.Query.Length > 1 ? $"{builder.Query.Substring(1)}&{toAppend}" : toAppend; } uri = builder.Uri; } Assert.Equal(uri.AbsoluteUri, callInfo.ArgAt <IWebApiRequest>(0).Options.Url.AbsoluteUri); var requestHeaders = callInfo.ArgAt <IWebApiRequest>(0).Options.RequestHeaders; Assert.Contains(new KeyValuePair <string, string>("Accept", "application/json"), requestHeaders); Assert.Contains(new KeyValuePair <string, string>("User-Agent", ((Gw2WebApiBaseClient)client).Connection.UserAgent), requestHeaders); }
public FileManager(DbManager dbManager, IPreferenceManager preferenceManager, IEndpointClient endpointClient, IFileClient fileClient) { this.dbManager = dbManager; this.preferenceManager = preferenceManager; this.endpointClient = endpointClient; this.fileClient = fileClient; }
protected virtual void AssertSchemaVersionRequest(CallInfo callInfo, IEndpointClient client) { var requestHeaders = callInfo.ArgAt <IWebApiRequest>(0).Options.RequestHeaders; if (!string.IsNullOrWhiteSpace(client.SchemaVersion)) { Assert.Contains(new KeyValuePair <string, string>("X-Schema-Version", client.SchemaVersion), requestHeaders); } else { Assert.DoesNotContain(requestHeaders, h => h.Key == "X-Schema-Version"); } }
protected virtual void AssertLocalizedRequest(CallInfo callInfo, IEndpointClient client) { var requestHeaders = callInfo.ArgAt <IWebApiRequest>(0).Options.RequestHeaders; if (client.IsLocalized) { Assert.Contains(new KeyValuePair <string, string>("Accept-Language", ((Gw2WebApiBaseClient)client).Connection.LocaleString), requestHeaders); } else { Assert.DoesNotContain(requestHeaders, h => h.Key == "Accept-Language"); } }
protected virtual void AssertAuthenticatedRequest(CallInfo callInfo, IEndpointClient client) { var requestHeaders = callInfo.ArgAt <IWebApiRequest>(0).Options.RequestHeaders; if (client.IsAuthenticated) { Assert.Contains(new KeyValuePair <string, string>("Authorization", $"Bearer {((Gw2WebApiBaseClient)client).Connection.AccessToken}"), requestHeaders); } else { Assert.DoesNotContain(requestHeaders, h => h.Key == "Authorization"); } }
public RequestBuilder(IEndpointClient endpointClient, IConnection connection, IGw2Client gw2Client) { this.baseUrl = endpointClient.BaseUrl; this.endpointPath = endpointClient.EndpointPath; this.schemaVersion = endpointClient.SchemaVersion; this.bulkQueryParameterIdName = endpointClient.BulkEndpointIdParameterName; this.bulkQueryParameterIdsName = endpointClient.BulkEndpointIdsParameterName; this.bulkObjectIdName = endpointClient.BulkEndpointIdObjectName; #if NETSTANDARD this.queryParams = endpointClient.EndpointQueryParameters.ShallowCopy(); #else this.queryParams = endpointClient.EndpointQueryParameters.AsReadOnly(); #endif this.connection = connection; this.gw2Client = gw2Client; this.authorization = endpointClient.IsAuthenticated ? $"{BEARER} {connection.AccessToken}" : null; this.locale = endpointClient.IsLocalized ? connection.LocaleString : null; this.userAgent = connection.UserAgent; }
public InventoryEndpoint(IEndpointClient client) : base(client) { feedApi = new FeedEndpoint(apiClient); payloadFactory = new Payload.PayloadFactory(); }
public BaseEndpoint(IEndpointClient apiClient) { this.apiClient = apiClient; client = apiClient.GetHttpHandler(); config = apiClient.GetEndpointConfig(); }
public FeedEndpoint(IEndpointClient apiClient) : base(apiClient) { payloadFactory = new Payload.PayloadFactory(); }
protected virtual void AssertLocalizedRequest(CallInfo callInfo, IEndpointClient client) { var requestHeaders = callInfo.ArgAt <IHttpRequest>(0).RequestHeaders; Assert.Contains(new KeyValuePair <string, string>("Accept-Language", ((IClientInternal)client).Connection.LocaleString), requestHeaders); }
public PriceEndpoint(IEndpointClient apiClient) : base(apiClient) { feedApi = new FeedEndpoint(apiClient); payloadFactory = new V2.Payload.PayloadFactory(); }
public SigninViewModel(IEndpointClient endpointClient, IPreferenceManager preferenceManager) { this.endpointClient = endpointClient; this.preferenceManager = preferenceManager; }
public CreateCustomerViewModel(IEndpointClient endpointClient) { this.endpointClient = endpointClient; }
public AddNewContactViewModel(IEndpointClient endpointClient) { this.endpointClient = endpointClient; }
/// <summary> /// Creates a new base endpoint client. /// </summary> /// <param name="client">The endpoint client.</param> /// <param name="connection">The connection used to make requests, see <see cref="IConnection"/>.</param> /// <param name="gw2Client">The Guild Wars 2 client.</param> /// <exception cref="ArgumentNullException"><paramref name="client"/>, <paramref name="connection"/> or <paramref name="gw2Client"/> is <c>null</c>.</exception> public DefaultEndpointClientImplementation(IEndpointClient client, IConnection connection, IGw2Client gw2Client) { this.client = client ?? throw new ArgumentNullException(nameof(client)); this.Connection = connection ?? throw new ArgumentNullException(nameof(connection)); this.Gw2Client = gw2Client ?? throw new ArgumentNullException(nameof(gw2Client)); }