Skip to content

Commit

Permalink
DOI client update
Browse files Browse the repository at this point in the history
  • Loading branch information
munrojm committed May 7, 2021
1 parent a9cea9a commit e66cd8a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
20 changes: 1 addition & 19 deletions src/mp_api/routes/dois/client.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,8 @@
from mp_api.core.client import BaseRester, MPRestError
from mp_api.core.client import BaseRester
from mp_api.routes.dois.models import DOIDoc


class DOIRester(BaseRester):

suffix = "doi"
document_model = DOIDoc # type: ignore

def get_eos_from_material_id(self, material_id: str):
"""
Get DOI and reference data for a given Materials Project ID.
Arguments:
material_id (str): Materials project ID
Returns:
results (Dict): Dictionary containing DOI and reference data of state data.
"""

result = self._make_request("{}/?all_fields=true".format(material_id))

if len(result.get("data", [])) > 0:
return result
else:
raise MPRestError("No document found")
13 changes: 13 additions & 0 deletions src/mp_api/routes/dois/client.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from typing import List, Optional
from mp_api.routes.dois.models import DOIDoc


class DOIRester:

def get_document_by_id(
self,
document_id: str,
fields: Optional[List[str]] = None,
monty_decode: bool = True,
version: Optional[str] = None,
) -> DOIDoc: ...

0 comments on commit e66cd8a

Please sign in to comment.