package com.balancedpayments;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import com.balancedpayments.core.Resource;
import com.balancedpayments.core.ResourceCollection;

public class Credit extends Resource {
    
    public Date created_at;
    public Integer amount;
    public String description;
    public String status;
    public BankAccount bank_account;
    public String account_uri;
    public Account account;
    public Map<String, String> meta;
    
    public static class Collection extends ResourceCollection<Credit> {
        public Collection(String uri) {
            super(Credit.class, uri);
        }
    };
    
    @Override
    public Map<String, Object> serialize() {
        Map<String, Object> payload = new HashMap<String, Object>();
        payload.put("meta", meta);
        return payload;
    }

    @Override
    public void deserialize(Map<String, Object> payload) {
        super.deserialize(payload);
        if (payload.containsKey("account_uri")) {
            account = null;
            account_uri = (String) payload.get("account_uri");
        }
        else if (payload.containsKey("account") && payload.get("account") != null) {
            account = new Account((Map<String, Object>) payload.get("account"));
            account_uri = account.uri;
        }
        else {
            account = null;
            account_uri = null;
        }
        bank_account = new BankAccount((Map<String, Object>) payload.get("bank_account"));
        created_at = deserializeDate((String) payload.get("created_at"));
        amount = ((Double) payload.get("amount")).intValue();
        description = (String) payload.get("description ");
        status = (String) payload.get("status");
        meta = (Map<String, String>) payload.get("meta");
    }
}

@@ -1695,17 +1695,16 @@
 cription
- 
 %22);%0A    

Update Credit.java