immoscout 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +30 -0
  3. data/.gitignore +14 -0
  4. data/.reek +6 -0
  5. data/.rspec +2 -0
  6. data/.rubocop.yml +15 -0
  7. data/.simplecov +3 -0
  8. data/.travis.yml +20 -0
  9. data/CODE_OF_CONDUCT.md +74 -0
  10. data/Gemfile +8 -0
  11. data/LICENSE +21 -0
  12. data/README.md +250 -0
  13. data/Rakefile +8 -0
  14. data/bin/console +14 -0
  15. data/bin/setup +8 -0
  16. data/doc/assets/logo.png +0 -0
  17. data/doc/assets/project.png +0 -0
  18. data/doc/assets/project.xcf +0 -0
  19. data/immoscout.gemspec +47 -0
  20. data/lib/immoscout.rb +27 -0
  21. data/lib/immoscout/api/client.rb +27 -0
  22. data/lib/immoscout/api/connection.rb +34 -0
  23. data/lib/immoscout/api/request.rb +33 -0
  24. data/lib/immoscout/configuration.rb +27 -0
  25. data/lib/immoscout/errors/failed.rb +11 -0
  26. data/lib/immoscout/models.rb +9 -0
  27. data/lib/immoscout/models/actions/attachment.rb +82 -0
  28. data/lib/immoscout/models/actions/contact.rb +75 -0
  29. data/lib/immoscout/models/actions/publish.rb +33 -0
  30. data/lib/immoscout/models/actions/real_estate.rb +122 -0
  31. data/lib/immoscout/models/apartment_buy.rb +90 -0
  32. data/lib/immoscout/models/base.rb +48 -0
  33. data/lib/immoscout/models/concerns/modelable.rb +55 -0
  34. data/lib/immoscout/models/concerns/propertiable.rb +56 -0
  35. data/lib/immoscout/models/concerns/renderable.rb +63 -0
  36. data/lib/immoscout/models/contact.rb +59 -0
  37. data/lib/immoscout/models/document.rb +31 -0
  38. data/lib/immoscout/models/house_buy.rb +87 -0
  39. data/lib/immoscout/models/parts/address.rb +26 -0
  40. data/lib/immoscout/models/parts/api_search_data.rb +19 -0
  41. data/lib/immoscout/models/parts/contact.rb +18 -0
  42. data/lib/immoscout/models/parts/coordinate.rb +18 -0
  43. data/lib/immoscout/models/parts/courtage.rb +19 -0
  44. data/lib/immoscout/models/parts/energy_certificate.rb +19 -0
  45. data/lib/immoscout/models/parts/energy_source.rb +17 -0
  46. data/lib/immoscout/models/parts/firing_type.rb +17 -0
  47. data/lib/immoscout/models/parts/geo_code.rb +18 -0
  48. data/lib/immoscout/models/parts/geo_hierarchy.rb +23 -0
  49. data/lib/immoscout/models/parts/price.rb +20 -0
  50. data/lib/immoscout/models/parts/publish_channel.rb +17 -0
  51. data/lib/immoscout/models/parts/real_estate.rb +17 -0
  52. data/lib/immoscout/models/parts/url.rb +18 -0
  53. data/lib/immoscout/models/parts/urls.rb +18 -0
  54. data/lib/immoscout/models/picture.rb +33 -0
  55. data/lib/immoscout/models/publish.rb +23 -0
  56. data/lib/immoscout/version.rb +5 -0
  57. metadata +268 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d84665a17f30c2eaf4eb162387b47477327c6aeaabe848cd3407c58454164850
4
+ data.tar.gz: 36645bd40f2b0734d1ea0409f60b752a282e2bb5cdceb0bd7d61658197a4ebbf
5
+ SHA512:
6
+ metadata.gz: 498747faccb6910c9d27552a6810f0197d7d214fe03299af085524628ec9843de6814ef09bcfe7bb1315a0bd4b0eeea7282e41357f126744626e99294852896f
7
+ data.tar.gz: 5213e82fc915a05d5e070e513921139d088680cf2cbca7f74697c0bc6b5a080c4d482026be66cab390fbab34f23d5132c4633382c51f029e32b6bd4b6de25f89
@@ -0,0 +1,30 @@
1
+ # http://editorconfig.org
2
+ root = true
3
+
4
+ [*]
5
+ indent_style = space
6
+ indent_size = 2
7
+ end_of_line = lf
8
+ charset = utf-8
9
+ trim_trailing_whitespace = true
10
+ insert_final_newline = true
11
+
12
+ [*.md]
13
+ trim_trailing_whitespace = true
14
+
15
+ [*.json]
16
+ indent_style = space
17
+ indent_size = 2
18
+
19
+ [*.yml]
20
+ indent_style = space
21
+ indent_size = 2
22
+
23
+ [Makefile]
24
+ trim_trailing_whitespace = true
25
+ indent_style = tab
26
+ indent_size = 4
27
+
28
+ [*.sh]
29
+ indent_style = space
30
+ indent_size = 2
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/api
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
13
+
14
+ spec/test_config\.yml
data/.reek ADDED
@@ -0,0 +1,6 @@
1
+ IrresponsibleModule:
2
+ enabled: false
3
+ ControlParameter:
4
+ enabled: false
5
+ TooManyStatements:
6
+ max: 15
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,15 @@
1
+ Documentation:
2
+ Enabled: false
3
+
4
+ StringLiterals:
5
+ Enabled: false
6
+
7
+ Metrics/BlockLength:
8
+ Exclude:
9
+ - "spec/**/*"
10
+ ExcludedMethods:
11
+ - included
12
+
13
+ AllCops:
14
+ Exclude:
15
+ - "immoscout.gemspec"
@@ -0,0 +1,3 @@
1
+ SimpleCov.start 'test_frameworks' do
2
+ add_filter '/vendor/bundle/'
3
+ end
@@ -0,0 +1,20 @@
1
+ sudo: false
2
+
3
+ env:
4
+ global:
5
+ - CC_TEST_REPORTER_ID=b3e18bf2298b2b26779929ff953cab53b2e5b791f5f8b0a8023fae0997088da7
6
+
7
+ language: ruby
8
+ rvm:
9
+ - 2.5
10
+ - 2.4
11
+ - 2.3
12
+ - 2.2
13
+
14
+ before_install: gem install bundler -v 1.15.4
15
+ before_script:
16
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
17
+ - chmod +x ./cc-test-reporter
18
+ - ./cc-test-reporter before-build
19
+ after_script:
20
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at development@hausgold.de. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ # Specify your gem's dependencies in immoscout.gemspec
8
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 HAUSGOLD
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,250 @@
1
+ ![Immoscout](doc/assets/project.png)
2
+
3
+ [![Build Status](https://travis-ci.org/hausgold/immoscout.svg?branch=master)](https://travis-ci.org/hausgold/immoscout)
4
+ [![Gem Version](https://badge.fury.io/rb/immoscout.svg)](https://badge.fury.io/rb/immoscout)
5
+ [![Maintainability](https://api.codeclimate.com/v1/badges/bfd4a5c188d5f1aebd60/maintainability)](https://codeclimate.com/github/hausgold/immoscout/maintainability)
6
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/bfd4a5c188d5f1aebd60/test_coverage)](https://codeclimate.com/github/hausgold/immoscout/test_coverage)
7
+ [![API docs](https://img.shields.io/badge/docs-API-blue.svg)](https://www.rubydoc.info/gems/immoscout)
8
+
9
+ This gem provides an API wrapper for the [Immobilienscout24 REST
10
+ API](https://api.immobilienscout24.de/our-apis/import-export.html). It provides
11
+ the well known _ActiveRecord-like_ model methods.
12
+
13
+ - [Installation](#installation)
14
+ - [Usage](#usage)
15
+ - [Configuration](#configuration)
16
+ - [Models](#models)
17
+ - [Real Estates](#real-estates)
18
+ - [Overview supported actions](#overview-supported-actions)
19
+ - [Initialize](#initialize)
20
+ - [Find](#find)
21
+ - [Create & Update & Destroy](#create--update--destroy)
22
+ - [Publish & Unpublish](#publish--unpublish)
23
+ - [Ontop-Placement](#ontop-placement)
24
+ - [Contact](#contact)
25
+ - [Overview supported actions](#overview-supported-actions-1)
26
+ - [Publish](#publish)
27
+ - [Overview supported actions](#overview-supported-actions-2)
28
+ - [Attachment (Picture & Document)](#attachment-picture--document)
29
+ - [Overview supported actions](#overview-supported-actions-3)
30
+ - [Development](#development)
31
+ - [Contributing](#contributing)
32
+ - [License](#license)
33
+ - [Code of Conduct](#code-of-conduct)
34
+
35
+ ## Installation
36
+
37
+ Add this line to your application's Gemfile:
38
+
39
+ ```ruby
40
+ gem 'immoscout'
41
+ ```
42
+
43
+ And then execute:
44
+
45
+ ```bash
46
+ $ bundle
47
+ ```
48
+
49
+ Or install it yourself as:
50
+
51
+ ```bash
52
+ $ gem install immoscout
53
+ ```
54
+
55
+ ## Usage
56
+
57
+ ### Configuration
58
+
59
+ ```ruby
60
+ Immoscout.configure do |config|
61
+ config.consumer_key = "key"
62
+ config.consumer_secret = "secret"
63
+ config.oauth_token = "token"
64
+ config.oauth_token_secret = "token_secret"
65
+ config.use_sandbox = true # default: false
66
+ config.user_name = "immoscout-user-name" # default: 'me'
67
+ end
68
+ ```
69
+
70
+ ### Models
71
+
72
+ #### Real Estates
73
+
74
+ Currently supported: `ApartmentBuy`, `HouseBuy`
75
+
76
+ ##### Overview supported actions
77
+ * .find(id)
78
+ * .all
79
+ * .first
80
+ * .last
81
+ * .new(hash)
82
+ * .from_raw(remote_hash_or_json)
83
+ * .create(hash)
84
+ * #save
85
+ * #destroy
86
+ * #publish
87
+ * #unpublish
88
+ * #place(placement_type)
89
+ * #unplace(placement_type)
90
+
91
+ ##### Initialize
92
+ ```ruby
93
+ # initialize with hash
94
+ house = Immoscout::Models::HouseBuy.new(title: "test", address: {street: "thestreet"})
95
+ # => #<Immoscout::Models::HouseBuy:0x0055c9fbbc6ea0 @address=#<Immoscout::Models::Parts::Address:0x0055c9fbbc6888 @street="thestreet">, @title="test">
96
+
97
+ # initialize with attribute writers
98
+ house = Immoscout::Models::HouseBuy.new
99
+ # => #<Immoscout::Models::HouseBuy:0x0055d31f734838>
100
+ house.title = "another title"
101
+ # => "another title"
102
+
103
+ # access nested attributes
104
+ house.build_address
105
+ # => #<Immoscout::Models::Parts::Address:0x0055c9fbc77d18>
106
+ house.address.street = "another street"
107
+
108
+ # lookup all allowed first-level attributes
109
+ house.attributes
110
+ # => [:address, :api_search_data, :building_energy_rating_type, ...]
111
+ house.address.attributes
112
+ # => [:city, :house_number, :postcode, :street, ...]
113
+ ```
114
+
115
+ ##### Find
116
+ ```ruby
117
+ apartment = Immoscout::Models::ApartmentBuy.find('ID')
118
+ # => #<Immoscout::Models::ApartmentBuy:0x0055c9fbfa0648>
119
+ apartment.address.street
120
+ # => 'Orig street name'
121
+ ```
122
+ ##### Create & Update & Destroy
123
+ ```ruby
124
+ apartment = Immoscout::Models::ApartmentBuy.find('ID')
125
+ apartment.address.street = "Changed street"
126
+ apartment.save
127
+ # => #<Immoscout::Models::ApartmentBuy:0x0055c9fbfa0648>
128
+
129
+ house = Immoscout::Models::HouseBuy.find('9473634')
130
+ house.destroy
131
+ # => #<Immoscout::Models::HouseBuy:0x0055d31f734838>
132
+ ```
133
+
134
+ ##### Publish & Unpublish
135
+ ```ruby
136
+ apartment = Immoscout::Models::ApartmentBuy.find('ID')
137
+ # => #<Immoscout::Models::ApartmentBuy:0x0055c9fbfa0648>
138
+ apartment.publish
139
+ # => #<Immoscout::Models::Publish:0x0085a2fbfa0688>
140
+ apartment.unpublish
141
+ # => #<Immoscout::Models::Publish:0x00831b2fbfc1234>
142
+ ```
143
+
144
+ ##### Ontop-Placement
145
+ ```ruby
146
+ # allowed placement types: showcaseplacement, premiumplacement, topplacement
147
+ apartment = Immoscout::Models::ApartmentBuy.find('ID')
148
+ # add premiumplacement
149
+ apartment.place(:premiumplacement)
150
+ # => #<Immoscout::Models::ApartmentBuy:0x0055c9fbfa0648>
151
+ # remove premiumplacement
152
+ apartment.unplace(:premiumplacement)
153
+ # => #<Immoscout::Models::ApartmentBuy:0x0055c9fbfa0648>
154
+ ```
155
+
156
+ #### Contact
157
+
158
+ ##### Overview supported actions
159
+ * .find(id)
160
+ * .all
161
+ * .first
162
+ * .last
163
+ * .new(hash)
164
+ * .from_raw(remote_hash_or_json)
165
+ * .create(hash)
166
+ * #save
167
+ * #destroy
168
+
169
+ ```ruby
170
+ contact = Immoscout::Models::Contact.new firstname: "John", lastname: "Doe"
171
+ # => #<Immoscout::Models::Contact:0x0055c9fb889878 @firstname="John", @lastname="Doe">
172
+ contact.email = "john.doe@example.com"
173
+ contact.salutation = "MALE"
174
+ contact.save
175
+ # => #<Immoscout::Models::Contact:0x0055c9fb889878 @email="john.doe@example.com", @firstname="John", @lastname="Doe", @salutation="MALE">
176
+ ```
177
+
178
+ #### Publish
179
+
180
+ 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.
181
+
182
+ ##### Overview supported actions
183
+ * .new(hash)
184
+ * .from_raw(remote_hash_or_json)
185
+ * #save
186
+ * #destroy
187
+
188
+ ```ruby
189
+ # NOTE: publish_channel#id = 10000 => publish on immobilienscout24
190
+ publish = Immoscout::Models::Publish.new real_estate: { id: "ID" }, publish_channel: {id: 10_000}
191
+
192
+ publish.save # published!
193
+ # => #<Immoscout::Models::Publish:0x0055c9faea1fb8>
194
+ publish.destroy # unpublished!
195
+ # => #<Immoscout::Models::Publish:0x0055c9faea1fb8>
196
+ ```
197
+
198
+ #### Attachment (Picture & Document)
199
+
200
+ ##### Overview supported actions
201
+ * .new(hash)
202
+ * .from_raw(remote_hash_or_json)
203
+ * #save
204
+ * #destroy
205
+
206
+ ```ruby
207
+ picture = Immoscout::Models::Picture.new title: "Badezimmer", title_picture: true, floor_plan: false
208
+ picture.file = File.open("the/path/to/the/file.jpg") #
209
+ picture.attachable = Immoscout::Models::HouseBuy.last # you can also pass the ID
210
+
211
+ picture.save # attachment upload!
212
+ # => #<Immoscout::Models::Picture:0x0055c9faea1fb8>
213
+
214
+ picture.destroy # attachment destroy!
215
+ # => #<Immoscout::Models::Picture:0x0055c9faea1fb8>
216
+ ```
217
+
218
+ ## Development
219
+
220
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run
221
+ `rake spec` to run the tests. You can also run `bin/console` for an interactive
222
+ prompt that will allow you to experiment.
223
+
224
+ To run specs against the immobilienscout24 sandbox api, you need to create some
225
+ keys and tokens. Copy the `spec/test_config.yml.example` to
226
+ `spec/test_config.yml` and fill in your generated values.
227
+
228
+ To install this gem onto your local machine, run `bundle exec rake install`. To
229
+ release a new version, update the version number in `version.rb`, and then run
230
+ `bundle exec rake release`, which will create a git tag for the version, push
231
+ git commits and tags, and push the `.gem` file to
232
+ [rubygems.org](https://rubygems.org).
233
+
234
+ ## Contributing
235
+
236
+ Bug reports and pull requests are welcome on GitHub at
237
+ https://github.com/hausgold/immoscout. This project is intended to be a safe,
238
+ welcoming space for collaboration, and contributors are expected to adhere to
239
+ the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
240
+
241
+ ## License
242
+
243
+ The gem is available as open source under the terms of the [MIT
244
+ License](http://opensource.org/licenses/MIT).
245
+
246
+ ## Code of Conduct
247
+
248
+ Everyone interacting in the Immoscout project’s codebases, issue trackers, chat
249
+ rooms and mailing lists is expected to follow the [code of
250
+ conduct](https://github.com/hausgold/immoscout/blob/master/CODE_OF_CONDUCT.md).