Skip to content

Commit 0bd7c04

Browse files
committed
Release 0.0.14
1 parent 27c3ac8 commit 0bd7c04

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2232
-2
lines changed

.fernignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Specify files that shouldn't be modified by Fern

.github/workflows/ci.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: ci
2+
3+
on: [push]
4+
jobs:
5+
compile:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- name: Checkout repo
9+
uses: actions/checkout@v3
10+
- name: Set up python
11+
uses: actions/setup-python@v4
12+
with:
13+
python-version: 3.7
14+
- name: Bootstrap poetry
15+
run: |
16+
curl -sSL https://install.python-poetry.org | python - -y
17+
- name: Install dependencies
18+
run: poetry install
19+
- name: Compile
20+
run: poetry run mypy .
21+
22+
publish:
23+
needs: [ compile ]
24+
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
25+
runs-on: ubuntu-latest
26+
27+
steps:
28+
- name: Checkout repo
29+
uses: actions/checkout@v3
30+
- name: Set up python
31+
uses: actions/setup-python@v4
32+
with:
33+
python-version: 3.7
34+
- name: Bootstrap poetry
35+
run: |
36+
curl -sSL https://install.python-poetry.org | python - -y
37+
- name: Install dependencies
38+
run: poetry install
39+
- name: Publish to pypi
40+
run: |
41+
poetry config repositories.remote https://upload.pypi.org/legacy/
42+
poetry --no-interaction -v publish --build --repository remote --username "$PYPI_USERNAME" --password "$PYPI_PASSWORD"
43+
env:
44+
PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}
45+
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dist/
2+
.mypy_cache/
3+
__pycache__/
4+
poetry.toml

README.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

pyproject.toml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
[tool.poetry]
3+
name = "codecombat"
4+
version = "0.0.14"
5+
description = ""
6+
authors = []
7+
packages = [
8+
{ include = "codecombat", from = "src"}
9+
]
10+
11+
[tool.poetry.dependencies]
12+
python = "^3.7"
13+
types-backports = "0.1.3"
14+
pydantic = "^1.9.2"
15+
backports-cached_property = "1.0.2"
16+
httpx = "0.23.3"
17+
18+
[tool.poetry.dev-dependencies]
19+
mypy = "0.971"
20+
21+
[build-system]
22+
requires = ["poetry-core"]
23+
build-backend = "poetry.core.masonry.api"

src/codecombat/__init__.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# This file was auto-generated by Fern from our API Definition.
2+
3+
from .environment import CodecombatApiEnvironment
4+
from .resources import (
5+
AceConfig,
6+
AuthIdentity,
7+
ClanResponse,
8+
ClassroomResponse,
9+
ClassroomResponseWithCode,
10+
Course,
11+
DatetimeString,
12+
HeroConfig,
13+
Level,
14+
LevelSessionResponse,
15+
License,
16+
LicenseStatsResponse,
17+
MemberStat,
18+
ObjectIdString,
19+
PlayStats,
20+
PlaytimeStatsResponse,
21+
RoleString,
22+
State,
23+
Subscription,
24+
UserResponse,
25+
UserRole,
26+
UserStats,
27+
auth,
28+
clans,
29+
classrooms,
30+
commons,
31+
stats,
32+
users,
33+
)
34+
35+
__all__ = [
36+
"AceConfig",
37+
"AuthIdentity",
38+
"ClanResponse",
39+
"ClassroomResponse",
40+
"ClassroomResponseWithCode",
41+
"CodecombatApiEnvironment",
42+
"Course",
43+
"DatetimeString",
44+
"HeroConfig",
45+
"Level",
46+
"LevelSessionResponse",
47+
"License",
48+
"LicenseStatsResponse",
49+
"MemberStat",
50+
"ObjectIdString",
51+
"PlayStats",
52+
"PlaytimeStatsResponse",
53+
"RoleString",
54+
"State",
55+
"Subscription",
56+
"UserResponse",
57+
"UserRole",
58+
"UserStats",
59+
"auth",
60+
"clans",
61+
"classrooms",
62+
"commons",
63+
"stats",
64+
"users",
65+
]

src/codecombat/client.py

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# This file was auto-generated by Fern from our API Definition.
2+
3+
import typing
4+
5+
from backports.cached_property import cached_property
6+
7+
from .environment import CodecombatApiEnvironment
8+
from .resources.auth.client import AsyncAuthClient, AuthClient
9+
from .resources.clans.client import AsyncClansClient, ClansClient
10+
from .resources.classrooms.client import AsyncClassroomsClient, ClassroomsClient
11+
from .resources.stats.client import AsyncStatsClient, StatsClient
12+
from .resources.users.client import AsyncUsersClient, UsersClient
13+
14+
15+
class CodecombatApi:
16+
def __init__(
17+
self,
18+
*,
19+
environment: CodecombatApiEnvironment = CodecombatApiEnvironment.PRODUCTION,
20+
username: typing.Optional[str] = None,
21+
password: typing.Optional[str] = None
22+
):
23+
self._environment = environment
24+
self._username = username
25+
self._password = password
26+
27+
@cached_property
28+
def auth(self) -> AuthClient:
29+
return AuthClient(environment=self._environment, username=self._username, password=self._password)
30+
31+
@cached_property
32+
def clans(self) -> ClansClient:
33+
return ClansClient(environment=self._environment, username=self._username, password=self._password)
34+
35+
@cached_property
36+
def classrooms(self) -> ClassroomsClient:
37+
return ClassroomsClient(environment=self._environment, username=self._username, password=self._password)
38+
39+
@cached_property
40+
def stats(self) -> StatsClient:
41+
return StatsClient(environment=self._environment, username=self._username, password=self._password)
42+
43+
@cached_property
44+
def users(self) -> UsersClient:
45+
return UsersClient(environment=self._environment, username=self._username, password=self._password)
46+
47+
48+
class AsyncCodecombatApi:
49+
def __init__(
50+
self,
51+
*,
52+
environment: CodecombatApiEnvironment = CodecombatApiEnvironment.PRODUCTION,
53+
username: typing.Optional[str] = None,
54+
password: typing.Optional[str] = None
55+
):
56+
self._environment = environment
57+
self._username = username
58+
self._password = password
59+
60+
@cached_property
61+
def auth(self) -> AsyncAuthClient:
62+
return AsyncAuthClient(environment=self._environment, username=self._username, password=self._password)
63+
64+
@cached_property
65+
def clans(self) -> AsyncClansClient:
66+
return AsyncClansClient(environment=self._environment, username=self._username, password=self._password)
67+
68+
@cached_property
69+
def classrooms(self) -> AsyncClassroomsClient:
70+
return AsyncClassroomsClient(environment=self._environment, username=self._username, password=self._password)
71+
72+
@cached_property
73+
def stats(self) -> AsyncStatsClient:
74+
return AsyncStatsClient(environment=self._environment, username=self._username, password=self._password)
75+
76+
@cached_property
77+
def users(self) -> AsyncUsersClient:
78+
return AsyncUsersClient(environment=self._environment, username=self._username, password=self._password)

src/codecombat/core/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# This file was auto-generated by Fern from our API Definition.
2+
3+
from .api_error import ApiError
4+
from .datetime_utils import serialize_datetime
5+
from .jsonable_encoder import jsonable_encoder
6+
from .remove_none_from_headers import remove_none_from_headers
7+
8+
__all__ = ["ApiError", "jsonable_encoder", "remove_none_from_headers", "serialize_datetime"]

src/codecombat/core/api_error.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This file was auto-generated by Fern from our API Definition.
2+
3+
import typing
4+
5+
6+
class ApiError(Exception):
7+
status_code: typing.Optional[int]
8+
body: typing.Any
9+
10+
def __init__(self, *, status_code: typing.Optional[int] = None, body: typing.Any = None):
11+
self.status_code = status_code
12+
self.body = body
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# This file was auto-generated by Fern from our API Definition.
2+
3+
import datetime as dt
4+
5+
6+
def serialize_datetime(v: dt.datetime) -> str:
7+
"""
8+
Serialize a datetime including timezone info.
9+
10+
Uses the timezone info provided if present, otherwise uses the current runtime's timezone info.
11+
12+
UTC datetimes end in "Z" while all other timezones are represented as offset from UTC, e.g. +05:00.
13+
"""
14+
15+
def _serialize_zoned_datetime(v: dt.datetime) -> str:
16+
if v.tzinfo is not None and v.tzinfo.tzname(None) == dt.timezone.utc.tzname(None):
17+
# UTC is a special case where we use "Z" at the end instead of "+00:00"
18+
return v.isoformat().replace("+00:00", "Z")
19+
else:
20+
# Delegate to the typical +/- offset format
21+
return v.isoformat()
22+
23+
if v.tzinfo is not None:
24+
return _serialize_zoned_datetime(v)
25+
else:
26+
local_tz = dt.datetime.now().astimezone().tzinfo
27+
localized_dt = v.replace(tzinfo=local_tz)
28+
return _serialize_zoned_datetime(localized_dt)

0 commit comments

Comments
 (0)