For example, we have a referral object that has the following structure defined in the media type.
# in the media type definition
attributes do
attribute :id, Integer, description: "Referral identifier"
attribute :prospect do
attribute :email, String, description: "Prospect's email"
attribute :name, String, description: "First and Last Names"
attribute :phone, String, description: "Phone Number"
end
attribute :advocate do
attribute :id, Integer, description: "ID of contact"
attribute :email, String, description: "Advocate's email"
end
end
In the Resource Definition, it would make sense to me that when I define an action referencing the media type, I can use that media type definition. So the payload would contain the attributes that I want to use from that media type. However, the code below causes the error
Attributor::AttributorException: can not construct from already-constructed Struct
because the prospect is already defined in the media type.
My impression was the the definition in the media type is available for use here. But it's not. Also having to set the type ie. String also seems weird because you've already defined, say, email as a String in the media type. Ideally I would only define it here if it was different from the media type definition.
# in the resource definition
media_type MediaTypes::Referral
routing { prefix '/referrals' }
action :create do
routing { post '' }
payload do
attribute :prospect do
attribute :email, String, required: true
attribute :phone, String
attribute :name, String
end
attribute :advocate do
attribute :id, Integer
attribute :email, String, required: true
end
end
response :created
end
So what would be the proper way to define this?
Thanks for your help, I'm confused.
Enric Ribas
--
You received this message because you are subscribed to the Google Groups "praxis-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to praxis-suppor...@googlegroups.com.
To post to this group, send email to praxis-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/praxis-support/c8d050b8-fc4e-4fac-b687-27a80082f61e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/praxis-support/a5b35d67-d696-4505-a576-d5352671ce3b%40googlegroups.com.