immoscout 1.3.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/documentation.yml +38 -0
- data/.github/workflows/test.yml +62 -0
- data/.yardopts +6 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile +1 -1
- data/Makefile +23 -7
- data/README.md +4 -4
- data/Rakefile +71 -2
- data/gemfiles/rails_5.2.gemfile +5 -3
- data/gemfiles/rails_6.0.gemfile +5 -3
- data/immoscout.gemspec +2 -2
- data/lib/immoscout/api/client.rb +4 -2
- data/lib/immoscout/api/connection.rb +4 -2
- data/lib/immoscout/api/request.rb +7 -3
- data/lib/immoscout/configuration.rb +7 -7
- data/lib/immoscout/errors/failed.rb +2 -0
- data/lib/immoscout/models/actions/attachment.rb +22 -8
- data/lib/immoscout/models/actions/contact.rb +10 -2
- data/lib/immoscout/models/actions/publish.rb +3 -1
- data/lib/immoscout/models/actions/real_estate.rb +13 -3
- data/lib/immoscout/models/apartment_buy.rb +1 -1
- data/lib/immoscout/models/base.rb +1 -0
- data/lib/immoscout/models/concerns/modelable.rb +6 -3
- data/lib/immoscout/models/concerns/propertiable.rb +4 -1
- data/lib/immoscout/models/concerns/renderable.rb +13 -0
- data/lib/immoscout/models/contact.rb +1 -1
- data/lib/immoscout/models/document.rb +1 -1
- data/lib/immoscout/models/house_buy.rb +1 -1
- data/lib/immoscout/models/picture.rb +2 -2
- data/lib/immoscout/models/publish.rb +1 -1
- data/lib/immoscout/models.rb +2 -0
- data/lib/immoscout/version.rb +1 -1
- data/lib/immoscout.rb +1 -1
- metadata +15 -7
- data/.travis.yml +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc74f7180d13859dedf5b42a8502e6d679b6c7348622c5f92de6a41c9daba822
|
4
|
+
data.tar.gz: 39c5063180247dfe8e9e279c0b0dc9f20d7a4204127ee763dd50690c92013fb7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 277085348b99e2e1cc4e58157f067a874f78a8fb008970eeb50ca290d121008a8ab2613fc08475ba276d94ca7c62a05236cc68aeabf8cce782742892412639f2
|
7
|
+
data.tar.gz: 0fcd17a5e12f726a74268e270c9e9113c6ba8d455086e764d503c49bc8897d77b2d3e6071fd36d661fb5bd8ca10e5fee70e5a7bebf77a5e17dc108ddedf55e3c
|
@@ -0,0 +1,38 @@
|
|
1
|
+
name: Build Documentation
|
2
|
+
on:
|
3
|
+
repository_dispatch:
|
4
|
+
types: [documentation]
|
5
|
+
|
6
|
+
concurrency:
|
7
|
+
group: 'docs'
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
docs:
|
11
|
+
name: Build gem documentation
|
12
|
+
runs-on: ubuntu-20.04
|
13
|
+
timeout-minutes: 5
|
14
|
+
steps:
|
15
|
+
- uses: actions/checkout@v2
|
16
|
+
|
17
|
+
- name: Install the correct Ruby version
|
18
|
+
uses: ruby/setup-ruby@v1
|
19
|
+
with:
|
20
|
+
ruby-version: 2.5
|
21
|
+
bundler-cache: true
|
22
|
+
|
23
|
+
- name: Prepare the virtual environment
|
24
|
+
uses: hausgold/actions/ci@master
|
25
|
+
with:
|
26
|
+
clone_token: '${{ secrets.CLONE_TOKEN }}'
|
27
|
+
settings: '${{ github.repository }}'
|
28
|
+
target: ci/gem-test
|
29
|
+
|
30
|
+
- name: Build gem documentation
|
31
|
+
run: make docs
|
32
|
+
|
33
|
+
- name: Upload the code coverage report
|
34
|
+
run: coverage
|
35
|
+
|
36
|
+
- name: Add this job to the commit status
|
37
|
+
run: commit-status '${{ job.status }}'
|
38
|
+
if: always()
|
@@ -0,0 +1,62 @@
|
|
1
|
+
name: Test
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
branches:
|
5
|
+
- '**'
|
6
|
+
schedule:
|
7
|
+
- cron: '0 0 * * MON'
|
8
|
+
|
9
|
+
concurrency:
|
10
|
+
group: '${{ github.ref }}'
|
11
|
+
cancel-in-progress: true
|
12
|
+
|
13
|
+
jobs:
|
14
|
+
test:
|
15
|
+
name: 'Test the gem (Ruby ${{ matrix.ruby }}, Rails ${{ matrix.rails }})'
|
16
|
+
runs-on: ubuntu-20.04
|
17
|
+
timeout-minutes: 5
|
18
|
+
strategy:
|
19
|
+
fail-fast: false
|
20
|
+
matrix:
|
21
|
+
ruby: [2.5, 2.6, 2.7]
|
22
|
+
rails: [5.2, '6.0']
|
23
|
+
env:
|
24
|
+
BUNDLE_GEMFILE: 'gemfiles/rails_${{ matrix.rails }}.gemfile'
|
25
|
+
steps:
|
26
|
+
- uses: actions/checkout@v2
|
27
|
+
|
28
|
+
- name: Install the correct Ruby version
|
29
|
+
uses: ruby/setup-ruby@v1
|
30
|
+
with:
|
31
|
+
ruby-version: ${{ matrix.ruby }}
|
32
|
+
bundler-cache: true
|
33
|
+
|
34
|
+
- name: Prepare the virtual environment
|
35
|
+
uses: hausgold/actions/ci@master
|
36
|
+
with:
|
37
|
+
clone_token: '${{ secrets.CLONE_TOKEN }}'
|
38
|
+
settings: '${{ github.repository }}'
|
39
|
+
target: ci/gem-test
|
40
|
+
|
41
|
+
- name: Run the gem tests
|
42
|
+
run: make test
|
43
|
+
|
44
|
+
- name: Upload the code coverage report
|
45
|
+
run: coverage
|
46
|
+
|
47
|
+
trigger-docs:
|
48
|
+
name: Trigger the documentation upload
|
49
|
+
runs-on: ubuntu-20.04
|
50
|
+
timeout-minutes: 2
|
51
|
+
needs: test
|
52
|
+
if: github.ref == 'refs/heads/master'
|
53
|
+
steps:
|
54
|
+
- name: Prepare the virtual environment
|
55
|
+
uses: hausgold/actions/ci@master
|
56
|
+
with:
|
57
|
+
clone_token: '${{ secrets.CLONE_TOKEN }}'
|
58
|
+
settings: '${{ github.repository }}'
|
59
|
+
target: ci/noop
|
60
|
+
|
61
|
+
- name: Trigger the documentation upload
|
62
|
+
run: workflow documentation
|
data/.yardopts
ADDED
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Makefile
CHANGED
@@ -31,7 +31,6 @@ APPRAISAL ?= appraisal
|
|
31
31
|
GEM ?= gem
|
32
32
|
RAKE ?= rake
|
33
33
|
YARD ?= yard
|
34
|
-
RAKE ?= rake
|
35
34
|
RUBOCOP ?= rubocop
|
36
35
|
|
37
36
|
# Files
|
@@ -61,6 +60,11 @@ all:
|
|
61
60
|
# test Run the whole test suite
|
62
61
|
# clean Clean the dependencies
|
63
62
|
#
|
63
|
+
# docs Generate the Ruby documentation of the library
|
64
|
+
# stats Print the code statistics (library and test suite)
|
65
|
+
# notes Print all the notes from the code
|
66
|
+
# release Release a new Gem version (maintainers only)
|
67
|
+
#
|
64
68
|
# shell Run an interactive shell on the container
|
65
69
|
# shell-irb Run an interactive IRB shell on the container
|
66
70
|
|
@@ -72,14 +76,18 @@ install:
|
|
72
76
|
$(GEM) install bundler -v "~> 1.0")
|
73
77
|
@$(call run-shell,$(BUNDLE) exec $(APPRAISAL) install)
|
74
78
|
|
75
|
-
update:
|
79
|
+
update:
|
76
80
|
# Install the dependencies
|
77
81
|
@$(MKDIR) -p $(VENDOR_DIR)
|
78
82
|
@$(call run-shell,$(BUNDLE) exec $(APPRAISAL) update)
|
79
83
|
|
80
|
-
test:
|
84
|
+
test: \
|
85
|
+
test-specs \
|
86
|
+
test-style
|
87
|
+
|
88
|
+
test-specs:
|
81
89
|
# Run the whole test suite
|
82
|
-
@$(call run-shell,$(BUNDLE) exec $(RAKE))
|
90
|
+
@$(call run-shell,$(BUNDLE) exec $(RAKE) stats spec)
|
83
91
|
|
84
92
|
$(TEST_GEMFILES): GEMFILE=$(@:test-%=%)
|
85
93
|
$(TEST_GEMFILES):
|
@@ -118,19 +126,27 @@ endif
|
|
118
126
|
|
119
127
|
distclean: clean clean-containers clean-images
|
120
128
|
|
121
|
-
shell:
|
129
|
+
shell:
|
122
130
|
# Run an interactive shell on the container
|
123
131
|
@$(call run-shell,$(BASH) -i)
|
124
132
|
|
125
|
-
shell-irb:
|
133
|
+
shell-irb:
|
126
134
|
# Run an interactive IRB shell on the container
|
127
135
|
@$(call run-shell,bin/console)
|
128
136
|
|
129
|
-
docs:
|
137
|
+
docs:
|
130
138
|
# Build the API documentation
|
131
139
|
@$(call run-shell,$(BUNDLE) exec $(YARD) -q && \
|
132
140
|
$(BUNDLE) exec $(YARD) stats --list-undoc --compact)
|
133
141
|
|
142
|
+
notes:
|
143
|
+
# Print the code statistics (library and test suite)
|
144
|
+
@$(call run-shell,$(BUNDLE) exec $(RAKE) notes)
|
145
|
+
|
146
|
+
stats:
|
147
|
+
# Print all the notes from the code
|
148
|
+
@$(call run-shell,$(BUNDLE) exec $(RAKE) stats)
|
149
|
+
|
134
150
|
release:
|
135
151
|
# Release a new gem version
|
136
152
|
@$(BUNDLE) exec $(RAKE) release
|
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
![Immoscout](doc/assets/project.svg)
|
2
2
|
|
3
|
-
[![
|
3
|
+
[![Continuous Integration](https://github.com/hausgold/immoscout/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/hausgold/immoscout/actions/workflows/test.yml)
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/immoscout.svg)](https://badge.fury.io/rb/immoscout)
|
5
|
-
[![
|
6
|
-
[![Test
|
7
|
-
[![API docs](https://
|
5
|
+
[![Test Coverage](https://automate-api.hausgold.de/v1/coverage_reports/immoscout/coverage.svg)](https://knowledge.hausgold.de/coverage)
|
6
|
+
[![Test Ratio](https://automate-api.hausgold.de/v1/coverage_reports/immoscout/ratio.svg)](https://knowledge.hausgold.de/coverage)
|
7
|
+
[![API docs](https://automate-api.hausgold.de/v1/coverage_reports/immoscout/documentation.svg)](https://www.rubydoc.info/gems/immoscout)
|
8
8
|
|
9
9
|
This gem provides an API wrapper for the [Immobilienscout24 REST
|
10
10
|
API](https://api.immobilienscout24.de/our-apis/import-export.html). It provides
|
data/Rakefile
CHANGED
@@ -1,8 +1,77 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
require 'rails/code_statistics'
|
6
|
+
require 'pp'
|
5
7
|
|
6
8
|
RSpec::Core::RakeTask.new(:spec)
|
7
9
|
|
8
10
|
task default: :spec
|
11
|
+
|
12
|
+
# Load some railties tasks
|
13
|
+
load 'rails/tasks/statistics.rake'
|
14
|
+
load 'rails/tasks/annotations.rake'
|
15
|
+
|
16
|
+
# Clear the default statistics directory constant
|
17
|
+
#
|
18
|
+
# rubocop:disable Style/MutableConstant because we define it
|
19
|
+
Object.send(:remove_const, :STATS_DIRECTORIES)
|
20
|
+
::STATS_DIRECTORIES = []
|
21
|
+
# rubocop:enable Style/MutableConstant
|
22
|
+
|
23
|
+
# Monkey patch the Rails +CodeStatistics+ class to support configurable
|
24
|
+
# patterns per path. This is reuqired to support top-level only file matches.
|
25
|
+
class CodeStatistics
|
26
|
+
DEFAULT_PATTERN = /^(?!\.).*?\.(rb|js|coffee|rake)$/.freeze
|
27
|
+
|
28
|
+
# Pass the possible +pattern+ argument down to the
|
29
|
+
# +calculate_directory_statistics+ method call.
|
30
|
+
def calculate_statistics
|
31
|
+
Hash[@pairs.map do |pair|
|
32
|
+
[pair.first, calculate_directory_statistics(*pair[1..-1])]
|
33
|
+
end]
|
34
|
+
end
|
35
|
+
|
36
|
+
# Match the pattern against the individual file name and the relative file
|
37
|
+
# path. This allows top-level only matches.
|
38
|
+
def calculate_directory_statistics(directory, pattern = DEFAULT_PATTERN)
|
39
|
+
stats = CodeStatisticsCalculator.new
|
40
|
+
|
41
|
+
Dir.foreach(directory) do |file_name|
|
42
|
+
path = "#{directory}/#{file_name}"
|
43
|
+
|
44
|
+
if File.directory?(path) && (/^\./ !~ file_name)
|
45
|
+
stats.add(calculate_directory_statistics(path, pattern))
|
46
|
+
elsif file_name =~ pattern || path =~ pattern
|
47
|
+
stats.add_by_file_path(path)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
stats
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# Configure all code statistics directories
|
56
|
+
vendors = [
|
57
|
+
[:unshift, 'Top-levels', 'lib', %r{lib(/immoscout)?/[^/]+\.rb$}],
|
58
|
+
[:unshift, 'Top-levels specs', 'spec', %r{spec/_spec\.rb$}],
|
59
|
+
|
60
|
+
[:unshift, 'API', 'lib/immoscout/api'],
|
61
|
+
[:unshift, 'Errors', 'lib/immoscout/errors'],
|
62
|
+
|
63
|
+
[:unshift, 'Models', 'lib/immoscout/models'],
|
64
|
+
[:unshift, 'Models specs', 'spec/models']
|
65
|
+
].reverse
|
66
|
+
|
67
|
+
vendors.each do |method, type, dir, pattern|
|
68
|
+
::STATS_DIRECTORIES.send(method, [type, dir, pattern].compact)
|
69
|
+
::CodeStatistics::TEST_TYPES << type if type.include? 'specs'
|
70
|
+
end
|
71
|
+
|
72
|
+
# Setup annotations
|
73
|
+
ENV['SOURCE_ANNOTATION_DIRECTORIES'] = 'spec,doc'
|
74
|
+
desc 'Enumerate all annotations'
|
75
|
+
task :notes do
|
76
|
+
SourceAnnotationExtractor.enumerate '@?OPTIMIZE|@?FIXME|@?TODO', tag: true
|
77
|
+
end
|
data/gemfiles/rails_5.2.gemfile
CHANGED
data/gemfiles/rails_6.0.gemfile
CHANGED
data/immoscout.gemspec
CHANGED
@@ -41,7 +41,7 @@ Gem::Specification.new do |spec|
|
|
41
41
|
spec.add_development_dependency 'appraisal'
|
42
42
|
spec.add_development_dependency 'bundler', '>= 1.16', '< 3'
|
43
43
|
spec.add_development_dependency 'factory_bot', '~> 4.11'
|
44
|
-
spec.add_development_dependency 'railties', '>= 4.2.0'
|
44
|
+
spec.add_development_dependency 'railties', '>= 4.2.0', '< 6.1'
|
45
45
|
spec.add_development_dependency 'rake', '~> 10.0'
|
46
46
|
spec.add_development_dependency 'rdoc', '~> 6.1'
|
47
47
|
spec.add_development_dependency 'redcarpet', '~> 3.4'
|
@@ -49,7 +49,7 @@ Gem::Specification.new do |spec|
|
|
49
49
|
spec.add_development_dependency 'rspec-json_expectations', '~> 1.4'
|
50
50
|
spec.add_development_dependency 'rubocop', '~> 0.63.1'
|
51
51
|
spec.add_development_dependency 'rubocop-rspec', '~> 1.31'
|
52
|
-
spec.add_development_dependency 'simplecov', '
|
52
|
+
spec.add_development_dependency 'simplecov', '< 0.18'
|
53
53
|
spec.add_development_dependency 'terminal-table', '~> 1.8'
|
54
54
|
spec.add_development_dependency 'timecop', '~> 0.9.1'
|
55
55
|
spec.add_development_dependency 'vcr', '~> 3.0'
|
data/lib/immoscout/api/client.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Immoscout
|
2
4
|
module Api
|
3
5
|
module Request
|
@@ -17,19 +19,21 @@ module Immoscout
|
|
17
19
|
request(:delete, path, payload, multipart)
|
18
20
|
end
|
19
21
|
|
22
|
+
# rubocop:disable Metrics/MethodLength because of the header handling
|
20
23
|
def request(method, path, payload = nil, multipart = nil)
|
21
24
|
connection.send(method, path, multipart) do |request|
|
22
25
|
if multipart
|
23
|
-
request.headers['Content-Type'] =
|
26
|
+
request.headers['Content-Type'] = 'multipart/form-data'
|
24
27
|
else
|
25
28
|
request.body = payload if payload
|
26
|
-
request.headers['Content-Type'] =
|
29
|
+
request.headers['Content-Type'] = 'application/json;charset=UTF-8'
|
27
30
|
end
|
28
|
-
request.headers['Accept'] =
|
31
|
+
request.headers['Accept'] = 'application/json'
|
29
32
|
request.headers['User-Agent'] = \
|
30
33
|
"HausgoldImmoscout/#{Immoscout::VERSION}"
|
31
34
|
end
|
32
35
|
end
|
36
|
+
# rubocop:enable Metrics/MethodLength
|
33
37
|
end
|
34
38
|
end
|
35
39
|
end
|
@@ -3,24 +3,24 @@
|
|
3
3
|
module Immoscout
|
4
4
|
class Configuration
|
5
5
|
include ActiveSupport::Configurable
|
6
|
-
config_accessor(:consumer_key) { ENV[
|
7
|
-
config_accessor(:consumer_secret) { ENV[
|
6
|
+
config_accessor(:consumer_key) { ENV['IMMOSCOUT_CONSUMER_KEY'] }
|
7
|
+
config_accessor(:consumer_secret) { ENV['IMMOSCOUT_CONSUMER_SECRET'] }
|
8
8
|
|
9
|
-
config_accessor(:oauth_token) { ENV[
|
10
|
-
config_accessor(:oauth_token_secret) { ENV[
|
9
|
+
config_accessor(:oauth_token) { ENV['IMMOSCOUT_OAUTH_TOKEN'] }
|
10
|
+
config_accessor(:oauth_token_secret) { ENV['IMMOSCOUT_OAUTH_TOKEN_SECRET'] }
|
11
11
|
|
12
12
|
config_accessor(:use_sandbox) { false }
|
13
13
|
|
14
|
-
config_accessor(:api_version) {
|
14
|
+
config_accessor(:api_version) { 'v1.0' }
|
15
15
|
|
16
16
|
config_accessor(:user_name) { 'me' }
|
17
17
|
|
18
18
|
config_accessor(:api_url_live) do
|
19
|
-
|
19
|
+
'https://rest.immobilienscout24.de/' \
|
20
20
|
"restapi/api/offer/#{api_version}"
|
21
21
|
end
|
22
22
|
config_accessor(:api_url_sandbox) do
|
23
|
-
|
23
|
+
'https://rest.sandbox-immobilienscout24.de/' \
|
24
24
|
"restapi/api/offer/#{api_version}"
|
25
25
|
end
|
26
26
|
end
|
@@ -1,6 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'json'
|
2
4
|
require_relative '../concerns/modelable'
|
3
5
|
|
6
|
+
# rubocop:disable Metrics/BlockLength because this is how an ActiveSupport
|
7
|
+
# concern looks like
|
4
8
|
module Immoscout
|
5
9
|
module Models
|
6
10
|
module Actions
|
@@ -12,11 +16,14 @@ module Immoscout
|
|
12
16
|
|
13
17
|
self.unpack_collection = proc do |hash|
|
14
18
|
hash
|
15
|
-
.fetch(
|
19
|
+
.fetch('common.attachments')
|
16
20
|
.first
|
17
|
-
.fetch(
|
21
|
+
.fetch('attachment')
|
18
22
|
end
|
19
23
|
|
24
|
+
# rubocop:disable Metrics/AbcSize because this is the
|
25
|
+
# bare minimum logic
|
26
|
+
# rubocop:disable Metrics/MethodLength dito
|
20
27
|
def save
|
21
28
|
attachable_id = attachable.try(:id) || attachable
|
22
29
|
response = api.post(
|
@@ -33,11 +40,15 @@ module Immoscout
|
|
33
40
|
self.id = id_from_response(response)
|
34
41
|
self
|
35
42
|
end
|
43
|
+
# rubocop:enable Metrics/AbcSize
|
44
|
+
# rubocop:enable Metrics/MethodLength
|
36
45
|
|
37
46
|
def destroy
|
38
47
|
attachable_id = attachable.try(:id) || attachable
|
39
48
|
response = api.delete(
|
40
|
-
"user/#{api.user_name}/
|
49
|
+
"user/#{api.user_name}/" \
|
50
|
+
"realestate/#{attachable_id}/" \
|
51
|
+
"attachment/#{id}"
|
41
52
|
)
|
42
53
|
handle_response(response)
|
43
54
|
self
|
@@ -61,14 +72,15 @@ module Immoscout
|
|
61
72
|
class_methods do
|
62
73
|
def content_type_from_extension(ext)
|
63
74
|
{
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
75
|
+
'.jpg' => 'image/jpeg',
|
76
|
+
'.jpeg' => 'image/jpeg',
|
77
|
+
'.gif' => 'image/gif',
|
78
|
+
'.png' => 'image/png',
|
79
|
+
'.pdf' => 'application/pdf'
|
69
80
|
}.fetch(ext)
|
70
81
|
end
|
71
82
|
|
83
|
+
# rubocop:disable Metrics/AbcSize because of the mapping logic
|
72
84
|
def all(real_estate_id)
|
73
85
|
response = api.get(
|
74
86
|
"user/#{api.user_name}/realestate/#{real_estate_id}/attachment"
|
@@ -79,8 +91,10 @@ module Immoscout
|
|
79
91
|
.map { |object| new(object) }
|
80
92
|
.select { |object| object.type =~ /#{name.demodulize}/i }
|
81
93
|
end
|
94
|
+
# rubocop:enable Metrics/AbcSize
|
82
95
|
end
|
83
96
|
end
|
84
97
|
end
|
85
98
|
end
|
86
99
|
end
|
100
|
+
# rubocop:enable Metrics/BlockLength
|
@@ -1,6 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'json'
|
2
4
|
require_relative '../concerns/modelable'
|
3
5
|
|
6
|
+
# rubocop:disable Metrics/BlockLength because this is how an ActiveSupport
|
7
|
+
# concern looks like
|
4
8
|
module Immoscout
|
5
9
|
module Models
|
6
10
|
module Actions
|
@@ -12,10 +16,12 @@ module Immoscout
|
|
12
16
|
|
13
17
|
self.unpack_collection = proc do |hash|
|
14
18
|
hash
|
15
|
-
.fetch(
|
16
|
-
.fetch(
|
19
|
+
.fetch('common.realtorContactDetailsList', {})
|
20
|
+
.fetch('realtorContactDetails', nil)
|
17
21
|
end
|
18
22
|
|
23
|
+
# rubocop:disable Metrics/AbcSize because this is the
|
24
|
+
# bare minimum logic
|
19
25
|
def save
|
20
26
|
response = \
|
21
27
|
if id
|
@@ -28,6 +34,7 @@ module Immoscout
|
|
28
34
|
self.id = id_from_response(response) unless id
|
29
35
|
self
|
30
36
|
end
|
37
|
+
# rubocop:enable Metrics/AbcSize
|
31
38
|
|
32
39
|
def destroy
|
33
40
|
response = api.delete("user/#{api.user_name}/contact/#{id}")
|
@@ -73,3 +80,4 @@ module Immoscout
|
|
73
80
|
end
|
74
81
|
end
|
75
82
|
end
|
83
|
+
# rubocop:enable Metrics/BlockLength
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'json'
|
2
4
|
require_relative '../concerns/modelable'
|
3
5
|
|
@@ -11,7 +13,7 @@ module Immoscout
|
|
11
13
|
include Immoscout::Models::Concerns::Modelable
|
12
14
|
|
13
15
|
def save
|
14
|
-
response = api.post(
|
16
|
+
response = api.post('publish', as_json)
|
15
17
|
handle_response(response)
|
16
18
|
self
|
17
19
|
end
|
@@ -1,6 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'json'
|
2
4
|
require_relative '../concerns/modelable'
|
3
5
|
|
6
|
+
# rubocop:disable Metrics/BlockLength because this is how an ActiveSupport
|
7
|
+
# concern looks like
|
4
8
|
module Immoscout
|
5
9
|
module Models
|
6
10
|
module Actions
|
@@ -12,11 +16,13 @@ module Immoscout
|
|
12
16
|
|
13
17
|
self.unpack_collection = proc do |hash|
|
14
18
|
hash
|
15
|
-
.fetch(
|
16
|
-
.fetch(
|
17
|
-
.fetch(
|
19
|
+
.fetch('realestates.realEstates', {})
|
20
|
+
.fetch('realEstateList', {})
|
21
|
+
.fetch('realEstateElement', nil)
|
18
22
|
end
|
19
23
|
|
24
|
+
# rubocop:disable Metrics/AbcSize because this is the
|
25
|
+
# bare minimum logic
|
20
26
|
def save
|
21
27
|
response = \
|
22
28
|
if id
|
@@ -29,6 +35,7 @@ module Immoscout
|
|
29
35
|
self.id = id_from_response(response) unless id
|
30
36
|
self
|
31
37
|
end
|
38
|
+
# rubocop:enable Metrics/AbcSize
|
32
39
|
|
33
40
|
def destroy
|
34
41
|
response = api.delete("user/#{api.user_name}/realestate/#{id}")
|
@@ -93,6 +100,7 @@ module Immoscout
|
|
93
100
|
find("ext-#{external_id}")
|
94
101
|
end
|
95
102
|
|
103
|
+
# rubocop:disable Metrics/AbcSize because of the mapping logic
|
96
104
|
def all
|
97
105
|
response = api.get("user/#{api.user_name}/realestate")
|
98
106
|
handle_response(response)
|
@@ -101,6 +109,7 @@ module Immoscout
|
|
101
109
|
.map { |object| new(object) }
|
102
110
|
.select { |object| object.type =~ /#{name.demodulize}/i }
|
103
111
|
end
|
112
|
+
# rubocop:enable Metrics/AbcSize
|
104
113
|
|
105
114
|
def first
|
106
115
|
all.first
|
@@ -120,3 +129,4 @@ module Immoscout
|
|
120
129
|
end
|
121
130
|
end
|
122
131
|
end
|
132
|
+
# rubocop:enable Metrics/BlockLength
|
@@ -17,7 +17,7 @@ module Immoscout
|
|
17
17
|
include Immoscout::Models::Concerns::Propertiable
|
18
18
|
include Immoscout::Models::Actions::RealEstate
|
19
19
|
|
20
|
-
self.json_wrapper =
|
20
|
+
self.json_wrapper = 'realestates.apartmentBuy'
|
21
21
|
|
22
22
|
property :id, alias: :@id
|
23
23
|
property :external_id
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'json'
|
2
4
|
|
3
5
|
module Immoscout
|
@@ -37,16 +39,17 @@ module Immoscout
|
|
37
39
|
|
38
40
|
def handle_response(response)
|
39
41
|
return response if response.success?
|
42
|
+
|
40
43
|
raise Immoscout::Errors::Failed, response
|
41
44
|
end
|
42
45
|
|
43
46
|
def id_from_response(response)
|
44
47
|
response
|
45
48
|
.body
|
46
|
-
.fetch(
|
49
|
+
.fetch('common.messages')
|
47
50
|
.first
|
48
|
-
.fetch(
|
49
|
-
.fetch(
|
51
|
+
.fetch('message', {})
|
52
|
+
.fetch('id', nil)
|
50
53
|
end
|
51
54
|
end
|
52
55
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Immoscout
|
2
4
|
module Models
|
3
5
|
module Concerns
|
@@ -16,7 +18,8 @@ module Immoscout
|
|
16
18
|
match = Regexp.last_match(1).intern
|
17
19
|
properties = self.class.properties
|
18
20
|
coerce_klass = properties.fetch(match).fetch(:coerce, nil)
|
19
|
-
return super if !properties.
|
21
|
+
return super if !properties.key?(match) || !coerce_klass
|
22
|
+
|
20
23
|
send("#{match}=", coerce_klass.new)
|
21
24
|
else
|
22
25
|
super
|
@@ -1,5 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'json'
|
2
4
|
|
5
|
+
# rubocop:disable Metrics/BlockLength because this is how an ActiveSupport
|
6
|
+
# concern looks like
|
3
7
|
module Immoscout
|
4
8
|
module Models
|
5
9
|
module Concerns
|
@@ -22,11 +26,16 @@ module Immoscout
|
|
22
26
|
self.class.try(:json_wrapper)
|
23
27
|
end
|
24
28
|
|
29
|
+
# rubocop:disable Metrics/PerceivedComplexity because this is the
|
30
|
+
# bare minimum logic
|
31
|
+
# rubocop:disable Metrics/MethodLength dito
|
32
|
+
# rubocop:disable Metrics/CyclomaticComplexity dito
|
25
33
|
def to_h
|
26
34
|
self.class.properties.each_with_object({}) do |(key, value), memo|
|
27
35
|
# skip if it's readonly and should not be exposed in #as_json
|
28
36
|
readonly = value.fetch(:readonly, false)
|
29
37
|
next if readonly.try(:call, self) || readonly == true
|
38
|
+
|
30
39
|
# use :alias instead of key as json-key
|
31
40
|
property = value.fetch(:alias, key)
|
32
41
|
# use :default if present AND value is nil
|
@@ -42,6 +51,9 @@ module Immoscout
|
|
42
51
|
memo
|
43
52
|
end
|
44
53
|
end
|
54
|
+
# rubocop:enable Metrics/PerceivedComplexity
|
55
|
+
# rubocop:enable Metrics/MethodLength
|
56
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
45
57
|
|
46
58
|
def to_json_wrapped
|
47
59
|
{ self.class.try(:json_wrapper) => to_json_unwrapped }
|
@@ -61,3 +73,4 @@ module Immoscout
|
|
61
73
|
end
|
62
74
|
end
|
63
75
|
end
|
76
|
+
# rubocop:enable Metrics/BlockLength
|
@@ -12,7 +12,7 @@ module Immoscout
|
|
12
12
|
include Immoscout::Models::Concerns::Propertiable
|
13
13
|
include Immoscout::Models::Actions::Contact
|
14
14
|
|
15
|
-
self.json_wrapper =
|
15
|
+
self.json_wrapper = 'common.realtorContactDetail'
|
16
16
|
|
17
17
|
property :id, alias: :@id
|
18
18
|
property :email
|
@@ -19,7 +19,7 @@ module Immoscout
|
|
19
19
|
include Immoscout::Models::Concerns::Propertiable
|
20
20
|
include Immoscout::Models::Actions::RealEstate
|
21
21
|
|
22
|
-
self.json_wrapper =
|
22
|
+
self.json_wrapper = 'realestates.houseBuy'
|
23
23
|
|
24
24
|
property :id, alias: :@id
|
25
25
|
property :external_id
|
@@ -14,10 +14,10 @@ module Immoscout
|
|
14
14
|
|
15
15
|
attr_accessor :attachable, :file
|
16
16
|
|
17
|
-
self.json_wrapper =
|
17
|
+
self.json_wrapper = 'common.attachment'
|
18
18
|
|
19
19
|
property :id, alias: :@id
|
20
|
-
property :type, alias: :'@xsi.type', default:
|
20
|
+
property :type, alias: :'@xsi.type', default: 'common:Picture'
|
21
21
|
property :href, alias: :'@xlink.href'
|
22
22
|
property :publish_date, alias: :@publish_date
|
23
23
|
property :creation, alias: :@creation
|
@@ -13,7 +13,7 @@ module Immoscout
|
|
13
13
|
include Immoscout::Models::Concerns::Propertiable
|
14
14
|
include Immoscout::Models::Actions::Publish
|
15
15
|
|
16
|
-
self.json_wrapper =
|
16
|
+
self.json_wrapper = 'common.publishObject'
|
17
17
|
|
18
18
|
property :real_estate, coerce: Immoscout::Models::Parts::RealEstate
|
19
19
|
property :publish_channel,
|
data/lib/immoscout/models.rb
CHANGED
data/lib/immoscout/version.rb
CHANGED
data/lib/immoscout.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: immoscout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcus Geissler
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -121,6 +121,9 @@ dependencies:
|
|
121
121
|
- - ">="
|
122
122
|
- !ruby/object:Gem::Version
|
123
123
|
version: 4.2.0
|
124
|
+
- - "<"
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '6.1'
|
124
127
|
type: :development
|
125
128
|
prerelease: false
|
126
129
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -128,6 +131,9 @@ dependencies:
|
|
128
131
|
- - ">="
|
129
132
|
- !ruby/object:Gem::Version
|
130
133
|
version: 4.2.0
|
134
|
+
- - "<"
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '6.1'
|
131
137
|
- !ruby/object:Gem::Dependency
|
132
138
|
name: rake
|
133
139
|
requirement: !ruby/object:Gem::Requirement
|
@@ -230,16 +236,16 @@ dependencies:
|
|
230
236
|
name: simplecov
|
231
237
|
requirement: !ruby/object:Gem::Requirement
|
232
238
|
requirements:
|
233
|
-
- - "
|
239
|
+
- - "<"
|
234
240
|
- !ruby/object:Gem::Version
|
235
|
-
version: '0.
|
241
|
+
version: '0.18'
|
236
242
|
type: :development
|
237
243
|
prerelease: false
|
238
244
|
version_requirements: !ruby/object:Gem::Requirement
|
239
245
|
requirements:
|
240
|
-
- - "
|
246
|
+
- - "<"
|
241
247
|
- !ruby/object:Gem::Version
|
242
|
-
version: '0.
|
248
|
+
version: '0.18'
|
243
249
|
- !ruby/object:Gem::Dependency
|
244
250
|
name: terminal-table
|
245
251
|
requirement: !ruby/object:Gem::Requirement
|
@@ -332,12 +338,14 @@ extensions: []
|
|
332
338
|
extra_rdoc_files: []
|
333
339
|
files:
|
334
340
|
- ".editorconfig"
|
341
|
+
- ".github/workflows/documentation.yml"
|
342
|
+
- ".github/workflows/test.yml"
|
335
343
|
- ".gitignore"
|
336
344
|
- ".reek"
|
337
345
|
- ".rspec"
|
338
346
|
- ".rubocop.yml"
|
339
347
|
- ".simplecov"
|
340
|
-
- ".
|
348
|
+
- ".yardopts"
|
341
349
|
- Appraisals
|
342
350
|
- CHANGELOG.md
|
343
351
|
- CODE_OF_CONDUCT.md
|
data/.travis.yml
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
sudo: false
|
2
|
-
|
3
|
-
env:
|
4
|
-
global:
|
5
|
-
- CC_TEST_REPORTER_ID=8615a2f049e99efe606a9121e6344b8d9139390648425cb3a0175696e000670d
|
6
|
-
|
7
|
-
language: ruby
|
8
|
-
rvm:
|
9
|
-
- 2.7
|
10
|
-
- 2.6
|
11
|
-
- 2.5
|
12
|
-
|
13
|
-
gemfile:
|
14
|
-
- gemfiles/rails_5.2.gemfile
|
15
|
-
- gemfiles/rails_6.0.gemfile
|
16
|
-
|
17
|
-
before_install: gem install bundler
|
18
|
-
before_script:
|
19
|
-
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
20
|
-
- chmod +x ./cc-test-reporter
|
21
|
-
- ./cc-test-reporter before-build
|
22
|
-
after_script:
|
23
|
-
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|