Hi,
I'm having trouble working with ERRest and EO with inheritance.
I have the following structure in my EO Model.
Order
- id
- quantity
- NSArray<AbstractPayment> payments
AbstractPayment
- id - autoIncrement
- status
CreditCardPayment extends AbstractPayment
- amount
- installments
DebitCardPayment extends AbstractPayment
- number
- holder
In my REST API, in my class OrderController doing well CreateAction:
public WOActionResults createAction() throws Throwable {
Order order = (Order)create(entityName(), filterWithAllRecursive());
}
I am making the following call with rest:
{
"status":"created",
"payments": [
{
"type": "CreditCardPayment"
"amount":100
"instalments": 1
}
]
}
If you notice my class CreditCardPayment extends AbstractPayment, and when I send my request to the list of payment am having the following error:
<com.webobjects.foundation.NSKeyValueCoding$UnknownKeyException message '<AbstractPayment 0x7656e376> takeValueForKey(): attempt to assign value to unknown key: 'amount'.
This class does not have an instance variable of the name amount or _amount, nor a method of the name setAmount or _setAmount' object '<AbstractPayment pk:"null">' key 'amount'>
I believe when it is done trying to convert JSON to the Order object it is trying to convert the List of payment for AbstractPayment and not to CreditCardPayment.
How can we show to create what should be done by CreditCardPayment DebitCartPayment or not by AbstractPayment?
Thank you.
Elizio
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden