zaim_api 0.1.0
zaim_api: ^0.1.0 copied to clipboard
Dart client for the Zaim REST API v2.1.0. OAuth 1.0a authentication, money record CRUD, categories, genres, accounts and the public master data endpoints, with no code generation.
0.1.0 #
First release. A Dart client for the Zaim REST API v2.1.0.
Authentication #
ZaimAuthFlowfor the three-legged OAuth 1.0a dance (request token, authorization URL, access token), signing with HMAC-SHA1 through theoauth1package.ZaimCredentialsandZaimRequestToken, both serialisable so they survive a redirect or a restart. Neither prints its secrets intoString().ZaimOAuthEndpointsfor the three documented URLs.
Endpoints #
UserApi.verify—GET /v2/home/user/verify.MoneyApi.listandMoneyApi.listAll, the latter walking pages of 100 as a lazyStream.MoneyApi.createPayment/createIncome/createTransfer,updatePayment/updateIncome/updateTransfer, and a singledelete(MoneyMode, int).CategoryApi.list,GenreApi.list,AccountApi.list.DefaultApiviaZaimClient.defaults()for the unauthenticated/v2/account,/v2/category,/v2/genreand/v2/currencymasters.
Models #
ZaimUser,ZaimUserCounters,MoneyRecord,MoneyMode,MoneyOrder,MoneyWriteResult,ZaimPlace,ZaimCategory,ZaimGenre,ZaimAccount,ZaimCurrency,DefaultAccount,DefaultCategory,DefaultGenre— all immutable, hand-writtenfromJson/toJson, with==,hashCodeandtoString.- Defensive parsing throughout: numeric strings are coerced, unknown fields
are ignored, and Zaim's
0-means-unset foreign keys becomenull. - JST timestamps are parsed into UTC
DateTimes denoting the same instant.
Behaviour #
mapping=1is sent automatically wherever Zaim requires it and is never part of a public signature.- Local validation raises
ArgumentErrorbefore any request: text fields at most 100 characters,limitin1..100,pageat least 1, positive amounts, the ±5 year date window, the three-month income window, and transfers between two different accounts. ZaimApiExceptioncarriesstatusCode, the server'smessageand the raw body;ZaimAuthExceptionsubclasses it for 401.http.Clientis injectable everywhere for tests;close()disposes only a client the package created itself.