banana-j / bananaj

Java API wrapper for MailChimp API 3.0
MIT License
38 stars 33 forks source link

somelist.getSegment() fails when there is an Interests condition type. #16

Closed gscriver closed 6 years ago

gscriver commented 6 years ago
java.lang.IllegalArgumentException: No enum constant com.github.alexanderwe.bananaj.model.list.segment.Operator.INTERESTCONTAINS
    at java.lang.Enum.valueOf(Unknown Source)
    at com.github.alexanderwe.bananaj.model.list.segment.Operator.valueOf(Operator.java:6)
    at com.github.alexanderwe.bananaj.model.list.MailChimpList.getSegment(MailChimpList.java:304)

JSON response from Mailchimp API

{
    "id": 40233,
    "name": "Math",
    "member_count": 1,
    "type": "saved",
    "created_at": "2018-02-28T22:41:39+00:00",
    "updated_at": "2018-02-28T22:41:39+00:00",
    "options": {
        "match": "any",
        "conditions": [{
            "condition_type": "Interests",
            "field": "interests-6dc9e2022a",
            "op": "interestcontains",
            "value": ["1a51eb7461"]
        }]
    },
    "list_id": "17a08b3a2d",
    "_links": [{
...
    }]
}
gscriver commented 6 years ago

The schema for each condition varies depending on the condition_type. In this case it will also fail because value is an array type where banbanaj only accepts a string for value.