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

Support for Custom Metaproperties #126

Merged
merged 3 commits into from
Aug 6, 2024

Conversation

jdickel
Copy link
Contributor

@jdickel jdickel commented Aug 6, 2024

I've create a PR for #112.

In this PR the Media class now returns customMetaproperties as Map<String, List<String> where the key is the property name without property_ prefix and the value is always a list of strings, even if the API returned a single String as value for that specific attribute. I did this for simlicity reasons.

The following API response as Media object

  "property_Articlenumber": "4711",
  "property_Testattribute": [
      "Value"
  ],
  "property_Asset_Type": [
      "Photos"
  ]

will be presented in the Java Object as below

"customMetaproperties": {
    "Articlenumber": [
        "4711"
    ],
    "Testattribute": [
        "Value"
    ],
    "Asset_Type": [
        "Photos"
    ]
}

Unfortunately the choice of Retrofit doesn't perfectly fit (pun not intended) to the choice of having "property_" prefixed attributes on the same level as all other Media attributes.
With Retrofit you're only capable of setting custom Adapters on the API delivered attributes like "isPublic" for example. If the delivered attribute is some kind of wildcard like "property_*" a custom adapter is not possible at all.
That's why i implemented a custom MediaTypeAdapter for the whole class as the only possible solution i could think of.

Please give some feedback on the implementation and let me know if this works fine to you.
Testcases are included.

@coveralls
Copy link

Coverage Status

coverage: 39.218%. remained the same
when pulling 3a3cf25 on jdickel:feature/support-custom-metadata
into 81cfc4b on Bynder:master.

@jdickel
Copy link
Contributor Author

jdickel commented Aug 6, 2024

I've also did the following

  • add .gitignore - to prevent checkin of target/ files
  • Windows OS support for testcases - There was an issue with D: when loading files from harddrive
  • updated from initMocks(this) to openMocks(this) due to deprecation.

Please check if those changes do not break anything on your end.

@ahongbynder ahongbynder merged commit 151c4cb into Bynder:master Aug 6, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants