Skip to content

Commit

Permalink
Merge fdcdb95 into 5ce585c
Browse files Browse the repository at this point in the history
  • Loading branch information
akilburge committed Jun 27, 2016
2 parents 5ce585c + fdcdb95 commit c25a2c3
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 386 deletions.
37 changes: 19 additions & 18 deletions lib/gogokit/client/seller_listing.rb
Expand Up @@ -14,11 +14,10 @@ module SellerListing
# @param [Hash] options Optional options
# @return [GogoKit::SellerListing] The requested listing
def get_seller_listing(listing_id, options = {})
root = get_root
object_from_response(GogoKit::SellerListing,
GogoKit::SellerListingRepresenter,
:get,
"#{root.links['self'].href}/sellerlistings/" \
"#{api_root_endpoint}/sellerlistings/" \
"#{listing_id}",
options)
end
Expand All @@ -29,11 +28,10 @@ def get_seller_listing(listing_id, options = {})
# @param [Hash] options Optional options
# @return [GogoKit::PagedResource] All listings for the authenticated user
def get_seller_listings(options = {})
root = get_root
object_from_response(GogoKit::PagedResource,
GogoKit::SellerListingsRepresenter,
:get,
"#{root.links['self'].href}/sellerlistings",
"#{api_root_endpoint}/sellerlistings",
options)
end

Expand All @@ -44,11 +42,10 @@ def get_seller_listings(options = {})
# @return [GogoKit::ListingConstraints] The constraints for creating a
# listing for an event
def get_listing_constraints_for_event(event_id, options = {})
root = get_root
object_from_response(GogoKit::ListingConstraints,
GogoKit::ListingConstraintsRepresenter,
:get,
"#{root.links['self'].href}/events/#{event_id}" \
"#{api_root_endpoint}/events/#{event_id}" \
'/listingconstraints',
options)
end
Expand All @@ -60,11 +57,10 @@ def get_listing_constraints_for_event(event_id, options = {})
# @return [GogoKit::ListingConstraints] The constraints for updating a
# listing
def get_listing_constraints(listing_id, options = {})
root = get_root
object_from_response(GogoKit::ListingConstraints,
GogoKit::ListingConstraintsRepresenter,
:get,
"#{root.links['self'].href}/sellerlistings/" \
"#{api_root_endpoint}/sellerlistings/" \
"#{listing_id}/constraints",
options)
end
Expand All @@ -75,11 +71,10 @@ def get_listing_constraints(listing_id, options = {})
# @param [Hash] options Optional options
# @return [GogoKit::SellerListing] The preview of a listing for an event
def create_seller_listing_preview(event_id, options = {})
root = get_root
object_from_response(GogoKit::SellerListing,
GogoKit::SellerListingRepresenter,
:post,
"#{root.links['self'].href}/events/" \
"#{api_root_endpoint}/events/" \
"#{event_id}/sellerlistingpreview",
options)
end
Expand All @@ -90,11 +85,10 @@ def create_seller_listing_preview(event_id, options = {})
# @param [Hash] options Optional options
# @return [GogoKit::SellerListing] The preview of a listing for an event
def create_seller_listing_update_preview(listing_id, options = {})
root = get_root
object_from_response(GogoKit::SellerListing,
GogoKit::SellerListingRepresenter,
:post,
"#{root.links['self'].href}/sellerlistings/" \
"#{api_root_endpoint}/sellerlistings/" \
"#{listing_id}/updatepreview",
options)
end
Expand All @@ -105,26 +99,34 @@ def create_seller_listing_update_preview(listing_id, options = {})
# @param [Hash] options Optional options
# @return [GogoKit::SellerListing] The newly created listing
def create_seller_listing(event_id, options = {})
root = get_root
object_from_response(GogoKit::SellerListing,
GogoKit::SellerListingRepresenter,
:post,
"#{root.links['self'].href}/events/" \
"#{api_root_endpoint}/events/" \
"#{event_id}/sellerlistings",
options)
end

# Creates a listing for aa requested event
# @return [GogoKit::SellerListing] The newly created listing
def create_seller_listing_for_requested_event(options = {})
object_from_response(GogoKit::SellerListing,
GogoKit::SellerListingRepresenter,
:post,
"#{api_root_endpoint}/sellerlistings",
options)
end

# Updates an existing listing
#
# @param [Integer] listing_id The ID of the listing
# @param [Hash] options Optional options
# @return [GogoKit::SellerListing] The updated created listing
def update_seller_listing(listing_id, options = {})
root = get_root
object_from_response(GogoKit::SellerListing,
GogoKit::SellerListingRepresenter,
:patch,
"#{root.links['self'].href}/sellerlistings/" \
"#{api_root_endpoint}/sellerlistings/" \
"#{listing_id}",
options)
end
Expand All @@ -135,8 +137,7 @@ def update_seller_listing(listing_id, options = {})
# @param [Hash] options Optional options
# @return [Hash] object containing response information
def delete_seller_listing(listing_id, options = {})
root = get_root
delete("#{root.links['self'].href}/sellerlistings/#{listing_id}",
delete("#{api_root_endpoint}/sellerlistings/#{listing_id}",
options)
end
end
Expand Down
13 changes: 13 additions & 0 deletions lib/gogokit/resource/seller_listing.rb
Expand Up @@ -14,13 +14,18 @@ module GogoKit
# @see http://viagogo.github.io/developer.viagogo.net/#sellerlisting
class SellerListing < Resource
attr_accessor :id,
:external_id,
:created_at,
:updated_at,
:in_hand_at,
:number_of_tickets,
:display_number_of_tickets,
:seating,
:display_seating,
:face_value,
:ticket_price,
:ticket_proceeds,
:instant_delivery,
:event,
:venue,
:ticket_type,
Expand All @@ -33,13 +38,21 @@ module SellerListingRepresenter
include GogoKit::ResourceRepresenter

property :id
property :external_id
property :created_at, type: DateTime
property :updated_at, type: DateTime
property :in_hand_at, type: DateTime
property :number_of_tickets
property :display_number_of_tickets
property :instant_delivery
property :seating,
extend: GogoKit::SeatingRepresenter,
class: GogoKit::Seating,
skip_parse: ->(fragment, _) { fragment.nil? }
property :display_seating,
extend: GogoKit::SeatingRepresenter,
class: GogoKit::Seating,
skip_parse: ->(fragment, _) { fragment.nil? }
property :face_value,
extend: GogoKit::MoneyRepresenter,
class: GogoKit::Money,
Expand Down

0 comments on commit c25a2c3

Please sign in to comment.