Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion torngen/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.8.1
5.9.0
2 changes: 1 addition & 1 deletion torngen/base_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from .base_path import Path
from .base_schema import BaseSchema

VERSION = "5.8.1"
VERSION = "5.9.0"


class _URLComponents(typing.NamedTuple):
Expand Down
46 changes: 24 additions & 22 deletions torngen/path/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from .company import Company
from .company_id import CompanyId
from .company_typeId import CompanyTypeId
from .faction import Faction
from .faction_chainId import FactionChainId
from .faction_crimeId import FactionCrimeId
Expand Down Expand Up @@ -31,35 +32,36 @@
from .user_tradeId import UserTradeId

__all__ = [
"Company",
"CompanyId",
"Forum",
"RacingRaceId",
"FactionTerritoryWarId",
"Faction",
"FactionChainId",
"FactionRankedWarId",
"Market",
"UserCrimeId",
"PropertyId",
"Company",
"TornIds",
"MarketId",
"FactionCrimeId",
"FactionChainId",
"FactionId",
"User",
"FactionRaidWarId",
"FactionRankedWarId",
"FactionTerritoryWarId",
"Forum",
"TornId",
"Racing",
"CompanyId",
"ForumCategoryIds",
"TornCrimeId",
"UserTradeId",
"Property",
"TornLogCategoryId",
"ForumThreadId",
"Key",
"Market",
"MarketId",
"UserId",
"MarketPropertyTypeId",
"Property",
"PropertyId",
"Racing",
"RacingRaceId",
"RacingTrackId",
"Key",
"Torn",
"TornCrimeId",
"TornId",
"TornIds",
"TornLogCategoryId",
"TornStockId",
"User",
"UserCrimeId",
"UserId",
"UserTradeId",
"RacingTrackId",
"CompanyTypeId",
]
31 changes: 31 additions & 0 deletions torngen/path/company.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from ..schema.company_lookup_response import CompanyLookupResponse
from ..schema.company_profile_response_mixed import CompanyProfileResponseMixed
from ..schema.company_stock_response import CompanyStockResponse
from ..schema.news_response import NewsResponse
from ..schema.timestamp_response import TimestampResponse


Expand Down Expand Up @@ -52,6 +53,36 @@ class Company(BaseQuery):

"""

news = Path(
"/company/news",
NewsResponse,
striptags=Parameter("striptags", "query", required=False, deprecated=False),
limit=Parameter("limit", "query", required=False, deprecated=False),
sort=Parameter("sort", "query", required=False, deprecated=False),
to=Parameter("to", "query", required=False, deprecated=False),
from_=Parameter("from", "query", required=False, deprecated=False),
cat=Parameter("cat", "query", required=True, deprecated=False),
timestamp=Parameter("timestamp", "query", required=False, deprecated=False),
comment=Parameter("comment", "query", required=False, deprecated=False),
key=Parameter("key", "query", required=False, deprecated=False),
)
"""
`/company/news`: Get your company's news details
Requires minimal access key.

# Parameters
- striptags : Determines if fields include HTML or not ('Hospitalized by <a href=...>user</a>' vs 'Hospitalized by user').
- limit : N/A
- sort : Sorted by the greatest timestamps
- to : Timestamp that sets the upper limit for the data returned. Data returned will be up to and including this time
- from_ : Timestamp that sets the lower limit for the data returned. Data returned will be after this time
- cat : News category type
- timestamp : Timestamp to bypass cache
- comment : Comment for your tool/service/bot/website to be visible in the logs.
- key : API key (Minimal). It's not required to use this parameter when passing the API key via the Authorization header.

"""

timestamp = Path(
"/company/timestamp",
TimestampResponse,
Expand Down
39 changes: 39 additions & 0 deletions torngen/path/company_typeId.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from ..base_path import Path
from ..base_query import BaseQuery
from ..parameter import Parameter
from ..schema.companies_response import CompaniesResponse


class CompanyTypeId(BaseQuery):
"""
A collection of paths representing `CompanyTypeId`.
"""

companies = Path(
"/company/{typeId}/companies",
CompaniesResponse,
typeId=Parameter("typeId", "path", required=True, deprecated=False),
limit=Parameter("limit", "query", required=False, deprecated=False),
offset=Parameter("offset", "query", required=False, deprecated=False),
striptags=Parameter("striptags", "query", required=False, deprecated=False),
timestamp=Parameter("timestamp", "query", required=False, deprecated=False),
comment=Parameter("comment", "query", required=False, deprecated=False),
key=Parameter("key", "query", required=False, deprecated=False),
)
"""
`/company/{typeId}/companies`: Get a list of companies for a specific company type
Requires public access key.

# Parameters
- typeId : Company type id
- limit : N/A
- offset : N/A
- striptags : Determines if fields include HTML or not ('Hospitalized by <a href=...>user</a>' vs 'Hospitalized by user').
- timestamp : Timestamp to bypass cache
- comment : Comment for your tool/service/bot/website to be visible in the logs.
- key : API key (Public). It's not required to use this parameter when passing the API key via the Authorization header.

"""

def __init__(self):
super().__init__(base_path="company/{typeId}")
4 changes: 2 additions & 2 deletions torngen/path/faction.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from ..schema.faction_hof_response import FactionHofResponse
from ..schema.faction_lookup_response import FactionLookupResponse
from ..schema.faction_members_response import FactionMembersResponse
from ..schema.faction_news_response import FactionNewsResponse
from ..schema.faction_ongoing_chain_response import FactionOngoingChainResponse
from ..schema.faction_positions_response import FactionPositionsResponse
from ..schema.faction_rackets_response import FactionRacketsResponse
Expand All @@ -31,6 +30,7 @@
from ..schema.faction_upgrades_response import FactionUpgradesResponse
from ..schema.faction_warfare_response import FactionWarfareResponse
from ..schema.faction_wars_response import FactionWarsResponse
from ..schema.news_response import NewsResponse
from ..schema.reports_response import ReportsResponse
from ..schema.revives_full_response import RevivesFullResponse
from ..schema.revives_response import RevivesResponse
Expand Down Expand Up @@ -100,7 +100,7 @@ class Faction(BaseQuery):

news = Path(
"/faction/news",
FactionNewsResponse,
NewsResponse,
striptags=Parameter("striptags", "query", required=False, deprecated=False),
limit=Parameter("limit", "query", required=False, deprecated=False),
sort=Parameter("sort", "query", required=False, deprecated=False),
Expand Down
31 changes: 31 additions & 0 deletions torngen/schema/companies_response.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import typing
from dataclasses import dataclass

from ..base_schema import BaseSchema
from .company_profile import CompanyProfile
from .request_metadata_with_links_and_total import RequestMetadataWithLinksAndTotal


@dataclass
class CompaniesResponse(BaseSchema):
"""
JSON object of `CompaniesResponse`.
"""

companies_timestamp: int
companies_delay: int
companies: typing.List[CompanyProfile]
_metadata: RequestMetadataWithLinksAndTotal

@staticmethod
def parse(data):
return CompaniesResponse(
companies_timestamp=BaseSchema.parse(data.get("companies_timestamp"), int),
companies_delay=BaseSchema.parse(data.get("companies_delay"), int),
companies=BaseSchema.parse(
data.get("companies"), typing.List[CompanyProfile]
),
_metadata=BaseSchema.parse(
data.get("_metadata"), RequestMetadataWithLinksAndTotal
),
)
3 changes: 3 additions & 0 deletions torngen/schema/company_news_category.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import typing

CompanyNewsCategory = typing.Literal["main", "funds", "training", "employees", "all"]
2 changes: 1 addition & 1 deletion torngen/schema/company_selection_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
"applications",
"employees",
"lookup",
"news",
"profile",
"stock",
"timestamp",
"companies",
"news",
"search",
]
)
2 changes: 2 additions & 0 deletions torngen/schema/faction_territory_ownership.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ class FactionTerritoryOwnership(BaseSchema):
"""

owned_by: None | FactionId
irradiated: bool
id: str
acquired_at: None | int

@staticmethod
def parse(data):
return FactionTerritoryOwnership(
owned_by=BaseSchema.parse(data.get("owned_by"), None | FactionId),
irradiated=BaseSchema.parse(data.get("irradiated"), bool),
id=BaseSchema.parse(data.get("id"), str),
acquired_at=BaseSchema.parse(data.get("acquired_at"), None | int),
)
23 changes: 23 additions & 0 deletions torngen/schema/news.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import typing
from dataclasses import dataclass

from ..base_schema import BaseSchema


@dataclass
class News(BaseSchema):
"""
JSON object of `News`.
"""

timestamp: int
text: str
id: str

@staticmethod
def parse(data):
return News(
timestamp=BaseSchema.parse(data.get("timestamp"), int),
text=BaseSchema.parse(data.get("text"), str),
id=BaseSchema.parse(data.get("id"), str),
)
23 changes: 23 additions & 0 deletions torngen/schema/news_response.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import typing
from dataclasses import dataclass

from ..base_schema import BaseSchema
from .news import News
from .request_metadata_with_links import RequestMetadataWithLinks


@dataclass
class NewsResponse(BaseSchema):
"""
JSON object of `NewsResponse`.
"""

news: typing.List[News]
_metadata: RequestMetadataWithLinks

@staticmethod
def parse(data):
return NewsResponse(
news=BaseSchema.parse(data.get("news"), typing.List[News]),
_metadata=BaseSchema.parse(data.get("_metadata"), RequestMetadataWithLinks),
)
6 changes: 2 additions & 4 deletions torngen/schema/torn_bounties_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,15 @@ class TornBountiesResponse(BaseSchema):
"""

bounties_timestamp: int
bounties_delay: typing.Optional[int]
bounties_delay: int
bounties: typing.List[Bounty]
_metadata: RequestMetadataWithLinksAndTotal

@staticmethod
def parse(data):
return TornBountiesResponse(
bounties_timestamp=BaseSchema.parse(data.get("bounties_timestamp"), int),
bounties_delay=BaseSchema.parse(
data.get("bounties_delay"), typing.Optional[int]
),
bounties_delay=BaseSchema.parse(data.get("bounties_delay"), int),
bounties=BaseSchema.parse(data.get("bounties"), typing.List[Bounty]),
_metadata=BaseSchema.parse(
data.get("_metadata"), RequestMetadataWithLinksAndTotal
Expand Down