diff --git a/wikirate4py/api.py b/wikirate4py/api.py index 56a26ea..ea7053f 100644 --- a/wikirate4py/api.py +++ b/wikirate4py/api.py @@ -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: @@ -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) @@ -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) @@ -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: @@ -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', '') diff --git a/wikirate4py/models.py b/wikirate4py/models.py index a6dfa34..f836968 100644 --- a/wikirate4py/models.py +++ b/wikirate4py/models.py @@ -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")