Skip to content

Commit

Permalink
(feat): embedded code snippets with latest API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] authored Mar 13, 2024
1 parent 29c7376 commit f66a4e2
Show file tree
Hide file tree
Showing 176 changed files with 8,144 additions and 1,809 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- name: Set up python
uses: actions/setup-python@v4
with:
python-version: 3.7
python-version: 3.8
- name: Bootstrap poetry
run: |
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
Expand All @@ -26,7 +26,7 @@ jobs:
- name: Set up python
uses: actions/setup-python@v4
with:
python-version: 3.7
python-version: 3.8
- name: Bootstrap poetry
run: |
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
Expand All @@ -45,7 +45,7 @@ jobs:
- name: Set up python
uses: actions/setup-python@v4
with:
python-version: 3.7
python-version: 3.8
- name: Bootstrap poetry
run: |
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
Expand Down
450 changes: 168 additions & 282 deletions poetry.lock

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "webflow"
version = "1.0.0"
version = "v1.1.0"
description = ""
readme = "README.md"
authors = []
Expand All @@ -9,12 +9,13 @@ packages = [
]

[tool.poetry.dependencies]
python = "^3.7"
python = "^3.8"
httpx = ">=0.21.2"
pydantic = ">= 1.9.2, < 2.5.0"
pydantic = ">= 1.9.2"
typing_extensions = ">= 4.0.0"

[tool.poetry.dev-dependencies]
mypy = "0.971"
mypy = "^1.8.0"
pytest = "^7.4.0"

[build-system]
Expand Down
54 changes: 54 additions & 0 deletions src/webflow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
CustomCodeBlock,
CustomCodeBlockType,
CustomCodeResponse,
Dom,
Domain,
DuplicateUserEmail,
EcommerceSettings,
Expand All @@ -44,12 +45,17 @@
FormSubmissionList,
FormSubmissionTrigger,
FormSubmissionTriggerPayload,
ImageNode,
InvalidDomain,
InvalidScopes,
InventoryItem,
InventoryItemInventoryType,
ListCustomCodeBlocks,
MissingScopes,
NoDomains,
Node,
NodeType,
NotEnterprisePlanSite,
OauthScope,
Order,
OrderAddress,
Expand Down Expand Up @@ -85,6 +91,8 @@
ProductAndSkUs,
ProductAndSkUsList,
ProductFieldData,
ProductFieldDataEcProductType,
ProductFieldDataTaxCategory,
PublishStatus,
PublishedItems,
PublishedSite,
Expand All @@ -96,12 +104,17 @@
Site,
SiteActivityLogItem,
SiteActivityLogItemResourceOperation,
SiteActivityLogItemUser,
SiteActivityLogResponse,
SitePublish,
SitePublishPayload,
Sites,
Sku,
SkuFieldData,
SkuFieldDataCompareAtPrice,
SkuFieldDataEcSkuBillingMethod,
SkuFieldDataEcSkuSubscriptionPlan,
SkuFieldDataEcSkuSubscriptionPlanInterval,
SkuFieldDataPrice,
SkuPropertyList,
SkuPropertyListEnumItem,
Expand All @@ -110,6 +123,7 @@
StripeCardBrand,
StripeCardExpires,
StripeDetails,
TextNode,
TriggerType,
User,
UserAccessGroupsItem,
Expand All @@ -136,11 +150,24 @@
)
from .resources import (
AccessGroupsListRequestSort,
DomWriteNodesItem,
InventoryUpdateRequestInventoryType,
OrdersListRequestStatus,
OrdersRefundRequestReason,
ProductSkuCreateProduct,
ProductSkuCreateProductFieldData,
ProductSkuCreateProductFieldDataEcProductType,
ProductSkuCreateProductFieldDataTaxCategory,
ProductSkuCreateSku,
ProductSkuCreateSkuFieldData,
ProductSkuCreateSkuFieldDataCompareAtPrice,
ProductSkuCreateSkuFieldDataEcSkuBillingMethod,
ProductSkuCreateSkuFieldDataEcSkuSubscriptionPlan,
ProductSkuCreateSkuFieldDataEcSkuSubscriptionPlanInterval,
ProductSkuCreateSkuFieldDataPrice,
ProductsCreateSkuResponse,
UsersListRequestSort,
UsersUpdateRequestData,
access_groups,
assets,
collections,
Expand Down Expand Up @@ -187,6 +214,8 @@
"CustomCodeBlock",
"CustomCodeBlockType",
"CustomCodeResponse",
"Dom",
"DomWriteNodesItem",
"Domain",
"DuplicateUserEmail",
"EcommerceSettings",
Expand All @@ -206,14 +235,19 @@
"FormSubmissionList",
"FormSubmissionTrigger",
"FormSubmissionTriggerPayload",
"ImageNode",
"InternalServerError",
"InvalidDomain",
"InvalidScopes",
"InventoryItem",
"InventoryItemInventoryType",
"InventoryUpdateRequestInventoryType",
"ListCustomCodeBlocks",
"MissingScopes",
"NoDomains",
"Node",
"NodeType",
"NotEnterprisePlanSite",
"NotFoundError",
"OauthScope",
"Order",
Expand Down Expand Up @@ -252,6 +286,19 @@
"ProductAndSkUs",
"ProductAndSkUsList",
"ProductFieldData",
"ProductFieldDataEcProductType",
"ProductFieldDataTaxCategory",
"ProductSkuCreateProduct",
"ProductSkuCreateProductFieldData",
"ProductSkuCreateProductFieldDataEcProductType",
"ProductSkuCreateProductFieldDataTaxCategory",
"ProductSkuCreateSku",
"ProductSkuCreateSkuFieldData",
"ProductSkuCreateSkuFieldDataCompareAtPrice",
"ProductSkuCreateSkuFieldDataEcSkuBillingMethod",
"ProductSkuCreateSkuFieldDataEcSkuSubscriptionPlan",
"ProductSkuCreateSkuFieldDataEcSkuSubscriptionPlanInterval",
"ProductSkuCreateSkuFieldDataPrice",
"ProductsCreateSkuResponse",
"PublishStatus",
"PublishedItems",
Expand All @@ -264,12 +311,17 @@
"Site",
"SiteActivityLogItem",
"SiteActivityLogItemResourceOperation",
"SiteActivityLogItemUser",
"SiteActivityLogResponse",
"SitePublish",
"SitePublishPayload",
"Sites",
"Sku",
"SkuFieldData",
"SkuFieldDataCompareAtPrice",
"SkuFieldDataEcSkuBillingMethod",
"SkuFieldDataEcSkuSubscriptionPlan",
"SkuFieldDataEcSkuSubscriptionPlanInterval",
"SkuFieldDataPrice",
"SkuPropertyList",
"SkuPropertyListEnumItem",
Expand All @@ -278,6 +330,7 @@
"StripeCardBrand",
"StripeCardExpires",
"StripeDetails",
"TextNode",
"TooManyRequestsError",
"TriggerType",
"UnauthorizedError",
Expand All @@ -293,6 +346,7 @@
"UserWebhookPayloadTriggerType",
"UsersListRequestSort",
"UsersNotEnabled",
"UsersUpdateRequestData",
"WebflowEnvironment",
"Webhook",
"WebhookList",
Expand Down
46 changes: 46 additions & 0 deletions src/webflow/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,29 @@


class Webflow:
"""
Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propogate to these functions.
Parameters:
- base_url: typing.Optional[str]. The base url to use for requests from the client.
- environment: WebflowEnvironment. The environment to use for requests from the client. from .environment import WebflowEnvironment
Defaults to WebflowEnvironment.DEFAULT
- access_token: typing.Union[str, typing.Callable[[], str]].
- timeout: typing.Optional[float]. The timeout to be used, in seconds, for requests by default the timeout is 60 seconds.
- httpx_client: typing.Optional[httpx.Client]. The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
---
from webflow.client import Webflow
client = Webflow(
access_token="YOUR_ACCESS_TOKEN",
)
"""

def __init__(
self,
*,
Expand Down Expand Up @@ -54,6 +77,29 @@ def __init__(


class AsyncWebflow:
"""
Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propogate to these functions.
Parameters:
- base_url: typing.Optional[str]. The base url to use for requests from the client.
- environment: WebflowEnvironment. The environment to use for requests from the client. from .environment import WebflowEnvironment
Defaults to WebflowEnvironment.DEFAULT
- access_token: typing.Union[str, typing.Callable[[], str]].
- timeout: typing.Optional[float]. The timeout to be used, in seconds, for requests by default the timeout is 60 seconds.
- httpx_client: typing.Optional[httpx.AsyncClient]. The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
---
from webflow.client import AsyncWebflow
client = AsyncWebflow(
access_token="YOUR_ACCESS_TOKEN",
)
"""

def __init__(
self,
*,
Expand Down
5 changes: 5 additions & 0 deletions src/webflow/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@
from .api_error import ApiError
from .client_wrapper import AsyncClientWrapper, BaseClientWrapper, SyncClientWrapper
from .datetime_utils import serialize_datetime
from .file import File, convert_file_dict_to_httpx_tuples
from .jsonable_encoder import jsonable_encoder
from .remove_none_from_dict import remove_none_from_dict
from .request_options import RequestOptions

__all__ = [
"ApiError",
"AsyncClientWrapper",
"BaseClientWrapper",
"File",
"RequestOptions",
"SyncClientWrapper",
"convert_file_dict_to_httpx_tuples",
"jsonable_encoder",
"remove_none_from_dict",
"serialize_datetime",
Expand Down
2 changes: 1 addition & 1 deletion src/webflow/core/client_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def get_headers(self) -> typing.Dict[str, str]:
headers: typing.Dict[str, str] = {
"X-Fern-Language": "Python",
"X-Fern-SDK-Name": "webflow",
"X-Fern-SDK-Version": "0.1.0b2",
"X-Fern-SDK-Version": "v1.1.0",
}
headers["Authorization"] = f"Bearer {self._get_access_token()}"
return headers
Expand Down
38 changes: 38 additions & 0 deletions src/webflow/core/file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# This file was auto-generated by Fern from our API Definition.

import typing

# File typing inspired by the flexibility of types within the httpx library
# https://github.com/encode/httpx/blob/master/httpx/_types.py
FileContent = typing.Union[typing.IO[bytes], bytes, str]
File = typing.Union[
# file (or bytes)
FileContent,
# (filename, file (or bytes))
typing.Tuple[typing.Optional[str], FileContent],
# (filename, file (or bytes), content_type)
typing.Tuple[typing.Optional[str], FileContent, typing.Optional[str]],
# (filename, file (or bytes), content_type, headers)
typing.Tuple[typing.Optional[str], FileContent, typing.Optional[str], typing.Mapping[str, str]],
]


def convert_file_dict_to_httpx_tuples(
d: typing.Dict[str, typing.Union[File, typing.List[File]]]
) -> typing.List[typing.Tuple[str, File]]:
"""
The format we use is a list of tuples, where the first element is the
name of the file and the second is the file object. Typically HTTPX wants
a dict, but to be able to send lists of files, you have to use the list
approach (which also works for non-lists)
https://github.com/encode/httpx/pull/1032
"""

httpx_tuples = []
for key, file_like in d.items():
if isinstance(file_like, list):
for file_like_item in file_like:
httpx_tuples.append((key, file_like_item))
else:
httpx_tuples.append((key, file_like))
return httpx_tuples
29 changes: 29 additions & 0 deletions src/webflow/core/request_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This file was auto-generated by Fern from our API Definition.

import typing

try:
from typing import NotRequired # type: ignore
except ImportError:
from typing_extensions import NotRequired # type: ignore


class RequestOptions(typing.TypedDict):
"""
Additional options for request-specific configuration when calling APIs via the SDK.
This is used primarily as an optional final parameter for service functions.
Attributes:
- timeout_in_seconds: int. The number of seconds to await an API call before timing out.
- additional_headers: typing.Dict[str, typing.Any]. A dictionary containing additional parameters to spread into the request's header dict
- additional_query_parameters: typing.Dict[str, typing.Any]. A dictionary containing additional parameters to spread into the request's query parameters dict
- additional_body_parameters: typing.Dict[str, typing.Any]. A dictionary containing additional parameters to spread into the request's body parameters dict
"""

timeout_in_seconds: NotRequired[int]
additional_headers: NotRequired[typing.Dict[str, typing.Any]]
additional_query_parameters: NotRequired[typing.Dict[str, typing.Any]]
additional_body_parameters: NotRequired[typing.Dict[str, typing.Any]]
Loading

0 comments on commit f66a4e2

Please sign in to comment.