See app/Examples for more examples
import Splitwise
import Data.String (fromString)
import System.Environment
-- | Example showing creating a group
createGroupExample :: IO ()
createGroupExample = do
apiAuth <- SplitwiseAPIKeyAuth . fromString <$> getEnv "SPLITWISE_API_TOKEN"
result <- runSplitwise apiAuth $ do
createGroup $ CreateGroupParams
{ name = "Test Group"
, groupType = GroupTypeHome
, simplifyByDefault = False
}
print resultBy default, the functions in Splitwise/Client.hs return aeson-schemas typed values:
-- See Splitwise/Data/Schema.hs for schema definitions
-- Given a FriendSchema like the following:
type FriendSchema = [schema|
{
id: Int,
first_name: Text,
last_name: Maybe Text,
email: Text,
registration_status: UserRegistrationStatus,
picture: {
small: Text,
medium: Text,
large: Text,
},
custom_picture: Bool,
groups: List {
group_id: Int,
balance: List #Balance,
},
balance: List #Balance,
updated_at: UTCTime,
}
|]
-- And a response, getting all the group ids:
let groupIDs = [get| .groups[].group_id |] friend
Sometimes all you need is Aeson - so the variants ending in JSON (e.g. getCurrenciesJSON) return Aeson values.
Users
- GET /get_current_user
- GET /get_user/:id
- POST /update_user/:id
Groups
- GET /get_groups
- GET /get_group/:id
- POST /create_group
- POST /delete_group/:id
- POST /undelete_group/:id
- POST /add_user_to_group
- POST /remove_user_from_group
Friends
- GET /get_friends
- GET /get_friend/:id
- POST /create_friend
- POST /create_friends
- POST /delete_friend/:id
Expenses
- GET /get_expense/:id
- GET /get_expenses - PAGINATED
- POST /create_expense
- POST /update_expense/:id
- POST /delete_expense/:id
- POST /undelete_expense/:id
Comments
- GET /get_comments
- POST /create_comment
- POST /delete_comment/:id
Notifications
- GET /get_notifications
Other
- GET /get_currencies
- GET /get_categories