Class: Believe::Resources::TicketSales

Inherits:
Object
  • Object
show all
Defined in:
lib/believe/resources/ticket_sales.rb

Overview

Ticket sales with 300 records for practicing pagination, filtering, and financial data

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ TicketSales

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of TicketSales.

Parameters:



174
175
176
# File 'lib/believe/resources/ticket_sales.rb', line 174

def initialize(client:)
  @client = client
end

Instance Method Details

#create(buyer_name:, currency:, discount:, match_id:, purchase_method:, quantity:, subtotal:, tax:, total:, unit_price:, buyer_email: nil, coupon_code: nil, request_options: {}) ⇒ ::Believe::Models::TicketSale

Record a new ticket sale.

Parameters:

  • buyer_name (String)

    Name of the ticket buyer

  • currency (String)

    Currency code (GBP, USD, or EUR)

  • discount (String)

    Discount amount applied from coupon

  • match_id (String)

    ID of the match

  • purchase_method (Symbol, ::Believe::Models::PurchaseMethod)

    How the ticket was purchased

  • quantity (Integer)

    Number of tickets purchased

  • subtotal (String)

    Subtotal before discount and tax (unit_price * quantity)

  • tax (String)

    Tax amount (20% UK VAT on discounted subtotal)

  • total (String)

    Final total (subtotal - discount + tax)

  • unit_price (String)

    Price per ticket (decimal string)

  • buyer_email (String, nil)

    Email of the ticket buyer

  • coupon_code (String, nil)

    Coupon code applied, if any

  • request_options (::Believe::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



41
42
43
44
45
46
47
48
49
50
# File 'lib/believe/resources/ticket_sales.rb', line 41

def create(params)
  parsed, options = ::Believe::TicketSaleCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "ticket-sales",
    body: parsed,
    model: ::Believe::TicketSale,
    options: options
  )
end

#delete(ticket_sale_id, request_options: {}) ⇒ nil

Remove a ticket sale from the database.

Parameters:

Returns:

  • (nil)

See Also:



162
163
164
165
166
167
168
169
# File 'lib/believe/resources/ticket_sales.rb', line 162

def delete(ticket_sale_id, params = {})
  @client.request(
    method: :delete,
    path: ["ticket-sales/%1$s", ticket_sale_id],
    model: NilClass,
    options: params[:request_options]
  )
end

#list(coupon_code: nil, currency: nil, limit: nil, match_id: nil, purchase_method: nil, skip: nil, request_options: {}) ⇒ ::Believe::Internal::SkipLimitPage<::Believe::Models::TicketSale>

Get a paginated list of all ticket sales with optional filtering. With 300 records, this endpoint is ideal for practicing pagination.

Parameters:

  • coupon_code (String, nil)

    Filter by coupon code (use ‘none’ for sales without coupons)

  • currency (String, nil)

    Filter by currency (GBP, USD, EUR)

  • limit (Integer)

    Maximum number of items to return (max: 100)

  • match_id (String, nil)

    Filter by match ID

  • purchase_method (Symbol, ::Believe::Models::PurchaseMethod, nil)

    Filter by purchase method

  • skip (Integer)

    Number of items to skip (offset)

  • request_options (::Believe::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/believe/resources/ticket_sales.rb', line 139

def list(params = {})
  parsed, options = ::Believe::TicketSaleListParams.dump_request(params)
  query = ::Believe::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "ticket-sales",
    query: query,
    page: ::Believe::Internal::SkipLimitPage,
    model: ::Believe::TicketSale,
    options: options
  )
end

#retrieve(ticket_sale_id, request_options: {}) ⇒ ::Believe::Models::TicketSale

Retrieve detailed information about a specific ticket sale.

Parameters:

Returns:

See Also:



62
63
64
65
66
67
68
69
# File 'lib/believe/resources/ticket_sales.rb', line 62

def retrieve(ticket_sale_id, params = {})
  @client.request(
    method: :get,
    path: ["ticket-sales/%1$s", ticket_sale_id],
    model: ::Believe::TicketSale,
    options: params[:request_options]
  )
end

#update(ticket_sale_id, buyer_email: nil, buyer_name: nil, coupon_code: nil, currency: nil, discount: nil, match_id: nil, purchase_method: nil, quantity: nil, subtotal: nil, tax: nil, total: nil, unit_price: nil, request_options: {}) ⇒ ::Believe::Models::TicketSale

Update specific fields of an existing ticket sale.

Parameters:

  • ticket_sale_id (String)
  • buyer_email (String, nil)
  • buyer_name (String, nil)
  • coupon_code (String, nil)
  • currency (String, nil)
  • discount (String, nil)
  • match_id (String, nil)
  • purchase_method (Symbol, ::Believe::Models::PurchaseMethod, nil)

    How the ticket was purchased.

  • quantity (Integer, nil)
  • subtotal (String, nil)
  • tax (String, nil)
  • total (String, nil)
  • unit_price (String, nil)
  • request_options (::Believe::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



106
107
108
109
110
111
112
113
114
115
# File 'lib/believe/resources/ticket_sales.rb', line 106

def update(ticket_sale_id, params = {})
  parsed, options = ::Believe::TicketSaleUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["ticket-sales/%1$s", ticket_sale_id],
    body: parsed,
    model: ::Believe::TicketSale,
    options: options
  )
end