/// <summary> /// Gets the contract items or bids. /// </summary> private void GetContractData <T>(APIProvider.ESIRequestCallback <T> callback, ESIAPICorporationMethods methodCorp, ESIAPICharacterMethods methodPersonal) where T : class { var cid = Character.Identity; ESIKey key; Enum method; long owner; // Special condition to identify corporation contracts in character query if (IssuedFor == IssuedFor.Corporation && ESIAPICorporationMethods. CorporationContracts.Equals(m_method)) { key = cid.FindAPIKeyWithAccess(methodCorp); method = methodCorp; owner = Character.CorporationID; } else { key = cid.FindAPIKeyWithAccess(methodPersonal); method = methodPersonal; owner = Character.CharacterID; } if (key != null) { EveMonClient.APIProviders.CurrentProvider.QueryEsiAsync(method, key.AccessToken, owner, ID, callback, method); } }
/// <summary> /// Gets the contract items or bids. /// </summary> private void GetContractData <T, U>(APIProvider.ESIRequestCallback <T> callback, ESIAPICorporationMethods methodCorp, ESIAPICharacterMethods methodPersonal, ResponseParams response) where T : List <U> where U : class { var cid = Character.Identity; ESIKey key; Enum method; long owner; // Special condition to identify corporation contracts in character query if (IssuedFor == IssuedFor.Corporation && ESIAPICorporationMethods. CorporationContracts.Equals(m_method)) { key = cid.FindAPIKeyWithAccess(methodCorp); method = methodCorp; owner = Character.CorporationID; } else { key = cid.FindAPIKeyWithAccess(methodPersonal); method = methodPersonal; owner = Character.CharacterID; } // Only query if the error count has not been exceeded if (key != null && !EsiErrors.IsErrorCountExceeded) { EveMonClient.APIProviders.CurrentProvider.QueryPagedEsi <T, U>(method, callback, new ESIParams(response, key.AccessToken) { ParamOne = owner, ParamTwo = ID }, method); } }
/// <summary> /// Finds the API key with access to the specified API method. /// </summary> /// <param name="method">The method.</param> /// <returns>The API key with access to the specified method or null if non found.</returns> public ESIKey FindAPIKeyWithAccess(ESIAPICorporationMethods method) => ESIKeys.FirstOrDefault(apiKey => apiKey.Monitored && (ulong)method == (apiKey.AccessMask & (ulong)method));