Skip to content

Commit

Permalink
All objects with defaults and all defaults being None now use repr_om…
Browse files Browse the repository at this point in the history
…it_defaults and omit_defaults

Fixes limx0#54
  • Loading branch information
ml31415 committed Mar 31, 2024
1 parent f89e636 commit 66d91c0
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 74 deletions.
6 changes: 3 additions & 3 deletions betfair_parser/spec/accounts/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class _AccountRequest(Request, frozen=True, tag_field="method", tag=accounts_tag
throws = AccountAPINGException


class _GetAccountFundsParams(Params, frozen=True):
class _GetAccountFundsParams(Params, omit_defaults=True, repr_omit_defaults=True, frozen=True):
wallet: Optional[Wallet] = None # Name of the wallet in question. Global wallet is returned by default


Expand All @@ -38,7 +38,7 @@ class GetAccountDetails(_AccountRequest, kw_only=True, frozen=True):
return_type = Response[AccountDetailsResponse]


class _GetAccountStatementParams(Params, frozen=True):
class _GetAccountStatementParams(Params, omit_defaults=True, repr_omit_defaults=True, frozen=True):
locale: Optional[str] = None # The language to be used where applicable. Defaults to account settings
from_record: Optional[int] = None # Specifies the first record that will be returned, defaults to 0
record_count: Optional[int] = None # Specifies the maximum number of records to be returned. Maximum 100
Expand All @@ -60,7 +60,7 @@ class GetAccountStatement(_AccountRequest, kw_only=True, frozen=True):
return_type = Response[AccountStatementReport]


class _ListCurrencyRatesParams(Params, frozen=True):
class _ListCurrencyRatesParams(Params, omit_defaults=True, repr_omit_defaults=True, frozen=True):
from_currency: Optional[str] = None # The currency from which the rates are computed. Only GBP for now.


Expand Down
24 changes: 12 additions & 12 deletions betfair_parser/spec/accounts/type_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from betfair_parser.spec.common import BaseMessage, Date


class ApplicationSubscription(BaseMessage, frozen=True):
class ApplicationSubscription(BaseMessage, omit_defaults=True, repr_omit_defaults=True, frozen=True):
"""Application subscription details"""

subscription_token: str # Application key identifier
Expand All @@ -25,7 +25,7 @@ class ApplicationSubscription(BaseMessage, frozen=True):
vendor_client_id: Optional[str] = None


class SubscriptionHistory(BaseMessage, frozen=True):
class SubscriptionHistory(BaseMessage, omit_defaults=True, repr_omit_defaults=True, frozen=True):
"""Application subscription history details"""

subscription_token: str # Application key identifier
Expand All @@ -38,7 +38,7 @@ class SubscriptionHistory(BaseMessage, frozen=True):
client_reference: Optional[str] = None


class SubscriptionTokenInfo(BaseMessage, frozen=True):
class SubscriptionTokenInfo(BaseMessage, omit_defaults=True, repr_omit_defaults=True, frozen=True):
"""Subscription token information"""

subscription_token: str
Expand All @@ -49,15 +49,15 @@ class SubscriptionTokenInfo(BaseMessage, frozen=True):
subscription_status: Optional[SubscriptionStatus] = None


class AccountSubscription(BaseMessage, frozen=True):
class AccountSubscription(BaseMessage, omit_defaults=True, repr_omit_defaults=True, frozen=True):
"""Application subscription details"""

subscription_tokens: list[SubscriptionTokenInfo]
application_name: Optional[str] = None
application_version_id: Optional[str] = None


class DeveloperAppVersion(BaseMessage, frozen=True):
class DeveloperAppVersion(BaseMessage, omit_defaults=True, repr_omit_defaults=True, frozen=True):
"""Describes a version of an external application"""

owner: str # The user who owns the specific version of the application
Expand Down Expand Up @@ -91,7 +91,7 @@ class DeveloperApp(BaseMessage, frozen=True):
app_versions: list[DeveloperAppVersion] # The application versions (including application keys)


class AccountFundsResponse(BaseMessage, frozen=True):
class AccountFundsResponse(BaseMessage, omit_defaults=True, repr_omit_defaults=True, frozen=True):
"""Response for retrieving available to bet."""

available_to_bet_balance: Optional[float] = None
Expand All @@ -108,7 +108,7 @@ class AccountFundsResponse(BaseMessage, frozen=True):
wallet: Optional[Wallet] = None


class AccountDetailsResponse(BaseMessage, frozen=True):
class AccountDetailsResponse(BaseMessage, omit_defaults=True, repr_omit_defaults=True, frozen=True):
"""Response for Account details."""

# Default user currency Code. See Currency Parameters for minimum bet sizes relating to each currency.
Expand All @@ -129,7 +129,7 @@ class AccountDetailsResponse(BaseMessage, frozen=True):
country_code: Optional[str] = None # The customer's country of residence (ISO 2 Char format)


class StatementLegacyData(BaseMessage, frozen=True):
class StatementLegacyData(BaseMessage, omit_defaults=True, repr_omit_defaults=True, frozen=True):
"""Summary of a cleared order."""

avg_price: Optional[float] # The average matched price of the bet (null if no part has been matched)
Expand Down Expand Up @@ -171,7 +171,7 @@ class StatementLegacyData(BaseMessage, frozen=True):
avg_price_raw: Optional[float] = None


class StatementItem(BaseMessage, kw_only=True, frozen=True):
class StatementItem(BaseMessage, kw_only=True, omit_defaults=True, repr_omit_defaults=True, frozen=True):
"""Summary of a cleared order."""

# An external reference, eg. equivalent to betId in the case of an exchange bet statement item.
Expand Down Expand Up @@ -200,7 +200,7 @@ class AccountStatementReport(BaseMessage, frozen=True):
more_available: bool # Indicates whether there are further result items beyond this page.


class CurrencyRate(BaseMessage, frozen=True):
class CurrencyRate(BaseMessage, omit_defaults=True, repr_omit_defaults=True, frozen=True):
currency_code: Optional[str] = None # Three-letter ISO 4217 code
rate: Optional[float] = None # Exchange rate for the currency specified in the request

Expand All @@ -212,7 +212,7 @@ class AuthorisationResponse(BaseMessage, frozen=True):
redirect_url: str # URL to redirect the user to the vendor page


class SubscriptionOptions(BaseMessage, frozen=True, rename=None):
class SubscriptionOptions(BaseMessage, frozen=True, omit_defaults=True, repr_omit_defaults=True, rename=None):
# No rename: SubscriptionOption fields don't use camelCase in Betfair API

"""Wrapper object containing details of how a subscription should be created"""
Expand Down Expand Up @@ -244,7 +244,7 @@ class VendorAccessTokenInfo(BaseMessage, frozen=True, rename=None):
application_subscription: ApplicationSubscription


class VendorDetails(BaseMessage, frozen=True):
class VendorDetails(BaseMessage, omit_defaults=True, repr_omit_defaults=True, frozen=True):
"""Wrapper object containing vendor name and redirect url"""

app_version_id: int # Internal id of the application
Expand Down
10 changes: 5 additions & 5 deletions betfair_parser/spec/betting/listings.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
)


class _ListingParams(Params, frozen=True):
class _ListingParams(Params, omit_defaults=True, repr_omit_defaults=True, frozen=True):
filter: MarketFilter
locale: Optional[str] = None

Expand Down Expand Up @@ -106,7 +106,7 @@ class ListVenues(_ListingRequest, kw_only=True, frozen=True):
# More complex listings


class _ListMarketBookParams(Params, frozen=True):
class _ListMarketBookParams(Params, omit_defaults=True, repr_omit_defaults=True, frozen=True):
market_ids: list[str] # One or more market ids
price_projection: Optional[PriceProjection] = None # The desired projection of price data
order_projection: Optional[OrderProjection] = None # The orders you want to receive in the response
Expand Down Expand Up @@ -144,7 +144,7 @@ class ListMarketBook(_ListingRequest, kw_only=True, frozen=True):
return_type = Response[list[MarketBook]]


class _ListMarketCatalogueParams(Params, kw_only=True, frozen=True):
class _ListMarketCatalogueParams(Params, kw_only=True, omit_defaults=True, repr_omit_defaults=True, frozen=True):
filter: MarketFilter # The filter to select desired markets
market_projection: Optional[set[MarketProjection]] = None # The type and amount of data returned about the market
sort: Optional[MarketSort] = None # The order of the results, defaults to RANK
Expand All @@ -169,7 +169,7 @@ class ListMarketCatalogue(_ListingRequest, kw_only=True, frozen=True):
ListMarketCatalog = ListMarketCatalogue # allow both spellings


class _ListMarketProfitAndLossParams(Params, frozen=True):
class _ListMarketProfitAndLossParams(Params, omit_defaults=True, repr_omit_defaults=True, frozen=True):
market_ids: set[MarketId] # List of markets to calculate profit and loss
include_settled_bets: Optional[bool] = False # Option to include settled bets (partially settled markets only)
include_bsp_bets: Optional[bool] = False # Option to include BSP bets
Expand All @@ -183,7 +183,7 @@ class ListMarketProfitAndLoss(_ListingRequest, kw_only=True, frozen=True):
return_type = Response[list[MarketProfitAndLoss]]


class _ListRunnerBookParams(Params, frozen=True):
class _ListRunnerBookParams(Params, omit_defaults=True, repr_omit_defaults=True, frozen=True):
market_id: MarketId # The unique id for the market
selection_id: SelectionId # The unique id for the selection in the market
handicap: Optional[Handicap] = None # The handicap associated with the runner in case of Asian handicap market
Expand Down
12 changes: 6 additions & 6 deletions betfair_parser/spec/betting/orders.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class _OrderRequest(Request, frozen=True, tag=betting_tag):
endpoint_type = EndpointType.BETTING


class _PlaceOrdersParams(Params, frozen=True):
class _PlaceOrdersParams(Params, omit_defaults=True, repr_omit_defaults=True, frozen=True):
market_id: str
instructions: list[PlaceInstruction]
customer_ref: Optional[CustomerRef] = None
Expand All @@ -62,7 +62,7 @@ class PlaceOrders(_OrderRequest, kw_only=True, frozen=True):
return_type = Response[PlaceExecutionReport]


class _CancelOrdersParams(Params, frozen=True):
class _CancelOrdersParams(Params, omit_defaults=True, repr_omit_defaults=True, frozen=True):
market_id: Optional[str] = None
instructions: Optional[list[CancelInstruction]] = None
customer_ref: Optional[CustomerRef] = None
Expand All @@ -78,7 +78,7 @@ class CancelOrders(_OrderRequest, kw_only=True, frozen=True):
return_type = Response[CancelExecutionReport]


class _ReplaceOrdersParams(Params, frozen=True):
class _ReplaceOrdersParams(Params, omit_defaults=True, repr_omit_defaults=True, frozen=True):
market_id: str
instructions: list[ReplaceInstruction]
customer_ref: Optional[CustomerRef] = None
Expand All @@ -98,7 +98,7 @@ class ReplaceOrders(_OrderRequest, kw_only=True, frozen=True):
return_type = Response[ReplaceExecutionReport]


class _ListClearedOrdersParams(Params, frozen=True):
class _ListClearedOrdersParams(Params, omit_defaults=True, repr_omit_defaults=True, frozen=True):
bet_status: BetStatus # Restricts the results to the specified status.
event_type_ids: Optional[set[EventTypeId]] = None # Restricts the results to the specified Event Type IDs.
event_ids: Optional[set[EventId]] = None # Restricts the results to the specified Event IDs.
Expand Down Expand Up @@ -143,7 +143,7 @@ class ListClearedOrders(_OrderRequest, kw_only=True, frozen=True):
return_type = Response[ClearedOrderSummaryReport]


class _ListCurrentOrdersParams(Params, frozen=True):
class _ListCurrentOrdersParams(Params, omit_defaults=True, repr_omit_defaults=True, frozen=True):
"""
Parameters for retrieving a list of current orders.
"""
Expand Down Expand Up @@ -180,7 +180,7 @@ class ListCurrentOrders(_OrderRequest, kw_only=True, frozen=True):
return_type = Response[CurrentOrderSummaryReport]


class _UpdateOrdersParams(Params, frozen=True):
class _UpdateOrdersParams(Params, omit_defaults=True, repr_omit_defaults=True, frozen=True):
market_id: str # The market id these orders are to be placed on
instructions: list[UpdateInstruction] # The limit of update instructions per request is 60
customer_ref: Optional[CustomerRef] = None
Expand Down
Loading

0 comments on commit 66d91c0

Please sign in to comment.