Module: BookingSync::API::Client::Payments

Included in:
BookingSync::API::Client
Defined in:
lib/bookingsync/api/client/payments.rb

Instance Method Summary collapse

Instance Method Details

#cancel_payment(payment) ⇒ NilClass

Cancel a payment

Parameters:

Returns:

  • (NilClass)

    Returns nil on success.



59
60
61
# File 'lib/bookingsync/api/client/payments.rb', line 59

def cancel_payment(payment)
  delete "payments/#{payment}"
end

#create_payment(booking_id, options = {}) ⇒ BookingSync::API::Resource

Create a new payment

Parameters:

  • booking_id (Integer)

    ID of the booking

  • options (Hash) (defaults to: {})

    payment attributes

Returns:



37
38
39
# File 'lib/bookingsync/api/client/payments.rb', line 37

def create_payment(booking_id, options = {})
  post("bookings/#{booking_id}/payments", payments: [options]).pop
end

#edit_payment(payment, options = {}) ⇒ BookingSync::API::Resource

Edit a payment

to be updated

Examples:

payment = @api.payments.first
@api.edit_payment(payment, { currency: "EURO" })

Parameters:

  • payment (BookingSync::API::Resource|Integer)

    payment or ID of the payment

  • options (Hash) (defaults to: {})

    payment attributes to be updated

Returns:



50
51
52
# File 'lib/bookingsync/api/client/payments.rb', line 50

def edit_payment(payment, options = {})
  put("payments/#{payment}", payments: [options]).pop
end

#payment(payment, options = {}) ⇒ BookingSync::API::Resource

Get a single payment

Parameters:

  • payment (BookingSync::API::Resource|Integer)

    Payment or ID of the payment.

  • options (Hash) (defaults to: {})

    A customizable set of query options.

Options Hash (options):

  • fields: (Array)

    List of fields to be fetched.

Returns:



28
29
30
# File 'lib/bookingsync/api/client/payments.rb', line 28

def payment(payment, options = {})
  get("payments/#{payment}", options).pop
end

#payments(options = {}, &block) ⇒ Array<BookingSync::API::Resource>

List payments

Returns payments for the account user is authenticated with.

Examples:

Get the list of payments for the current account

payments = @api.payments
payments.first.kind # => "cash"

Get the list of payments only with kind and currency for smaller response

@api.payments(fields: [:kind, :currency])

Parameters:

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • fields: (Array)

    List of fields to be fetched.

Returns:

See Also:



17
18
19
# File 'lib/bookingsync/api/client/payments.rb', line 17

def payments(options = {}, &block)
  paginate :payments, options, &block
end