MCPcopy
hub / github.com/openai/openai-python / unwrap

Method unwrap

src/openai/resources/webhooks/webhooks.py:119–139  ·  view source on GitHub ↗

Validates that the given payload was sent by OpenAI and parses the payload.

(
        self,
        payload: str | bytes,
        headers: HeadersLike,
        *,
        secret: str | None = None,
    )

Source from the content-addressed store, hash-verified

117
118class AsyncWebhooks(AsyncAPIResource):
119 def unwrap(
120 self,
121 payload: str | bytes,
122 headers: HeadersLike,
123 *,
124 secret: str | None = None,
125 ) -> UnwrapWebhookEvent:
126 """Validates that the given payload was sent by OpenAI and parses the payload."""
127 if secret is None:
128 secret = self._client.webhook_secret
129
130 self.verify_signature(payload=payload, headers=headers, secret=secret)
131
132 body = payload.decode("utf-8") if isinstance(payload, bytes) else payload
133 return cast(
134 UnwrapWebhookEvent,
135 construct_type(
136 type_=UnwrapWebhookEvent,
137 value=json.loads(body),
138 ),
139 )
140
141 def verify_signature(
142 self,

Callers

nothing calls this directly

Calls 3

verify_signatureMethod · 0.95
construct_typeFunction · 0.85
decodeMethod · 0.80

Tested by

no test coverage detected