<commit_before>package com.wepay.model;

import java.io.IOException;
import java.math.BigDecimal;

import org.json.*;

import com.wepay.WePay;
import com.wepay.net.WePayResource;
import com.wepay.exception.WePayException;
import com.wepay.model.data.*;

public class Account extends WePayResource {
		
	protected Long account_id;
	protected String state;
	protected String account_uri;
	protected BigDecimal payment_limit;
	protected String verification_state;
	protected String verification_uri;
	protected AccountData accountData;
	
	public Account(Long account_id) {
		this.account_id = account_id;
	}
	
	public static Account fetch(Long account_id, String access_token) throws JSONException, IOException, WePayException {
		JSONObject params = new JSONObject();
		params.put("account_id", account_id);
		String response = request("/account", params, access_token);
		Account a = gson.fromJson(response, Account.class);
		AccountData ad = gson.fromJson(response, AccountData.class);
		a.accountData = ad;
		return a;
	}
	
	public static Account[] find(AccountFindData findData, String access_token) throws JSONException, IOException, WePayException {
		JSONObject params = new JSONObject();
		if (findData.name != null) params.put("name", findData.name);
		if (findData.reference_id != null) params.put("reference_id", findData.reference_id);
		if (findData.sort_order != null) params.put("sort_order", findData.sort_order);
		JSONArray results = new JSONArray(request("/account/find", params, access_token));
		Account[] found = new Account[results.length()];
		for (int i = 0; i < found.length; i++) {
			Account a = gson.fromJson(results.get(i).toString(), Account.class);
			AccountData ad = gson.fromJson(results.get(i).toString(), AccountData.class);
			a.accountData = ad;
			found[i] = a;
		}
		return found;
	}
	
	public static Account create(AccountData data, String access_token) throws JSONException, IOException, WePayException {
		JSONObject params = new JSONObject();
		params.put("name", data.name);
		params.put("description", data.description);
		if (data.reference_id != null) params.put("reference_id", data.reference_id);
		if (data.type != null) params.put("type", data.type);
		if (data.image_uri != null) params.put("image_uri", data.image_uri);
		if (data.gaq_domains != null) params.put("gaq_domains", data.gaq_domains);
		if (data.theme_object != null) params.put("theme_object", ThemeObjectData.build_theme_object(data.theme_object));
		if (data.mcc != null) params.put("mcc", data.mcc);
		if (data.callback_uri != null) params.put("callback_uri", data.callback_uri);
		String response = request("/account/create", params, access_token);
		Account a = gson.fromJson(response, Account.class);
		a.accountData = data;
		return a;
	}
	
	public void modify(AccountData newData, String access_token) throws JSONException, IOException, WePayException {
		JSONObject params = new JSONObject();
		params.put("account_id", this.account_id);
		if (newData.name != null) params.put("name", newData.name);
		if (newData.description != null) params.put("description", newData.description);
		if (newData.reference_id != null) params.put("reference_id", newData.reference_id);
		if (newData.image_uri != null) params.put("image_uri", newData.image_uri);
		if (newData.gaq_domains != null) params.put("gaq_domains", newData.gaq_domains);		
		if (newData.theme_object != null) params.put("theme_object", ThemeObjectData.build_theme_object(newData.theme_object));
		if (newData.callback_uri != null) params.put("callback_uri", newData.callback_uri);	
		String response = request("/account/modify", params, access_token);
		Account a = gson.fromJson(response, Account.class);
		AccountData ad = gson.fromJson(response, AccountData.class);
		ad.callback_uri = newData.callback_uri;
		this.account_id = a.account_id;
		this.account_uri = a.account_uri;
		this.payment_limit = a.payment_limit;
		this.verification_state = a.verification_state; 
		this.verification_uri = a.verification_uri;
		this.accountData = ad;
	}
	
	public void delete(String reason, String access_token) throws JSONException, IOException, WePayException {
		JSONObject params = new JSONObject();
		params.put("account_id", this.account_id);
		if (reason != null) params.put("reason", reason);
		request("/account/delete", params, access_token);
	}
	
	public AccountBalanceData balance(String access_token) throws JSONException, IOException, WePayException {
		JSONObject params = new JSONObject();
		params.put("account_id", this.account_id);
		AccountBalanceData ab = gson.fromJson(request("/account/balance", params, access_token), AccountBalanceData.class);
		return ab;
	}
	
	public String add_bank(AccountAddBankData addBankData, String access_token) throws JSONException, IOException, WePayException {
		JSONObject params = new JSONObject();
		params.put("account_id", this.account_id);
		if (addBankData != null) {
			if (addBankData.mode != null) params.put("mode", addBankData.mode);
			if (addBankData.redirect_uri != null) params.put("redirect_uri", addBankData.redirect_uri);
		}
		JSONObject object = new JSONObject(request("/account/add_bank", params, access_token));
		return object.getString("add_bank_uri");
	}
	
	public void set_tax(AccountTaxData[] taxesData, String access_token) throws JSONException, IOException, WePayException {
		JSONObject params = new JSONObject();
		params.put("account_id", this.account_id);
		JSONArray taxes = new JSONArray();
		if (taxesData != null) {
			for (int i = 0; i < taxesData.length; i++) {
				taxes.put(AccountTaxData.build_tax(taxesData[i]));
			}
		}
		params.put("taxes", taxes);
		request("/account/set_tax", params, access_token);
	}

	public AccountTaxData[] get_tax(String access_token) throws JSONException, IOException, WePayException {
		JSONObject params = new JSONObject();
		params.put("account_id", this.account_id);
		JSONArray array = new JSONArray(request("/account/get_tax", params, access_token));
		AccountTaxData[] taxData = new AccountTaxData[array.length()];
		for (int i = 0; i < array.length(); i++) {
			taxData[i] = gson.fromJson(array.get(i).toString(), AccountTaxData.class);
		}
		return taxData;
	}
	
	public Long getAccount_id() {
		return account_id;
	}
	
	public String getName() {
		return accountData.name;
	}
	
	public String getState() {
		return state;
	}<commit_msg>added Account.set_tax() overload method for single AccountTaxData object<commit_after>package com.wepay.model;

import java.io.IOException;
import java.math.BigDecimal;

import org.json.*;

import com.wepay.WePay;
import com.wepay.net.WePayResource;
import com.wepay.exception.WePayException;
import com.wepay.model.data.*;

public class Account extends WePayResource {
		
	protected Long account_id;
	protected String state;
	protected String account_uri;
	protected BigDecimal payment_limit;
	protected String verification_state;
	protected String verification_uri;
	protected AccountData accountData;
	
	public Account(Long account_id) {
		this.account_id = account_id;
	}
	
	public static Account fetch(Long account_id, String access_token) throws JSONException, IOException, WePayException {
		JSONObject params = new JSONObject();
		params.put("account_id", account_id);
		String response = request("/account", params, access_token);
		Account a = gson.fromJson(response, Account.class);
		AccountData ad = gson.fromJson(response, AccountData.class);
		a.accountData = ad;
		return a;
	}
	
	public static Account[] find(AccountFindData findData, String access_token) throws JSONException, IOException, WePayException {
		JSONObject params = new JSONObject();
		if (findData.name != null) params.put("name", findData.name);
		if (findData.reference_id != null) params.put("reference_id", findData.reference_id);
		if (findData.sort_order != null) params.put("sort_order", findData.sort_order);
		JSONArray results = new JSONArray(request("/account/find", params, access_token));
		Account[] found = new Account[results.length()];
		for (int i = 0; i < found.length; i++) {
			Account a = gson.fromJson(results.get(i).toString(), Account.class);
			AccountData ad = gson.fromJson(results.get(i).toString(), AccountData.class);
			a.accountData = ad;
			found[i] = a;
		}
		return found;
	}
	
	public static Account create(AccountData data, String access_token) throws JSONException, IOException, WePayException {
		JSONObject params = new JSONObject();
		params.put("name", data.name);
		params.put("description", data.description);
		if (data.reference_id != null) params.put("reference_id", data.reference_id);
		if (data.type != null) params.put("type", data.type);
		if (data.image_uri != null) params.put("image_uri", data.image_uri);
		if (data.gaq_domains != null) params.put("gaq_domains", data.gaq_domains);
		if (data.theme_object != null) params.put("theme_object", ThemeObjectData.build_theme_object(data.theme_object));
		if (data.mcc != null) params.put("mcc", data.mcc);
		if (data.callback_uri != null) params.put("callback_uri", data.callback_uri);
		String response = request("/account/create", params, access_token);
		Account a = gson.fromJson(response, Account.class);
		a.accountData = data;
		return a;
	}
	
	public void modify(AccountData newData, String access_token) throws JSONException, IOException, WePayException {
		JSONObject params = new JSONObject();
		params.put("account_id", this.account_id);
		if (newData.name != null) params.put("name", newData.name);
		if (newData.description != null) params.put("description", newData.description);
		if (newData.reference_id != null) params.put("reference_id", newData.reference_id);
		if (newData.image_uri != null) params.put("image_uri", newData.image_uri);
		if (newData.gaq_domains != null) params.put("gaq_domains", newData.gaq_domains);		
		if (newData.theme_object != null) params.put("theme_object", ThemeObjectData.build_theme_object(newData.theme_object));
		if (newData.callback_uri != null) params.put("callback_uri", newData.callback_uri);	
		String response = request("/account/modify", params, access_token);
		Account a = gson.fromJson(response, Account.class);
		AccountData ad = gson.fromJson(response, AccountData.class);
		ad.callback_uri = newData.callback_uri;
		this.account_id = a.account_id;
		this.account_uri = a.account_uri;
		this.payment_limit = a.payment_limit;
		this.verification_state = a.verification_state; 
		this.verification_uri = a.verification_uri;
		this.accountData = ad;
	}
	
	public void delete(String reason, String access_token) throws JSONException, IOException, WePayException {
		JSONObject params = new JSONObject();
		params.put("account_id", this.account_id);
		if (reason != null) params.put("reason", reason);
		request("/account/delete", params, access_token);
	}
	
	public AccountBalanceData balance(String access_token) throws JSONException, IOException, WePayException {
		JSONObject params = new JSONObject();
		params.put("account_id", this.account_id);
		AccountBalanceData ab = gson.fromJson(request("/account/balance", params, access_token), AccountBalanceData.class);
		return ab;
	}
	
	public String add_bank(AccountAddBankData addBankData, String access_token) throws JSONException, IOException, WePayException {
		JSONObject params = new JSONObject();
		params.put("account_id", this.account_id);
		if (addBankData != null) {
			if (addBankData.mode != null) params.put("mode", addBankData.mode);
			if (addBankData.redirect_uri != null) params.put("redirect_uri", addBankData.redirect_uri);
		}
		JSONObject object = new JSONObject(request("/account/add_bank", params, access_token));
		return object.getString("add_bank_uri");
	}
	
	public void set_tax(AccountTaxData[] taxesData, String access_token) throws JSONException, IOException, WePayException {
		JSONObject params = new JSONObject();
		params.put("account_id", this.account_id);
		JSONArray taxes = new JSONArray();
		if (taxesData != null) {
			for (int i = 0; i < taxesData.length; i++) {
				taxes.put(AccountTaxData.build_tax(taxesData[i]));
			}
		}
		params.put("taxes", taxes);
		request("/account/set_tax", params, access_token);
	}
	public void set_tax(AccountTaxData taxData, String access_token) throws JSONException, IOException, WePayException {
		//overload function for single AccountTaxData object
		JSONObject params = new JSONObject();
		params.put("account_id", this.account_id);
		JSONArray taxes = new JSONArray();
		if (taxData != null) taxes.put(AccountTaxData.build_tax(taxData));
		params.put("taxes", taxes);
		request("/account/set_tax", params, access_token);
	}

	public AccountTaxData[] get_tax(String access_token) throws JSONException, IOException, WePayException {
		JSONObject params = new JSONObject();
		params.put("account_id", this.account_id);
		JSONArray array = new JSONArray(request("/account/get_tax", params, access_token));
		AccountTaxData[] taxData = new AccountTaxData[array.length()];
		for (int i = 0; i < array.length(); i++) {
			taxData[i] = gson.fromJson(array.get(i).toString(), AccountTaxData.class);
		}
		return taxData;
	}
	
	public Long getAccount_id() {
		return account_id;
	}
	
	public String getName() {
		return accountData.name;
	}
	
	public String getState() {
		return state;
	}
{'fraction_non_alphanumeric': 0.12712955251003255, 'fraction_numerical': 0.0004543045354736125, 'mean_word_length': 5.44921875, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5439783', 'n_tokens_mistral': 4340, 'n_tokens_neox': 4056, 'n_words': 956}