Customer Fields

To add or update customer fields, call the method with a JSONObject containing the field names and values:

val fields = JSONObject().put("email", "[email protected]")
Indigitall.assignOrUpdateValueToCustomerFields(context, fields, object : CustomerCallback(context) {
    override fun onSuccess(customer: Customer) {
        // Customer fields were saved
    }

    override fun onError(errorModel: ErrorModel?) {
        // Handle the error
    }
})
JSONObject fields = new JSONObject();
try {
  fields.put("email", "[email protected]");
  fields.put("name", "Peter");
} catch (JSONException exception) {
  throw new IllegalArgumentException("Invalid customer fields", exception);
}

Indigitall.assignOrUpdateValueToCustomerFields(context, fields, new CustomerCallback(context) {
  @Override
  public void onSuccess(Customer customer) {
    // Customer fields were saved
  }

  @Override
  public void onError(ErrorModel errorModel) {
    // Handle the error
  }
});

For example:

val fields = JSONObject()
  .put("email", "[email protected]")
  .put("phone", "123456")
  .put("name", "Peter")
  .put("last_name", "Brice")

Indigitall.assignOrUpdateValueToCustomerFields(context, fields, object : CustomerCallback(context) {
  override fun onSuccess(customer: Customer) {
    // Customer fields were saved
  }

  override fun onError(errorModel: ErrorModel?) {
    // Handle the error
  }
})
JSONObject fields = new JSONObject();
try {
        fields.put("email", "[email protected]");
        fields.put("phone", "123456");
        fields.put("name", "Peter");
        fields.put("last_name", "Brice");
} catch (JSONException exception) {
    throw new IllegalArgumentException("Invalid customer fields", exception);
}

Indigitall.assignOrUpdateValueToCustomerFields(context, fields, new CustomerCallback(context) {
    @Override
    public void onSuccess(Customer customer) {
        // Customer fields were saved
    }

    @Override
    public void onError(ErrorModel errorModel) {
        // Handle the error
    }
});

Otherwise, if you want to eliminate a field, you have to do this with an arrayList of the fieldNames:

Indigitall.deleteValuesFromCustomerFields(context, arrayListOf(customerFieldKey), object: CustomerCallback(context) {
  override fun onSuccess(customer: Customer) {
    //do something
  }

  override fun onError(errorModel: ErrorModel?) {
		//log error
  }
})
ArrayList<String> fieldNames = new ArrayList<>();
fieldNames.add(customerFieldKey);

Indigitall.deleteValuesFromCustomerFields(context, fieldNames, new CustomerCallback(context) {
  @Override
  public void onSuccess(Customer customer) {
    // Customer fields were deleted
  }

  @Override
  public void onError(ErrorModel errorModel) {
    // Handle the error
  }
});