Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# IDE files
.idea
.vscode

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Links to the Demand API documentation are included for each function.
[Get Project Detailed Report](https://developers.dynata.com/demand-api-reference/core-resources/projects/get-project-detailed-report): get_project_detailed_report(project_id)
[Get Pricing & Feasibility](https://developers.dynata.com/demand-api-reference/core-resources/pricing-feasibility/get-pricing-feasibility): get_feasibility(project_id)
[Get Invoice PDF](https://developers.dynata.com/demand-api-reference/billing_invoicing/invoicing/get-invoices): get_invoice(project_id)
[Get Invoices Summary PDF](https://developers.dynata.com): get_invoices_summary(\*\*kwargs)

### Line Item Functions

Expand Down
7 changes: 7 additions & 0 deletions dynatademand/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,13 @@ def get_sources(self):
)
return self._api_get('/sources')

def get_invoices_summary(self, **kwargs):
self.validator.validate_request(
'get_invoices_summary',
query_params=kwargs
)
return self._api_get('/projects/invoices/summary', kwargs)

def reconcile_project(self, project_id, file, message):
'''
Sends a reconciliation request
Expand Down
17 changes: 17 additions & 0 deletions dynatademand/schemas/request/query/get_invoices_summary.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"type": "object",
"properties": {
"startDate": {
"type": "string",
"description": "The format is YY-MM-DD"
},
"endDate": {
"type": "string",
"description": "The format is YY-MM-DD"
},
"extProjectId": {
"type": "string"
}
},
"required": []
}
1 change: 1 addition & 0 deletions dynatademand/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

# Invoices
'get_invoice': ['path', ],
'get_invoices_summary': ['query', ],

# Line items
'close_line_item': ['path', ],
Expand Down
Binary file added tests/test_files/get_invoices_summary.pdf
Binary file not shown.
16 changes: 16 additions & 0 deletions tests/test_invoices.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,19 @@ def test_get_invoice(self):
self.api.get_invoice(1337)
self.assertEqual(len(responses.calls), 1)
self.assertEqual(responses.calls[0].response.headers['content-type'], 'application/pdf')

@responses.activate
def test_get_invoices_summary(self):
with open('./tests/test_files/get_invoices_summary.pdf', 'rb') as summary_file:
responses.add(
responses.GET,
'{}/sample/v1/projects/invoices/summary'.format(BASE_HOST),
body=summary_file.read(),
content_type='application/pdf',
stream=True,
status=200)
self.api.get_invoices_summary(startDate='2019-06-12',
endDate='2019-06-19',
extProjectId='010528ef-8984-48c1-a06d-4dae730da027')
self.assertEqual(len(responses.calls), 1)
self.assertEqual(responses.calls[0].response.headers['content-type'], 'application/pdf')