Skip to content

Commit

Permalink
feat: add more account helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
iloveitaly committed Feb 28, 2024
1 parent a73540e commit a66bf39
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions netsuite/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import configparser
import os
import re
import typing as t

from pydantic import BaseModel
Expand Down Expand Up @@ -30,14 +31,25 @@ class UsernamePasswordAuth(BaseModel):
class Config(BaseModel):
account: str
auth: t.Union[TokenAuth, UsernamePasswordAuth]
# TODO: Support OAuth2
# auth: Union[OAuth2, TokenAuth]

log_level: t.Optional[str] = None

# TODO ODBC is not yet fully supported, but this is the first step
odbc_data_source: t.Literal["NetSuite.com", "NetSuite2.com"] = "NetSuite.com"

# TODO: Support OAuth2
# auth: Union[OAuth2, TokenAuth]
@property
def is_token_auth(self) -> bool:
return isinstance(self.auth, TokenAuth)

@property
def is_sandbox(self) -> bool:
return re.search(r"_SB[\d]+$", self.account) is not None

@property
def account_number(self) -> str:
return self.account.split("_")[0]

@property
def account_slugified(self) -> str:
Expand Down

0 comments on commit a66bf39

Please sign in to comment.