Module: BookingSync::API::Client::Sources

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

Instance Method Summary collapse

Instance Method Details

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

Create a new source

Parameters:

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

    source attributes

Returns:



36
37
38
# File 'lib/bookingsync/api/client/sources.rb', line 36

def create_source(options = {})
  post(:sources, sources: [options]).pop
end

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

Edit a source

ID of the source to be updated exception is raised otherwise

Examples:

source = @api.sources.first
@api.edit_source(source, { name: "Lorem" })

Parameters:

Returns:



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

def edit_source(source, options = {})
  put("sources/#{source}", sources: [options]).pop
end

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

Get a single source

Parameters:

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

    Source or ID of the source.

  • 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/sources.rb', line 28

def source(source, options = {})
  get("sources/#{source}", options).pop
end

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

List sources

Returns sources for the account user is authenticated with.

Examples:

Get the list of sources for the current account

sources = @api.sources
sources.first.name # => "HomeAway.com"

Get the list of sources only with name and account_id for smaller response

@api.sources(fields: [:name, :account_id])

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/sources.rb', line 17

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