public class Parser
extends java.lang.Object
Parses the Mautic REST API responses and constructs jMautic model objects from it.
Internally, it uses jackson-databind to parse the JSON stream and map it to jMautic model classes.
Although we could use jackson-databind annotations to map JSON fields to jMautic model classes, this parser does not relies on it. We cannot predict when the Mautic developers will change it's API, and jMautic intention is to support all versions of the Mautic API. So the use of annotations may make harder to support several distinct JSON formats in the same code.
For now, the Parser will change the parsed JSON, in a way that it is easy to map the JSON tree into jMautic model objects. This includes renaming fields, moving fields around in the tree, and other things.
Future versions of jMautic may handle changes in the Mautic API by creating an interface from this class public methods, and then creating multiple implementations of this new interface.
Constructor and Description |
---|
Parser() |
Modifier and Type | Method and Description |
---|---|
GetContactResult |
parseGetContact(java.io.InputStream input)
Parses the JSON returned by the
GET /contacts/ID Mautic endpoint and creates
a GetContactResult object from it. |
ListContactsResult |
parseListContacts(java.io.InputStream input)
Parses the JSON returned by the
GET /contacts Mautic endpoint, and creates
a ListContactsResult instance from it. |
public ListContactsResult parseListContacts(java.io.InputStream input) throws MauticException
GET /contacts
Mautic endpoint, and creates
a ListContactsResult instance from it.input
- the InputStream to read the endpoint responseMauticException
- if an error occurs mapping the input to the ListContactsResult
instancepublic GetContactResult parseGetContact(java.io.InputStream input) throws MauticException
GET /contacts/ID
Mautic endpoint and creates
a GetContactResult object from it.input
- the InputStream to read the returned JSON from the APIMauticException
- if an error occurrs while reading or mapping the JSON
to a GetContactResult instance.