14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'app/controllers/api/v1/openai/products_controller.rb', line 14
def show
if locale = get_locale
catalog = Catalog.locale_to_catalog(locale)
catalog_item_id = params[:id]
openai_feed = OpenaiFeed.find_by(catalog_id: catalog.id, catalog_item_id: catalog_item_id)
if openai_feed
response.['Content-Type'] = 'application/json'
self.response_body = {
feed_info: {
title: "#{catalog.company.legal_name} Product Feed - Item #{catalog_item_id}",
description: 'Individual product data for OpenAI Agentic Commerce',
last_updated: openai_feed.updated_at.iso8601,
catalog_item_id: catalog_item_id,
locale: locale
},
product: openai_feed.json_data
}.to_json
else
response.['Content-Type'] = 'application/json'
self.status = 404
self.response_body = {
error: 'Product not found',
catalog_item_id: catalog_item_id,
locale: locale
}.to_json
end
else
response.['Content-Type'] = 'application/json'
self.status = 404
self.response_body = { error: 'Locale not set' }.to_json
end
end
|