Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add INARA & Community Goals api #11

Closed
18 tasks done
irongut opened this issue Jun 15, 2020 · 6 comments · Fixed by #71
Closed
18 tasks done

Add INARA & Community Goals api #11

irongut opened this issue Jun 15, 2020 · 6 comments · Fixed by #71
Assignees
Labels
CGs INARA getCommunityGoals API Cmdr-Profile INARA getCommanderProfile API Demo Demo applications documentation Improvements or additions to documentation enhancement New feature or request INARA INARA API Network Network Layer Tests Unit tests

Comments

@irongut
Copy link
Owner

irongut commented Jun 15, 2020

Feature Request

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

  • Add a PostData method to IDownloadService & implementations.
  • Change InaraService to use IDownloadService instead of it's own HttpClient.
  • Add InaraIdentity class to encapsulate identity & api keys for Inara API. This must be provided by calling app.
  • Change CG service to a singleton that caches & returns the data like other EDlib API Services.
  • Allow variable cache for CGs; min 60 minutes.
  • Change the BoW to json.
  • Allow variable number of days back to return goals returned but cache all the data; min 7 days.
  • Allow calling code to provide alternative BoWs as an optional json string. See Rework News & CG classification #56 Rework News & CG classification.
  • Add methods to CG service to get all (usually 15) or a specific number of CGs.
  • Implement UnitTests using appsettings.json & user secrets to store credentials locally but not in git. CI builds use an Action that replaces values in appsettings.json with values from GitHub Secrets. Use EliteALD credentials.
  • Add latest two CGs to Demo app output. Use appsettings.json, user secrets & GitHub Secrets to provide credentials like tests.
  • Implement Inara getCommanderProfile API, see below.
  • Implement tests for getCommanderProfile API.
  • Add getCommanderProfile API to Demo app. too likely to be throttled
  • Preserve attributes for linker.
  • CI Build: Copy secrets to appsettings.json in Demo app.
  • Ensure all INARA classes are tested.
  • Documentation, documentation, documentation.

Requires

  • Models/CommunityGoal.cs
  • Models/InaraEvent.cs
  • Models/InaraHeader.cs
  • Models/InaraInputOutput.cs renamed to InaraRequest
  • Models/InaraIdentity.cs (new)
  • Models/Topic.cs
  • Resources/CGBoW.csv converted to CGBoW.json
  • Services/CommunityGoalsService.cs
  • Services/InaraService.cs
  • IDownloadService

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 irongut added the enhancement New feature or request label Jun 15, 2020
@irongut irongut self-assigned this Jun 15, 2020
@irongut irongut added CGs INARA getCommunityGoals API Network Network Layer labels Jun 15, 2020
@irongut irongut added the INARA INARA API label Jul 3, 2020
@irongut
Copy link
Owner Author

irongut commented Aug 30, 2020

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.

@irongut irongut pinned this issue Aug 30, 2020
@irongut irongut added the documentation Improvements or additions to documentation label Nov 29, 2020
@irongut irongut unpinned this issue Apr 8, 2021
@github-actions
Copy link

github-actions bot commented Apr 9, 2021

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.

@github-actions github-actions bot added the stale label Apr 9, 2021
@irongut irongut removed the stale label Apr 9, 2021
@irongut irongut pinned this issue Apr 26, 2021
irongut added a commit that referenced this issue Apr 26, 2021
irongut added a commit that referenced this issue Apr 26, 2021
irongut added a commit that referenced this issue Apr 26, 2021
irongut added a commit that referenced this issue Apr 26, 2021
@irongut
Copy link
Owner Author

irongut commented Apr 27, 2021

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

@irongut
Copy link
Owner Author

irongut commented Apr 28, 2021

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:

  • an exact match found using an app api key.
  • an exact match not found using an app api key.
  • only a user api key sent, without a searchName.
  • an exact match found using a user api key.
  • an exact match not found using a user api key.

@irongut
Copy link
Owner Author

irongut commented Apr 28, 2021

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:

  • the events::eventStatus is 202 instead of 200 - this may trip up error checking!
  • a status text property is added to events: "eventStatusText": "Multiple results found."
  • a commanderName property is added to events::eventData
  • the otherNamesFound property is added to events::eventData with a list of other matches
    "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
Copy link
Owner Author

irongut commented Apr 29, 2021

Additional Research

Research with Postman.

  • Request a different Cmdr to Irongut with app api key.
  • Request a different Cmdr to Irongut with user api key.
  • Request a non-existent Cmdr; no matches. e.g. 01234
  • Request a non-existent Cmdr; partial matches only. e.g. seraphin

Non-existent Cmdr with user api key:

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

Unit Tests

  • Query for exact match with app api key.
  • Query for exact match with user api key.
  • Query for multiple partial matches with user api key.
  • Query using user api key only.
  • Query for no matches - only if that doesn't throw an exception.

irongut added a commit that referenced this issue Apr 30, 2021
irongut added a commit that referenced this issue Apr 30, 2021
irongut added a commit that referenced this issue Apr 30, 2021
irongut added a commit that referenced this issue Apr 30, 2021
irongut added a commit that referenced this issue May 1, 2021
irongut added a commit that referenced this issue May 1, 2021
irongut added a commit that referenced this issue May 1, 2021
irongut added a commit that referenced this issue May 1, 2021
irongut added a commit that referenced this issue May 1, 2021
irongut added a commit that referenced this issue May 2, 2021
irongut added a commit that referenced this issue May 2, 2021
irongut added a commit that referenced this issue May 2, 2021
irongut added a commit that referenced this issue May 2, 2021
irongut added a commit that referenced this issue May 2, 2021
@irongut irongut added Cmdr-Profile INARA getCommanderProfile API Demo Demo applications Tests Unit tests labels May 3, 2021
@irongut irongut unpinned this issue May 3, 2021
irongut added a commit that referenced this issue May 5, 2021
irongut added a commit that referenced this issue May 5, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CGs INARA getCommunityGoals API Cmdr-Profile INARA getCommanderProfile API Demo Demo applications documentation Improvements or additions to documentation enhancement New feature or request INARA INARA API Network Network Layer Tests Unit tests
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant