bigdata-corp-api 0.18.3__tar.gz → 0.18.9__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: bigdata-corp-api
3
- Version: 0.18.3
3
+ Version: 0.18.9
4
4
  Summary: Python API to facilitate interaction with BigDataCorp end-points
5
5
  License: BSD-3-Clause License
6
6
  License-File: LICENSE
@@ -9,7 +9,9 @@ Author-email: a.baceti@murabei.com
9
9
  Requires-Python: >=3.6
10
10
  Classifier: Programming Language :: Python :: 3
11
11
  Classifier: Operating System :: OS Independent
12
- Requires-Dist: requests
12
+ Requires-Dist: loguru
13
+ Requires-Dist: requests (>=2.32.5,<3.0.0)
14
+ Requires-Dist: tenacity (>=9.1.4,<10.0.0)
13
15
  Project-URL: Homepage, https://github.com/Murabei-OpenSource-Codes/bigdata-corp-api
14
16
  Description-Content-Type: text/markdown
15
17
 
@@ -37,10 +39,11 @@ call dataset list or fetch methods.
37
39
 
38
40
  ### Scope
39
41
 
40
- Owns HTTP communication, dataset constants, exception types, usage
41
- reporting, and certificate file downloads from on-demand responses.
42
- Credential storage, orchestration, and downstream persistence live in
43
- consuming services.
42
+ Owns HTTP communication, dataset constants, exception types, retry and
43
+ pagination, parallel batch fetches, usage reporting, local CPF, CNPJ,
44
+ and CNJ checks, and certificate file downloads from on-demand
45
+ responses. Credential storage, orchestration, and downstream
46
+ persistence live in consuming services.
44
47
 
45
48
  ## Install
46
49
 
@@ -78,19 +81,40 @@ datasets = api.list_cpf_dataset()
78
81
 
79
82
  # Fetch one dataset
80
83
  result = api.get_cpf_dataset(
81
- cpf="12345678901",
84
+ cpf="52998224725",
82
85
  dataset="basic_data",
83
86
  )
84
87
 
85
- # Fetch multiple datasets
88
+ # Append dataset_params to the Datasets field
89
+ result = api.get_cnpj_dataset(
90
+ cnpj="00000000000191",
91
+ dataset="processes",
92
+ dataset_params="{NextPageId}.limit(500)",
93
+ )
94
+
95
+ # Fetch multiple datasets in parallel
86
96
  batch = api.get_cpf_datasets(
87
- cpf="12345678901",
97
+ cpf="52998224725",
88
98
  datasets=["basic_data", "occupation_data"],
89
99
  )
100
+
101
+ # Soft-fail non-critical errors; per-dataset q and Datasets suffixes
102
+ batch = api.get_cpf_datasets(
103
+ cpf="52998224725",
104
+ datasets=["basic_data", "processes"],
105
+ skip_errors=True,
106
+ query_params={"processes": ", returnupdates{false}"},
107
+ dataset_params={"processes": "{NextPageId}.limit(500)"},
108
+ )
109
+ # Soft failures are under batch["__errors__"]
90
110
  ```
91
111
 
92
112
  CNPJ and process queries follow the same pattern via `list_cnpj_dataset`,
93
113
  `get_cnpj_dataset`, `list_process_dataset`, and `get_process_dataset`.
114
+ Fetch methods check CPF, CNPJ, and CNJ numbers locally and raise
115
+ `BigDataCorpAPIInvalidDocumentException` before the HTTP call.
116
+ Batch helpers accept `skip_errors`, a `query_params` mapping (suffix for
117
+ `q`), and a `dataset_params` mapping (suffix for `Datasets`).
94
118
 
95
119
  Usage reporting for a date range:
96
120
 
@@ -105,7 +129,7 @@ Download a certificate file from an on-demand dataset response:
105
129
 
106
130
  ```python
107
131
  cert_response = api.get_cpf_dataset(
108
- cpf="12345678901",
132
+ cpf="52998224725",
109
133
  dataset="ondemand_cert_debt_absence_by_state_person",
110
134
  )
111
135
  file_data = api.get_result_file(
@@ -117,13 +141,19 @@ file_data = api.get_result_file(
117
141
 
118
142
  ## Configuration
119
143
 
144
+ The auth token is passed to `BigDataCorpAPI` at construction time.
145
+ Timeout, batch parallelism, and the pagination page cap are read from
146
+ the environment when set. A blank value keeps the default. Any other
147
+ value must be a positive integer.
148
+
120
149
  | Variable | Required | Description |
121
150
  |----------|----------|-------------|
122
- | `BIGDATA_AUTH_TOKEN` | Yes (for tests) | BigDataCorp API token passed to `BigDataCorpAPI` |
123
- | `TEST_CPF` | Tests only | Valid CPF used by integration tests |
124
-
125
- The token is supplied at construction time; this package does not read
126
- environment variables during normal API calls.
151
+ | `BIGDATACORP__REQUEST_TIMEOUT` | No | HTTP timeout in seconds (default `60`) |
152
+ | `BIGDATACORP__N_PARALLEL` | No | Max threads for batch fetches (default `8`) |
153
+ | `BIGDATACORP__MAX_PAGES` | No | Extra pages after the first (default `200`) |
154
+ | `BIGDATA_AUTH_TOKEN` | Tests | Token for integration tests |
155
+ | `TEST_CPF` | Tests | Valid CPF for integration tests |
156
+ | `TEST_CNPJ` | Tests | Valid CNPJ for integration tests |
127
157
 
128
158
  ## Development
129
159
 
@@ -139,6 +169,7 @@ Run tests (integration tests call the live API when env vars are set):
139
169
  ```bash
140
170
  export BIGDATA_AUTH_TOKEN="your-token"
141
171
  export TEST_CPF="valid-cpf"
172
+ export TEST_CNPJ="valid-cnpj"
142
173
  python -m unittest discover -s src/bigdatacorp_api/tests
143
174
  ```
144
175
 
@@ -22,10 +22,11 @@ call dataset list or fetch methods.
22
22
 
23
23
  ### Scope
24
24
 
25
- Owns HTTP communication, dataset constants, exception types, usage
26
- reporting, and certificate file downloads from on-demand responses.
27
- Credential storage, orchestration, and downstream persistence live in
28
- consuming services.
25
+ Owns HTTP communication, dataset constants, exception types, retry and
26
+ pagination, parallel batch fetches, usage reporting, local CPF, CNPJ,
27
+ and CNJ checks, and certificate file downloads from on-demand
28
+ responses. Credential storage, orchestration, and downstream
29
+ persistence live in consuming services.
29
30
 
30
31
  ## Install
31
32
 
@@ -63,19 +64,40 @@ datasets = api.list_cpf_dataset()
63
64
 
64
65
  # Fetch one dataset
65
66
  result = api.get_cpf_dataset(
66
- cpf="12345678901",
67
+ cpf="52998224725",
67
68
  dataset="basic_data",
68
69
  )
69
70
 
70
- # Fetch multiple datasets
71
+ # Append dataset_params to the Datasets field
72
+ result = api.get_cnpj_dataset(
73
+ cnpj="00000000000191",
74
+ dataset="processes",
75
+ dataset_params="{NextPageId}.limit(500)",
76
+ )
77
+
78
+ # Fetch multiple datasets in parallel
71
79
  batch = api.get_cpf_datasets(
72
- cpf="12345678901",
80
+ cpf="52998224725",
73
81
  datasets=["basic_data", "occupation_data"],
74
82
  )
83
+
84
+ # Soft-fail non-critical errors; per-dataset q and Datasets suffixes
85
+ batch = api.get_cpf_datasets(
86
+ cpf="52998224725",
87
+ datasets=["basic_data", "processes"],
88
+ skip_errors=True,
89
+ query_params={"processes": ", returnupdates{false}"},
90
+ dataset_params={"processes": "{NextPageId}.limit(500)"},
91
+ )
92
+ # Soft failures are under batch["__errors__"]
75
93
  ```
76
94
 
77
95
  CNPJ and process queries follow the same pattern via `list_cnpj_dataset`,
78
96
  `get_cnpj_dataset`, `list_process_dataset`, and `get_process_dataset`.
97
+ Fetch methods check CPF, CNPJ, and CNJ numbers locally and raise
98
+ `BigDataCorpAPIInvalidDocumentException` before the HTTP call.
99
+ Batch helpers accept `skip_errors`, a `query_params` mapping (suffix for
100
+ `q`), and a `dataset_params` mapping (suffix for `Datasets`).
79
101
 
80
102
  Usage reporting for a date range:
81
103
 
@@ -90,7 +112,7 @@ Download a certificate file from an on-demand dataset response:
90
112
 
91
113
  ```python
92
114
  cert_response = api.get_cpf_dataset(
93
- cpf="12345678901",
115
+ cpf="52998224725",
94
116
  dataset="ondemand_cert_debt_absence_by_state_person",
95
117
  )
96
118
  file_data = api.get_result_file(
@@ -102,13 +124,19 @@ file_data = api.get_result_file(
102
124
 
103
125
  ## Configuration
104
126
 
127
+ The auth token is passed to `BigDataCorpAPI` at construction time.
128
+ Timeout, batch parallelism, and the pagination page cap are read from
129
+ the environment when set. A blank value keeps the default. Any other
130
+ value must be a positive integer.
131
+
105
132
  | Variable | Required | Description |
106
133
  |----------|----------|-------------|
107
- | `BIGDATA_AUTH_TOKEN` | Yes (for tests) | BigDataCorp API token passed to `BigDataCorpAPI` |
108
- | `TEST_CPF` | Tests only | Valid CPF used by integration tests |
109
-
110
- The token is supplied at construction time; this package does not read
111
- environment variables during normal API calls.
134
+ | `BIGDATACORP__REQUEST_TIMEOUT` | No | HTTP timeout in seconds (default `60`) |
135
+ | `BIGDATACORP__N_PARALLEL` | No | Max threads for batch fetches (default `8`) |
136
+ | `BIGDATACORP__MAX_PAGES` | No | Extra pages after the first (default `200`) |
137
+ | `BIGDATA_AUTH_TOKEN` | Tests | Token for integration tests |
138
+ | `TEST_CPF` | Tests | Valid CPF for integration tests |
139
+ | `TEST_CNPJ` | Tests | Valid CNPJ for integration tests |
112
140
 
113
141
  ## Development
114
142
 
@@ -124,6 +152,7 @@ Run tests (integration tests call the live API when env vars are set):
124
152
  ```bash
125
153
  export BIGDATA_AUTH_TOKEN="your-token"
126
154
  export TEST_CPF="valid-cpf"
155
+ export TEST_CNPJ="valid-cnpj"
127
156
  python -m unittest discover -s src/bigdatacorp_api/tests
128
157
  ```
129
158
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "bigdata-corp-api"
3
- version = "0.18.3"
3
+ version = "0.18.9"
4
4
  description = "Python API to facilitate interaction with BigDataCorp end-points"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.6"
@@ -14,7 +14,9 @@ classifiers = [
14
14
  "Operating System :: OS Independent",
15
15
  ]
16
16
  dependencies = [
17
- "requests",
17
+ "loguru",
18
+ "requests (>=2.32.5,<3.0.0)",
19
+ "tenacity (>=9.1.4,<10.0.0)"
18
20
  ]
19
21
 
20
22
  [tool.poetry]
@@ -0,0 +1,15 @@
1
+ """Auxiliary modules for BigDataCorp API."""
2
+
3
+ # Local imports
4
+ from bigdatacorp_api.aux.base import BaseBigDataCorpAPIMixin
5
+ from bigdatacorp_api.aux.person import PersonBigDataCorpAPIMixin
6
+ from bigdatacorp_api.aux.company import CompanyBigDataCorpAPIMixin
7
+ from bigdatacorp_api.aux.process import ProcessBigDataCorpAPIMixin
8
+ from bigdatacorp_api.aux.system import SystemBigDataCorpAPIMixin
9
+
10
+ __all__ = [
11
+ "BaseBigDataCorpAPIMixin",
12
+ "PersonBigDataCorpAPIMixin",
13
+ "CompanyBigDataCorpAPIMixin",
14
+ "ProcessBigDataCorpAPIMixin",
15
+ "SystemBigDataCorpAPIMixin"]