我是您的助手,以下是要翻译的内容:
但是我没有得到任何帮助,因为我一直遇到以下错误:
我正在使用Ember作为我的前端,并使用Grape API提供我的API。
前端发送了类似于以下内容的东西:
{
"service"=>{
"name"=>"Name",
"duration"=>"30",
"user"=>nil,
"organization"=>"org",
"category"=>nil,
"description"=>"description",
"disabled"=>true,
"color"=>nil,
"availabilities"=>[
{
"day"=>"Saturday",
"enabled"=>false,
"timeSlots"=>[
{
"startAt"=>"09:00 AM",
"endAt"=>"05:00 PM"
}
]
},
{
"day"=>"Sunday",
"enabled"=>false,
"timeSlots"=>[
{
"startAt"=>"09:00 AM",
"endAt"=>"05:00 PM"
}
]
},
{
"day"=>"Monday",
"enabled"=>true,
"timeSlots"=>[
{
"startAt"=>"09:00 AM",
"endAt"=>"05:00 PM"
},
{
"startAt"=>"05:00 AM",
"endAt"=>"09:00 PM"
},
{
"startAt"=>"05:00 AM",
"endAt"=>"09:00 PM"
}
]
},
{
"day"=>"Tuesday",
"enabled"=>true,
"timeSlots"=>[
{
"startAt"=>"09:00 AM",
"endAt"=>"05:00 PM"
}
]
},
{
"day"=>"Wednesday",
"enabled"=>true,
"timeSlots"=>[
{
"startAt"=>"09:00 AM",
"endAt"=>"05:00 PM"
}
]
},
{
"day"=>"Thursday",
"enabled"=>true,
"timeSlots"=>[
{
"startAt"=>"09:00 AM",
"endAt"=>"05:00 PM"
}
]
},
{
"day"=>"Friday",
"enabled"=>true,
"timeSlots"=>[
{
"startAt"=>"09:00 AM",
"endAt"=>"05:00 PM"
}
]
}
]
}
}
我正在努力实现Grape API接口以接收有效载荷,最终得到以下代码:
resource :services do
params do
requires :service, type: Hash do
requires :name, type: String
requires :organization, type: String
requires :duration, type: Integer
requires :category, type: String
optional :color, type: String
optional :description, type: String
optional :disabled, type: Boolean
requires :availabilities, type: Array do
requires :day, type: String
optional :enabled, type: Boolean
optional :timeSlots, type: Array do
requires :startAt, type: Time
requires :endtAt, type: Time
end
end
end
end
post do
puts params
end
end
但是我没有得到任何帮助,因为我一直遇到以下错误:
ERROR -- service[availabilities][0][timeSlots][0][endtAt] is missing