stackin-python-sdk 0.4.0__tar.gz → 0.6.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: stackin-python-sdk
3
- Version: 0.4.0
3
+ Version: 0.6.0
4
4
  Summary: Python SDK for issuing, consulting and cancelling electronic invoices.
5
5
  License-Expression: MIT
6
6
  License-File: LICENSE
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "stackin-python-sdk"
3
- version = "0.4.0"
3
+ version = "0.6.0"
4
4
  authors = [
5
5
  { name = "Fernando Celmer", email = "email@fernandocelmer.com" },
6
6
  ]
@@ -45,7 +45,7 @@ Changelog = "https://github.com/stackin-io/stackin-python-sdk/releases"
45
45
 
46
46
  [tool.poetry]
47
47
  name = "stackin-python-sdk"
48
- version = "0.4.0"
48
+ version = "0.6.0"
49
49
  description = "Python SDK for issuing, consulting and cancelling electronic invoices."
50
50
  authors = ["Fernando Celmer <email@fernandocelmer.com>"]
51
51
  readme = "README.md"
@@ -1,6 +1,6 @@
1
1
  """Invoice __init__ module."""
2
2
 
3
- __version__ = "0.4.0"
3
+ __version__ = "0.6.0"
4
4
  __description__ = (
5
5
  "Python SDK for issuing, consulting and cancelling electronic invoices."
6
6
  )
@@ -3,6 +3,7 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import os
6
+ from typing import Any
6
7
 
7
8
  import requests
8
9
 
@@ -244,6 +245,45 @@ class Invoice:
244
245
 
245
246
  return self._request("GET", "/received-invoices", params=params)
246
247
 
248
+ def history(
249
+ self,
250
+ *,
251
+ document_type: DocumentType | None = None,
252
+ status: str | None = None,
253
+ limit: int | None = None,
254
+ offset: int | None = None,
255
+ sort_by: str | None = None,
256
+ order_by: str | None = None,
257
+ ) -> dict:
258
+ """This company's own issuance history, newest first.
259
+
260
+ The counterpart of received(): that one lists what was issued
261
+ against the company, this one what the company issued.
262
+ """
263
+ params: dict[str, object] = {}
264
+ if document_type is not None:
265
+ params["document_type"] = document_type.value
266
+ if status is not None:
267
+ params["status"] = status
268
+ if limit is not None:
269
+ params["limit"] = limit
270
+ if offset is not None:
271
+ params["offset"] = offset
272
+ if sort_by is not None:
273
+ params["sort_by"] = sort_by
274
+ if order_by is not None:
275
+ params["order_by"] = order_by
276
+
277
+ return self._request("GET", "/invoices", params=params)
278
+
279
+ def submissions(self, invoice_id: str) -> list:
280
+ """Every attempt made for one invoice, and what came back.
281
+
282
+ consult() gives the status; this gives the reason. Takes the
283
+ invoice_id because a rejected document has no access key.
284
+ """
285
+ return self._request("GET", f"/invoices/{invoice_id}/submissions")
286
+
247
287
  def manifest(
248
288
  self,
249
289
  access_key: str,
@@ -295,7 +335,7 @@ class Invoice:
295
335
  json: dict | None = None,
296
336
  params: dict | None = None,
297
337
  idempotency_key: str | None = None,
298
- ) -> dict:
338
+ ) -> Any:
299
339
  response = self._send(
300
340
  method,
301
341
  path,
@@ -307,7 +347,9 @@ class Invoice:
307
347
  body = response.json() if response.content else {}
308
348
  except ValueError:
309
349
  body = {}
310
- return body.get("result", body)
350
+ if isinstance(body, dict):
351
+ return body.get("result", body)
352
+ return body
311
353
 
312
354
  def _send(
313
355
  self,