Module: Immobilienscout24::Api::RealEstate

Included in:
Immobilienscout24::Api
Defined in:
lib/immobilienscout24/api/real_estate.rb

Overview

Methods for the RealEstate API

Per default the client will use the current user (‘me`). If you want to use an other user then you have to provide the id in the options hash.

Examples:

client.real_estate(663515214, user: immoscout_user_id)

See Also:

Instance Method Summary collapse

Instance Method Details

#create_real_estate(estate, options = {}) ⇒ Hashie::Mash

Create a real estate

Examples:

client.create_real_estate(estate)

Parameters:

  • estate (Hash)

    Estate data

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

    Additional options

Returns:

  • (Hashie::Mash)

    Immobilienscout24 response

See Also:



47
48
49
# File 'lib/immobilienscout24/api/real_estate.rb', line 47

def create_real_estate(estate, options = {})
  post real_estate_endpoint("/realestate", options), estate
end

#delete_real_estate(id, options = {}) ⇒ Hashie::Mash

Delete a real estate

Examples:

client.delete_real_estate(estate_id, data)

Parameters:

  • id (String, Integer)

    Real estate id

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

    Additional options

Returns:

  • (Hashie::Mash)

    Immobilienscout24 response

See Also:



72
73
74
# File 'lib/immobilienscout24/api/real_estate.rb', line 72

def delete_real_estate(id, options = {})
  delete real_estate_endpoint("/realestate/#{id}", options)
end

#real_estate(id, options = {}) ⇒ Hashie::Mash

Get a single real estate

Examples:

client.real_estate(real_estate_id)

Parameters:

  • id (String, Integer)

    Real estate id

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

    Additional options

Returns:

  • (Hashie::Mash)

    Immobilienscout24 response

See Also:



35
36
37
# File 'lib/immobilienscout24/api/real_estate.rb', line 35

def real_estate(id, options = {})
  get real_estate_endpoint("/realestate/#{id}", options)
end

#real_estate_endpoint(resource, options = {}) ⇒ String

Generates the real estate endpoint

Parameters:

  • resource (String, Integer)

    In most cases the id of the real estate

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

    Additional options

Returns:

  • (String)

    The url to the real estate resource



83
84
85
86
# File 'lib/immobilienscout24/api/real_estate.rb', line 83

def real_estate_endpoint(resource, options = {})
  options = {user: "me"}.merge(options)
  user_real_estate_endpoint(options.fetch(:user), resource, options)
end

#real_estates(params = {}, options = {}) ⇒ Hashie::Mash

Get a list of all real estates

Examples:

client.real_estates

Parameters:

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

    Additional options

Returns:

  • (Hashie::Mash)

    Immobilienscout24 response

See Also:



23
24
25
# File 'lib/immobilienscout24/api/real_estate.rb', line 23

def real_estates(params = {}, options = {})
  get real_estate_endpoint("/realestate", options), params
end

#update_real_estate(id, estate, options = {}) ⇒ Hashie::Mash

Update a real estate

Examples:

client.update_real_estate(estate_id, data)

Parameters:

  • id (String, Integer)

    Real estate id

  • estate (Hash)

    Estate data

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

    Additional options

Returns:

  • (Hashie::Mash)

    Immobilienscout24 response

See Also:



60
61
62
# File 'lib/immobilienscout24/api/real_estate.rb', line 60

def update_real_estate(id, estate, options = {})
  put real_estate_endpoint("/realestate/#{id}", options), estate
end

#user_real_estate_endpoint(user, resource, options = {}) ⇒ Object



88
89
90
# File 'lib/immobilienscout24/api/real_estate.rb', line 88

def user_real_estate_endpoint(user, resource, options = {})
  [user_endpoint("/user/#{user}"), resource].join
end