Complete rewrite against Splitwise's official OpenAPI 3.0.1 specification.
This release is not backwards compatible.
Breaking changes
- Authentication is now OAuth 2.0 or a personal API key. OAuth 1.0 and
theoauth1dependency are gone. Existing OAuth 1.0 tokens cannot be
converted; users must authorize again. The consumer key/secret from
https://secure.splitwise.com/apps is reused as the OAuth 2.0 client
ID/secret. - Typed models instead of raw strings. Every method returns a model
(CurrentUser,Group,Expense, …) orvoid; nothing returns a JSON
Stringor anintstatus code any more. - Failures are exceptions. Non-2xx responses throw
SplitwiseHttpException(withSplitwiseBadRequestException,
SplitwiseUnauthorizedException,SplitwiseForbiddenException,
SplitwiseNotFoundException,SplitwiseRateLimitException); a 200 that
reportssuccess: falseor non-emptyerrorsthrows
SplitwiseRequestFailedException. - POST parameters are sent as a JSON body instead of query-string
parameters.BodyEncoding.formUrlEncodedis available as an escape hatch;
createFriendsalways uses it. parseSentencewas removed:parse_sentenceis no longer part of the
Splitwise API.- Minimum Dart SDK is 3.9.
- The unconditional
printof every response body was removed. SplitwiseNotificationandSplitwiseCategoryare named to avoid clashing
with Flutter'sNotificationandCategory.
Migration from 2.x
| 2.x | 3.x |
|---|---|
SplitWiseService.initialize(key, secret) |
SplitwiseClient.apiKey(apiKey) or SplitwiseOAuth2(clientId:, clientSecret:, redirectUri:) |
validateClient() → auth URL |
SplitwiseOAuth2.authorizationUrl(state:) |
validateClient(verifier:) → TokensHelper |
SplitwiseOAuth2.exchangeCode(code) → OAuth2Token |
validateClient(tokens:) |
SplitwiseClient.accessToken(token.accessToken) |
TokensHelper.toJSON() / fromJSON() |
OAuth2Token.toJson() / OAuth2Token.fromJson() |
getCurrentUser() → String |
getCurrentUser() → CurrentUser |
updateUser(id, Map) |
updateUser(id, UpdateUserRequest(...)) |
createGroup(Map) |
createGroup(CreateGroupRequest(name:, ...)) |
unDeleteGroup(id) |
undeleteGroup(id) |
addUserToGroup(Map) |
addUserToGroup(groupId:, userId:) or addUserToGroupByEmail(groupId:, email:, firstName:, lastName:) |
removeUserFromGroup(Map) |
removeUserFromGroup(groupId:, userId:) |
createFriend(Map) |
createFriend(email:, firstName:, lastName:) |
createFriends(Map) |
createFriends([NewFriend(email:, ...)]) |
getExpenses(options: Map) |
getExpenses(groupId:, friendId:, datedAfter:, ..., limit:, offset:) |
createExpense(Map) |
createExpense(EqualGroupSplit(...)) or createExpense(SplitByShares(...)) |
updateExpense(id, Map) |
updateExpense(id, UpdateExpenseRequest(...)) |
unDeleteExpense(id) |
undeleteExpense(id) |
getComments(int) |
getComments(expenseId:) |
createComment(Map) |
createComment(expenseId:, content:) |
getNotifications(options: Map) |
getNotifications(updatedAfter:, limit:) |
parseSentence(Map) |
removed |
t.success / t.errors checks |
catch SplitwiseRequestFailedException |
Fixed
deleteGroup,unDeleteGroup,addUserToGroup,removeUserFromGroup,
deleteFriend,deleteExpenseandunDeleteExpensethrew
NoSuchMethodErrorat runtime (they inspected.successon aString).updateUserposted to a malformed URL.addUserToGroupandremoveUserFromGroupignored their arguments.createExpensediscarded the response.dart analyzefailed becauselintswas not a dev dependency.
Added
- Test suite: offline tests against the committed OpenAPI document
(spec/openapi.json), including a coverage test that fails if any
documented operation lacks a client method, plus an opt-in live suite
(SPLITWISE_API_KEY=... dart test --tags live). SplitwiseClient(httpClient:)for injecting anhttp.Client.
Notes on the specification
create_friend's schema listsemailas required but the property is
nameduser_email; this package sendsuser_email.create_group's description documentsusers__{i}__user_idwhile its
example showsusers__{i}__id; this package sendsuser_id.- The OAuth 2.0 endpoints are resolved against
https://www.splitwise.com/
(the host used by the Splitwise web app and other SDKs) and can be
overridden withSplitwiseOAuth2(oauthBaseUrl:).
- pub.dev: https://pub.dev/packages/splitwise_api/versions/3.0.0
- Install:
dart pub add splitwise_api(orsplitwise_api: ^3.0.0) - CI on this commit: analyze/format/test green,
panascore 160/160