Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
ERPNext.Client
Description
This is a Haskell API client for ERPNext. It aims to be a light-weight library based on http-client and user-provided record types.
API documentation:
Synopsis
- getDocTypeList :: forall a. (IsDocType a, FromJSON a) => Manager -> Config -> [QueryStringParam] -> IO (ApiResponse [a])
- getDocType :: forall a. (IsDocType a, FromJSON a) => Manager -> Config -> Text -> IO (ApiResponse a)
- postDocType :: forall a. (IsDocType a, FromJSON a, ToJSON a) => Manager -> Config -> a -> IO (ApiResponse a)
- putDocType :: forall a. (IsDocType a, FromJSON a, ToJSON a) => Manager -> Config -> Text -> a -> IO (ApiResponse a)
- deleteDocType :: forall a. IsDocType a => Manager -> Config -> Text -> IO (ApiResponse ())
- mkSecret :: Text -> Secret
- mkConfig :: Text -> Text -> Secret -> Config
- class IsDocType a where
- docTypeName :: Text
- data Config
- data Secret
- data QueryStringParam
- data ApiResponse a
- = Ok (Response ByteString) Value a
- | Err (Response ByteString) (Maybe (Value, Text))
- getResponse :: ApiResponse a -> Response ByteString
Documentation
getDocTypeList :: forall a. (IsDocType a, FromJSON a) => Manager -> Config -> [QueryStringParam] -> IO (ApiResponse [a]) Source #
Get a list of all documents of a given DocType.
The QueryStringParam
s can select fields, filter, order, enable
paging, and more.
getDocType :: forall a. (IsDocType a, FromJSON a) => Manager -> Config -> Text -> IO (ApiResponse a) Source #
Get a single document of a given DocType by name.
postDocType :: forall a. (IsDocType a, FromJSON a, ToJSON a) => Manager -> Config -> a -> IO (ApiResponse a) Source #
Create a new document of a given DocType.
putDocType :: forall a. (IsDocType a, FromJSON a, ToJSON a) => Manager -> Config -> Text -> a -> IO (ApiResponse a) Source #
Update a document of a given DocType by name.
deleteDocType :: forall a. IsDocType a => Manager -> Config -> Text -> IO (ApiResponse ()) Source #
Delete a single document of a given DocType by name.
The phantom type parameter a
is used to figure out the DocType.
A customer can be deleted like this:
res <- deleteDocType @Customer manager config "customer name"
mkSecret :: Text -> Secret Source #
Create the API secret used together with the API key for authorization.
class IsDocType a where Source #
Type class for types which represent an ERPNext DocType. Each DocType has a unique name but there can still be multiple „views“ (i.e. records types) for one DocType.
Methods
docTypeName :: Text Source #
data QueryStringParam Source #
Constructors
Debug Bool | If |
AsDict Bool | If |
LimitStart Int | Page offset (starts at 0) |
LimitPageLength Int | Page size |
Asc Text | Ascending order by given field |
Desc Text | Descending order by given field |
Fields [Text] | Select fields |
AndFilter [Filter] | Filter terms combined with logical AND |
OrFilter [Filter] | Filter terms combined with logical OR |
data ApiResponse a Source #
The API response.
Constructors
Ok | The OK response. |
Fields
| |
Err | The error response. |
Instances
Show a => Show (ApiResponse a) Source # | |
Defined in ERPNext.Client Methods showsPrec :: Int -> ApiResponse a -> ShowS # show :: ApiResponse a -> String # showList :: [ApiResponse a] -> ShowS # |
getResponse :: ApiResponse a -> Response ByteString Source #
Get the full response from the API response.