Debian Codegraph @

stripe/entitlements/_feature_service.py

raw
1 # -*- coding: utf-8 -*-
2 # File generated from our OpenAPI spec
3 from stripe._stripe_service import StripeService
4 from stripe._util import sanitize_id
5 from typing import Optional, cast
6 from typing_extensions import TYPE_CHECKING
7
8 if TYPE_CHECKING:
9 from stripe._list_object import ListObject
10 from stripe._request_options import RequestOptions
11 from stripe.entitlements._feature import Feature
12 from stripe.params.entitlements._feature_create_params import (
13 FeatureCreateParams,
14 )
15 from stripe.params.entitlements._feature_list_params import (
16 FeatureListParams,
17 )
18 from stripe.params.entitlements._feature_retrieve_params import (
19 FeatureRetrieveParams,
20 )
21 from stripe.params.entitlements._feature_update_params import (
22 FeatureUpdateParams,
23 )
24
25
26 class FeatureService(StripeService):
27 def list(
28 self,
29 params: Optional["FeatureListParams"] = None,
30 options: Optional["RequestOptions"] = None,
31 ) -> "ListObject[Feature]":
32 """
33 Retrieve a list of features
34 """
35 return cast(
36 "ListObject[Feature]",
37 self._request(
38 "get",
39 "/v1/entitlements/features",
40 base_address="api",
41 params=params,
42 options=options,
43 ),
44 )
45
46 async def list_async(
47 self,
48 params: Optional["FeatureListParams"] = None,
49 options: Optional["RequestOptions"] = None,
50 ) -> "ListObject[Feature]":
51 """
52 Retrieve a list of features
53 """
54 return cast(
55 "ListObject[Feature]",
56 await self._request_async(
57 "get",
58 "/v1/entitlements/features",
59 base_address="api",
60 params=params,
61 options=options,
62 ),
63 )
64
65 def create(
66 self,
67 params: "FeatureCreateParams",
68 options: Optional["RequestOptions"] = None,
69 ) -> "Feature":
70 """
71 Creates a feature
72 """
73 return cast(
74 "Feature",
75 self._request(
76 "post",
77 "/v1/entitlements/features",
78 base_address="api",
79 params=params,
80 options=options,
81 ),
82 )
83
84 async def create_async(
85 self,
86 params: "FeatureCreateParams",
87 options: Optional["RequestOptions"] = None,
88 ) -> "Feature":
89 """
90 Creates a feature
91 """
92 return cast(
93 "Feature",
94 await self._request_async(
95 "post",
96 "/v1/entitlements/features",
97 base_address="api",
98 params=params,
99 options=options,
100 ),
101 )
102
103 def retrieve(
104 self,
105 id: str,
106 params: Optional["FeatureRetrieveParams"] = None,
107 options: Optional["RequestOptions"] = None,
108 ) -> "Feature":
109 """
110 Retrieves a feature
111 """
112 return cast(
113 "Feature",
114 self._request(
115 "get",
116 "/v1/entitlements/features/{id}".format(id=sanitize_id(id)),
117 base_address="api",
118 params=params,
119 options=options,
120 ),
121 )
122
123 async def retrieve_async(
124 self,
125 id: str,
126 params: Optional["FeatureRetrieveParams"] = None,
127 options: Optional["RequestOptions"] = None,
128 ) -> "Feature":
129 """
130 Retrieves a feature
131 """
132 return cast(
133 "Feature",
134 await self._request_async(
135 "get",
136 "/v1/entitlements/features/{id}".format(id=sanitize_id(id)),
137 base_address="api",
138 params=params,
139 options=options,
140 ),
141 )
142
143 def update(
144 self,
145 id: str,
146 params: Optional["FeatureUpdateParams"] = None,
147 options: Optional["RequestOptions"] = None,
148 ) -> "Feature":
149 """
150 Update a feature's metadata or permanently deactivate it.
151 """
152 return cast(
153 "Feature",
154 self._request(
155 "post",
156 "/v1/entitlements/features/{id}".format(id=sanitize_id(id)),
157 base_address="api",
158 params=params,
159 options=options,
160 ),
161 )
162
163 async def update_async(
164 self,
165 id: str,
166 params: Optional["FeatureUpdateParams"] = None,
167 options: Optional["RequestOptions"] = None,
168 ) -> "Feature":
169 """
170 Update a feature's metadata or permanently deactivate it.
171 """
172 return cast(
173 "Feature",
174 await self._request_async(
175 "post",
176 "/v1/entitlements/features/{id}".format(id=sanitize_id(id)),
177 base_address="api",
178 params=params,
179 options=options,
180 ),
181 )