|
| 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 Union |
| 6 | +from typing_extensions import Literal |
| 7 | + |
| 8 | +import httpx |
| 9 | + |
| 10 | +from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given |
| 11 | +from ..._utils import maybe_transform, async_maybe_transform |
| 12 | +from ..._compat import cached_property |
| 13 | +from ..._resource import SyncAPIResource, AsyncAPIResource |
| 14 | +from ..._response import ( |
| 15 | + to_raw_response_wrapper, |
| 16 | + to_streamed_response_wrapper, |
| 17 | + async_to_raw_response_wrapper, |
| 18 | + async_to_streamed_response_wrapper, |
| 19 | +) |
| 20 | +from ..._base_client import make_request_options |
| 21 | +from ...types.templates import export_html_create_params |
| 22 | +from ...types.templates.export_html_create_response import ExportHTMLCreateResponse |
| 23 | + |
| 24 | +__all__ = ["ExportHTMLResource", "AsyncExportHTMLResource"] |
| 25 | + |
| 26 | + |
| 27 | +class ExportHTMLResource(SyncAPIResource): |
| 28 | + @cached_property |
| 29 | + def with_raw_response(self) -> ExportHTMLResourceWithRawResponse: |
| 30 | + """ |
| 31 | + This property can be used as a prefix for any HTTP method call to return |
| 32 | + the raw response object instead of the parsed content. |
| 33 | +
|
| 34 | + For more information, see https://www.github.com/unlayer/unlayer-python#accessing-raw-response-data-eg-headers |
| 35 | + """ |
| 36 | + return ExportHTMLResourceWithRawResponse(self) |
| 37 | + |
| 38 | + @cached_property |
| 39 | + def with_streaming_response(self) -> ExportHTMLResourceWithStreamingResponse: |
| 40 | + """ |
| 41 | + An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 42 | +
|
| 43 | + For more information, see https://www.github.com/unlayer/unlayer-python#with_streaming_response |
| 44 | + """ |
| 45 | + return ExportHTMLResourceWithStreamingResponse(self) |
| 46 | + |
| 47 | + def create( |
| 48 | + self, |
| 49 | + *, |
| 50 | + design: object, |
| 51 | + project_id: str | Omit = omit, |
| 52 | + custom_js: Union[str, SequenceNotStr[str]] | Omit = omit, |
| 53 | + design_tags: object | Omit = omit, |
| 54 | + design_tags_config: object | Omit = omit, |
| 55 | + display_mode: Literal["email", "web", "popup", "document"] | Omit = omit, |
| 56 | + editor_version: str | Omit = omit, |
| 57 | + language: str | Omit = omit, |
| 58 | + languages: SequenceNotStr[str] | Omit = omit, |
| 59 | + merge_tags: object | Omit = omit, |
| 60 | + merge_tags_schema: object | Omit = omit, |
| 61 | + safe_html: bool | Omit = omit, |
| 62 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 63 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 64 | + extra_headers: Headers | None = None, |
| 65 | + extra_query: Query | None = None, |
| 66 | + extra_body: Body | None = None, |
| 67 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
| 68 | + ) -> ExportHTMLCreateResponse: |
| 69 | + """ |
| 70 | + Export a design as rendered HTML. |
| 71 | +
|
| 72 | + Args: |
| 73 | + design: Unlayer design JSON |
| 74 | +
|
| 75 | + project_id: The project ID (required for PAT auth, auto-resolved for API key auth) |
| 76 | +
|
| 77 | + extra_headers: Send extra headers |
| 78 | +
|
| 79 | + extra_query: Add additional query parameters to the request |
| 80 | +
|
| 81 | + extra_body: Add additional JSON properties to the request |
| 82 | +
|
| 83 | + timeout: Override the client-level default timeout for this request, in seconds |
| 84 | + """ |
| 85 | + return self._post( |
| 86 | + "/v3/templates/export/html", |
| 87 | + body=maybe_transform( |
| 88 | + { |
| 89 | + "design": design, |
| 90 | + "custom_js": custom_js, |
| 91 | + "design_tags": design_tags, |
| 92 | + "design_tags_config": design_tags_config, |
| 93 | + "display_mode": display_mode, |
| 94 | + "editor_version": editor_version, |
| 95 | + "language": language, |
| 96 | + "languages": languages, |
| 97 | + "merge_tags": merge_tags, |
| 98 | + "merge_tags_schema": merge_tags_schema, |
| 99 | + "safe_html": safe_html, |
| 100 | + }, |
| 101 | + export_html_create_params.ExportHTMLCreateParams, |
| 102 | + ), |
| 103 | + options=make_request_options( |
| 104 | + extra_headers=extra_headers, |
| 105 | + extra_query=extra_query, |
| 106 | + extra_body=extra_body, |
| 107 | + timeout=timeout, |
| 108 | + query=maybe_transform({"project_id": project_id}, export_html_create_params.ExportHTMLCreateParams), |
| 109 | + ), |
| 110 | + cast_to=ExportHTMLCreateResponse, |
| 111 | + ) |
| 112 | + |
| 113 | + |
| 114 | +class AsyncExportHTMLResource(AsyncAPIResource): |
| 115 | + @cached_property |
| 116 | + def with_raw_response(self) -> AsyncExportHTMLResourceWithRawResponse: |
| 117 | + """ |
| 118 | + This property can be used as a prefix for any HTTP method call to return |
| 119 | + the raw response object instead of the parsed content. |
| 120 | +
|
| 121 | + For more information, see https://www.github.com/unlayer/unlayer-python#accessing-raw-response-data-eg-headers |
| 122 | + """ |
| 123 | + return AsyncExportHTMLResourceWithRawResponse(self) |
| 124 | + |
| 125 | + @cached_property |
| 126 | + def with_streaming_response(self) -> AsyncExportHTMLResourceWithStreamingResponse: |
| 127 | + """ |
| 128 | + An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 129 | +
|
| 130 | + For more information, see https://www.github.com/unlayer/unlayer-python#with_streaming_response |
| 131 | + """ |
| 132 | + return AsyncExportHTMLResourceWithStreamingResponse(self) |
| 133 | + |
| 134 | + async def create( |
| 135 | + self, |
| 136 | + *, |
| 137 | + design: object, |
| 138 | + project_id: str | Omit = omit, |
| 139 | + custom_js: Union[str, SequenceNotStr[str]] | Omit = omit, |
| 140 | + design_tags: object | Omit = omit, |
| 141 | + design_tags_config: object | Omit = omit, |
| 142 | + display_mode: Literal["email", "web", "popup", "document"] | Omit = omit, |
| 143 | + editor_version: str | Omit = omit, |
| 144 | + language: str | Omit = omit, |
| 145 | + languages: SequenceNotStr[str] | Omit = omit, |
| 146 | + merge_tags: object | Omit = omit, |
| 147 | + merge_tags_schema: object | Omit = omit, |
| 148 | + safe_html: bool | Omit = omit, |
| 149 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 150 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 151 | + extra_headers: Headers | None = None, |
| 152 | + extra_query: Query | None = None, |
| 153 | + extra_body: Body | None = None, |
| 154 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
| 155 | + ) -> ExportHTMLCreateResponse: |
| 156 | + """ |
| 157 | + Export a design as rendered HTML. |
| 158 | +
|
| 159 | + Args: |
| 160 | + design: Unlayer design JSON |
| 161 | +
|
| 162 | + project_id: The project ID (required for PAT auth, auto-resolved for API key auth) |
| 163 | +
|
| 164 | + extra_headers: Send extra headers |
| 165 | +
|
| 166 | + extra_query: Add additional query parameters to the request |
| 167 | +
|
| 168 | + extra_body: Add additional JSON properties to the request |
| 169 | +
|
| 170 | + timeout: Override the client-level default timeout for this request, in seconds |
| 171 | + """ |
| 172 | + return await self._post( |
| 173 | + "/v3/templates/export/html", |
| 174 | + body=await async_maybe_transform( |
| 175 | + { |
| 176 | + "design": design, |
| 177 | + "custom_js": custom_js, |
| 178 | + "design_tags": design_tags, |
| 179 | + "design_tags_config": design_tags_config, |
| 180 | + "display_mode": display_mode, |
| 181 | + "editor_version": editor_version, |
| 182 | + "language": language, |
| 183 | + "languages": languages, |
| 184 | + "merge_tags": merge_tags, |
| 185 | + "merge_tags_schema": merge_tags_schema, |
| 186 | + "safe_html": safe_html, |
| 187 | + }, |
| 188 | + export_html_create_params.ExportHTMLCreateParams, |
| 189 | + ), |
| 190 | + options=make_request_options( |
| 191 | + extra_headers=extra_headers, |
| 192 | + extra_query=extra_query, |
| 193 | + extra_body=extra_body, |
| 194 | + timeout=timeout, |
| 195 | + query=await async_maybe_transform( |
| 196 | + {"project_id": project_id}, export_html_create_params.ExportHTMLCreateParams |
| 197 | + ), |
| 198 | + ), |
| 199 | + cast_to=ExportHTMLCreateResponse, |
| 200 | + ) |
| 201 | + |
| 202 | + |
| 203 | +class ExportHTMLResourceWithRawResponse: |
| 204 | + def __init__(self, export_html: ExportHTMLResource) -> None: |
| 205 | + self._export_html = export_html |
| 206 | + |
| 207 | + self.create = to_raw_response_wrapper( |
| 208 | + export_html.create, |
| 209 | + ) |
| 210 | + |
| 211 | + |
| 212 | +class AsyncExportHTMLResourceWithRawResponse: |
| 213 | + def __init__(self, export_html: AsyncExportHTMLResource) -> None: |
| 214 | + self._export_html = export_html |
| 215 | + |
| 216 | + self.create = async_to_raw_response_wrapper( |
| 217 | + export_html.create, |
| 218 | + ) |
| 219 | + |
| 220 | + |
| 221 | +class ExportHTMLResourceWithStreamingResponse: |
| 222 | + def __init__(self, export_html: ExportHTMLResource) -> None: |
| 223 | + self._export_html = export_html |
| 224 | + |
| 225 | + self.create = to_streamed_response_wrapper( |
| 226 | + export_html.create, |
| 227 | + ) |
| 228 | + |
| 229 | + |
| 230 | +class AsyncExportHTMLResourceWithStreamingResponse: |
| 231 | + def __init__(self, export_html: AsyncExportHTMLResource) -> None: |
| 232 | + self._export_html = export_html |
| 233 | + |
| 234 | + self.create = async_to_streamed_response_wrapper( |
| 235 | + export_html.create, |
| 236 | + ) |
0 commit comments