Initial commit
This commit is contained in:
19
app/serializers/active_storage/serializable_attachment.rb
Normal file
19
app/serializers/active_storage/serializable_attachment.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
class ActiveStorage::SerializableAttachment < JSONAPI::Serializable::Resource
|
||||
type 'active_storage_attachment'
|
||||
|
||||
attributes :content_type
|
||||
attribute :filename do
|
||||
@object.filename.to_s
|
||||
end
|
||||
|
||||
attribute :url do
|
||||
Rails.application.routes.url_helpers.rails_blob_url(@object, host: AppHost.new.domain_with_port)
|
||||
end
|
||||
|
||||
attribute :thumbnail_url do
|
||||
if @object.variable?
|
||||
Rails.application.routes.url_helpers.rails_representation_url(@object.variant(resize: "150x150"), host: AppHost.new.domain_with_port)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
14
app/serializers/deserializable_note.rb
Normal file
14
app/serializers/deserializable_note.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
class DeserializableNote < JSONAPI::Deserializable::Resource
|
||||
|
||||
Note.new.attributes.keys.each do |attr|
|
||||
attribute attr.to_sym
|
||||
end
|
||||
end
|
||||
|
||||
class SerializableNote < JSONAPI::Serializable::Resource
|
||||
type 'note'
|
||||
|
||||
Note.new.attributes.keys.each do |attr|
|
||||
attribute attr.to_sym
|
||||
end
|
||||
end
|
||||
20
app/serializers/serializable_acquired_media_release.rb
Normal file
20
app/serializers/serializable_acquired_media_release.rb
Normal file
@@ -0,0 +1,20 @@
|
||||
class SerializableAcquiredMediaRelease < JSONAPI::Serializable::Resource
|
||||
type 'acquired_media_release'
|
||||
|
||||
attributes :project_id, :contract_template_id, :tagging_status, :name, :person_name,
|
||||
:person_address_street1, :person_address_street2, :person_address_city, :person_address_state,
|
||||
:person_address_zip, :person_address_country, :person_phone, :person_email, :person_fax,
|
||||
:person_title, :person_company, :created_at, :updated_at, :collection_uid, :territory_old, :term_old,
|
||||
:applicable_medium_id, :applicable_medium_text, :territory_id, :territory_text, :term_id, :term_text,
|
||||
:restriction_id, :restriction_text, :categories, :description, :tag_list
|
||||
|
||||
has_many :file_infos do
|
||||
data do
|
||||
@object.file_infos
|
||||
end
|
||||
|
||||
meta do
|
||||
{ count: @object.file_infos.size }
|
||||
end
|
||||
end
|
||||
end
|
||||
18
app/serializers/serializable_broadcast.rb
Normal file
18
app/serializers/serializable_broadcast.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class SerializableBroadcast < JSONAPI::Serializable::Resource
|
||||
type 'broadcast'
|
||||
|
||||
%i[name status stream_server_url stream_key project_id streamer_status created_at].each do |key|
|
||||
attribute key
|
||||
end
|
||||
|
||||
has_many :files do
|
||||
data do
|
||||
@object.files
|
||||
end
|
||||
meta do
|
||||
{ count: @object.files.size }
|
||||
end
|
||||
end
|
||||
end
|
||||
7
app/serializers/serializable_contract_template.rb
Normal file
7
app/serializers/serializable_contract_template.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
class SerializableContractTemplate < JSONAPI::Serializable::Resource
|
||||
type 'contract_template'
|
||||
|
||||
ContractTemplate.new.attributes.keys.each do |attr|
|
||||
attribute attr.to_sym
|
||||
end
|
||||
end
|
||||
5
app/serializers/serializable_contract_template_list.rb
Normal file
5
app/serializers/serializable_contract_template_list.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class SerializableContractTemplateList < JSONAPI::Serializable::Resource
|
||||
type 'contract_template'
|
||||
attributes :name
|
||||
end
|
||||
|
||||
5
app/serializers/serializable_file_info.rb
Normal file
5
app/serializers/serializable_file_info.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class SerializableFileInfo < JSONAPI::Serializable::Resource
|
||||
type 'file_info'
|
||||
|
||||
attributes :filename, :content_type, :byte_size
|
||||
end
|
||||
9
app/serializers/serializable_note.rb
Normal file
9
app/serializers/serializable_note.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
class SerializableNote < JSONAPI::Serializable::Resource
|
||||
type 'note'
|
||||
|
||||
Note.new.attributes.keys.each do |attr|
|
||||
attribute attr.to_sym
|
||||
end
|
||||
|
||||
attribute :email
|
||||
end
|
||||
4
app/serializers/serializable_project.rb
Normal file
4
app/serializers/serializable_project.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
class SerializableProject < JSONAPI::Serializable::Resource
|
||||
type 'project'
|
||||
attributes :name, :created_at, :updated_at
|
||||
end
|
||||
5
app/serializers/serializable_user.rb
Normal file
5
app/serializers/serializable_user.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class SerializableUser < JSONAPI::Serializable::Resource
|
||||
type "user"
|
||||
|
||||
attributes :email
|
||||
end
|
||||
Reference in New Issue
Block a user