webhook-platform 1.0.2__tar.gz → 1.1.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,8 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: webhook-platform
3
- Version: 1.0.2
3
+ Version: 1.1.0
4
4
  Summary: Official Python SDK for Webhook Platform
5
- Author-email: Webhook Platform <hello@webhook-platform.com>
5
+ Author-email: Vadym Kykalo <vadymkykalo@gmail.com>
6
6
  License: MIT
7
7
  Project-URL: Homepage, https://github.com/vadymkykalo/webhook-platform
8
8
  Project-URL: Repository, https://github.com/vadymkykalo/webhook-platform
@@ -119,12 +119,12 @@ print(f"Test {'passed' if result.success else 'failed'}: {result.latency_ms}ms")
119
119
  ```python
120
120
  from webhook_platform import SubscriptionCreateParams
121
121
 
122
- # Subscribe endpoint to event types
122
+ # Subscribe endpoint to an event type
123
123
  subscription = client.subscriptions.create(
124
124
  project_id,
125
125
  SubscriptionCreateParams(
126
126
  endpoint_id=endpoint.id,
127
- event_types=["order.completed", "order.cancelled"],
127
+ event_type="order.completed",
128
128
  enabled=True,
129
129
  ),
130
130
  )
@@ -136,7 +136,7 @@ subscriptions = client.subscriptions.list(project_id)
136
136
  client.subscriptions.update(
137
137
  project_id,
138
138
  subscription_id,
139
- event_types=["order.*"],
139
+ event_type="order.shipped",
140
140
  )
141
141
 
142
142
  # Delete subscription
@@ -90,12 +90,12 @@ print(f"Test {'passed' if result.success else 'failed'}: {result.latency_ms}ms")
90
90
  ```python
91
91
  from webhook_platform import SubscriptionCreateParams
92
92
 
93
- # Subscribe endpoint to event types
93
+ # Subscribe endpoint to an event type
94
94
  subscription = client.subscriptions.create(
95
95
  project_id,
96
96
  SubscriptionCreateParams(
97
97
  endpoint_id=endpoint.id,
98
- event_types=["order.completed", "order.cancelled"],
98
+ event_type="order.completed",
99
99
  enabled=True,
100
100
  ),
101
101
  )
@@ -107,7 +107,7 @@ subscriptions = client.subscriptions.list(project_id)
107
107
  client.subscriptions.update(
108
108
  project_id,
109
109
  subscription_id,
110
- event_types=["order.*"],
110
+ event_type="order.shipped",
111
111
  )
112
112
 
113
113
  # Delete subscription
@@ -4,13 +4,13 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "webhook-platform"
7
- version = "1.0.2"
7
+ version = "1.1.0"
8
8
  description = "Official Python SDK for Webhook Platform"
9
9
  readme = "README.md"
10
10
  license = {text = "MIT"}
11
11
  requires-python = ">=3.8"
12
12
  authors = [
13
- {name = "Webhook Platform", email = "hello@webhook-platform.com"}
13
+ {name = "Vadym Kykalo", email = "vadymkykalo@gmail.com"}
14
14
  ]
15
15
  keywords = ["webhook", "webhooks", "api", "events", "delivery"]
16
16
  classifiers = [
@@ -192,25 +192,25 @@ class TestTypeClasses:
192
192
  data = {
193
193
  "id": "sub_123",
194
194
  "endpointId": "ep_456",
195
- "eventTypes": ["order.completed", "order.cancelled"],
195
+ "eventType": "order.completed",
196
196
  "enabled": True,
197
197
  "createdAt": "2024-01-01T00:00:00Z",
198
198
  }
199
199
  subscription = Subscription.from_dict(data)
200
200
  assert subscription.id == "sub_123"
201
201
  assert subscription.endpoint_id == "ep_456"
202
- assert subscription.event_types == ["order.completed", "order.cancelled"]
202
+ assert subscription.event_type == "order.completed"
203
203
 
204
204
  def test_subscription_create_params_to_dict(self):
205
205
  """SubscriptionCreateParams should convert to dict correctly."""
206
206
  params = SubscriptionCreateParams(
207
207
  endpoint_id="ep_123",
208
- event_types=["order.completed"],
208
+ event_type="order.completed",
209
209
  enabled=True,
210
210
  )
211
211
  data = params.to_dict()
212
212
  assert data["endpointId"] == "ep_123"
213
- assert data["eventTypes"] == ["order.completed"]
213
+ assert data["eventType"] == "order.completed"
214
214
  assert data["enabled"] is True
215
215
 
216
216
  def test_delivery_from_dict(self):
@@ -20,13 +20,14 @@ from .types import (
20
20
  Delivery,
21
21
  DeliveryAttempt,
22
22
  DeliveryListParams,
23
+ DeliveryStatus,
23
24
  PaginatedResponse,
24
25
  EndpointTestResult,
25
26
  RateLimitInfo,
26
27
  WebhookEvent,
27
28
  )
28
29
 
29
- __version__ = "1.0.0"
30
+ __version__ = "1.1.0"
30
31
  __all__ = [
31
32
  "WebhookPlatform",
32
33
  "WebhookPlatformError",
@@ -47,6 +48,7 @@ __all__ = [
47
48
  "Delivery",
48
49
  "DeliveryAttempt",
49
50
  "DeliveryListParams",
51
+ "DeliveryStatus",
50
52
  "PaginatedResponse",
51
53
  "EndpointTestResult",
52
54
  "RateLimitInfo",
@@ -28,7 +28,7 @@ from .errors import (
28
28
 
29
29
  DEFAULT_BASE_URL = "http://localhost:8080"
30
30
  DEFAULT_TIMEOUT = 30
31
- SDK_VERSION = "1.0.0"
31
+ SDK_VERSION = "1.1.0"
32
32
 
33
33
 
34
34
  class WebhookPlatform:
@@ -261,15 +261,33 @@ class Subscriptions:
261
261
  self,
262
262
  project_id: str,
263
263
  subscription_id: str,
264
- event_types: Optional[List[str]] = None,
264
+ event_type: Optional[str] = None,
265
265
  enabled: Optional[bool] = None,
266
+ ordering_enabled: Optional[bool] = None,
267
+ max_attempts: Optional[int] = None,
268
+ timeout_seconds: Optional[int] = None,
269
+ retry_delays: Optional[str] = None,
270
+ payload_template: Optional[str] = None,
271
+ custom_headers: Optional[str] = None,
266
272
  ) -> Subscription:
267
273
  """Update subscription."""
268
274
  body: Dict[str, Any] = {}
269
- if event_types is not None:
270
- body["eventTypes"] = event_types
275
+ if event_type is not None:
276
+ body["eventType"] = event_type
271
277
  if enabled is not None:
272
278
  body["enabled"] = enabled
279
+ if ordering_enabled is not None:
280
+ body["orderingEnabled"] = ordering_enabled
281
+ if max_attempts is not None:
282
+ body["maxAttempts"] = max_attempts
283
+ if timeout_seconds is not None:
284
+ body["timeoutSeconds"] = timeout_seconds
285
+ if retry_delays is not None:
286
+ body["retryDelays"] = retry_delays
287
+ if payload_template is not None:
288
+ body["payloadTemplate"] = payload_template
289
+ if custom_headers is not None:
290
+ body["customHeaders"] = custom_headers
273
291
 
274
292
  data = self._client._request(
275
293
  "PUT",
@@ -7,9 +7,10 @@ from enum import Enum
7
7
 
8
8
  class DeliveryStatus(str, Enum):
9
9
  PENDING = "PENDING"
10
+ PROCESSING = "PROCESSING"
10
11
  SUCCESS = "SUCCESS"
11
12
  FAILED = "FAILED"
12
- DEAD_LETTER = "DEAD_LETTER"
13
+ DLQ = "DLQ"
13
14
 
14
15
 
15
16
  @dataclass
@@ -98,33 +99,68 @@ class EndpointUpdateParams:
98
99
  class Subscription:
99
100
  id: str
100
101
  endpoint_id: str
101
- event_types: List[str]
102
+ event_type: str
102
103
  enabled: bool
103
104
  created_at: str
105
+ project_id: Optional[str] = None
106
+ ordering_enabled: bool = False
107
+ max_attempts: int = 7
108
+ timeout_seconds: int = 30
109
+ retry_delays: Optional[str] = None
110
+ payload_template: Optional[str] = None
111
+ custom_headers: Optional[str] = None
112
+ updated_at: Optional[str] = None
104
113
 
105
114
  @classmethod
106
115
  def from_dict(cls, data: Dict[str, Any]) -> "Subscription":
107
116
  return cls(
108
117
  id=data["id"],
109
118
  endpoint_id=data["endpointId"],
110
- event_types=data["eventTypes"],
119
+ event_type=data["eventType"],
111
120
  enabled=data["enabled"],
112
121
  created_at=data["createdAt"],
122
+ project_id=data.get("projectId"),
123
+ ordering_enabled=data.get("orderingEnabled", False),
124
+ max_attempts=data.get("maxAttempts", 7),
125
+ timeout_seconds=data.get("timeoutSeconds", 30),
126
+ retry_delays=data.get("retryDelays"),
127
+ payload_template=data.get("payloadTemplate"),
128
+ custom_headers=data.get("customHeaders"),
129
+ updated_at=data.get("updatedAt"),
113
130
  )
114
131
 
115
132
 
116
133
  @dataclass
117
134
  class SubscriptionCreateParams:
118
135
  endpoint_id: str
119
- event_types: List[str]
136
+ event_type: str
120
137
  enabled: bool = True
138
+ ordering_enabled: Optional[bool] = None
139
+ max_attempts: Optional[int] = None
140
+ timeout_seconds: Optional[int] = None
141
+ retry_delays: Optional[str] = None
142
+ payload_template: Optional[str] = None
143
+ custom_headers: Optional[str] = None
121
144
 
122
145
  def to_dict(self) -> Dict[str, Any]:
123
- return {
146
+ result: Dict[str, Any] = {
124
147
  "endpointId": self.endpoint_id,
125
- "eventTypes": self.event_types,
148
+ "eventType": self.event_type,
126
149
  "enabled": self.enabled,
127
150
  }
151
+ if self.ordering_enabled is not None:
152
+ result["orderingEnabled"] = self.ordering_enabled
153
+ if self.max_attempts is not None:
154
+ result["maxAttempts"] = self.max_attempts
155
+ if self.timeout_seconds is not None:
156
+ result["timeoutSeconds"] = self.timeout_seconds
157
+ if self.retry_delays is not None:
158
+ result["retryDelays"] = self.retry_delays
159
+ if self.payload_template is not None:
160
+ result["payloadTemplate"] = self.payload_template
161
+ if self.custom_headers is not None:
162
+ result["customHeaders"] = self.custom_headers
163
+ return result
128
164
 
129
165
 
130
166
  @dataclass
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: webhook-platform
3
- Version: 1.0.2
3
+ Version: 1.1.0
4
4
  Summary: Official Python SDK for Webhook Platform
5
- Author-email: Webhook Platform <hello@webhook-platform.com>
5
+ Author-email: Vadym Kykalo <vadymkykalo@gmail.com>
6
6
  License: MIT
7
7
  Project-URL: Homepage, https://github.com/vadymkykalo/webhook-platform
8
8
  Project-URL: Repository, https://github.com/vadymkykalo/webhook-platform
@@ -119,12 +119,12 @@ print(f"Test {'passed' if result.success else 'failed'}: {result.latency_ms}ms")
119
119
  ```python
120
120
  from webhook_platform import SubscriptionCreateParams
121
121
 
122
- # Subscribe endpoint to event types
122
+ # Subscribe endpoint to an event type
123
123
  subscription = client.subscriptions.create(
124
124
  project_id,
125
125
  SubscriptionCreateParams(
126
126
  endpoint_id=endpoint.id,
127
- event_types=["order.completed", "order.cancelled"],
127
+ event_type="order.completed",
128
128
  enabled=True,
129
129
  ),
130
130
  )
@@ -136,7 +136,7 @@ subscriptions = client.subscriptions.list(project_id)
136
136
  client.subscriptions.update(
137
137
  project_id,
138
138
  subscription_id,
139
- event_types=["order.*"],
139
+ event_type="order.shipped",
140
140
  )
141
141
 
142
142
  # Delete subscription