irongut / EDlib

A .Net Standard library for creating companion apps for the game Elite Dangerous by Frontier Developments.
MIT License
4 stars 0 forks source link

Add INARA & Community Goals api #11

Closed irongut closed 3 years ago

irongut commented 4 years ago

Feature Request

Port INARA & Community Goals api from EliteALD. Allow new services in EDlib or consuming code to add new INARA api methods.

Requires

Linked To

14 Make the library linker safe

56 Rework News & CG classification

60 Galactic Standings is not link safe

irongut/EliteALD#154 Complete transfer of code to EDlib

irongut commented 4 years ago

Adaptive Cache Timing

Api method services will set the cache time but implement an adaptive cache that increases the time if there has been no change in the data for an extended period. e.g. Cache for 1 hour, if no changes in 3 days change cache expiry to 4 hours, if no changes after 7 days change cache expiry to 1 day; any update resets the cache time to 1 hour.

Knowing where the cache is in the current cycle will require a setting (platform specific) so better left to consuming code. Implement a minimum 1 hour cache time in the api service but allow consumer to increase it.

github-actions[bot] commented 3 years ago

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this issue will be closed in 30 days.

irongut commented 3 years ago

CommunityGoalsService.GetData should check if its local cache covers the same requestDays & maybe identity before returning that data. Atm it does not.

irongut commented 3 years ago

getCommanderProfile

Returns basic information about a commander from Inara like ranks, squadron, etc.

eventData Input Properties

Property name Description
searchName (string) Commander's name. The input name provided is used in an exact match search against in-game commander names. If not found, it is then used to search Inara user names. If an exact match is not found, the first result of the search is returned. If no input name provided and personal API key is used, the profile of the current user is returned.

Note: The 'commanderName' in the output is returned just when the 'searchName' and commander's in-game name exactly match (and is known). When there is no exact match, other possible names are returned in the 'otherNamesFound' list (up to 20 records).

Notes

Use Postman to research response when:

irongut commented 3 years ago

getCommanderProfile Research

Exact Match

Data returned in events (eventStatus and eventData) is the same for app key & user key. Headers are different - with app key the header contains only eventStatus, with user api key the header also contains data:

    "header": {
        "eventData": {
            "userID": "151725",
            "userName": "Irongut"
        },
        "eventStatus": 200
    },

EDlib's InaraHeader class does not include an eventData property atm.

Including a commanderName property with a user api key doesn't change the response.

Partial Match

Like an exact match, headers are the only difference in response between a partial match with an app api key and a partial match with a user api key.

Partial match returns the most likely result and a list of other names found. Compared to an exact match:

    "otherNamesFound": [
        "IronGear",
        "Irongrip",
        "irongear_",
        "Ironglove",
        "Irongaming",
        "Irongamer39",
        "IronGhost24",
        "Irongolem27",
        "IronGremlin",
        "IronGauntlet",
        "Ironghost250",
        "Irongunner1224",
        "IronGAMER 76201",
        "IronGlint713649"
    ]

User Api Key Only

The response with only a user api key and no searchName parameter is the same as an exact match with a user api key. (The data is for the user who matches the api key.)

irongut commented 3 years ago

Additional Research

Research with Postman.

Non-existent Cmdr with user api key:

{
    "header": {
        "eventData": {
            "userID": "151725",
            "userName": "Irongut"
        },
        "eventStatus": 200
    },
    "events": [
        {
            "eventStatus": 204,
            "eventStatusText": "No results found."
        }
    ]
}

Unit Tests