|
| 1 | +from ..base import Base |
| 2 | +from ...exceptions import NotFoundItemError |
| 3 | + |
| 4 | +class Revisions(Base): |
| 5 | + def __init__(self, access_token, server_url) -> None: |
| 6 | + super().__init__(access_token, server_url) |
| 7 | + |
| 8 | + self.endpoint = "/rest/v1.0" |
| 9 | + |
| 10 | + def get(self, company_id, project_id, per_page=100): |
| 11 | + """ |
| 12 | + Gets all the available drawing revisions |
| 13 | +
|
| 14 | + Parameters |
| 15 | + ---------- |
| 16 | + company_id : int |
| 17 | + unique identifier for the company |
| 18 | + project_id : int |
| 19 | + unique identifier for the project |
| 20 | + per_page : int, default 100 |
| 21 | + number of drawing revisions to include per page |
| 22 | +
|
| 23 | + Returns |
| 24 | + ------- |
| 25 | + drawing_revisions : list |
| 26 | + available drawing revisions data |
| 27 | + """ |
| 28 | + headers = { |
| 29 | + "Procore-Company-Id": f"{company_id}" |
| 30 | + } |
| 31 | + |
| 32 | + n_revisions = 1 |
| 33 | + page = 1 |
| 34 | + drawing_revisions = [] |
| 35 | + |
| 36 | + while n_revisions > 0: |
| 37 | + params = { |
| 38 | + "page": page, |
| 39 | + "per_page": per_page |
| 40 | + } |
| 41 | + |
| 42 | + revision_selection = self.get_request( |
| 43 | + api_url=f"{self.endpoint}/projects/{project_id}/drawing_revisions", |
| 44 | + additional_headers=headers, |
| 45 | + params=params |
| 46 | + ) |
| 47 | + |
| 48 | + n_revisions = len(revision_selection) |
| 49 | + drawing_revisions += revision_selection |
| 50 | + page += 1 |
| 51 | + |
| 52 | + return drawing_revisions |
| 53 | + |
| 54 | + def show(self, company_id, project_id, drawing_revision_id): |
| 55 | + """ |
| 56 | + Shows a specific drawing revision |
| 57 | +
|
| 58 | + Parameters |
| 59 | + ---------- |
| 60 | + company_id : int |
| 61 | + unique identifier for the company |
| 62 | + project_id : int |
| 63 | + unique identifier for the project |
| 64 | + drawing_revision_id : int |
| 65 | + unique identifier for the drawing revision |
| 66 | +
|
| 67 | + Returns |
| 68 | + ------- |
| 69 | + drawing_revision_info : dict |
| 70 | + specific drawing revision information |
| 71 | + """ |
| 72 | + headers = { |
| 73 | + "Procore-Company-Id": f"{company_id}" |
| 74 | + } |
| 75 | + |
| 76 | + drawing_revision_info = self.get_request( |
| 77 | + api_url=f"{self.endpoint}/projects/{project_id}/drawing_revisions/{drawing_revision_id}", |
| 78 | + additional_headers=headers |
| 79 | + ) |
| 80 | + |
| 81 | + return drawing_revision_info |
0 commit comments