ballast 0.1.0.0 → 0.2.0.0
raw patch · 4 files changed
+266/−576 lines, 4 filesdep ~hspecdep ~http-clientdep ~http-client-tlsPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: hspec, http-client, http-client-tls
API changes (from Hackage documentation)
- Ballast.Types: GetOrderResponse :: ResponseMessage -> GetOrderResponseResource -> ResponseStatus -> ResponseResourceLocation -> Maybe ResponseWarnings -> Maybe ResponseErrors -> GetOrderResponse
- Ballast.Types: GetOrderTrackingsResponse :: ResponseMessage -> GetOrderTrackingsResponseResource -> ResponseResourceLocation -> ResponseStatus -> Maybe ResponseWarnings -> Maybe ResponseErrors -> GetOrderTrackingsResponse
- Ballast.Types: GetOrdersResponse :: ResponseMessage -> GetOrdersResponseResource -> ResponseStatus -> ResponseResourceLocation -> Maybe ResponseWarnings -> Maybe ResponseErrors -> GetOrdersResponse
- Ballast.Types: GetProductResponse :: ResponseStatus -> Maybe ResponseResourceLocation -> ResponseMessage -> Maybe GetProductResponseResource -> Maybe ResponseWarnings -> Maybe ResponseErrors -> GetProductResponse
- Ballast.Types: GetReceivingHoldsResponse :: ResponseStatus -> ResponseResourceLocation -> ItemResourceHoldsResource -> ResponseMessage -> Maybe ResponseWarnings -> Maybe ResponseErrors -> GetReceivingHoldsResponse
- Ballast.Types: GetReceivingInstructionsRecipientsResponse :: ResponseStatus -> ResponseResourceLocation -> ItemResourceInstructionsRecipientsResource -> ResponseMessage -> Maybe ResponseWarnings -> Maybe ResponseErrors -> GetReceivingInstructionsRecipientsResponse
- Ballast.Types: GetReceivingItemsResponse :: ResponseStatus -> ResponseResourceLocation -> ItemResourceItemsResource -> ResponseMessage -> Maybe ResponseWarnings -> Maybe ResponseErrors -> GetReceivingItemsResponse
- Ballast.Types: GetReceivingLabelsResponse :: ResponseStatus -> ResponseResourceLocation -> ItemResourceLabelsResource -> ResponseMessage -> Maybe ResponseWarnings -> Maybe ResponseErrors -> GetReceivingLabelsResponse
- Ballast.Types: GetReceivingShipmentsResponse :: ResponseStatus -> ResponseResourceLocation -> ItemResourceShipmentsResource -> ResponseMessage -> Maybe ResponseWarnings -> Maybe ResponseErrors -> GetReceivingShipmentsResponse
- Ballast.Types: GetReceivingTrackingsResponse :: ResponseStatus -> ResponseResourceLocation -> ItemResourceTrackingsResource -> ResponseMessage -> Maybe ResponseWarnings -> Maybe ResponseErrors -> GetReceivingTrackingsResponse
- Ballast.Types: RateResponse :: ResponseStatus -> ResponseMessage -> Maybe ResponseWarnings -> Maybe ResponseErrors -> Maybe ResponseResourceLocation -> Maybe RateResource -> RateResponse
- Ballast.Types: ReceivingResponse :: ResponseStatus -> ResponseMessage -> Maybe ResponseWarnings -> Maybe ResponseErrors -> Maybe ResponseResourceLocation -> ReceivingResource -> ReceivingResponse
- Ballast.Types: ReceivingsResponse :: ResponseResourceLocation -> ResponseStatus -> ResponseMessage -> Maybe ResponseWarnings -> Maybe ResponseErrors -> ReceivingsResource -> ReceivingsResponse
- Ballast.Types: StockResponse :: ResponseStatus -> ResponseMessage -> Maybe ResponseWarnings -> Maybe ResponseErrors -> Maybe ResponseResourceLocation -> StockResource -> StockResponse
- Ballast.Types: [gorErrors] :: GetOrdersResponse -> Maybe ResponseErrors
- Ballast.Types: [gorMessage] :: GetOrdersResponse -> ResponseMessage
- Ballast.Types: [gorResourceLocation] :: GetOrdersResponse -> ResponseResourceLocation
- Ballast.Types: [gorResource] :: GetOrdersResponse -> GetOrdersResponseResource
- Ballast.Types: [gorStatus] :: GetOrdersResponse -> ResponseStatus
- Ballast.Types: [gorWarnings] :: GetOrdersResponse -> Maybe ResponseWarnings
- Ballast.Types: [goreErrors] :: GetOrderResponse -> Maybe ResponseErrors
- Ballast.Types: [goreMessage] :: GetOrderResponse -> ResponseMessage
- Ballast.Types: [goreResourceLocation] :: GetOrderResponse -> ResponseResourceLocation
- Ballast.Types: [goreResource] :: GetOrderResponse -> GetOrderResponseResource
- Ballast.Types: [goreStatus] :: GetOrderResponse -> ResponseStatus
- Ballast.Types: [goreWarnings] :: GetOrderResponse -> Maybe ResponseWarnings
- Ballast.Types: [gotrErrors] :: GetOrderTrackingsResponse -> Maybe ResponseErrors
- Ballast.Types: [gotrMessage] :: GetOrderTrackingsResponse -> ResponseMessage
- Ballast.Types: [gotrResourceLocation] :: GetOrderTrackingsResponse -> ResponseResourceLocation
- Ballast.Types: [gotrResource] :: GetOrderTrackingsResponse -> GetOrderTrackingsResponseResource
- Ballast.Types: [gotrStatus] :: GetOrderTrackingsResponse -> ResponseStatus
- Ballast.Types: [gotrWarnings] :: GetOrderTrackingsResponse -> Maybe ResponseWarnings
- Ballast.Types: [gpreErrors] :: GetProductResponse -> Maybe ResponseErrors
- Ballast.Types: [gpreMessage] :: GetProductResponse -> ResponseMessage
- Ballast.Types: [gpreResourceLocation] :: GetProductResponse -> Maybe ResponseResourceLocation
- Ballast.Types: [gpreResource] :: GetProductResponse -> Maybe GetProductResponseResource
- Ballast.Types: [gpreStatus] :: GetProductResponse -> ResponseStatus
- Ballast.Types: [gpreWarnings] :: GetProductResponse -> Maybe ResponseWarnings
- Ballast.Types: [grhrErrors] :: GetReceivingHoldsResponse -> Maybe ResponseErrors
- Ballast.Types: [grhrMessage] :: GetReceivingHoldsResponse -> ResponseMessage
- Ballast.Types: [grhrResourceLocation] :: GetReceivingHoldsResponse -> ResponseResourceLocation
- Ballast.Types: [grhrResource] :: GetReceivingHoldsResponse -> ItemResourceHoldsResource
- Ballast.Types: [grhrStatus] :: GetReceivingHoldsResponse -> ResponseStatus
- Ballast.Types: [grhrWarnings] :: GetReceivingHoldsResponse -> Maybe ResponseWarnings
- Ballast.Types: [grirErrors] :: GetReceivingItemsResponse -> Maybe ResponseErrors
- Ballast.Types: [grirMessage] :: GetReceivingItemsResponse -> ResponseMessage
- Ballast.Types: [grirResourceLocation] :: GetReceivingItemsResponse -> ResponseResourceLocation
- Ballast.Types: [grirResource] :: GetReceivingItemsResponse -> ItemResourceItemsResource
- Ballast.Types: [grirStatus] :: GetReceivingItemsResponse -> ResponseStatus
- Ballast.Types: [grirWarnings] :: GetReceivingItemsResponse -> Maybe ResponseWarnings
- Ballast.Types: [grirrErrors] :: GetReceivingInstructionsRecipientsResponse -> Maybe ResponseErrors
- Ballast.Types: [grirrMessage] :: GetReceivingInstructionsRecipientsResponse -> ResponseMessage
- Ballast.Types: [grirrResourceLocation] :: GetReceivingInstructionsRecipientsResponse -> ResponseResourceLocation
- Ballast.Types: [grirrResource] :: GetReceivingInstructionsRecipientsResponse -> ItemResourceInstructionsRecipientsResource
- Ballast.Types: [grirrStatus] :: GetReceivingInstructionsRecipientsResponse -> ResponseStatus
- Ballast.Types: [grirrWarnings] :: GetReceivingInstructionsRecipientsResponse -> Maybe ResponseWarnings
- Ballast.Types: [grlrErrors] :: GetReceivingLabelsResponse -> Maybe ResponseErrors
- Ballast.Types: [grlrMessage] :: GetReceivingLabelsResponse -> ResponseMessage
- Ballast.Types: [grlrResourceLocation] :: GetReceivingLabelsResponse -> ResponseResourceLocation
- Ballast.Types: [grlrResource] :: GetReceivingLabelsResponse -> ItemResourceLabelsResource
- Ballast.Types: [grlrStatus] :: GetReceivingLabelsResponse -> ResponseStatus
- Ballast.Types: [grlrWarnings] :: GetReceivingLabelsResponse -> Maybe ResponseWarnings
- Ballast.Types: [grsrErrors] :: GetReceivingShipmentsResponse -> Maybe ResponseErrors
- Ballast.Types: [grsrMessage] :: GetReceivingShipmentsResponse -> ResponseMessage
- Ballast.Types: [grsrResourceLocation] :: GetReceivingShipmentsResponse -> ResponseResourceLocation
- Ballast.Types: [grsrResource] :: GetReceivingShipmentsResponse -> ItemResourceShipmentsResource
- Ballast.Types: [grsrStatus] :: GetReceivingShipmentsResponse -> ResponseStatus
- Ballast.Types: [grsrWarnings] :: GetReceivingShipmentsResponse -> Maybe ResponseWarnings
- Ballast.Types: [grtrErrors] :: GetReceivingTrackingsResponse -> Maybe ResponseErrors
- Ballast.Types: [grtrMessage] :: GetReceivingTrackingsResponse -> ResponseMessage
- Ballast.Types: [grtrResourceLocation] :: GetReceivingTrackingsResponse -> ResponseResourceLocation
- Ballast.Types: [grtrResource] :: GetReceivingTrackingsResponse -> ItemResourceTrackingsResource
- Ballast.Types: [grtrStatus] :: GetReceivingTrackingsResponse -> ResponseStatus
- Ballast.Types: [grtrWarnings] :: GetReceivingTrackingsResponse -> Maybe ResponseWarnings
- Ballast.Types: [rateResponseErrors] :: RateResponse -> Maybe ResponseErrors
- Ballast.Types: [rateResponseMessage] :: RateResponse -> ResponseMessage
- Ballast.Types: [rateResponseResourceLocation] :: RateResponse -> Maybe ResponseResourceLocation
- Ballast.Types: [rateResponseResource] :: RateResponse -> Maybe RateResource
- Ballast.Types: [rateResponseStatus] :: RateResponse -> ResponseStatus
- Ballast.Types: [rateResponseWarnings] :: RateResponse -> Maybe ResponseWarnings
- Ballast.Types: [receivingResponseErrors] :: ReceivingResponse -> Maybe ResponseErrors
- Ballast.Types: [receivingResponseMessage] :: ReceivingResponse -> ResponseMessage
- Ballast.Types: [receivingResponseResourceLocation] :: ReceivingResponse -> Maybe ResponseResourceLocation
- Ballast.Types: [receivingResponseResource] :: ReceivingResponse -> ReceivingResource
- Ballast.Types: [receivingResponseStatus] :: ReceivingResponse -> ResponseStatus
- Ballast.Types: [receivingResponseWarnings] :: ReceivingResponse -> Maybe ResponseWarnings
- Ballast.Types: [receivingsResponseErrors] :: ReceivingsResponse -> Maybe ResponseErrors
- Ballast.Types: [receivingsResponseMessage] :: ReceivingsResponse -> ResponseMessage
- Ballast.Types: [receivingsResponseResourceLocation] :: ReceivingsResponse -> ResponseResourceLocation
- Ballast.Types: [receivingsResponseResource] :: ReceivingsResponse -> ReceivingsResource
- Ballast.Types: [receivingsResponseStatus] :: ReceivingsResponse -> ResponseStatus
- Ballast.Types: [receivingsResponseWarnings] :: ReceivingsResponse -> Maybe ResponseWarnings
- Ballast.Types: [stockResponseErrors] :: StockResponse -> Maybe ResponseErrors
- Ballast.Types: [stockResponseMessage] :: StockResponse -> ResponseMessage
- Ballast.Types: [stockResponseResourceLocation] :: StockResponse -> Maybe ResponseResourceLocation
- Ballast.Types: [stockResponseResource] :: StockResponse -> StockResource
- Ballast.Types: [stockResponseStatus] :: StockResponse -> ResponseStatus
- Ballast.Types: [stockResponseWarnings] :: StockResponse -> Maybe ResponseWarnings
- Ballast.Types: data GetOrderResponse
- Ballast.Types: data GetOrderTrackingsResponse
- Ballast.Types: data GetOrdersResponse
- Ballast.Types: data GetProductResponse
- Ballast.Types: data GetReceivingHoldsResponse
- Ballast.Types: data GetReceivingInstructionsRecipientsResponse
- Ballast.Types: data GetReceivingItemsResponse
- Ballast.Types: data GetReceivingLabelsResponse
- Ballast.Types: data GetReceivingShipmentsResponse
- Ballast.Types: data GetReceivingTrackingsResponse
- Ballast.Types: data RateResponse
- Ballast.Types: data ReceivingResponse
- Ballast.Types: data ReceivingsResponse
- Ballast.Types: data StockResponse
- Ballast.Types: instance Data.Aeson.Types.FromJSON.FromJSON Ballast.Types.GetOrderResponse
- Ballast.Types: instance Data.Aeson.Types.FromJSON.FromJSON Ballast.Types.GetOrderTrackingsResponse
- Ballast.Types: instance Data.Aeson.Types.FromJSON.FromJSON Ballast.Types.GetOrdersResponse
- Ballast.Types: instance Data.Aeson.Types.FromJSON.FromJSON Ballast.Types.GetProductResponse
- Ballast.Types: instance Data.Aeson.Types.FromJSON.FromJSON Ballast.Types.GetReceivingHoldsResponse
- Ballast.Types: instance Data.Aeson.Types.FromJSON.FromJSON Ballast.Types.GetReceivingInstructionsRecipientsResponse
- Ballast.Types: instance Data.Aeson.Types.FromJSON.FromJSON Ballast.Types.GetReceivingItemsResponse
- Ballast.Types: instance Data.Aeson.Types.FromJSON.FromJSON Ballast.Types.GetReceivingLabelsResponse
- Ballast.Types: instance Data.Aeson.Types.FromJSON.FromJSON Ballast.Types.GetReceivingShipmentsResponse
- Ballast.Types: instance Data.Aeson.Types.FromJSON.FromJSON Ballast.Types.GetReceivingTrackingsResponse
- Ballast.Types: instance Data.Aeson.Types.FromJSON.FromJSON Ballast.Types.RateResponse
- Ballast.Types: instance Data.Aeson.Types.FromJSON.FromJSON Ballast.Types.ReceivingResponse
- Ballast.Types: instance Data.Aeson.Types.FromJSON.FromJSON Ballast.Types.ReceivingsResponse
- Ballast.Types: instance Data.Aeson.Types.FromJSON.FromJSON Ballast.Types.StockResponse
- Ballast.Types: instance GHC.Classes.Eq Ballast.Types.GetOrderResponse
- Ballast.Types: instance GHC.Classes.Eq Ballast.Types.GetOrderTrackingsResponse
- Ballast.Types: instance GHC.Classes.Eq Ballast.Types.GetOrdersResponse
- Ballast.Types: instance GHC.Classes.Eq Ballast.Types.GetProductResponse
- Ballast.Types: instance GHC.Classes.Eq Ballast.Types.GetReceivingHoldsResponse
- Ballast.Types: instance GHC.Classes.Eq Ballast.Types.GetReceivingInstructionsRecipientsResponse
- Ballast.Types: instance GHC.Classes.Eq Ballast.Types.GetReceivingItemsResponse
- Ballast.Types: instance GHC.Classes.Eq Ballast.Types.GetReceivingLabelsResponse
- Ballast.Types: instance GHC.Classes.Eq Ballast.Types.GetReceivingShipmentsResponse
- Ballast.Types: instance GHC.Classes.Eq Ballast.Types.GetReceivingTrackingsResponse
- Ballast.Types: instance GHC.Classes.Eq Ballast.Types.RateResponse
- Ballast.Types: instance GHC.Classes.Eq Ballast.Types.ReceivingResponse
- Ballast.Types: instance GHC.Classes.Eq Ballast.Types.ReceivingsResponse
- Ballast.Types: instance GHC.Classes.Eq Ballast.Types.StockResponse
- Ballast.Types: instance GHC.Show.Show Ballast.Types.GetOrderResponse
- Ballast.Types: instance GHC.Show.Show Ballast.Types.GetOrderTrackingsResponse
- Ballast.Types: instance GHC.Show.Show Ballast.Types.GetOrdersResponse
- Ballast.Types: instance GHC.Show.Show Ballast.Types.GetProductResponse
- Ballast.Types: instance GHC.Show.Show Ballast.Types.GetReceivingHoldsResponse
- Ballast.Types: instance GHC.Show.Show Ballast.Types.GetReceivingInstructionsRecipientsResponse
- Ballast.Types: instance GHC.Show.Show Ballast.Types.GetReceivingItemsResponse
- Ballast.Types: instance GHC.Show.Show Ballast.Types.GetReceivingLabelsResponse
- Ballast.Types: instance GHC.Show.Show Ballast.Types.GetReceivingShipmentsResponse
- Ballast.Types: instance GHC.Show.Show Ballast.Types.GetReceivingTrackingsResponse
- Ballast.Types: instance GHC.Show.Show Ballast.Types.RateResponse
- Ballast.Types: instance GHC.Show.Show Ballast.Types.ReceivingResponse
- Ballast.Types: instance GHC.Show.Show Ballast.Types.ReceivingsResponse
- Ballast.Types: instance GHC.Show.Show Ballast.Types.StockResponse
- Ballast.Types: type CreateOrderResponse = GetOrdersResponse
- Ballast.Types: type ModifyProductResponse = ModifyProductsResponse
+ Ballast.Client: shipwireTest :: (FromJSON (ShipwireReturn a)) => ShipwireConfig -> Manager -> ShipwireRequest a TupleBS8 ByteString -> IO (Either ShipwireError (ShipwireReturn a))
+ Ballast.Client: shipwireTest' :: (FromJSON (ShipwireReturn a)) => ShipwireConfig -> ShipwireRequest a TupleBS8 ByteString -> Manager -> IO (Response ByteString)
+ Ballast.Types: GenericResponse :: ResponseStatus -> ResponseMessage -> Maybe ResponseWarnings -> Maybe ResponseErrors -> Maybe ResponseResourceLocation -> Maybe a -> GenericResponse a
+ Ballast.Types: [genericResponseErrors] :: GenericResponse a -> Maybe ResponseErrors
+ Ballast.Types: [genericResponseMessage] :: GenericResponse a -> ResponseMessage
+ Ballast.Types: [genericResponseResourceLocation] :: GenericResponse a -> Maybe ResponseResourceLocation
+ Ballast.Types: [genericResponseResource] :: GenericResponse a -> Maybe a
+ Ballast.Types: [genericResponseStatus] :: GenericResponse a -> ResponseStatus
+ Ballast.Types: [genericResponseWarnings] :: GenericResponse a -> Maybe ResponseWarnings
+ Ballast.Types: data GenericResponse a
+ Ballast.Types: instance Data.Aeson.Types.FromJSON.FromJSON a => Data.Aeson.Types.FromJSON.FromJSON (Ballast.Types.GenericResponse a)
+ Ballast.Types: instance GHC.Classes.Eq a => GHC.Classes.Eq (Ballast.Types.GenericResponse a)
+ Ballast.Types: instance GHC.Show.Show a => GHC.Show.Show (Ballast.Types.GenericResponse a)
- Ballast.Types: CommercialInvoiceValue :: Double -> CommercialInvoiceValue
+ Ballast.Types: CommercialInvoiceValue :: Centi -> CommercialInvoiceValue
- Ballast.Types: [unCommercialInvoiceValue] :: CommercialInvoiceValue -> Double
+ Ballast.Types: [unCommercialInvoiceValue] :: CommercialInvoiceValue -> Centi
- Ballast.Types: type CreateReceivingResponse = ReceivingsResponse
+ Ballast.Types: type CreateReceivingResponse = GenericResponse ReceivingsResource
- Ballast.Types: type GetReceivingsResponse = ReceivingsResponse
+ Ballast.Types: type GetReceivingsResponse = GenericResponse ReceivingsResource
Files
- ballast.cabal +10/−9
- src/Ballast/Client.hs +34/−0
- src/Ballast/Types.hs +33/−312
- tests/tests.hs +189/−255
ballast.cabal view
@@ -1,12 +1,12 @@ name: ballast-version: 0.1.0.0+version: 0.2.0.0 synopsis: Shipwire API client description: Please see README.md-homepage: https://github.com/bitemyapp/ballast#readme+homepage: https://github.com/alexeyzab/ballast#readme license: BSD3 license-file: LICENSE author: Alexey Zabelin, Chris Allen-maintainer: cma@bitemyapp.com+maintainer: zabelin.alex@gmail.com copyright: 2016 Chris Allen category: Web build-type: Simple@@ -20,8 +20,8 @@ build-depends: base >= 4.7 && < 5 , aeson >= 0.11.1 && <1.3 , bytestring >= 0.10.0 && <0.11- , http-client >= 0.4.30 && <0.6- , http-client-tls+ , http-client >= 0.5 && <0.6+ , http-client-tls >= 0.3 && <0.3.6 , http-types >= 0.8 && <0.10 , text >= 0.11 && <1.3 , utf8-string@@ -43,14 +43,15 @@ build-depends: base, ballast, bytestring,- hspec >= 1.8 && <2.3,+ hspec >= 1.8 && <2.5, hspec-expectations, text, time,- either-unwrap- + either-unwrap,+ http-client >= 0.5 && <0.6,+ http-client-tls >= 0.3 && <0.3.6 default-language: Haskell2010 source-repository head type: git- location: https://github.com/bitemyapp/ballast+ location: https://github.com/alexeyzab/ballast
src/Ballast/Client.hs view
@@ -298,3 +298,37 @@ case result of Left s -> return (Left (ShipwireError s response)) (Right r) -> return (Right r)++-- | This function is only used internally to speed up the test suite.+-- Instead of creating a new Manager we reuse the same one.+shipwireTest ::+ (FromJSON (ShipwireReturn a))+ => ShipwireConfig+ -> Manager+ -> ShipwireRequest a TupleBS8 BSL.ByteString+ -> IO (Either ShipwireError (ShipwireReturn a))+shipwireTest config tlsManager request = do+ response <- shipwireTest' config request tlsManager+ let result = eitherDecode $ responseBody response+ case result of+ Left s -> return (Left (ShipwireError s response))+ (Right r) -> return (Right r)++shipwireTest' :: (FromJSON (ShipwireReturn a))+ => ShipwireConfig+ -> ShipwireRequest a TupleBS8 BSL.ByteString+ -> Manager+ -> IO (Response BSL.ByteString)+shipwireTest' ShipwireConfig {..} ShipwireRequest {..} manager = do+ initReq <- parseRequest $ T.unpack $ T.append (hostUri host) endpoint+ let reqBody | rMethod == NHTM.methodGet = mempty+ | otherwise = filterBody params+ reqURL = paramsToByteString $ filterQuery params+ req = initReq { method = rMethod+ , requestBody = RequestBodyLBS reqBody+ , queryString = reqURL+ }+ shipwireUser = unUsername email+ shipwirePass = unPassword pass+ authorizedRequest = applyBasicAuth shipwireUser shipwirePass req+ httpLbs authorizedRequest manager
src/Ballast/Types.hs view
@@ -28,7 +28,7 @@ , Currency(..) , GroupBy(..) , WarehouseArea(..)- , RateResponse(..)+ , GenericResponse(..) , ResponseStatus(..) , ResponseMessage(..) , ResponseWarnings(..)@@ -102,7 +102,6 @@ , ShipwireReturn , RateRequest , StockRequest- , StockResponse(..) , ParentId(..) , ProductIdParam(..) , ProductExternalIdParam(..)@@ -182,7 +181,6 @@ , CommerceNameParam(..) , CreateReceivingResponse , GetReceivingsResponse- , ReceivingsResponse(..) , ReceivingsResource(..) , ReceivingsItems(..) , ReceivingsItem(..)@@ -291,7 +289,6 @@ , Note(..) , ReceivingInstructionsRecipient(..) , GetReceivingRequest- , ReceivingResponse(..) , ReceivingId(..) , getReceivingId , ModifyReceivingRequest@@ -302,18 +299,12 @@ , CancelReceivingLabelsRequest , CancelReceivingLabelsResponse , GetReceivingHoldsRequest- , GetReceivingHoldsResponse(..) , IncludeClearedParam(..) , GetReceivingInstructionsRecipientsRequest- , GetReceivingInstructionsRecipientsResponse(..) , GetReceivingItemsRequest- , GetReceivingItemsResponse(..) , GetReceivingShipmentsRequest- , GetReceivingShipmentsResponse(..) , GetReceivingTrackingsRequest- , GetReceivingTrackingsResponse(..) , GetReceivingLabelsRequest- , GetReceivingLabelsResponse(..) , GetProductsRequest , GetProductsResponse(..) , GetProductsResponseResource(..)@@ -517,12 +508,9 @@ , ModifyProductsRequest , ModifyProductsResponse(..) , GetProductRequest- , GetProductResponse(..) , GetProductResponseResource(..) , ModifyProductRequest- , ModifyProductResponse , CreateOrderRequest- , CreateOrderResponse , CreateOrder(..) , OrderItem(..) , CommercialInvoiceValueCurrency(..)@@ -558,7 +546,6 @@ , SameDay(..) , ProcessAfterDate(..) , GetOrdersRequest- , GetOrdersResponse(..) , GetOrdersResponseResource(..) , GetOrdersResponseResourceItems(..) , GetOrdersResponseResourceItemResource(..)@@ -647,7 +634,6 @@ , CancelOrderResponse , IdWrapper(..) , GetOrderTrackingsRequest- , GetOrderTrackingsResponse(..) , GetOrderTrackingsResponseResource(..) , GetOrderTrackingsResponseResourceItems(..) , GetOrderTrackingsResponseResourceItem(..)@@ -659,7 +645,6 @@ , ValidateAddressWarnings(..) , WarningObject(..) , GetOrderRequest- , GetOrderResponse(..) , GetOrderResponseResource , ExtendedAttributesResponse(..) , ExtendedAttributesResponseResource(..)@@ -726,7 +711,7 @@ --------------------------------------------------------------- data RateRequest-type instance ShipwireReturn RateRequest = RateResponse+type instance ShipwireReturn RateRequest = GenericResponse RateResource newtype SKU = SKU { unSku :: Text@@ -935,19 +920,19 @@ { unWarehouseArea :: Text } deriving (Eq, Show, ToJSON, FromJSON) -data RateResponse = RateResponse- { rateResponseStatus :: ResponseStatus- , rateResponseMessage :: ResponseMessage- , rateResponseWarnings :: Maybe ResponseWarnings- , rateResponseErrors :: Maybe ResponseErrors- , rateResponseResourceLocation :: Maybe ResponseResourceLocation- , rateResponseResource :: Maybe RateResource+data GenericResponse a = GenericResponse+ { genericResponseStatus :: ResponseStatus+ , genericResponseMessage :: ResponseMessage+ , genericResponseWarnings :: Maybe ResponseWarnings+ , genericResponseErrors :: Maybe ResponseErrors+ , genericResponseResourceLocation :: Maybe ResponseResourceLocation+ , genericResponseResource :: Maybe a } deriving (Eq, Show) -instance FromJSON RateResponse where- parseJSON = withObject "RateResponse" parse+instance FromJSON a => FromJSON (GenericResponse a) where+ parseJSON = withObject "GenericResponse" parse where- parse o = RateResponse+ parse o = GenericResponse <$> o .: "status" <*> o .: "message" <*> o .:? "warnings"@@ -1449,7 +1434,7 @@ ----------------------------------------------------------------- data StockRequest-type instance ShipwireReturn StockRequest = StockResponse+type instance ShipwireReturn StockRequest = GenericResponse StockResource instance ShipwireHasParam StockRequest SKU instance ShipwireHasParam StockRequest ParentId@@ -1472,26 +1457,6 @@ instance ShipwireHasParam StockRequest Next instance ShipwireHasParam StockRequest Limit -data StockResponse = StockResponse- { stockResponseStatus :: ResponseStatus- , stockResponseMessage :: ResponseMessage- , stockResponseWarnings :: Maybe ResponseWarnings- , stockResponseErrors :: Maybe ResponseErrors- , stockResponseResourceLocation :: Maybe ResponseResourceLocation- , stockResponseResource :: StockResource- } deriving (Eq, Show)--instance FromJSON StockResponse where- parseJSON = withObject "StockResponse" parse- where- parse o = StockResponse- <$> o .: "status"- <*> o .: "message"- <*> o .:? "warnings"- <*> o .:? "errors"- <*> o .:? "resourceLocation"- <*> o .: "resource"- newtype ParentId = ParentId { parentId :: Text } deriving (Eq, Show)@@ -1957,9 +1922,9 @@ -- | GET /api/v3/receivings data GetReceivingsRequest-type instance ShipwireReturn GetReceivingsRequest = GetReceivingsResponse+type instance ShipwireReturn GetReceivingsRequest = GenericResponse ReceivingsResource -type CreateReceivingResponse = ReceivingsResponse+type CreateReceivingResponse = GenericResponse ReceivingsResource instance ShipwireHasParam GetReceivingsRequest ExpandReceivingsParam instance ShipwireHasParam GetReceivingsRequest CommerceNameParam@@ -1974,23 +1939,23 @@ -- | POST /api/v3/receivings data CreateReceivingRequest-type instance ShipwireReturn CreateReceivingRequest = CreateReceivingResponse+type instance ShipwireReturn CreateReceivingRequest = GenericResponse ReceivingsResource -type GetReceivingsResponse = ReceivingsResponse+type GetReceivingsResponse = GenericResponse ReceivingsResource instance ShipwireHasParam CreateReceivingRequest ExpandReceivingsParam -- | GET /api/v3/receivings/{id} data GetReceivingRequest-type instance ShipwireReturn GetReceivingRequest = ReceivingResponse+type instance ShipwireReturn GetReceivingRequest = GenericResponse ReceivingResource instance ShipwireHasParam GetReceivingRequest ExpandReceivingsParam -- | PUT /api/v3/receivings/{id} data ModifyReceivingRequest-type instance ShipwireReturn ModifyReceivingRequest = ReceivingsResponse+type instance ShipwireReturn ModifyReceivingRequest = GenericResponse ReceivingsResource instance ShipwireHasParam ModifyReceivingRequest ExpandReceivingsParam @@ -2007,34 +1972,34 @@ -- | GET /api/v3/receivings/{id}/holds data GetReceivingHoldsRequest-type instance ShipwireReturn GetReceivingHoldsRequest = GetReceivingHoldsResponse+type instance ShipwireReturn GetReceivingHoldsRequest = GenericResponse ItemResourceHoldsResource instance ShipwireHasParam GetReceivingHoldsRequest IncludeClearedParam -- | GET /api/v3/receivings/{id}/instructionsRecipients data GetReceivingInstructionsRecipientsRequest-type instance ShipwireReturn GetReceivingInstructionsRecipientsRequest = GetReceivingInstructionsRecipientsResponse+type instance ShipwireReturn GetReceivingInstructionsRecipientsRequest = GenericResponse ItemResourceInstructionsRecipientsResource -- | GET /api/v3/receivings/{id}/items data GetReceivingItemsRequest-type instance ShipwireReturn GetReceivingItemsRequest = GetReceivingItemsResponse+type instance ShipwireReturn GetReceivingItemsRequest = GenericResponse ItemResourceItemsResource -- | GET /api/v3/receivings/{id}/shipments data GetReceivingShipmentsRequest-type instance ShipwireReturn GetReceivingShipmentsRequest = GetReceivingShipmentsResponse+type instance ShipwireReturn GetReceivingShipmentsRequest = GenericResponse ItemResourceShipmentsResource -- | GET /api/v3/receivings/{id}/trackings data GetReceivingTrackingsRequest-type instance ShipwireReturn GetReceivingTrackingsRequest = GetReceivingTrackingsResponse+type instance ShipwireReturn GetReceivingTrackingsRequest = GenericResponse ItemResourceTrackingsResource -- | GET /api/v3/receivings/{id}/labels data GetReceivingLabelsRequest-type instance ShipwireReturn GetReceivingLabelsRequest = GetReceivingLabelsResponse+type instance ShipwireReturn GetReceivingLabelsRequest = GenericResponse ItemResourceLabelsResource -- | ISO 8601 format, ex: "2014-05-30T13:08:29-07:00" newtype UpdatedAfter = UpdatedAfter@@ -2139,26 +2104,6 @@ toShipwireParam (CommerceNameParam ns) = (Query ("commerceName", TE.encodeUtf8 (T.intercalate "," ns)) :) -data ReceivingsResponse = ReceivingsResponse- { receivingsResponseResourceLocation :: ResponseResourceLocation- , receivingsResponseStatus :: ResponseStatus- , receivingsResponseMessage :: ResponseMessage- , receivingsResponseWarnings :: Maybe ResponseWarnings- , receivingsResponseErrors :: Maybe ResponseErrors- , receivingsResponseResource :: ReceivingsResource- } deriving (Eq, Show)--instance FromJSON ReceivingsResponse where- parseJSON = withObject "ReceivingsResponse" parse- where- parse o = ReceivingsResponse- <$> o .: "resourceLocation"- <*> o .: "status"- <*> o .: "message"- <*> o .:? "warnings"- <*> o .:? "errors"- <*> o .: "resource"- data ReceivingsResource = ReceivingsResource { receivingsResponseNext :: Maybe ResponseNext , receivingsResponseOffset :: ResponseOffset@@ -3132,28 +3077,8 @@ ,"name" .= rirName ,"note" .= rirNote] -data ReceivingResponse = ReceivingResponse- { receivingResponseStatus :: ResponseStatus- , receivingResponseMessage :: ResponseMessage- , receivingResponseWarnings :: Maybe ResponseWarnings- , receivingResponseErrors :: Maybe ResponseErrors- , receivingResponseResourceLocation :: Maybe ResponseResourceLocation- , receivingResponseResource :: ReceivingResource- } deriving (Eq, Show)- type ReceivingResource = ReceivingsItemResource -instance FromJSON ReceivingResponse where- parseJSON = withObject "GetReceivingResponse" parse- where- parse o = ReceivingResponse- <$> o .: "status"- <*> o .: "message"- <*> o .:? "warnings"- <*> o .:? "errors"- <*> o .:? "resourceLocation"- <*> o .: "resource"- newtype ReceivingId = ReceivingId { unReceivingId :: Text } deriving (Eq, Show, FromJSON)@@ -3185,26 +3110,6 @@ type CancelReceivingLabelsResponse = CancelReceivingResponse -data GetReceivingHoldsResponse = GetReceivingHoldsResponse- { grhrStatus :: ResponseStatus- , grhrResourceLocation :: ResponseResourceLocation- , grhrResource :: ItemResourceHoldsResource- , grhrMessage :: ResponseMessage- , grhrWarnings :: Maybe ResponseWarnings- , grhrErrors :: Maybe ResponseErrors- } deriving (Eq, Show)--instance FromJSON GetReceivingHoldsResponse where- parseJSON = withObject "GetReceivingHoldsResponse" parse- where- parse o = GetReceivingHoldsResponse- <$> o .: "status"- <*> o .: "resourceLocation"- <*> o .: "resource"- <*> o .: "message"- <*> o .:? "warnings"- <*> o .:? "errors"- data IncludeClearedParam = IncludeCleared | DontIncludeCleared@@ -3216,106 +3121,6 @@ toShipwireParam DontIncludeCleared = (Query ("includeCleared", TE.encodeUtf8 $ (T.pack . show) (0 :: Int)) :) -data GetReceivingInstructionsRecipientsResponse = GetReceivingInstructionsRecipientsResponse- { grirrStatus :: ResponseStatus- , grirrResourceLocation :: ResponseResourceLocation- , grirrResource :: ItemResourceInstructionsRecipientsResource- , grirrMessage :: ResponseMessage- , grirrWarnings :: Maybe ResponseWarnings- , grirrErrors :: Maybe ResponseErrors- } deriving (Eq, Show)--instance FromJSON GetReceivingInstructionsRecipientsResponse where- parseJSON = withObject "GetReceivingInstructionsRecipientsResponse" parse- where- parse o = GetReceivingInstructionsRecipientsResponse- <$> o .: "status"- <*> o .: "resourceLocation"- <*> o .: "resource"- <*> o .: "message"- <*> o .:? "warnings"- <*> o .:? "errors"--data GetReceivingItemsResponse = GetReceivingItemsResponse- { grirStatus :: ResponseStatus- , grirResourceLocation :: ResponseResourceLocation- , grirResource :: ItemResourceItemsResource- , grirMessage :: ResponseMessage- , grirWarnings :: Maybe ResponseWarnings- , grirErrors :: Maybe ResponseErrors- } deriving (Eq, Show)--instance FromJSON GetReceivingItemsResponse where- parseJSON = withObject "GetReceivingItemsResponse" parse- where- parse o = GetReceivingItemsResponse- <$> o .: "status"- <*> o .: "resourceLocation"- <*> o .: "resource"- <*> o .: "message"- <*> o .:? "warnings"- <*> o .:? "errors"--data GetReceivingShipmentsResponse = GetReceivingShipmentsResponse- { grsrStatus :: ResponseStatus- , grsrResourceLocation :: ResponseResourceLocation- , grsrResource :: ItemResourceShipmentsResource- , grsrMessage :: ResponseMessage- , grsrWarnings :: Maybe ResponseWarnings- , grsrErrors :: Maybe ResponseErrors- } deriving (Eq, Show)--instance FromJSON GetReceivingShipmentsResponse where- parseJSON = withObject "GetReceivingShipmentsResponse" parse- where- parse o = GetReceivingShipmentsResponse- <$> o .: "status"- <*> o .: "resourceLocation"- <*> o .: "resource"- <*> o .: "message"- <*> o .:? "warnings"- <*> o .:? "errors"--data GetReceivingTrackingsResponse = GetReceivingTrackingsResponse- { grtrStatus :: ResponseStatus- , grtrResourceLocation :: ResponseResourceLocation- , grtrResource :: ItemResourceTrackingsResource- , grtrMessage :: ResponseMessage- , grtrWarnings :: Maybe ResponseWarnings- , grtrErrors :: Maybe ResponseErrors- } deriving (Eq, Show)--instance FromJSON GetReceivingTrackingsResponse where- parseJSON = withObject "GetReceivingTrackingsResponse" parse- where- parse o = GetReceivingTrackingsResponse- <$> o .: "status"- <*> o .: "resourceLocation"- <*> o .: "resource"- <*> o .: "message"- <*> o .:? "warnings"- <*> o .:? "errors"--data GetReceivingLabelsResponse = GetReceivingLabelsResponse- { grlrStatus :: ResponseStatus- , grlrResourceLocation :: ResponseResourceLocation- , grlrResource :: ItemResourceLabelsResource- , grlrMessage :: ResponseMessage- , grlrWarnings :: Maybe ResponseWarnings- , grlrErrors :: Maybe ResponseErrors- } deriving (Eq, Show)--instance FromJSON GetReceivingLabelsResponse where- parseJSON = withObject "GetReceivingLabelsResponse" parse- where- parse o = GetReceivingLabelsResponse- <$> o .: "status"- <*> o .: "resourceLocation"- <*> o .: "resource"- <*> o .: "message"- <*> o .:? "warnings"- <*> o .:? "errors"- ----------------------------------------------------------------------- -- Product Endpoint -- https://www.shipwire.com/w/developers/product -- -----------------------------------------------------------------------@@ -3343,42 +3148,20 @@ -- | PUT /api/v3/products data ModifyProductsRequest-type instance ShipwireReturn ModifyProductsRequest = ModifyProductsResponse+type instance ShipwireReturn ModifyProductsRequest = GenericResponse GetProductsResponseResource -- | PUT /api/v3/products/{id} data ModifyProductRequest-type instance ShipwireReturn ModifyProductRequest = ModifyProductResponse--type ModifyProductResponse = ModifyProductsResponse+type instance ShipwireReturn ModifyProductRequest = GenericResponse GetProductsResponseResource -- | GET /api/v3/products/{id} data GetProductRequest-type instance ShipwireReturn GetProductRequest = GetProductResponse+type instance ShipwireReturn GetProductRequest = GenericResponse GetProductResponseResource -- | POST /api/v3/products/retire data RetireProductsRequest type instance ShipwireReturn RetireProductsRequest = RetireProductsResponse -data GetProductResponse = GetProductResponse- { gpreStatus :: ResponseStatus- , gpreResourceLocation :: Maybe ResponseResourceLocation- , gpreMessage :: ResponseMessage- , gpreResource :: Maybe GetProductResponseResource- , gpreWarnings :: Maybe ResponseWarnings- , gpreErrors :: Maybe ResponseErrors- } deriving (Eq, Show)--instance FromJSON GetProductResponse where- parseJSON = withObject "GetProductResponse" parse- where- parse o = GetProductResponse- <$> o .: "status"- <*> o .:? "resourceLocation"- <*> o .: "message"- <*> o .:? "resource"- <*> o .:? "warnings"- <*> o .:? "errors"- newtype GetProductResponseResource = GetProductResponseResource { gprrProductWrapper :: ProductsWrapper } deriving (Eq, Show, FromJSON)@@ -5501,7 +5284,7 @@ -- | GET /api/v3/orders data GetOrdersRequest-type instance ShipwireReturn GetOrdersRequest = GetOrdersResponse+type instance ShipwireReturn GetOrdersRequest = GenericResponse GetOrdersResponseResource instance ShipwireHasParam GetOrdersRequest ExpandOrdersParam instance ShipwireHasParam GetOrdersRequest CommerceNameParam@@ -5517,18 +5300,16 @@ -- | GET /api/v3/orders/{id} or /api/v3/orders/E{externalId} data GetOrderRequest-type instance ShipwireReturn GetOrderRequest = GetOrderResponse+type instance ShipwireReturn GetOrderRequest = GenericResponse GetOrderResponseResource instance ShipwireHasParam GetOrderRequest ExpandOrdersParam -- | POST /api/v3/orders data CreateOrderRequest-type instance ShipwireReturn CreateOrderRequest = CreateOrderResponse+type instance ShipwireReturn CreateOrderRequest = GenericResponse GetOrdersResponseResource instance ShipwireHasParam CreateOrderRequest ExpandOrdersParam -type CreateOrderResponse = GetOrdersResponse- -- | POST /api/v3/orders/{id}/cancel or /api/v3/orders/E{externalId}/cancel data CancelOrderRequest type instance ShipwireReturn CancelOrderRequest = CancelOrderResponse@@ -5537,50 +5318,10 @@ -- | GET /api/v3/orders/{id}/trackings or /api/v3/orders/E{externalId}/trackings data GetOrderTrackingsRequest-type instance ShipwireReturn GetOrderTrackingsRequest = GetOrderTrackingsResponse--data GetOrderResponse = GetOrderResponse- { goreMessage :: ResponseMessage- , goreResource :: GetOrderResponseResource- , goreStatus :: ResponseStatus- , goreResourceLocation :: ResponseResourceLocation- , goreWarnings :: Maybe ResponseWarnings- , goreErrors :: Maybe ResponseErrors- } deriving (Eq, Show)--instance FromJSON GetOrderResponse where- parseJSON = withObject "GetOrderResponse" parse- where- parse o = GetOrderResponse- <$> o .: "message"- <*> o .: "resource"- <*> o .: "status"- <*> o .: "resourceLocation"- <*> o .:? "warnings"- <*> o .:? "errors"+type instance ShipwireReturn GetOrderTrackingsRequest = GenericResponse GetOrderTrackingsResponseResource type GetOrderResponseResource = GetOrdersResponseResourceItemResource -data GetOrderTrackingsResponse = GetOrderTrackingsResponse- { gotrMessage :: ResponseMessage- , gotrResource :: GetOrderTrackingsResponseResource- , gotrResourceLocation :: ResponseResourceLocation- , gotrStatus :: ResponseStatus- , gotrWarnings :: Maybe ResponseWarnings- , gotrErrors :: Maybe ResponseErrors- } deriving (Eq, Show)--instance FromJSON GetOrderTrackingsResponse where- parseJSON = withObject "GetOrderTrackingsResponse" parse- where- parse o = GetOrderTrackingsResponse- <$> o .: "message"- <*> o .: "resource"- <*> o .: "resourceLocation"- <*> o .: "status"- <*> o .:? "warnings"- <*> o .:? "errors"- data GetOrderTrackingsResponseResource = GetOrderTrackingsResponseResource { gotrrItems :: GetOrderTrackingsResponseResourceItems , gotrrNext :: Maybe ResponseNext@@ -5719,26 +5460,6 @@ toShipwireParam (ExpandOrdersParam xs) = (Query ("expand", (BS8.intercalate "," (map expandOrdersToBS8 xs))) :) -data GetOrdersResponse = GetOrdersResponse- { gorMessage :: ResponseMessage- , gorResource :: GetOrdersResponseResource- , gorStatus :: ResponseStatus- , gorResourceLocation :: ResponseResourceLocation- , gorWarnings :: Maybe ResponseWarnings- , gorErrors :: Maybe ResponseErrors- } deriving (Eq, Show)--instance FromJSON GetOrdersResponse where- parseJSON = withObject "GetOrdersResponse" parse- where- parse o = GetOrdersResponse- <$> o .: "message"- <*> o .: "resource"- <*> o .: "status"- <*> o .: "resourceLocation"- <*> o .:? "warnings"- <*> o .:? "errors"- data GetOrdersResponseResource = GetOrdersResponseResource { gorrItems :: GetOrdersResponseResourceItems , gorrNext :: Maybe ResponseNext@@ -6741,7 +6462,7 @@ } deriving (Eq, Show, ToJSON) newtype CommercialInvoiceValue = CommercialInvoiceValue- { unCommercialInvoiceValue :: Double+ { unCommercialInvoiceValue :: Centi } deriving (Eq, Show, ToJSON, FromJSON) newtype OrderItems = OrderItems
tests/tests.hs view
@@ -10,6 +10,8 @@ import qualified Data.Text as T import Data.Time (Day(..), secondsToDiffTime) import Data.Time.Clock (UTCTime(..), getCurrentTime, utctDayTime)+import Network.HTTP.Client (Manager, newManager)+import Network.HTTP.Client.TLS (tlsManagerSettings) import Test.Hspec import Test.Hspec.Expectations.Contrib (isRight) @@ -354,43 +356,6 @@ (Nothing) ] -exampleCreateMarketingInsert :: [CreateProductsWrapper]-exampleCreateMarketingInsert = [CpwMarketingInsert $ MarketingInsert- Nothing- (SKU "HspecTestInsert3")- Nothing- (MarketingInsertClassification)- (Description "Hspec test marketing insert3")- (InclusionRuleType "CUSTOM")- (Just $ MarketingInsertAlternateNames [MarketingInsertAlternateName (Name "HspecMI33")])- (MarketingInsertDimensions- (MarketingInsertLength 0.1)- (MarketingInsertWidth 0.1)- (MarketingInsertHeight 0.1)- (MarketingInsertWeight 0.2)- )- (Nothing)- (Just $ MarketingInsertInclusionRules- (Just $ InsertAfterDate $ UTCTime (ModifiedJulianDay 150000) (secondsToDiffTime 10))- (Just $ InsertBeforeDate $ UTCTime (ModifiedJulianDay 150000) (secondsToDiffTime 10))- (Just $ InsertWhenWorthValue 5)- (Just $ InsertWhenQuantity 5)- (Just $ InsertWhenWorthCurrency "USD")- )- (MarketingInsertMasterCase- (IndividualItemsPerCase 10)- (SKU "HspecTestMIMCSKU")- Nothing- (Description "Hspec test marketing insert master case2")- (MarketingInsertMasterCaseDimensions- (MarketingInsertMasterCaseDimensionsLength 8)- (MarketingInsertMasterCaseDimensionsWidth 8)- (MarketingInsertMasterCaseDimensionsHeight 8)- (MarketingInsertMasterCaseDimensionsWeight 8)- )- )- ]- exampleOrder :: T.Text -> SKU -> CreateOrder exampleOrder randomPart productSku = CreateOrder@@ -455,20 +420,20 @@ (Commercial) (Nothing) -createReceivingHelper :: ShipwireConfig -> CreateReceiving -> IO (Either ShipwireError (ShipwireReturn CreateReceivingRequest), ReceivingId)-createReceivingHelper conf cr = do- receiving <- shipwire conf $ createReceiving cr- let Right ReceivingsResponse {..} = receiving- ReceivingsResource {..} = receivingsResponseResource+createReceivingHelper :: ShipwireConfig -> Manager -> CreateReceiving -> IO (Either ShipwireError (ShipwireReturn CreateReceivingRequest), ReceivingId)+createReceivingHelper conf manager cr = do+ receiving <- shipwireTest conf manager $ createReceiving cr+ let Right GenericResponse {..} = receiving+ Just ReceivingsResource {..} = genericResponseResource ReceivingsItems {..} = receivingsResponseItems ReceivingsItem {..} = last unReceivingsItems ReceivingsItemResource {..} = receivingsItemResource receivingId = T.pack $ show $ unId rirId return (receiving, ReceivingId receivingId) -createBaseProductHelper :: ShipwireConfig -> [CreateProductsWrapper] -> IO (Either ShipwireError (ShipwireReturn CreateProductsRequest), Id, SKU)-createBaseProductHelper conf cp = do- baseProduct <- shipwire conf $ createProduct cp+createBaseProductHelper :: ShipwireConfig -> Manager -> [CreateProductsWrapper] -> IO (Either ShipwireError (ShipwireReturn CreateProductsRequest), Id, SKU)+createBaseProductHelper conf manager cp = do+ baseProduct <- shipwireTest conf manager $ createProduct cp let Right GetProductsResponse {..} = baseProduct GetProductsResponseResource {..} = gprResource GetProductsResponseResourceItems {..} = gprrItems@@ -478,23 +443,12 @@ productSku = bprSku $ unwrapBaseProduct pwBaseProduct return (baseProduct, productId, productSku) -createMarketingInsertHelper :: ShipwireConfig -> [CreateProductsWrapper] -> IO (Either ShipwireError (ShipwireReturn CreateProductsRequest), Id)-createMarketingInsertHelper conf cp = do- marketingInsert <- shipwire conf $ createProduct cp- let Right GetProductsResponse {..} = marketingInsert- GetProductsResponseResource {..} = gprResource- GetProductsResponseResourceItems {..} = gprrItems- GetProductsResponseResourceItem {..} = last gprriItems- pwMarketingInsert@(PwMarketingInsert _) = gprriResource- productId = mirId $ unwrapMarketingInsert pwMarketingInsert- return (marketingInsert, productId)--createOrderHelper :: ShipwireConfig -> CreateOrder -> IO (Either ShipwireError (ShipwireReturn CreateOrderRequest), Id)-createOrderHelper conf co = do- order <- shipwire conf $ createOrder co- exampleOrd <- shipwire conf $ getOrders -&- (OrderNoParam $ getOrderNo co)- let Right GetOrdersResponse {..} = exampleOrd- GetOrdersResponseResource {..} = gorResource+createOrderHelper :: ShipwireConfig -> Manager -> CreateOrder -> IO (Either ShipwireError (ShipwireReturn CreateOrderRequest), Id)+createOrderHelper conf manager co = do+ order <- shipwireTest conf manager $ createOrder co+ exampleOrd <- shipwireTest conf manager $ getOrders -&- (OrderNoParam $ getOrderNo co)+ let Right GenericResponse {..} = exampleOrd+ Just GetOrdersResponseResource {..} = genericResponseResource GetOrdersResponseResourceItems {..} = gorrItems GetOrdersResponseResourceItem {..} = head $ gorriItems GetOrdersResponseResourceItemResource {..} = gorriResource@@ -547,34 +501,13 @@ allIds = baseProductIds <> marketingInsertIds <> kitIds <> virtualKitIds return allIds -getAllReceivingsIds :: ReceivingsResponse -> IO [Integer]+getAllReceivingsIds :: GenericResponse ReceivingsResource -> IO [Integer] getAllReceivingsIds rr = do- let receivingsResource = receivingsResponseResource rr+ let (Just receivingsResource) = genericResponseResource rr receivingsItems = receivingsResponseItems receivingsResource ids = map (unId . rirId . receivingsItemResource) $ unReceivingsItems receivingsItems return ids --- dumpStuff = do--- t <- getCurrentTimeInSeconds--- let result = encode $ exampleOrder t--- return result---- tryStuff = do--- let t = "123" :: T.Text--- config <- sandboxEnvConfig--- randomPart <- getTimestamp--- (_, productId) <- createBaseProductHelper config exampleCreateBaseProduct--- (result, productId, _) <- createBaseProductHelper config $ exampleCreateBaseProduct randomPart--- return result---- seeStuff = do--- config <- sandboxEnvConfig--- (_, productId) <- createBaseProductHelper config exampleCreateBaseProduct--- randomPart <- getCurrentTimeInSeconds--- (_, orderId) <- createOrderHelper config $ exampleOrder randomPart--- result <- shipwire config $ getOrderTrackings $ WrappedId $ Id orderId--- return result- unwrapBaseProduct :: ProductsWrapper -> BaseProductResponseResource unwrapBaseProduct (PwBaseProduct x) = x unwrapBaseProduct _ = error "Bad input"@@ -605,64 +538,64 @@ main :: IO () main = do-+ manager <- newManager tlsManagerSettings config <- sandboxEnvConfig- hspec $ do+ hspec $ parallel $ do describe "get rates" $ do it "gets the correct rates" $ do randomPart <- getTimestamp- (_, productId, productSku) <- createBaseProductHelper config $ exampleCreateBaseProduct randomPart+ (_, productId, productSku) <- createBaseProductHelper config manager $ exampleCreateBaseProduct randomPart let getRt = mkGetRate (RateOptions USD GroupByAll Nothing Nothing Nothing (Just IgnoreUnknownSkus) CanSplit (WarehouseArea "US") Nothing Nothing Nothing) (RateOrder exampleShipTo (exampleItems productSku))- result <- shipwire config $ createRateRequest getRt+ result <- shipwireTest config manager $ createRateRequest getRt result `shouldSatisfy` isRight- _ <- shipwire config $ retireProducts $ ProductsToRetire [productId]- let Right RateResponse {..} = result- rateResponseWarnings `shouldBe` Nothing- rateResponseErrors `shouldBe` Nothing+ _ <- shipwireTest config manager $ retireProducts $ ProductsToRetire [productId]+ let Right GenericResponse {..} = result+ genericResponseWarnings `shouldBe` Nothing+ genericResponseErrors `shouldBe` Nothing describe "get stock info" $ do it "gets stock info with optional args" $ do randomPart <- getTimestamp- (_, productId, _) <- createBaseProductHelper config $ exampleCreateBaseProduct randomPart- result <- shipwire config $ getStockInfo -&- (SKU "HspecTest5")- _ <- shipwire config $ retireProducts $ ProductsToRetire [productId]+ (_, productId, _) <- createBaseProductHelper config manager $ exampleCreateBaseProduct randomPart+ result <- shipwireTest config manager $ getStockInfo -&- (SKU "HspecTest5")+ _ <- shipwireTest config manager $ retireProducts $ ProductsToRetire [productId] result `shouldSatisfy` isRight- let Right StockResponse {..} = result- stockResponseWarnings `shouldBe` Nothing- stockResponseErrors `shouldBe` Nothing+ let Right GenericResponse {..} = result+ genericResponseWarnings `shouldBe` Nothing+ genericResponseErrors `shouldBe` Nothing describe "get receivings" $ do it "gets an itemized list of receivings with optional args" $ do randomPart <- getTimestamp- (_, productId, productSku) <- createBaseProductHelper config $ exampleCreateBaseProduct randomPart- (_, receivingId) <- createReceivingHelper config $ exampleCreateReceiving productSku- result <- shipwire config $ getReceivings -&- (ExpandReceivingsParam [ExpandAll])+ (_, productId, productSku) <- createBaseProductHelper config manager $ exampleCreateBaseProduct randomPart+ (_, receivingId) <- createReceivingHelper config manager $ exampleCreateReceiving productSku+ result <- shipwireTest config manager $ getReceivings -&- (ExpandReceivingsParam [ExpandAll]) -&- (ReceivingStatusParams [StatusCanceled]) -&- (WarehouseIdParam ["TEST 1"]) -&- (UpdatedAfter $ (UTCTime (ModifiedJulianDay 88000) (secondsToDiffTime 10)))- _ <- shipwire config $ cancelReceiving receivingId- _ <- shipwire config $ retireProducts $ ProductsToRetire [productId]+ _ <- shipwireTest config manager $ cancelReceiving receivingId+ _ <- shipwireTest config manager $ retireProducts $ ProductsToRetire [productId] result `shouldSatisfy` isRight describe "create a new receiving" $ do it "creates a new receiving with optional args" $ do randomPart <- getTimestamp- (_, productId, productSku) <- createBaseProductHelper config $ exampleCreateBaseProduct randomPart- (receiving, receivingId) <- createReceivingHelper config $ exampleCreateReceiving productSku+ (_, productId, productSku) <- createBaseProductHelper config manager $ exampleCreateBaseProduct randomPart+ (receiving, receivingId) <- createReceivingHelper config manager $ exampleCreateReceiving productSku receiving `shouldSatisfy` isRight- _ <- shipwire config $ cancelReceiving receivingId- _ <- shipwire config $ retireProducts $ ProductsToRetire [productId]- let Right ReceivingsResponse {..} = receiving- receivingsResponseErrors `shouldBe` Nothing- receivingsResponseWarnings `shouldBe` Nothing+ _ <- shipwireTest config manager $ cancelReceiving receivingId+ _ <- shipwireTest config manager $ retireProducts $ ProductsToRetire [productId]+ let Right GenericResponse {..} = receiving+ genericResponseErrors `shouldBe` Nothing+ genericResponseWarnings `shouldBe` Nothing it "doesn't create a receiving with bad JSON" $ do randomPart <- getTimestamp- (_, productId, _) <- createBaseProductHelper config $ exampleCreateBaseProduct randomPart- result <- shipwire config $ createReceiving exampleBadCreateReceiving- _ <- shipwire config $ retireProducts $ ProductsToRetire [productId]- let Right ReceivingsResponse {..} = result- receivingsResponseErrors `shouldBe`+ (_, productId, _) <- createBaseProductHelper config manager $ exampleCreateBaseProduct randomPart+ result <- shipwireTest config manager $ createReceiving exampleBadCreateReceiving+ _ <- shipwireTest config manager $ retireProducts $ ProductsToRetire [productId]+ let Right GenericResponse {..} = result+ genericResponseErrors `shouldBe` Just (ResponseErrors [ Error@@ -675,31 +608,31 @@ describe "get information about a receiving" $ do it "gets info about a receiving" $ do randomPart <- getTimestamp- (_, productId, productSku) <- createBaseProductHelper config $ exampleCreateBaseProduct randomPart- (_, receivingId) <- createReceivingHelper config $ exampleCreateReceiving productSku- result <- shipwire config $ getReceiving receivingId -&- (ExpandReceivingsParam [ExpandHolds, ExpandItems])+ (_, productId, productSku) <- createBaseProductHelper config manager $ exampleCreateBaseProduct randomPart+ (_, receivingId) <- createReceivingHelper config manager $ exampleCreateReceiving productSku+ result <- shipwireTest config manager $ getReceiving receivingId -&- (ExpandReceivingsParam [ExpandHolds, ExpandItems]) result `shouldSatisfy` isRight- _ <- shipwire config $ cancelReceiving receivingId- _ <- shipwire config $ retireProducts $ ProductsToRetire [productId]- let Right ReceivingResponse {..} = result- receivingResponseErrors `shouldBe` Nothing- receivingResponseWarnings `shouldBe` Nothing+ _ <- shipwireTest config manager $ cancelReceiving receivingId+ _ <- shipwireTest config manager $ retireProducts $ ProductsToRetire [productId]+ let Right GenericResponse {..} = result+ genericResponseErrors `shouldBe` Nothing+ genericResponseWarnings `shouldBe` Nothing describe "modify information about a receiving" $ do it "modifies info about a receiving" $ do randomPart <- getTimestamp- (_, productId, productSku) <- createBaseProductHelper config $ exampleCreateBaseProduct randomPart- (_, receivingId) <- createReceivingHelper config $ exampleCreateReceiving productSku- result <- shipwire config $ modifyReceiving receivingId exampleModifiedReceiving+ (_, productId, productSku) <- createBaseProductHelper config manager $ exampleCreateBaseProduct randomPart+ (_, receivingId) <- createReceivingHelper config manager $ exampleCreateReceiving productSku+ result <- shipwireTest config manager $ modifyReceiving receivingId exampleModifiedReceiving result `shouldSatisfy` isRight- let Right ReceivingsResponse {..} = result- receivingsResponseErrors `shouldBe` Nothing- receivingsResponseWarnings `shouldBe` Nothing- modifiedReceiving <- shipwire config $ getReceiving receivingId- _ <- shipwire config $ cancelReceiving receivingId- _ <- shipwire config $ retireProducts $ ProductsToRetire [productId]- let Right ReceivingResponse {..} = modifiedReceiving- ReceivingsItemResource {..} = receivingResponseResource+ let Right modifyReceivingResponse = result+ genericResponseErrors modifyReceivingResponse `shouldBe` Nothing+ genericResponseWarnings modifyReceivingResponse `shouldBe` Nothing+ modifiedReceiving <- shipwireTest config manager $ getReceiving receivingId+ _ <- shipwireTest config manager $ cancelReceiving receivingId+ _ <- shipwireTest config manager $ retireProducts $ ProductsToRetire [productId]+ let Right GenericResponse {..} = modifiedReceiving+ Just ReceivingsItemResource {..} = genericResponseResource ItemResourceShipFrom {..} = rirShipFrom ItemResourceShipFromResource {..} = irsfResource irsfrCountry `shouldBe` Just (Country "Modified Country")@@ -707,112 +640,112 @@ describe "cancel a receiving" $ do it "cancels a receiving" $ do randomPart <- getTimestamp- (_, productId, productSku) <- createBaseProductHelper config $ exampleCreateBaseProduct randomPart- (_, receivingId) <- createReceivingHelper config $ exampleCreateReceiving productSku- result <- shipwire config $ cancelReceiving receivingId+ (_, productId, productSku) <- createBaseProductHelper config manager $ exampleCreateBaseProduct randomPart+ (_, receivingId) <- createReceivingHelper config manager $ exampleCreateReceiving productSku+ result <- shipwireTest config manager $ cancelReceiving receivingId result `shouldSatisfy` isRight- _ <- shipwire config $ cancelReceiving receivingId- _ <- shipwire config $ retireProducts $ ProductsToRetire [productId]+ _ <- shipwireTest config manager $ cancelReceiving receivingId+ _ <- shipwireTest config manager $ retireProducts $ ProductsToRetire [productId] let Right SimpleResponse {..} = result message `shouldBe` (ResponseMessage "Receiving was cancelled") describe "cancel shipping labels" $ do it "cancels shipping labels on a receiving" $ do randomPart <- getTimestamp- (_, productId, productSku) <- createBaseProductHelper config $ exampleCreateBaseProduct randomPart- (_, receivingId) <- createReceivingHelper config $ exampleCreateReceiving productSku- result <- shipwire config $ cancelReceivingLabels receivingId+ (_, productId, productSku) <- createBaseProductHelper config manager $ exampleCreateBaseProduct randomPart+ (_, receivingId) <- createReceivingHelper config manager $ exampleCreateReceiving productSku+ result <- shipwireTest config manager $ cancelReceivingLabels receivingId result `shouldSatisfy` isRight- _ <- shipwire config $ cancelReceiving receivingId- _ <- shipwire config $ retireProducts $ ProductsToRetire [productId]+ _ <- shipwireTest config manager $ cancelReceiving receivingId+ _ <- shipwireTest config manager $ retireProducts $ ProductsToRetire [productId] let Right SimpleResponse {..} = result message `shouldBe` (ResponseMessage "Labels cancelled") describe "get list of holds for a receiving" $ do it "gets a list of holds for a receiving" $ do randomPart <- getTimestamp- (_, productId, productSku) <- createBaseProductHelper config $ exampleCreateBaseProduct randomPart- (_, receivingId) <- createReceivingHelper config $ exampleCreateReceiving productSku- result <- shipwire config $ getReceivingHolds receivingId -&- IncludeCleared+ (_, productId, productSku) <- createBaseProductHelper config manager $ exampleCreateBaseProduct randomPart+ (_, receivingId) <- createReceivingHelper config manager $ exampleCreateReceiving productSku+ result <- shipwireTest config manager $ getReceivingHolds receivingId -&- IncludeCleared result `shouldSatisfy` isRight- _ <- shipwire config $ cancelReceiving receivingId- _ <- shipwire config $ retireProducts $ ProductsToRetire [productId]- let Right GetReceivingHoldsResponse {..} = result- grhrWarnings `shouldBe` Nothing- grhrErrors `shouldBe` Nothing+ _ <- shipwireTest config manager $ cancelReceiving receivingId+ _ <- shipwireTest config manager $ retireProducts $ ProductsToRetire [productId]+ let Right GenericResponse {..} = result+ genericResponseWarnings `shouldBe` Nothing+ genericResponseErrors `shouldBe` Nothing describe "get email recipients and instructions for a receiving" $ do it "gets email recipients and instructions for a receiving" $ do randomPart <- getTimestamp- (_, productId, productSku) <- createBaseProductHelper config $ exampleCreateBaseProduct randomPart- (_, receivingId) <- createReceivingHelper config $ exampleCreateReceiving productSku- result <- shipwire config $ getReceivingInstructionsRecipients receivingId+ (_, productId, productSku) <- createBaseProductHelper config manager $ exampleCreateBaseProduct randomPart+ (_, receivingId) <- createReceivingHelper config manager $ exampleCreateReceiving productSku+ result <- shipwireTest config manager $ getReceivingInstructionsRecipients receivingId result `shouldSatisfy` isRight- _ <- shipwire config $ cancelReceiving receivingId- _ <- shipwire config $ retireProducts $ ProductsToRetire [productId]- let Right GetReceivingInstructionsRecipientsResponse {..} = result- grirrWarnings `shouldBe` Nothing- grirrErrors `shouldBe` Nothing+ _ <- shipwireTest config manager $ cancelReceiving receivingId+ _ <- shipwireTest config manager $ retireProducts $ ProductsToRetire [productId]+ let Right GenericResponse {..} = result+ genericResponseWarnings `shouldBe` Nothing+ genericResponseErrors `shouldBe` Nothing describe "get contents of a receiving" $ do it "gets contents of a receiving" $ do randomPart <- getTimestamp- (_, productId, productSku) <- createBaseProductHelper config $ exampleCreateBaseProduct randomPart- (_, receivingId) <- createReceivingHelper config $ exampleCreateReceiving productSku- result <- shipwire config $ getReceivingItems receivingId+ (_, productId, productSku) <- createBaseProductHelper config manager $ exampleCreateBaseProduct randomPart+ (_, receivingId) <- createReceivingHelper config manager $ exampleCreateReceiving productSku+ result <- shipwireTest config manager $ getReceivingItems receivingId result `shouldSatisfy` isRight- _ <- shipwire config $ cancelReceiving receivingId- _ <- shipwire config $ retireProducts $ ProductsToRetire [productId]- let Right GetReceivingItemsResponse {..} = result- grirWarnings `shouldBe` Nothing- grirErrors `shouldBe` Nothing+ _ <- shipwireTest config manager $ cancelReceiving receivingId+ _ <- shipwireTest config manager $ retireProducts $ ProductsToRetire [productId]+ let Right GenericResponse {..} = result+ genericResponseWarnings `shouldBe` Nothing+ genericResponseErrors `shouldBe` Nothing describe "get shipping dimension and container information" $ do it "gets shipping dimension and container infromation" $ do randomPart <- getTimestamp- (_, productId, productSku) <- createBaseProductHelper config $ exampleCreateBaseProduct randomPart- (_, receivingId) <- createReceivingHelper config $ exampleCreateReceiving productSku- result <- shipwire config $ getReceivingShipments receivingId+ (_, productId, productSku) <- createBaseProductHelper config manager $ exampleCreateBaseProduct randomPart+ (_, receivingId) <- createReceivingHelper config manager $ exampleCreateReceiving productSku+ result <- shipwireTest config manager $ getReceivingShipments receivingId result `shouldSatisfy` isRight- _ <- shipwire config $ cancelReceiving receivingId- _ <- shipwire config $ retireProducts $ ProductsToRetire [productId]- let Right GetReceivingShipmentsResponse {..} = result- grsrWarnings `shouldBe` Nothing- grsrErrors `shouldBe` Nothing+ _ <- shipwireTest config manager $ cancelReceiving receivingId+ _ <- shipwireTest config manager $ retireProducts $ ProductsToRetire [productId]+ let Right GenericResponse {..} = result+ genericResponseWarnings `shouldBe` Nothing+ genericResponseErrors `shouldBe` Nothing describe "get tracking information for a receiving" $ do it "gets tracking information for a receiving" $ do randomPart <- getTimestamp- (_, productId, productSku) <- createBaseProductHelper config $ exampleCreateBaseProduct randomPart- (_, receivingId) <- createReceivingHelper config $ exampleCreateReceiving productSku- result <- shipwire config $ getReceivingTrackings receivingId+ (_, productId, productSku) <- createBaseProductHelper config manager $ exampleCreateBaseProduct randomPart+ (_, receivingId) <- createReceivingHelper config manager $ exampleCreateReceiving productSku+ result <- shipwireTest config manager $ getReceivingTrackings receivingId result `shouldSatisfy` isRight- _ <- shipwire config $ cancelReceiving receivingId- _ <- shipwire config $ retireProducts $ ProductsToRetire [productId]- let Right GetReceivingTrackingsResponse {..} = result- grtrWarnings `shouldBe` Nothing- grtrErrors `shouldBe` Nothing+ _ <- shipwireTest config manager $ cancelReceiving receivingId+ _ <- shipwireTest config manager $ retireProducts $ ProductsToRetire [productId]+ let Right GenericResponse {..} = result+ genericResponseWarnings `shouldBe` Nothing+ genericResponseErrors `shouldBe` Nothing describe "get labels information for a receiving" $ do it "gets labels information for a receiving" $ do randomPart <- getTimestamp- (_, productId, productSku) <- createBaseProductHelper config $ exampleCreateBaseProduct randomPart- (_, receivingId) <- createReceivingHelper config $ exampleCreateReceiving productSku- result <- shipwire config $ getReceivingLabels receivingId+ (_, productId, productSku) <- createBaseProductHelper config manager $ exampleCreateBaseProduct randomPart+ (_, receivingId) <- createReceivingHelper config manager $ exampleCreateReceiving productSku+ result <- shipwireTest config manager $ getReceivingLabels receivingId result `shouldSatisfy` isRight- _ <- shipwire config $ cancelReceiving receivingId- _ <- shipwire config $ retireProducts $ ProductsToRetire [productId]- let Right GetReceivingLabelsResponse {..} = result- grlrWarnings `shouldBe` Nothing- grlrErrors `shouldBe` Nothing+ _ <- shipwireTest config manager $ cancelReceiving receivingId+ _ <- shipwireTest config manager $ retireProducts $ ProductsToRetire [productId]+ let Right GenericResponse {..} = result+ genericResponseWarnings `shouldBe` Nothing+ genericResponseErrors `shouldBe` Nothing describe "get an itemized list of products" $ do it "gets an itemized list of products" $ do randomPart <- getTimestamp- (_, productId, _) <- createBaseProductHelper config $ exampleCreateBaseProduct randomPart- result <- shipwire config $ getProducts -&- (ExpandProductsParam [ExpandEnqueuedDimensions])+ (_, productId, _) <- createBaseProductHelper config manager $ exampleCreateBaseProduct randomPart+ result <- shipwireTest config manager $ getProducts result `shouldSatisfy` isRight- _ <- shipwire config $ retireProducts $ ProductsToRetire [productId]+ _ <- shipwireTest config manager $ retireProducts $ ProductsToRetire [productId] let Right GetProductsResponse {..} = result gprWarnings `shouldBe` Nothing gprErrors `shouldBe` Nothing@@ -820,51 +753,52 @@ describe "create a product" $ do it "creates all possible product classifications" $ do randomPart <- getTimestamp- (prd, productId, _) <- createBaseProductHelper config $ exampleCreateBaseProduct randomPart+ (prd, productId, _) <- createBaseProductHelper config manager $ exampleCreateBaseProduct randomPart prd `shouldSatisfy` isRight let Right GetProductsResponse {..} = prd- _ <- shipwire config $ retireProducts $ ProductsToRetire [productId]+ _ <- shipwireTest config manager $ retireProducts $ ProductsToRetire [productId] gprWarnings `shouldBe` Nothing gprErrors `shouldBe` Nothing describe "modify products" $ do it "modifies several previously created products" $ do randomPart <- getTimestamp- (_, productId, productSku) <- createBaseProductHelper config $ exampleCreateBaseProduct randomPart- result <- shipwire config $ modifyProducts $ exampleModifyProducts productId productSku+ (_, productId, productSku) <- createBaseProductHelper config manager $ exampleCreateBaseProduct randomPart+ result <- shipwireTest config manager $ modifyProducts $ exampleModifyProducts productId productSku result `shouldSatisfy` isRight- let Right ModifyProductsResponse {..} = result- _ <- shipwire config $ retireProducts $ ProductsToRetire [productId]- mprWarnings `shouldBe` Nothing- mprErrors `shouldBe` Nothing+ let Right GenericResponse {..} = result+ _ <- shipwireTest config manager $ retireProducts $ ProductsToRetire [productId]+ genericResponseWarnings `shouldBe` Nothing+ genericResponseErrors `shouldBe` Nothing describe "modify a product" $ do it "modifies a single product" $ do randomPart <- getTimestamp- (_, productId, productSku) <- createBaseProductHelper config $ exampleCreateBaseProduct randomPart- result <- shipwire config $ modifyProduct (exampleModifyProduct productId productSku) productId+ (_, productId, productSku) <- createBaseProductHelper config manager $ exampleCreateBaseProduct randomPart+ result <- shipwireTest config manager $ modifyProduct (exampleModifyProduct productId productSku) productId result `shouldSatisfy` isRight- let Right ModifyProductsResponse {..} = result- _ <- shipwire config $ retireProducts $ ProductsToRetire [productId]- mprWarnings `shouldBe` Nothing- mprErrors `shouldBe` Nothing+ let Right GenericResponse {..} = result+ _ <- shipwireTest config manager $ retireProducts $ ProductsToRetire [productId]+ genericResponseWarnings `shouldBe` Nothing+ genericResponseErrors `shouldBe` Nothing describe "get a product" $ do it "gets information about a single product" $ do randomPart <- getTimestamp- (_, productId, _) <- createBaseProductHelper config $ exampleCreateBaseProduct randomPart- result <- shipwire config $ getProduct productId+ (_, productId, _) <- createBaseProductHelper config manager $ exampleCreateBaseProduct randomPart+ result <- shipwireTest config manager $ getProduct productId result `shouldSatisfy` isRight- _ <- shipwire config $ retireProducts $ ProductsToRetire [productId]- let Right GetProductResponse {..} = result- gpreStatus `shouldNotBe` (ResponseStatus 404)- gpreWarnings `shouldBe` Nothing- gpreErrors `shouldBe` Nothing+ _ <- shipwireTest config manager $ retireProducts $ ProductsToRetire [productId]+ let Right GenericResponse {..} = result+ genericResponseStatus `shouldNotBe` (ResponseStatus 404)+ genericResponseWarnings `shouldBe` Nothing+ genericResponseErrors `shouldBe` Nothing describe "retire a product" $ do it "retires a product" $ do- (_, anotherProductId) <- createMarketingInsertHelper config exampleCreateMarketingInsert- result <- shipwire config $ retireProducts $ ProductsToRetire [anotherProductId]+ randomPart <- getTimestamp+ (_, productId, _) <- createBaseProductHelper config manager $ exampleCreateBaseProduct randomPart+ result <- shipwire config $ retireProducts $ ProductsToRetire [productId] let Right RetireProductsResponse {..} = result MoreInfo {..} = fromJust $ rprMoreInfo MoreInfoItems {..} = last miItems@@ -876,48 +810,48 @@ describe "create an order" $ do it "creates an order" $ do randomPart <- getTimestamp- (_, productId, productSku) <- createBaseProductHelper config $ exampleCreateBaseProduct randomPart- (result, orderId) <- createOrderHelper config $ exampleOrder randomPart productSku- _ <- shipwire config $ cancelOrder $ WrappedId $ orderId- _ <- shipwire config $ retireProducts $ ProductsToRetire [productId]+ (_, productId, productSku) <- createBaseProductHelper config manager $ exampleCreateBaseProduct randomPart+ (result, orderId) <- createOrderHelper config manager $ exampleOrder randomPart productSku+ _ <- shipwireTest config manager $ cancelOrder $ WrappedId $ orderId+ _ <- shipwireTest config manager $ retireProducts $ ProductsToRetire [productId] result `shouldSatisfy` isRight- let Right GetOrdersResponse {..} = result- gorWarnings `shouldBe` Nothing- gorErrors `shouldBe` Nothing+ let Right GenericResponse {..} = result+ genericResponseWarnings `shouldBe` Nothing+ genericResponseErrors `shouldBe` Nothing describe "get orders" $ do it "gets all the orders" $ do randomPart <- getTimestamp- (_, productId, productSku) <- createBaseProductHelper config $ exampleCreateBaseProduct randomPart- (_, orderId) <- createOrderHelper config $ exampleOrder randomPart productSku- result <- shipwire config $ getOrders- _ <- shipwire config $ cancelOrder $ WrappedId $ orderId- _ <- shipwire config $ retireProducts $ ProductsToRetire [productId]+ (_, productId, productSku) <- createBaseProductHelper config manager $ exampleCreateBaseProduct randomPart+ (_, orderId) <- createOrderHelper config manager $ exampleOrder randomPart productSku+ result <- shipwireTest config manager $ getOrders+ _ <- shipwireTest config manager $ cancelOrder $ WrappedId $ orderId+ _ <- shipwireTest config manager $ retireProducts $ ProductsToRetire [productId] result `shouldSatisfy` isRight- let Right GetOrdersResponse {..} = result- gorWarnings `shouldBe` Nothing- gorErrors `shouldBe` Nothing+ let Right GenericResponse {..} = result+ genericResponseWarnings `shouldBe` Nothing+ genericResponseErrors `shouldBe` Nothing describe "get an order" $ do it "gets an information about an order" $ do randomPart <- getTimestamp- (_, productId, productSku) <- createBaseProductHelper config $ exampleCreateBaseProduct randomPart- (_, orderId) <- createOrderHelper config $ exampleOrder randomPart productSku- result <- shipwire config $ getOrder $ WrappedId $ orderId- _ <- shipwire config $ cancelOrder $ WrappedId $ orderId- _ <- shipwire config $ retireProducts $ ProductsToRetire [productId]+ (_, productId, productSku) <- createBaseProductHelper config manager $ exampleCreateBaseProduct randomPart+ (_, orderId) <- createOrderHelper config manager $ exampleOrder randomPart productSku+ result <- shipwireTest config manager $ getOrder $ WrappedId $ orderId+ _ <- shipwireTest config manager $ cancelOrder $ WrappedId $ orderId+ _ <- shipwireTest config manager $ retireProducts $ ProductsToRetire [productId] result `shouldSatisfy` isRight- let Right GetOrderResponse {..} = result- goreWarnings `shouldBe` Nothing- goreErrors `shouldBe` Nothing+ let Right GenericResponse {..} = result+ genericResponseWarnings `shouldBe` Nothing+ genericResponseErrors `shouldBe` Nothing describe "cancel an order" $ do it "cancels an order" $ do randomPart <- getTimestamp- (_, productId, productSku) <- createBaseProductHelper config $ exampleCreateBaseProduct randomPart- (_, orderId) <- createOrderHelper config $ exampleOrder randomPart productSku- result <- shipwire config $ cancelOrder $ WrappedId $ orderId- _ <- shipwire config $ retireProducts $ ProductsToRetire [productId]+ (_, productId, productSku) <- createBaseProductHelper config manager $ exampleCreateBaseProduct randomPart+ (_, orderId) <- createOrderHelper config manager $ exampleOrder randomPart productSku+ result <- shipwireTest config manager $ cancelOrder $ WrappedId $ orderId+ _ <- shipwireTest config manager $ retireProducts $ ProductsToRetire [productId] result `shouldSatisfy` isRight let Right SimpleResponse {..} = result warnings `shouldBe` Nothing@@ -927,19 +861,19 @@ describe "get tracking information for this order" $ do it "gets tracking information for this order" $ do randomPart <- getTimestamp- (_, productId, productSku) <- createBaseProductHelper config $ exampleCreateBaseProduct randomPart- (_, orderId) <- createOrderHelper config $ exampleOrder randomPart productSku- result <- shipwire config $ getOrderTrackings $ WrappedId $ orderId- _ <- shipwire config $ cancelOrder $ WrappedId $ orderId- _ <- shipwire config $ retireProducts $ ProductsToRetire [productId]+ (_, productId, productSku) <- createBaseProductHelper config manager $ exampleCreateBaseProduct randomPart+ (_, orderId) <- createOrderHelper config manager $ exampleOrder randomPart productSku+ result <- shipwireTest config manager $ getOrderTrackings $ WrappedId $ orderId+ _ <- shipwireTest config manager $ cancelOrder $ WrappedId $ orderId+ _ <- shipwireTest config manager $ retireProducts $ ProductsToRetire [productId] result `shouldSatisfy` isRight- let Right GetOrderTrackingsResponse {..} = result- gotrWarnings `shouldBe` Nothing- gotrErrors `shouldBe` Nothing+ let Right GenericResponse {..} = result+ genericResponseWarnings `shouldBe` Nothing+ genericResponseErrors `shouldBe` Nothing describe "validate address" $ do it "validates an address" $ do- result <- shipwire config $ validateAddress exampleAddress+ result <- shipwireTest config manager $ validateAddress exampleAddress result `shouldSatisfy` isRight let Right ValidateAddressResponse {..} = result varMessage `shouldBe` (ResponseMessage "The address provided is valid")