payi 0.1.0a58__py3-none-any.whl → 0.1.0a60__py3-none-any.whl

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.

Potentially problematic release.


This version of payi might be problematic. Click here for more details.

Files changed (48) hide show
  1. payi/_version.py +1 -1
  2. payi/lib/instrument.py +128 -18
  3. payi/pagination.py +50 -0
  4. payi/resources/categories/categories.py +108 -23
  5. payi/resources/categories/resources.py +42 -12
  6. payi/resources/experiences/types/types.py +37 -17
  7. payi/resources/limits/limits.py +21 -30
  8. payi/resources/use_cases/__init__.py +14 -0
  9. payi/resources/use_cases/definitions/__init__.py +14 -0
  10. payi/resources/use_cases/definitions/definitions.py +68 -18
  11. payi/resources/use_cases/definitions/kpis.py +584 -0
  12. payi/resources/use_cases/kpis.py +469 -0
  13. payi/resources/use_cases/use_cases.py +32 -0
  14. payi/types/__init__.py +3 -3
  15. payi/types/categories/__init__.py +1 -1
  16. payi/types/categories/resource_list_params.py +17 -0
  17. payi/types/category_list_params.py +15 -0
  18. payi/types/category_list_resources_params.py +15 -0
  19. payi/types/category_response.py +0 -5
  20. payi/types/experiences/__init__.py +0 -1
  21. payi/types/experiences/type_list_params.py +6 -1
  22. payi/types/limit_list_params.py +4 -13
  23. payi/types/limit_list_response.py +30 -0
  24. payi/types/use_cases/__init__.py +4 -1
  25. payi/types/use_cases/definition_list_params.py +6 -1
  26. payi/types/use_cases/definitions/__init__.py +8 -0
  27. payi/types/use_cases/definitions/kpi_create_params.py +17 -0
  28. payi/types/use_cases/definitions/kpi_create_response.py +20 -0
  29. payi/types/use_cases/definitions/kpi_delete_response.py +20 -0
  30. payi/types/use_cases/definitions/kpi_list_params.py +17 -0
  31. payi/types/use_cases/definitions/kpi_list_response.py +20 -0
  32. payi/types/use_cases/definitions/kpi_retrieve_response.py +20 -0
  33. payi/types/use_cases/definitions/kpi_update_params.py +16 -0
  34. payi/types/use_cases/definitions/kpi_update_response.py +20 -0
  35. payi/types/use_cases/kpi_create_params.py +13 -0
  36. payi/types/use_cases/kpi_list_params.py +17 -0
  37. payi/types/use_cases/kpi_list_response.py +21 -0
  38. payi/types/use_cases/kpi_update_params.py +13 -0
  39. {payi-0.1.0a58.dist-info → payi-0.1.0a60.dist-info}/METADATA +91 -28
  40. {payi-0.1.0a58.dist-info → payi-0.1.0a60.dist-info}/RECORD +42 -29
  41. payi/types/categories/resource_list_response.py +0 -10
  42. payi/types/category_list_resources_response.py +0 -10
  43. payi/types/category_list_response.py +0 -10
  44. payi/types/experiences/type_list_response.py +0 -10
  45. payi/types/paged_limit_list.py +0 -52
  46. payi/types/use_cases/definition_list_response.py +0 -10
  47. {payi-0.1.0a58.dist-info → payi-0.1.0a60.dist-info}/WHEEL +0 -0
  48. {payi-0.1.0a58.dist-info → payi-0.1.0a60.dist-info}/licenses/LICENSE +0 -0
@@ -2,25 +2,16 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- from typing import List
6
- from typing_extensions import Annotated, TypedDict
7
-
8
- from .._utils import PropertyInfo
5
+ from typing_extensions import TypedDict
9
6
 
10
7
  __all__ = ["LimitListParams"]
11
8
 
12
9
 
13
10
  class LimitListParams(TypedDict, total=False):
14
- limit_name: str
11
+ cursor: str
15
12
 
16
- page_number: int
13
+ limit: int
17
14
 
18
- page_size: int
15
+ limit_name: str
19
16
 
20
17
  sort_ascending: bool
21
-
22
- sort_by: str
23
-
24
- tag_list: Annotated[List[str], PropertyInfo(alias="TagList")]
25
-
26
- tags: str
@@ -0,0 +1,30 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from typing import List, Optional
4
+ from datetime import datetime
5
+ from typing_extensions import Literal
6
+
7
+ from .._models import BaseModel
8
+ from .total_cost_data import TotalCostData
9
+
10
+ __all__ = ["LimitListResponse"]
11
+
12
+
13
+ class LimitListResponse(BaseModel):
14
+ limit_creation_timestamp: datetime
15
+
16
+ limit_id: str
17
+
18
+ limit_name: str
19
+
20
+ limit_type: Literal["block", "allow"]
21
+
22
+ limit_update_timestamp: datetime
23
+
24
+ max: float
25
+
26
+ totals: TotalCostData
27
+
28
+ limit_tags: Optional[List[str]] = None
29
+
30
+ threshold: Optional[float] = None
@@ -2,9 +2,12 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ from .kpi_list_params import KpiListParams as KpiListParams
6
+ from .kpi_create_params import KpiCreateParams as KpiCreateParams
7
+ from .kpi_list_response import KpiListResponse as KpiListResponse
8
+ from .kpi_update_params import KpiUpdateParams as KpiUpdateParams
5
9
  from .use_case_definition import UseCaseDefinition as UseCaseDefinition
6
10
  from .definition_list_params import DefinitionListParams as DefinitionListParams
7
11
  from .property_create_params import PropertyCreateParams as PropertyCreateParams
8
12
  from .definition_create_params import DefinitionCreateParams as DefinitionCreateParams
9
- from .definition_list_response import DefinitionListResponse as DefinitionListResponse
10
13
  from .definition_update_params import DefinitionUpdateParams as DefinitionUpdateParams
@@ -8,5 +8,10 @@ __all__ = ["DefinitionListParams"]
8
8
 
9
9
 
10
10
  class DefinitionListParams(TypedDict, total=False):
11
+ cursor: str
12
+
13
+ limit: int
14
+
15
+ sort_ascending: bool
16
+
11
17
  use_case_name: str
12
- """Use Case name"""
@@ -2,4 +2,12 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ from .kpi_list_params import KpiListParams as KpiListParams
6
+ from .kpi_create_params import KpiCreateParams as KpiCreateParams
7
+ from .kpi_list_response import KpiListResponse as KpiListResponse
8
+ from .kpi_update_params import KpiUpdateParams as KpiUpdateParams
9
+ from .kpi_create_response import KpiCreateResponse as KpiCreateResponse
10
+ from .kpi_delete_response import KpiDeleteResponse as KpiDeleteResponse
11
+ from .kpi_update_response import KpiUpdateResponse as KpiUpdateResponse
12
+ from .kpi_retrieve_response import KpiRetrieveResponse as KpiRetrieveResponse
5
13
  from .limit_config_create_params import LimitConfigCreateParams as LimitConfigCreateParams
@@ -0,0 +1,17 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing_extensions import Literal, Required, TypedDict
6
+
7
+ __all__ = ["KpiCreateParams"]
8
+
9
+
10
+ class KpiCreateParams(TypedDict, total=False):
11
+ description: Required[str]
12
+
13
+ name: Required[str]
14
+
15
+ goal: float
16
+
17
+ kpi_type: Literal["boolean", "number", "percentage", "likert5", "likert7", "likert10"]
@@ -0,0 +1,20 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from typing import Optional
4
+ from typing_extensions import Literal
5
+
6
+ from ...._models import BaseModel
7
+
8
+ __all__ = ["KpiCreateResponse"]
9
+
10
+
11
+ class KpiCreateResponse(BaseModel):
12
+ description: str
13
+
14
+ name: str
15
+
16
+ request_id: str
17
+
18
+ goal: Optional[float] = None
19
+
20
+ kpi_type: Optional[Literal["boolean", "number", "percentage", "likert5", "likert7", "likert10"]] = None
@@ -0,0 +1,20 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from typing import Optional
4
+ from typing_extensions import Literal
5
+
6
+ from ...._models import BaseModel
7
+
8
+ __all__ = ["KpiDeleteResponse"]
9
+
10
+
11
+ class KpiDeleteResponse(BaseModel):
12
+ description: str
13
+
14
+ name: str
15
+
16
+ request_id: str
17
+
18
+ goal: Optional[float] = None
19
+
20
+ kpi_type: Optional[Literal["boolean", "number", "percentage", "likert5", "likert7", "likert10"]] = None
@@ -0,0 +1,17 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing_extensions import TypedDict
6
+
7
+ __all__ = ["KpiListParams"]
8
+
9
+
10
+ class KpiListParams(TypedDict, total=False):
11
+ cursor: str
12
+
13
+ kpi_name: str
14
+
15
+ limit: int
16
+
17
+ sort_ascending: bool
@@ -0,0 +1,20 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from typing import Optional
4
+ from typing_extensions import Literal
5
+
6
+ from ...._models import BaseModel
7
+
8
+ __all__ = ["KpiListResponse"]
9
+
10
+
11
+ class KpiListResponse(BaseModel):
12
+ description: str
13
+
14
+ name: str
15
+
16
+ request_id: str
17
+
18
+ goal: Optional[float] = None
19
+
20
+ kpi_type: Optional[Literal["boolean", "number", "percentage", "likert5", "likert7", "likert10"]] = None
@@ -0,0 +1,20 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from typing import Optional
4
+ from typing_extensions import Literal
5
+
6
+ from ...._models import BaseModel
7
+
8
+ __all__ = ["KpiRetrieveResponse"]
9
+
10
+
11
+ class KpiRetrieveResponse(BaseModel):
12
+ description: str
13
+
14
+ name: str
15
+
16
+ request_id: str
17
+
18
+ goal: Optional[float] = None
19
+
20
+ kpi_type: Optional[Literal["boolean", "number", "percentage", "likert5", "likert7", "likert10"]] = None
@@ -0,0 +1,16 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Optional
6
+ from typing_extensions import Required, TypedDict
7
+
8
+ __all__ = ["KpiUpdateParams"]
9
+
10
+
11
+ class KpiUpdateParams(TypedDict, total=False):
12
+ use_case_name: Required[str]
13
+
14
+ description: Optional[str]
15
+
16
+ goal: Optional[float]
@@ -0,0 +1,20 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from typing import Optional
4
+ from typing_extensions import Literal
5
+
6
+ from ...._models import BaseModel
7
+
8
+ __all__ = ["KpiUpdateResponse"]
9
+
10
+
11
+ class KpiUpdateResponse(BaseModel):
12
+ description: str
13
+
14
+ name: str
15
+
16
+ request_id: str
17
+
18
+ goal: Optional[float] = None
19
+
20
+ kpi_type: Optional[Literal["boolean", "number", "percentage", "likert5", "likert7", "likert10"]] = None
@@ -0,0 +1,13 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing_extensions import Required, TypedDict
6
+
7
+ __all__ = ["KpiCreateParams"]
8
+
9
+
10
+ class KpiCreateParams(TypedDict, total=False):
11
+ use_case_id: Required[str]
12
+
13
+ score: float
@@ -0,0 +1,17 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing_extensions import TypedDict
6
+
7
+ __all__ = ["KpiListParams"]
8
+
9
+
10
+ class KpiListParams(TypedDict, total=False):
11
+ cursor: str
12
+
13
+ kpi_name: str
14
+
15
+ limit: int
16
+
17
+ sort_ascending: bool
@@ -0,0 +1,21 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from typing import Optional
4
+ from datetime import datetime
5
+ from typing_extensions import Literal
6
+
7
+ from ..._models import BaseModel
8
+
9
+ __all__ = ["KpiListResponse"]
10
+
11
+
12
+ class KpiListResponse(BaseModel):
13
+ kpi_name: Optional[str] = None
14
+
15
+ create_timestamp: Optional[datetime] = None
16
+
17
+ kpi_type: Optional[Literal["boolean", "number", "percentage", "likert5", "likert7", "likert10"]] = None
18
+
19
+ score: Optional[float] = None
20
+
21
+ update_timestamp: Optional[datetime] = None
@@ -0,0 +1,13 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing_extensions import Required, TypedDict
6
+
7
+ __all__ = ["KpiUpdateParams"]
8
+
9
+
10
+ class KpiUpdateParams(TypedDict, total=False):
11
+ use_case_id: Required[str]
12
+
13
+ score: float
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: payi
3
- Version: 0.1.0a58
3
+ Version: 0.1.0a60
4
4
  Summary: The official Python library for the payi API
5
5
  Project-URL: Homepage, https://github.com/Pay-i/pay-i-python
6
6
  Project-URL: Repository, https://github.com/Pay-i/pay-i-python
@@ -65,11 +65,11 @@ client = Payi(
65
65
  api_key=os.environ.get("PAYI_API_KEY"), # This is the default and can be omitted
66
66
  )
67
67
 
68
- limit_response = client.limits.create(
69
- limit_name="x",
70
- max=1,
68
+ use_case_definition = client.use_cases.definitions.create(
69
+ description="Sample Use Case Definition Description",
70
+ name="SampleUseCaseDefinition",
71
71
  )
72
- print(limit_response.request_id)
72
+ print(use_case_definition.request_id)
73
73
  ```
74
74
 
75
75
  While you can provide an `api_key` keyword argument,
@@ -92,11 +92,11 @@ client = AsyncPayi(
92
92
 
93
93
 
94
94
  async def main() -> None:
95
- limit_response = await client.limits.create(
96
- limit_name="x",
97
- max=1,
95
+ use_case_definition = await client.use_cases.definitions.create(
96
+ description="Sample Use Case Definition Description",
97
+ name="SampleUseCaseDefinition",
98
98
  )
99
- print(limit_response.request_id)
99
+ print(use_case_definition.request_id)
100
100
 
101
101
 
102
102
  asyncio.run(main())
@@ -113,6 +113,69 @@ Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typ
113
113
 
114
114
  Typed requests and responses provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `basic`.
115
115
 
116
+ ## Pagination
117
+
118
+ List methods in the Payi API are paginated.
119
+
120
+ This library provides auto-paginating iterators with each list response, so you do not have to request successive pages manually:
121
+
122
+ ```python
123
+ from payi import Payi
124
+
125
+ client = Payi()
126
+
127
+ all_definitions = []
128
+ # Automatically fetches more pages as needed.
129
+ for definition in client.use_cases.definitions.list():
130
+ # Do something with definition here
131
+ all_definitions.append(definition)
132
+ print(all_definitions)
133
+ ```
134
+
135
+ Or, asynchronously:
136
+
137
+ ```python
138
+ import asyncio
139
+ from payi import AsyncPayi
140
+
141
+ client = AsyncPayi()
142
+
143
+
144
+ async def main() -> None:
145
+ all_definitions = []
146
+ # Iterate through items across all pages, issuing requests as needed.
147
+ async for definition in client.use_cases.definitions.list():
148
+ all_definitions.append(definition)
149
+ print(all_definitions)
150
+
151
+
152
+ asyncio.run(main())
153
+ ```
154
+
155
+ Alternatively, you can use the `.has_next_page()`, `.next_page_info()`, or `.get_next_page()` methods for more granular control working with pages:
156
+
157
+ ```python
158
+ first_page = await client.use_cases.definitions.list()
159
+ if first_page.has_next_page():
160
+ print(f"will fetch next page using these details: {first_page.next_page_info()}")
161
+ next_page = await first_page.get_next_page()
162
+ print(f"number of items we just fetched: {len(next_page.items)}")
163
+
164
+ # Remove `await` for non-async usage.
165
+ ```
166
+
167
+ Or just work directly with the returned data:
168
+
169
+ ```python
170
+ first_page = await client.use_cases.definitions.list()
171
+
172
+ print(f"next page cursor: {first_page.cursor}") # => "next page cursor: ..."
173
+ for definition in first_page.items:
174
+ print(definition.request_id)
175
+
176
+ # Remove `await` for non-async usage.
177
+ ```
178
+
116
179
  ## Nested params
117
180
 
118
181
  Nested parameters are dictionaries, typed using `TypedDict`, for example:
@@ -122,7 +185,7 @@ from payi import Payi
122
185
 
123
186
  client = Payi()
124
187
 
125
- experience_type = client.experiences.types.create(
188
+ use_case_definition = client.use_cases.definitions.create(
126
189
  description="x",
127
190
  name="x",
128
191
  limit_config={
@@ -132,7 +195,7 @@ experience_type = client.experiences.types.create(
132
195
  "threshold": 0,
133
196
  },
134
197
  )
135
- print(experience_type.limit_config)
198
+ print(use_case_definition.limit_config)
136
199
  ```
137
200
 
138
201
  ## Handling errors
@@ -151,9 +214,9 @@ from payi import Payi
151
214
  client = Payi()
152
215
 
153
216
  try:
154
- client.limits.create(
155
- limit_name="x",
156
- max=1,
217
+ client.use_cases.definitions.create(
218
+ description="Sample Use Case Definition Description",
219
+ name="SampleUseCaseDefinition",
157
220
  )
158
221
  except payi.APIConnectionError as e:
159
222
  print("The server could not be reached")
@@ -197,9 +260,9 @@ client = Payi(
197
260
  )
198
261
 
199
262
  # Or, configure per-request:
200
- client.with_options(max_retries=5).limits.create(
201
- limit_name="x",
202
- max=1,
263
+ client.with_options(max_retries=5).use_cases.definitions.create(
264
+ description="Sample Use Case Definition Description",
265
+ name="SampleUseCaseDefinition",
203
266
  )
204
267
  ```
205
268
 
@@ -223,9 +286,9 @@ client = Payi(
223
286
  )
224
287
 
225
288
  # Override per-request:
226
- client.with_options(timeout=5.0).limits.create(
227
- limit_name="x",
228
- max=1,
289
+ client.with_options(timeout=5.0).use_cases.definitions.create(
290
+ description="Sample Use Case Definition Description",
291
+ name="SampleUseCaseDefinition",
229
292
  )
230
293
  ```
231
294
 
@@ -267,14 +330,14 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to
267
330
  from payi import Payi
268
331
 
269
332
  client = Payi()
270
- response = client.limits.with_raw_response.create(
271
- limit_name="x",
272
- max=1,
333
+ response = client.use_cases.definitions.with_raw_response.create(
334
+ description="Sample Use Case Definition Description",
335
+ name="SampleUseCaseDefinition",
273
336
  )
274
337
  print(response.headers.get('X-My-Header'))
275
338
 
276
- limit = response.parse() # get the object that `limits.create()` would have returned
277
- print(limit.request_id)
339
+ definition = response.parse() # get the object that `use_cases.definitions.create()` would have returned
340
+ print(definition.request_id)
278
341
  ```
279
342
 
280
343
  These methods return an [`APIResponse`](https://github.com/Pay-i/pay-i-python/tree/main/src/payi/_response.py) object.
@@ -288,9 +351,9 @@ The above interface eagerly reads the full response body when you make the reque
288
351
  To stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.
289
352
 
290
353
  ```python
291
- with client.limits.with_streaming_response.create(
292
- limit_name="x",
293
- max=1,
354
+ with client.use_cases.definitions.with_streaming_response.create(
355
+ description="Sample Use Case Definition Description",
356
+ name="SampleUseCaseDefinition",
294
357
  ) as response:
295
358
  print(response.headers.get("X-My-Header"))
296
359