-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
5 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module Spree | ||
module Api | ||
module V2 | ||
module Organizer | ||
class BaseController < ::Spree::Api::V2::BaseController | ||
include Spree::Api::V2::CollectionOptionsHelpers | ||
|
||
def render_serialized_payload(status = 200) | ||
render json: yield, status: status, content_type: content_type | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
34 changes: 34 additions & 0 deletions
34
app/controllers/spree/api/v2/organizer/tickets_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module Spree | ||
module Api | ||
module V2 | ||
module Organizer | ||
class TicketsController < ::Spree::Api::V2::Organizer::BaseController | ||
def index | ||
event = Spree::Taxon.find(params[:event_id]) | ||
|
||
resource = event.products.page(params[:page]).per(params[:per_page]) | ||
|
||
render_serialized_payload do | ||
collection_serializer.new( | ||
resource, | ||
collection_options(resource) | ||
).serializable_hash | ||
end | ||
end | ||
|
||
def show | ||
resource = Spree::Product.find(params[:id]) | ||
|
||
render_serialized_payload do | ||
Spree::V2::Organizer::TicketSerializer.new(resource).serializable_hash | ||
end | ||
end | ||
|
||
def collection_serializer | ||
::Spree::V2::Organizer::TicketSerializer | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module Spree | ||
module V2 | ||
module Organizer | ||
class BaseSerializer | ||
include JSONAPI::Serializer | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module Spree | ||
module V2 | ||
module Organizer | ||
class TicketSerializer < BaseSerializer | ||
set_type :ticket | ||
attributes :name, :price, :compare_at_price, :available_on, :kyc, :description, :shipping_category_id, :product_type, :status | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters