erpnext-api-client-0.1.0.1: Generic API client library for ERPNext
Safe HaskellSafe-Inferred
LanguageGHC2021

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:

https://docs.frappe.io/framework/user/en/api/rest

Synopsis

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 QueryStringParams 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.

mkConfig :: Text -> Text -> Secret -> Config Source #

Create an API client configuration.

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.

data Config Source #

API client configuration.

data Secret Source #

Opaque type to store the API secret.

data QueryStringParam Source #

Constructors

Debug Bool

If True, makes API returning query analysis info instead of data

AsDict Bool

If False, makes API returning the data records as mixed-type arrays which cannot be parsed by this library (default: True)

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

  • (Response ByteString)

    The server's full response including header information.

  • Value

    The returned JSON.

  • a

    The result parsed from the returned JSON.

Err

The error response.

Fields

  • (Response ByteString)

    The server's full response including header information.

  • (Maybe (Value, Text))

    If the response is valid JSON, Just the returned JSON and the parse error message telling why Value couldn't be parsed into a.

Instances

Instances details
Show a => Show (ApiResponse a) Source # 
Instance details

Defined in ERPNext.Client

getResponse :: ApiResponse a -> Response ByteString Source #

Get the full response from the API response.