webex-teams-api: A Haskell bindings for Webex Teams API

[ library, mit, program, web ] [ Propose Tags ] [ Report a vulnerability ]
Versions [RSS] 0.2.0.0, 0.2.0.1
Change log ChangeLog.md
Dependencies aeson, attoparsec, base (>=4.7 && <5), bitset-word8, bytestring, conduit, data-default, http-conduit, network-uri, optparse-applicative, text, utf8-string, webex-teams-api [details]
License MIT
Copyright 2017-2020 Naoto Shimazaki
Author Naoto Shimazaki
Maintainer Naoto.Shimazaki@gmail.com
Category Web
Home page https://github.com/nshimaza/webex-teams-api#readme
Bug tracker https://github.com/nshimaza/webex-teams-api/issues
Source repo head: git clone https://github.com/nshimaza/webex-teams-api
Uploaded by nshimaza at 2020-07-29T15:12:25Z
Distributions LTSHaskell:0.2.0.1, NixOS:0.2.0.1, Stackage:0.2.0.1
Reverse Dependencies 2 direct, 0 indirect [details]
Executables webex-teams-api-exe
Downloads 1411 total (13 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2020-07-29 [all 1 reports]

Readme for webex-teams-api-0.2.0.1

[back to package description]

webex-teams-api

License: MIT Build Status Hackage Stackage Nightly Stackage LTS

A Haskell bindings for Cisco Webex Teams (formerly Cisco Spark) API

Webex-teams-api (formerly cisco-spark-api) package provides types and functions for accessing Cisco Webex Teams REST API. Details of the API is available from developer site of Cisco Webex

This package is designed to improve type safety over the API. Each entity is separately typed. JSON messages contained in REST responses are decoded into appropriate type of Haskell record. JSON messages sent in REST requests are encoded only from correct type of record.

Some Webex Teams REST API return list of objects. Those APIs require HTTP Link Header based pagination. Haskell functions for those APIs automatically request subsequent pages as needed. This repo provides optional packages for streaming response of list API. Webex-teams-conduit and webex-teams-pipes are thin wrappers of list API. They transform chunky response from list API into seamless stream of elements.

This package also provides some sample usage in command line application style. See source under app directory of the source package.

Sample Usage

Sending a message to a Room.

    let auth        = Authorization "your authorization token"
        roomId      = RoomId "Room ID your message to be sent"
        messageText = MessageText "your message"
        message     = CreateMessage (Just roomId) Nothing Nothing (Just messageText) Nothing Nothing
    createEntity auth def createMessage >>= print . getResponseBody

Following example is calling List Membership API which returns membership between Rooms and users (Person). You can extract each Membership from Conduit pipe. The streamListWithFilter, provided by webex-teams-conduit, automatically performs pagenation when it is asked more element and last response had link of subsequent page in HTTP Link Header.

    let auth   = Authorization "your authorization token"
        filter = MembershipFilter yourRoomId Nothing Nothing
    runConduit $ streamListWithFilter auth def filter .| takeC 200 .| mapM_C print

You can find more examples in app/Main.hs under webex-teams-pipes or webex-teams-conduit.

Support for Lens

This package provides many of records representing objects communicated via Webex Teams REST API. Those records are designed to allow create lenses by Control.Lens.TH.makeFields.

Following example creates overloaded accessors for 'Person', 'Room' and 'Team'.

makeFields ''Person
makeFields ''Room
makeFields ''Team

You can access 'personId', 'roomId' and 'teamId' via overloaded accessor function 'id' like this.

    let yourPersonId = yourPerson ^. id
        yourRoomId = yourRoom ^. id
        yourTeamId = yourTeam ^. id

This package does not provide pre-generated lenses for you because not everyone need it but you can make it by yourself so easily as described.

Limitation

  • WebHook API is not yet implemented.
  • Relative reference in Link Header is not recognized as next page