Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vasgat committed Jul 27, 2023
1 parent bf26942 commit 7999992
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
31 changes: 28 additions & 3 deletions wikirate4py/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def request(self, method, path, headers, params, files={}):

# if an error was returned throw an exception
try:
response = self.session.request(method, path, auth=self.auth, data=params, headers=headers, timeout=120,
response = self.session.request(method, path, auth=self.auth, data=params, headers=headers, timeout=480,
files=files)

if files.get("card[subcards][+file][file]") is not None:
Expand Down Expand Up @@ -185,6 +185,28 @@ def get_companies(self, **kwargs):
filters=('name', 'company_category', 'company_group', 'country'),
**kwargs)

@objectify(CompanyItem, list=True)
def get_companies_of(self, identifier, **kwargs):
"""get_companies(*, offset, limit)
Returns a list of WikiRate Companies
Parameters
----------
offset
default value 0, the (zero-based) offset of the first item in the collection to return
limit
default value 20, the maximum number of entries to return. If the value exceeds the maximum, then the maximum value will be used.
Returns
-------
:py:class:`List`\[:class:`~wikirate4py.models.CompanyItem`]
"""
return self.get("/~{0}+companies.json".format(identifier), endpoint_params=('limit', 'offset'),
filters=('name', 'company_category', 'company_group', 'country'),
**kwargs)

@objectify(Topic)
def get_topic(self, identifier):
"""get_topic(identifier)
Expand Down Expand Up @@ -537,7 +559,7 @@ def get_answers_by_id(self, identifier, **kwargs):
return self.get("/~{0}+Answer.json".format(identifier), endpoint_params=('limit', 'offset', 'view'),
filters=('year', 'status', 'company_group', 'country', 'value', 'value_from', 'value_to',
'updated', 'company_id', 'company_name', 'dataset', 'updater', 'outliers', 'source',
'verification', 'bookmark', 'published'),
'verification', 'bookmark', 'published', 'metric_name'),
**kwargs)

@objectify(AnswerItem, True)
Expand Down Expand Up @@ -1205,7 +1227,7 @@ def update_research_metric_answer(self, **kwargs):
"""
required_params = ('metric_designer', 'metric_name', 'company', 'year')
optional_params = ('value', 'source', 'comment')
optional_params = ('value', 'source', 'comment', 'unpublished')

for k in required_params:
if k not in kwargs or kwargs.get(k) is None:
Expand Down Expand Up @@ -1659,3 +1681,6 @@ def verify_answer(self, identifier):

def get_comments(self, identifier):
return self.get("/~{0}+discussion.json".format(identifier)).json().get('content', '')

def get_content(self, identifier):
return self.get("/{0}.json".format(identifier)).json().get('content', '')
2 changes: 1 addition & 1 deletion wikirate4py/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ class RelationshipAnswerItem(WikiRateEntity):

def __init__(self, data):
self.raw = data
if data.get("type", {}).get("name") != 'Relationship Answer' and data["type"] != 'Relationship Answer':
if data["type"] != 'Relationship Answer' and data.get("type", {}).get("name") != 'Relationship Answer':
raise WikiRate4PyException('Invalid type of entity')

self.id = data.get("id")
Expand Down

0 comments on commit 7999992

Please sign in to comment.