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, options = {}) ⇒ Array

Cancel a payment

to be canceled

Parameters:

Returns:

  • (Array) —

    An empty Array on success, exception is raised otherwise



48
49
50
# File 'lib/bookingsync/api/client/payments.rb', line 48

def cancel_payment(payment, options = {})
  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:



26
27
28
# File 'lib/bookingsync/api/client/payments.rb', line 26

def create_payment(booking_id, options = {})
  post(:payments, booking_id: booking_id, 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:



39
40
41
# File 'lib/bookingsync/api/client/payments.rb', line 39

def edit_payment(payment, options = {})
  put("payments/#{payment}", payments: [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