summaryrefslogtreecommitdiff
path: root/app/serializers/product_serializer.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/serializers/product_serializer.rb')
-rw-r--r--app/serializers/product_serializer.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/app/serializers/product_serializer.rb b/app/serializers/product_serializer.rb
new file mode 100644
index 0000000..ab23d01
--- /dev/null
+++ b/app/serializers/product_serializer.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+# ProductSerializer
+class ProductSerializer < BaseSerializer
+ include Rails.application.routes.url_helpers
+ extend ActionView::RoutingUrlFor
+
+ attributes :name, :public_id, :unitary_price, :bulk_price, :available_quantity, :categories
+
+ attribute :picture do |object|
+ object.picture.url
+ end
+
+ attribute :company do |object|
+ { name: object.company_name, short_name: object.company_short_name }
+ end
+end