packages feed

line-bot-sdk 0.7.0 → 0.7.1

raw patch · 8 files changed

+50/−21 lines, 8 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ Line.Bot.Webhook.Events: MessageSourceGroup :: Id 'Group -> Id 'User -> MessageSource
+ Line.Bot.Webhook.Events: MessageSourceRoom :: Id 'Room -> Id 'User -> MessageSource
+ Line.Bot.Webhook.Events: MessageSourceUser :: Id 'User -> MessageSource
+ Line.Bot.Webhook.Events: [$sel:messageSource:EventMessage] :: Event -> MessageSource
+ Line.Bot.Webhook.Events: data MessageSource
+ Line.Bot.Webhook.Events: instance Data.Aeson.Types.FromJSON.FromJSON Line.Bot.Webhook.Events.MessageSource
+ Line.Bot.Webhook.Events: instance Data.Aeson.Types.ToJSON.ToJSON Line.Bot.Webhook.Events.MessageSource
+ Line.Bot.Webhook.Events: instance GHC.Show.Show Line.Bot.Webhook.Events.MessageSource
- Line.Bot.Webhook.Events: EventMessage :: ReplyToken -> Message -> Source -> EpochMilli -> Event
+ Line.Bot.Webhook.Events: EventMessage :: ReplyToken -> Message -> MessageSource -> EpochMilli -> Event

Files

LICENSE view
@@ -1,4 +1,4 @@-Copyright Alexandre Moreno (c) 2018+Copyright Alexandre Moreno (c) 2019-2021  All rights reserved. 
README.md view
@@ -1,4 +1,5 @@-# line-bot-sdk [![Build Status](https://travis-ci.org/moleike/line-bot-sdk.svg?branch=master)](https://travis-ci.org/moleike/line-bot-sdk)+# line-bot-sdk [![Build Actions](https://github.com/moleike/line-bot-sdk/workflows/build/badge.svg)](https://github.com/moleike/line-bot-sdk/actions)+  Servant library for building LINE chatbots.  
line-bot-sdk.cabal view
@@ -1,18 +1,18 @@ name:                line-bot-sdk-version:             0.7.0+version:             0.7.1 synopsis:            Haskell SDK for LINE Messaging API homepage:            https://github.com/moleike/line-bot-sdk#readme bug-reports:         https://github.com/moleike/line-bot-sdk/issues license:             BSD3+x-license:           BSD-3-Clause license-file:        LICENSE author:              Alexandre Moreno maintainer:          Alexandre Moreno <alexmorenocano@gmail.com>-stability:           experimental-copyright:           (c) 2018 Alexandre Moreno+copyright:           (c) Alexandre Moreno, 2019-2021 category:            Network, Web build-type:          Simple-extra-source-files:  README.md-cabal-version:       >=1.10+extra-doc-files:     README.md+cabal-version:       >=1.18 description:   A Servant library for building LINE chatbots. This package is composed   of the following modules:@@ -111,6 +111,8 @@     deepseq   ghc-options:         -threaded -rtsopts -with-rtsopts=-N   default-language:    Haskell2010+  build-tool-depends: hspec-discover:hspec-discover+  source-repository head   type:     git
src/Line/Bot/Client.hs view
@@ -12,8 +12,8 @@  -- | -- Module      : Line.Bot.Client--- Copyright   : (c) Alexandre Moreno, 2019--- License     : BSD3+-- Copyright   : (c) Alexandre Moreno, 2019-2021+-- License     : BSD-3-Clause -- Maintainer  : alexmorenocano@gmail.com -- Stability   : experimental 
src/Line/Bot/Internal/Endpoints.hs view
@@ -6,10 +6,11 @@ {-# LANGUAGE TypeFamilies          #-} {-# LANGUAGE TypeOperators         #-} {-# LANGUAGE UndecidableInstances  #-}+ -- | -- Module      : Line.Bot.Internal.Endpoints--- Copyright   : (c) Alexandre Moreno, 2019--- License     : BSD3+-- Copyright   : (c) Alexandre Moreno, 2019-2021+-- License     : BSD-3-Clause -- Maintainer  : alexmorenocano@gmail.com -- Stability   : experimental 
src/Line/Bot/Types.hs view
@@ -14,10 +14,11 @@ {-# LANGUAGE OverloadedStrings         #-} {-# LANGUAGE RecordWildCards           #-} {-# LANGUAGE StandaloneDeriving        #-}+ -- | -- Module      : Line.Bot.Types--- Copyright   : (c) Alexandre Moreno, 2019--- License     : BSD3+-- Copyright   : (c) Alexandre Moreno, 2019-2021+-- License     : BSD-3-Clause -- Maintainer  : alexmorenocano@gmail.com -- Stability   : experimental 
src/Line/Bot/Webhook.hs view
@@ -15,8 +15,8 @@  -- | -- Module      : Line.Bot.Webhook--- Copyright   : (c) Alexandre Moreno, 2019--- License     : BSD3+-- Copyright   : (c) Alexandre Moreno, 2019-2021+-- License     : BSD-3-Clause -- Maintainer  : alexmorenocano@gmail.com -- Stability   : experimental 
src/Line/Bot/Webhook/Events.hs view
@@ -12,8 +12,8 @@  -- | -- Module      : Line.Bot.Webhook.Events--- Copyright   : (c) Alexandre Moreno, 2019--- License     : BSD3+-- Copyright   : (c) Alexandre Moreno, 2019-2021+-- License     : BSD-3-Clause -- Maintainer  : alexmorenocano@gmail.com -- Stability   : experimental @@ -24,6 +24,7 @@   , ContentProvider(..)   , EpochMilli(..)   , Source(..)+  , MessageSource(..)   , Members(..)   , Postback(..)   , Beacon(..)@@ -60,10 +61,10 @@  -- | Events generated on the LINE Platform. data Event =-    EventMessage      { replyToken :: ReplyToken-                      , message    :: Message-                      , source     :: Source-                      , timestamp  :: EpochMilli+    EventMessage      { replyToken    :: ReplyToken+                      , message       :: Message+                      , messageSource :: MessageSource+                      , timestamp     :: EpochMilli                       }   | EventFollow       { replyToken :: ReplyToken                       , source     :: Source@@ -117,6 +118,7 @@       , contentsFieldName = undefined       }     , constructorTagModifier = drop 5 >>> \(x:xs) -> toLower x : xs+    , fieldLabelModifier = \s -> if s == "messageSource" then "source" else s     }  data Message =@@ -205,6 +207,28 @@   toJSON (Source (UserId a))  = object ["type" .= String "user", "userId" .= a]   toJSON (Source (GroupId a)) = object ["type" .= String "group", "groupId" .= a]   toJSON (Source (RoomId a))  = object ["type" .= String "room", "roomId" .= a]++data MessageSource+  = MessageSourceUser (Id 'User)+  | MessageSourceGroup (Id 'Group) (Id 'User)+  | MessageSourceRoom (Id 'Room) (Id 'User)++deriving instance Show MessageSource+deriving instance Typeable MessageSource++instance FromJSON MessageSource where+  parseJSON = withObject "MessageSource" $ \o -> do+    messageType <- o .: "type"+    case messageType of+      "user"  -> MessageSourceUser . UserId  <$> o .: "userId"+      "group" -> MessageSourceGroup <$> (GroupId <$> o .: "groupId") <*> (UserId <$> o .: "userId")+      "room"  -> MessageSourceRoom <$> (RoomId  <$> o .: "roomId") <*> (UserId <$> o .: "userId")+      _       -> fail ("unknown message source: " ++ messageType)++instance ToJSON MessageSource where+  toJSON (MessageSourceUser (UserId a))  = object ["type" .= String "user", "userId" .= a]+  toJSON (MessageSourceGroup (GroupId a) (UserId b)) = object ["type" .= String "group", "groupId" .= a, "userId" .= b]+  toJSON (MessageSourceRoom (RoomId a) (UserId b))  = object ["type" .= String "room", "roomId" .= a, "userId" .= b]  newtype Members = Members { members :: [Source] }   deriving (Show, Generic)