Project

immoscout

0.0
Low commit activity in last 3 years
Ruby client for the Immobilienscout24 REST API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
 Dependencies

Development

>= 1.16, < 3
>= 4.2.0, < 6.1
~> 10.0
~> 6.1
~> 3.4
~> 3.0
~> 0.63.1
< 0.18
~> 0.9.1
~> 3.0
~> 3.5
~> 0.9.18

Runtime

 Project Readme

Immoscout

Continuous Integration Gem Version Test Coverage Test Ratio API docs

This gem provides an API wrapper for the Immobilienscout24 REST API. It provides the well known ActiveRecord-like model methods.

  • Installation
  • Usage
    • Configuration
    • Models
      • Real Estates
        • Overview supported actions
        • Initialize
        • Find
        • Create & Update & Destroy
        • Publish & Unpublish
        • Ontop-Placement
      • Contact
        • Overview supported actions
      • Publish
        • Overview supported actions
      • Attachment (Picture & Document)
        • Overview supported actions
  • Development
  • Contributing
  • License
  • Code of Conduct

Installation

Add this line to your application's Gemfile:

gem 'immoscout'

And then execute:

$ bundle

Or install it yourself as:

$ gem install immoscout

Usage

Configuration

Immoscout.configure do |config|
  config.consumer_key = "key"
  config.consumer_secret = "secret"
  config.oauth_token = "token"
  config.oauth_token_secret = "token_secret"
  config.use_sandbox = true # default: false
  config.user_name = "immoscout-user-name" # default: 'me'
end

Models

Real Estates

Currently supported: ApartmentBuy, HouseBuy

Overview supported actions
  • .find(id)
  • .all
  • .first
  • .last
  • .new(hash)
  • .from_raw(remote_hash_or_json)
  • .create(hash)
  • #save
  • #destroy
  • #publish
  • #unpublish
  • #place(placement_type)
  • #unplace(placement_type)
Initialize
# initialize with hash
house = Immoscout::Models::HouseBuy.new(title: "test", address: {street: "thestreet"})
# => #<Immoscout::Models::HouseBuy:0x0055c9fbbc6ea0 @address=#<Immoscout::Models::Parts::Address:0x0055c9fbbc6888 @street="thestreet">, @title="test">

# initialize with attribute writers
house = Immoscout::Models::HouseBuy.new
# => #<Immoscout::Models::HouseBuy:0x0055d31f734838>
house.title = "another title"
# => "another title"

# access nested attributes
house.build_address
# => #<Immoscout::Models::Parts::Address:0x0055c9fbc77d18>
house.address.street = "another street"

# lookup all allowed first-level attributes
house.attributes
# => [:address, :api_search_data, :building_energy_rating_type, ...]
house.address.attributes
# => [:city, :house_number, :postcode, :street, ...]
Find
apartment = Immoscout::Models::ApartmentBuy.find('ID')
# => #<Immoscout::Models::ApartmentBuy:0x0055c9fbfa0648>
apartment.address.street
# => 'Orig street name'
Create & Update & Destroy
apartment = Immoscout::Models::ApartmentBuy.find('ID')
apartment.address.street = "Changed street"
apartment.save
# => #<Immoscout::Models::ApartmentBuy:0x0055c9fbfa0648>

house = Immoscout::Models::HouseBuy.find('9473634')
house.destroy
# => #<Immoscout::Models::HouseBuy:0x0055d31f734838>
Publish & Unpublish
apartment = Immoscout::Models::ApartmentBuy.find('ID')
# => #<Immoscout::Models::ApartmentBuy:0x0055c9fbfa0648>
apartment.publish
# => #<Immoscout::Models::Publish:0x0085a2fbfa0688>
apartment.unpublish
# => #<Immoscout::Models::Publish:0x00831b2fbfc1234>
Ontop-Placement
# allowed placement types: showcaseplacement, premiumplacement, topplacement
apartment = Immoscout::Models::ApartmentBuy.find('ID')
# add premiumplacement
apartment.place(:premiumplacement)
# => #<Immoscout::Models::ApartmentBuy:0x0055c9fbfa0648>
# remove premiumplacement
apartment.unplace(:premiumplacement)
# => #<Immoscout::Models::ApartmentBuy:0x0055c9fbfa0648>

Contact

Overview supported actions
  • .find(id)
  • .all
  • .first
  • .last
  • .new(hash)
  • .from_raw(remote_hash_or_json)
  • .create(hash)
  • #save
  • #destroy
contact = Immoscout::Models::Contact.new firstname: "John", lastname: "Doe"
# => #<Immoscout::Models::Contact:0x0055c9fb889878 @firstname="John", @lastname="Doe">
contact.email = "john.doe@example.com"
contact.salutation = "MALE"
contact.save
# => #<Immoscout::Models::Contact:0x0055c9fb889878 @email="john.doe@example.com", @firstname="John", @lastname="Doe", @salutation="MALE">

Publish

If you don't like or can't use the #publish and #unpublish methods defined for realestate models, you can create the Publish instance yourself.

Overview supported actions
  • .new(hash)
  • .from_raw(remote_hash_or_json)
  • #save
  • #destroy
# NOTE: publish_channel#id = 10000 => publish on immobilienscout24
publish = Immoscout::Models::Publish.new real_estate: { id: "ID" }, publish_channel: {id: 10_000}

publish.save # published!
# => #<Immoscout::Models::Publish:0x0055c9faea1fb8>
publish.destroy # unpublished!
# => #<Immoscout::Models::Publish:0x0055c9faea1fb8>

Attachment (Picture & Document)

Overview supported actions
  • .new(hash)
  • .from_raw(remote_hash_or_json)
  • #save
  • #destroy
picture = Immoscout::Models::Picture.new title: "Badezimmer", title_picture: true, floor_plan: false
picture.file = File.open("the/path/to/the/file.jpg") #
picture.attachable = Immoscout::Models::HouseBuy.last # you can also pass the ID

picture.save # attachment upload!
# => #<Immoscout::Models::Picture:0x0055c9faea1fb8>

picture.destroy # attachment destroy!
# => #<Immoscout::Models::Picture:0x0055c9faea1fb8>

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To run specs against the immobilienscout24 sandbox api, you need to create some keys and tokens. Copy the spec/test_config.yml.example to spec/test_config.yml and fill in your generated values.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/hausgold/immoscout. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Immoscout project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.