atlassian-connect-core 0.6.0.0 → 0.7.0.0
raw patch · 2 files changed
+30/−8 lines, 2 filesdep ~basePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base
API changes (from Hackage documentation)
- Snap.AtlassianConnect: baseUrl :: Tenant -> ConnectURI
- Snap.AtlassianConnect: connectAES :: Connect -> AES
- Snap.AtlassianConnect: connectBaseUrl :: Connect -> URI
- Snap.AtlassianConnect: connectHostWhitelist :: Connect -> [HostName]
- Snap.AtlassianConnect: connectPageTokenTimeout :: Connect -> Timeout
- Snap.AtlassianConnect: connectPlugin :: Connect -> Plugin
- Snap.AtlassianConnect: issueId :: IssueDetails -> IssueId
- Snap.AtlassianConnect: issueKey :: IssueDetails -> IssueKey
- Snap.AtlassianConnect: issueSummary :: IssueDetails -> IssueSummary
- Snap.AtlassianConnect: key :: Tenant -> TenantKey
- Snap.AtlassianConnect: lrBaseUrl :: LifecycleResponse -> ConnectURI
- Snap.AtlassianConnect: lrClientKey :: LifecycleResponse -> ClientKey
- Snap.AtlassianConnect: lrDescription :: LifecycleResponse -> Maybe Text
- Snap.AtlassianConnect: lrEventType :: LifecycleResponse -> Maybe Text
- Snap.AtlassianConnect: lrKey :: LifecycleResponse -> Text
- Snap.AtlassianConnect: lrPluginsVersion :: LifecycleResponse -> Maybe Text
- Snap.AtlassianConnect: lrProductType :: LifecycleResponse -> Maybe Text
- Snap.AtlassianConnect: lrPublicKey :: LifecycleResponse -> Text
- Snap.AtlassianConnect: lrServerVersion :: LifecycleResponse -> Maybe Text
- Snap.AtlassianConnect: lrSharedSecret :: LifecycleResponse -> Maybe Text
- Snap.AtlassianConnect: pageTokenAllowInsecurePolling :: PageToken -> Bool
- Snap.AtlassianConnect: pageTokenHost :: PageToken -> TenantKey
- Snap.AtlassianConnect: pageTokenTimestamp :: PageToken -> UTCTime
- Snap.AtlassianConnect: pageTokenUser :: PageToken -> Maybe UserKey
- Snap.AtlassianConnect: productType :: Tenant -> Text
- Snap.AtlassianConnect: publicKey :: Tenant -> Text
- Snap.AtlassianConnect: sharedSecret :: Tenant -> Text
- Snap.AtlassianConnect: tenantId :: Tenant -> Integer
- Snap.AtlassianConnect: userEmail :: UserDetails -> UserEmail
- Snap.AtlassianConnect: userKey :: UserDetails -> UserKey
- Snap.AtlassianConnect.HostRequest: instance Constructor C1_0ProductErrorResponse
- Snap.AtlassianConnect.HostRequest: instance Datatype D1ProductErrorResponse
- Snap.AtlassianConnect.HostRequest: instance Generic ProductErrorResponse
- Snap.AtlassianConnect.HostRequest: instance Selector S1_0_0ProductErrorResponse
- Snap.AtlassianConnect.HostRequest: instance Selector S1_0_1ProductErrorResponse
- Snap.AtlassianConnect.HostRequest: instance Show ProductErrorResponse
- Snap.AtlassianConnect.HostRequest: perCode :: ProductErrorResponse -> HttpResponseCode
- Snap.AtlassianConnect.HostRequest: perMessage :: ProductErrorResponse -> Text
+ Snap.AtlassianConnect: [baseUrl] :: Tenant -> ConnectURI
+ Snap.AtlassianConnect: [connectAES] :: Connect -> AES
+ Snap.AtlassianConnect: [connectBaseUrl] :: Connect -> URI
+ Snap.AtlassianConnect: [connectHostWhitelist] :: Connect -> [HostName]
+ Snap.AtlassianConnect: [connectPageTokenTimeout] :: Connect -> Timeout
+ Snap.AtlassianConnect: [connectPlugin] :: Connect -> Plugin
+ Snap.AtlassianConnect: [issueId] :: IssueDetails -> IssueId
+ Snap.AtlassianConnect: [issueKey] :: IssueDetails -> IssueKey
+ Snap.AtlassianConnect: [issueSummary] :: IssueDetails -> IssueSummary
+ Snap.AtlassianConnect: [key] :: Tenant -> TenantKey
+ Snap.AtlassianConnect: [lrBaseUrl] :: LifecycleResponse -> ConnectURI
+ Snap.AtlassianConnect: [lrClientKey] :: LifecycleResponse -> ClientKey
+ Snap.AtlassianConnect: [lrDescription] :: LifecycleResponse -> Maybe Text
+ Snap.AtlassianConnect: [lrEventType] :: LifecycleResponse -> Maybe Text
+ Snap.AtlassianConnect: [lrKey] :: LifecycleResponse -> Text
+ Snap.AtlassianConnect: [lrPluginsVersion] :: LifecycleResponse -> Maybe Text
+ Snap.AtlassianConnect: [lrProductType] :: LifecycleResponse -> Maybe Text
+ Snap.AtlassianConnect: [lrPublicKey] :: LifecycleResponse -> Text
+ Snap.AtlassianConnect: [lrServerVersion] :: LifecycleResponse -> Maybe Text
+ Snap.AtlassianConnect: [lrSharedSecret] :: LifecycleResponse -> Maybe Text
+ Snap.AtlassianConnect: [pageTokenAllowInsecurePolling] :: PageToken -> Bool
+ Snap.AtlassianConnect: [pageTokenHost] :: PageToken -> TenantKey
+ Snap.AtlassianConnect: [pageTokenTimestamp] :: PageToken -> UTCTime
+ Snap.AtlassianConnect: [pageTokenUser] :: PageToken -> Maybe UserKey
+ Snap.AtlassianConnect: [productType] :: Tenant -> Text
+ Snap.AtlassianConnect: [publicKey] :: Tenant -> Text
+ Snap.AtlassianConnect: [sharedSecret] :: Tenant -> Text
+ Snap.AtlassianConnect: [tenantId] :: Tenant -> Integer
+ Snap.AtlassianConnect: [userEmail] :: UserDetails -> UserEmail
+ Snap.AtlassianConnect: [userKey] :: UserDetails -> UserKey
+ Snap.AtlassianConnect.HostRequest: [perCode] :: ProductErrorResponse -> HttpResponseCode
+ Snap.AtlassianConnect.HostRequest: [perMessage] :: ProductErrorResponse -> Text
+ Snap.AtlassianConnect.HostRequest: hostPostRequestExtended :: FromJSON a => Tenant -> ByteString -> [(ByteString, Maybe ByteString)] -> Endo Request -> Handler b Connect (Either ProductErrorResponse (Maybe a))
+ Snap.AtlassianConnect.HostRequest: hostPutRequestExtended :: FromJSON a => Tenant -> ByteString -> [(ByteString, Maybe ByteString)] -> Endo Request -> Handler b Connect (Either ProductErrorResponse (Maybe a))
+ Snap.AtlassianConnect.HostRequest: instance GHC.Generics.Constructor Snap.AtlassianConnect.HostRequest.C1_0ProductErrorResponse
+ Snap.AtlassianConnect.HostRequest: instance GHC.Generics.Datatype Snap.AtlassianConnect.HostRequest.D1ProductErrorResponse
+ Snap.AtlassianConnect.HostRequest: instance GHC.Generics.Generic Snap.AtlassianConnect.HostRequest.ProductErrorResponse
+ Snap.AtlassianConnect.HostRequest: instance GHC.Generics.Selector Snap.AtlassianConnect.HostRequest.S1_0_0ProductErrorResponse
+ Snap.AtlassianConnect.HostRequest: instance GHC.Generics.Selector Snap.AtlassianConnect.HostRequest.S1_0_1ProductErrorResponse
+ Snap.AtlassianConnect.HostRequest: instance GHC.Show.Show Snap.AtlassianConnect.HostRequest.ProductErrorResponse
- Snap.AtlassianConnect.HostRequest: hostRequest :: FromJSON a => StdMethod -> Tenant -> ByteString -> [(ByteString, Maybe ByteString)] -> Endo Request -> Handler b Connect (Either ProductErrorResponse a)
+ Snap.AtlassianConnect.HostRequest: hostRequest :: FromJSON a => StdMethod -> Tenant -> ByteString -> [(ByteString, Maybe ByteString)] -> Endo Request -> Handler b Connect (Either ProductErrorResponse (Maybe a))
Files
atlassian-connect-core.cabal view
@@ -10,7 +10,7 @@ -- PVP summary: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change-version: 0.6.0.0+version: 0.7.0.0 -- A short (one-line) description of the package. synopsis: Atlassian Connect snaplet for the Snap Framework and helper code.
src/Snap/AtlassianConnect/HostRequest.hs view
@@ -29,7 +29,9 @@ hostRequest , hostGetRequest , hostPostRequest+ , hostPostRequestExtended , hostPutRequest+ , hostPutRequestExtended , StdMethod(..) , ProductErrorResponse(..) -- * Request Modifiers@@ -86,21 +88,40 @@ -- This example assumes that you are using the OverloadedStrings LANGUAGE pragma and that you don't need to modify the request. -- You might want to might want to modify the request for multiple reasons. Too add proxy details for example. hostGetRequest :: FromJSON a => AC.Tenant -> B.ByteString -> [(B.ByteString, Maybe B.ByteString)] -> Endo Request -> SS.Handler b AC.Connect (Either ProductErrorResponse a)-hostGetRequest = hostRequest GET+hostGetRequest = hostRequestWithContent GET --- | This is a convinience method that calls 'hostRequest' as a POST method.+-- | This is a convinience method that calls 'hostRequest' as a POST method and requires that the+-- resource returns content. hostPostRequest :: FromJSON a => AC.Tenant -> B.ByteString -> [(B.ByteString, Maybe B.ByteString)] -> Endo Request -> SS.Handler b AC.Connect (Either ProductErrorResponse a)-hostPostRequest = hostRequest POST+hostPostRequest = hostRequestWithContent POST +-- | This is the same method as hostPostRequest except that if HTTP 204 No Content is returned then+-- you will get nothing instead of an error.+hostPostRequestExtended :: FromJSON a => AC.Tenant -> B.ByteString -> [(B.ByteString, Maybe B.ByteString)] -> Endo Request -> SS.Handler b AC.Connect (Either ProductErrorResponse (Maybe a))+hostPostRequestExtended = hostRequest POST+ -- | This is a convinience method that calls 'hostRequest' as a PUT method. hostPutRequest :: FromJSON a => AC.Tenant -> B.ByteString -> [(B.ByteString, Maybe B.ByteString)] -> Endo Request -> SS.Handler b AC.Connect (Either ProductErrorResponse a)-hostPutRequest = hostRequest PUT+hostPutRequest = hostRequestWithContent PUT +-- | This is the same method as hostPutRequest except that if HTTP 204 No Content is returned then+-- you will get nothing instead of an error.+hostPutRequestExtended :: FromJSON a => AC.Tenant -> B.ByteString -> [(B.ByteString, Maybe B.ByteString)] -> Endo Request -> SS.Handler b AC.Connect (Either ProductErrorResponse (Maybe a))+hostPutRequestExtended = hostRequest PUT++hostRequestWithContent :: FromJSON a => StdMethod -> AC.Tenant -> B.ByteString -> [(B.ByteString, Maybe B.ByteString)] -> Endo Request -> SS.Handler b AC.Connect (Either ProductErrorResponse a)+hostRequestWithContent httpMethod tenant productRelativeUrl queryParams modifications = errorNoContent <$> hostRequest httpMethod tenant productRelativeUrl queryParams modifications++errorNoContent :: Either ProductErrorResponse (Maybe a) -> Either ProductErrorResponse a+errorNoContent (Left x) = Left x+errorNoContent (Right Nothing) = Left (ProductErrorResponse 204 "We expected to get content back from this resource but instead we recieved no content.")+errorNoContent (Right (Just x)) = Right x+ -- | As an Atlassian Connect application you will want to make requests of the Host Applicaiton (JIRA / Confluence) -- so that you can get important information. This function lets you do so by doing most of the heavy lifting of -- having to create a JWT token and a Query String Hash. It also asserts that you intended to get a JSON response. -- You should use this method or the helper methods whenever you want to make requests of the host application.-hostRequest :: FromJSON a => StdMethod -> AC.Tenant -> B.ByteString -> [(B.ByteString, Maybe B.ByteString)] -> Endo Request -> SS.Handler b AC.Connect (Either ProductErrorResponse a)+hostRequest :: FromJSON a => StdMethod -> AC.Tenant -> B.ByteString -> [(B.ByteString, Maybe B.ByteString)] -> Endo Request -> SS.Handler b AC.Connect (Either ProductErrorResponse (Maybe a)) hostRequest standardHttpMethod tenant productRelativeUrl queryParams requestModifications = do currentTime <- MI.liftIO P.getPOSIXTime pluginKey' <- fmap (CD.pluginKey . AC.connectPlugin) get@@ -146,11 +167,12 @@ expiryPeriod :: Minute expiryPeriod = 1 -responder :: FromJSON a => Int -> BL.ByteString -> Either ProductErrorResponse a+responder :: FromJSON a => Int -> BL.ByteString -> Either ProductErrorResponse (Maybe a) responder responseCode body+ | responseCode == 204 = Right Nothing | 200 <= responseCode && responseCode < 300 = case eitherDecode body of- Right jsonResponse -> Right jsonResponse+ Right jsonResponse -> Right . Just $ jsonResponse Left err -> Left $ ProductErrorResponse responseCode (T.pack $ "Could not parse the json response: " ++ show err) | otherwise = Left $ ProductErrorResponse responseCode (T.decodeUtf8 . BL.toStrict $ body)