Skip to content

Commit

Permalink
Purty
Browse files Browse the repository at this point in the history
  • Loading branch information
tiphdousset committed Mar 22, 2021
1 parent f61c2f3 commit 484a403
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
15 changes: 9 additions & 6 deletions src/AWS/Core/Types.purs
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,19 @@ derive newtype instance showEndpoint :: Show Endpoint

derive newtype instance encodeEndpoint :: EncodeJson Endpoint

newtype Tags = Tags (Map.Map String String)
newtype Tags
= Tags (Map.Map String String)

derive newtype instance showTags :: Show Tags

derive instance ntTags :: Newtype Tags _

instance tagsDecoder :: DecodeJson Tags where
decodeJson = decodeAsMap >>> map Tags
instance tagsDecoder :: DecodeJson Tags where
decodeJson = decodeAsMap >>> map Tags
where
decodeAsMap str = do
obj <- decodeJson str
pure $ Map.fromFoldable $ (F.toUnfoldable obj :: Array _)
decodeAsMap str = do
obj <- decodeJson str
pure $ Map.fromFoldable $ (F.toUnfoldable obj :: Array _)

type BasicClientPropsR r
= ( accessKeyId :: Maybe AccessKeyId
Expand Down
23 changes: 12 additions & 11 deletions src/AWS/S3/S3.purs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ type GetObjectResponse
, contentLength :: Int
, contentEncoding :: String
, contentType :: String
, tags :: Tags
, tags :: Tags
}

getObject :: S3 -> GetObjectParams -> Aff GetObjectResponse
Expand All @@ -110,16 +110,17 @@ getObject client { bucket: BucketName name, key: BucketKey key } =

convert :: InternalGetObjectResponse -> Either JsonDecodeError GetObjectResponse
convert internalResponse = parse internalResponse."Metadata" <#> addTags
where
addTags tags = { body: internalResponse."Body"
, contentLength: internalResponse."ContentLength"
, contentEncoding: internalResponse."ContentEncoding"
, contentType: internalResponse."ContentType"
, tags : tags
}
parse :: Json -> Either JsonDecodeError Tags
parse = decodeJson

where
addTags tags =
{ body: internalResponse."Body"
, contentLength: internalResponse."ContentLength"
, contentEncoding: internalResponse."ContentEncoding"
, contentType: internalResponse."ContentType"
, tags: tags
}

parse :: Json -> Either JsonDecodeError Tags
parse = decodeJson

type InternalGetSignedUrlParams
= { "Bucket" :: String
Expand Down

0 comments on commit 484a403

Please sign in to comment.