Files
gw-svelte/mail-api/mail_api/__pycache__/myob.cpython-314.pyc
T

87 lines
11 KiB
Plaintext
Raw Normal View History

2026-06-17 21:51:29 +12:00
+
¢1jYãó6a0t$Rt^RIHt^RIt^RIt^RIt^RIt^RIH t H
t
H t H t H
t
HtHtHtHtHt!RR]4t]P*!4tRsR]R&R sR
]R &^<tR R
ltRRltRRltRRltRRltRRlt RRRRRR/RRllt!RRlt"R#)MYOB AccountRight Live integration — create customer contacts.
Used when the owner ticks "Also create in MYOB" while adding a new client in the
control panel. The integration is optional: when the required environment
variables are not set, :func:`is_configured` returns ``False`` and the caller
skips MYOB entirely (the local client is still created).
Auth model (MYOB OAuth 2.0):
* A developer key/secret (``client_id`` / ``client_secret``) identifies this
app to MYOB.
* A long-lived refresh token mints short-lived bearer access tokens. We cache
the access token in memory and refresh it shortly before it expires.
* Each AccountRight company file lives at its own base URI and is gated by a
company-file token: ``base64("username:password")`` sent as the
``x-myobapi-cftoken`` header (password may be blank).
All HTTP calls are synchronous (``requests``); the async app invokes the public
helpers via ``asyncio.to_thread`` so the event loop is never blocked.
)Ú annotationsN)
Ú MYOB_API_KEYÚMYOB_API_SECRETÚMYOB_CF_PASSWORDÚMYOB_CF_USERNAMEÚMYOB_COMPANY_FILE_URIÚ MYOB_ENABLEDÚMYOB_HTTP_TIMEOUT_SECONDSÚMYOB_REFRESH_TOKENÚMYOB_TOKEN_URLÚloggercó]tRt^+tRtRtR#)Ú MyobErrorz0Raised when a MYOB API call cannot be completed.©N)Ú__name__Ú
__module__Ú __qualname__Ú__firstlineno__Ú__doc__Ú__static_attributes__róÚmail_api/myob.pyrr+sÝ:rrÚÚstrÚ
_cached_tokengÚfloatÚ_cached_token_expires_atcóV^8„dQhRR/#)éÚreturnÚboolr)Úformats"rÚ __annotate__r"8s÷ñrcó\#)z=True when every credential needed to talk to MYOB is present.)rrrrÚ
is_configuredr$8sä ÐrcóV^8„dQhRR/#©rrrr)r!s"rr"r"=s÷11rcóˆ\ R\ 2PR4p\P!V4P R4#)Ú:zutf-8Úascii)rrÚencodeÚbase64Ú b64encodeÚdecode)Úraws rÚ _cf_tokenr/=s<Ü
Ð ˜aÔ 0Ð
2×
9¸
B€CÜ × Ò ˜ × Ó 0rcóV^8„dQhRR/#r&r)r!s"rr"r"Bs÷-ñ-˜-rc ó \P!\R\R\RRR\
/RR/\ R7pTP^È8wd\R
TP R 24hTP4p\TPR
4;'gR4P4pT'g \R4h\TPRR44pTs\$P&!4\)^T\*,
4,s\.P0!RT4T# \Pdp\RT 24ThR p?ii;i \dp\R 4ThR p?ii;i \ \3dRpL¬i;i)z†Exchange the stored refresh token for a fresh access token.
Caches the result in module state. Raises :class:`MyobError` on failure.
Ú client_idÚ
client_secretÚ
grant_typeÚ
refresh_tokenú Content-Typez!application/x-www-form-urlencoded)ÚdataÚheadersÚtimeoutz(Could not reach the MYOB token service: Nz MYOB token refresh failed (HTTP z=). Check MYOB_API_KEY / MYOB_API_SECRET / MYOB_REFRESH_TOKEN.z3MYOB token service returned an unreadable response.Ú access_tokenrz2MYOB token service did not return an access token.Ú
expires_ini°z)MYOB: access token refreshed (valid ~%ds))ÚrequestsÚpostr rrr
r ÚRequestExceptionrÚ status_codeÚjsonÚ
ValueErrorrÚgetÚstripÚintÚ TypeErrorrÚtimeÚ monotonicÚmaxÚ_TOKEN_EXPIRY_SKEW_SECONDSrr Úinfo)ÚrespÚexcÚpayloadÚtokenr;s rÚ_refresh_access_tokenrOBs~ð
SÜ}Š}Ü àœ\ؤؘoØÔ!3ð ð $Ð%HÐ

ˆð ×ј3ÔÜØ.¨t×/?Ñ/?Ð.@ðAIð
Ió
ð
ð
XØ—))“+ˆô
 ˜NÓ1¨rÓ :€Eß ÜÐܘŸ \°4Ó
ð€MÜ#Ÿ~š~Ó/´#°a¸ÔF`Õ9`Ó2aÕÜ
‡K‚KÐ;¸ZÔ €Løô5 × SÜÐBÀ3À%ÐIÈsÐRûðSûô ôXÜÐNÐTWÐWûðXûô
”zÐ ØŠ
ðúsA8D"Á%EÂ;E-Ä"E Ä7EÅE Å E*Å E%Å%E*Å-FÆFcóV^8„dQhRR/#r&r)r!s"rr"r"rs÷''rcóä\;_uu_4\'d/\P!4\8d\uuRRR4#\ 4uuRRR4# +'giR#;i©N)Ú _token_lockrrFrGrrOrrrÚ
_access_tokenrTrs9ß Žß ‹=œTŸ^š^Ó-Ô0HÔ ÷
Šô
ús0AÁ
AÁ A/ cóV^8„dQhRR/#)rrúdict[str, str]r)r!s"rr"r"ys÷ñrc óLRR\4 2R\RRR\4RRRR/#) Ú
AuthorizationzBearer z
x-myobapi-keyzx-myobapi-versionÚv2zx-myobapi-cftokenr6zapplication/jsonÚAccept)rTrr/rrrÚ _api_headersr[ys8à˜7¤=£?Ð"3МؘTØœY›[ØÐÐ
 ðrcó V^8„dQhRRRR/#)rÚ full_namerrztuple[str, str]r)r!s"rr"r"s÷+˜+ +rcó®VP4pV'gR#\V4^8Xd V^,R3#V^,RPVR,43#)zBBest-effort split of a single owner name into first/last for MYOB.rÚNN)rr)ÚsplitÚlenÚjoin)r]Úpartss& rÚ _split_nameresKà O‰OÓ €Eß ØˆÜ
ˆ5ƒzQ„Øa•˜"ˆØ !Hc—hh˜u R *rÚphoneÚstreetÚsourcec ó0V^8„dQhRRRRRRRRRRRR/#) rÚemailrr]rfrgrhrrVr)r!s"rr"r"ŽsF÷77 ð7ð7 ð 7
ð 7
ð
7ñ7)rcó®\4'g \R4h\V4wrVRRRVRVRRRR^R VR
VR V/./pV'd R V 2VR
&\ R2p\P
!VV\
4\R7p T PR9d'\T 4p \RT P RT 24hT PPRR4p T 'd)T PR4PR^4R,MRp
\P !RT
;'gRT4RT
RT /# \Pdp
\RT
24T
hRp
?
ii;i)aCreate an individual customer contact in MYOB.
Returns ``{"uid": ..., "uri": ...}`` parsed from the ``Location`` header MYOB
returns on a successful create. Raises :class:`MyobError` on any failure so