justimmo_client 0.4.6 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3e15b372bb14b581f41d8d71b5f9886c7c8240c3
4
- data.tar.gz: f31c58d987586ce4c2cef6aee84b8cf84a0ebd3f
3
+ metadata.gz: b165d1e85b2806d6a48d4549205b005bdb24ae3d
4
+ data.tar.gz: 9095e7b611ba1ba1d3cc9b2fc9d9fe5bde5dd66f
5
5
  SHA512:
6
- metadata.gz: 9d5ac18de60aa2c2c498c79a8fedacf7a801f273df5ce89be60ef78e9b10246c37f460970f8f3188a0d554b06134105782461fcc2f08177d631739fb5dabadaa
7
- data.tar.gz: 93ae8c831522281f4db7e7e7cfcc6c586a4377bab9fad325626992ab5f7a7d1983dd0801d2993cfc0a402a695606d943cdaf4cdce4c9004234457a7208f94d81
6
+ metadata.gz: 81adda6c7d8369c9f7b8750e9436b23311a7b9c2358ec464cdced91bd83fbbfd1beac8fde7857ad905aa9d981867361ab1abcb2f66e4c71e77b17c2807c9ec7c
7
+ data.tar.gz: e09286bf5cc8089d57153396677bbe8fc561fb135a2ac6552c35f7cab68554d92ea6ac567ad78d34e177f3eb06c504252a2319b9995ccfe86fa23a6b000c20be
data/.gitlab-ci.yml CHANGED
@@ -1,46 +1,99 @@
1
- .test_job: &test_job
2
- environment: testing
1
+ image: "ruby:2.4"
2
+
3
+ stages:
4
+ - prepare
5
+ - test
6
+ - deploy
7
+
8
+ # Templates
9
+
10
+ .ruby_2_4_cache: &ruby_2_4_cache
3
11
  cache:
12
+ key: "$CI_COMMIT_REF_NAME-ruby_2_4"
4
13
  paths:
5
- - cache/bundler
6
- before_script:
7
- - bundle install --without development -j $(nproc) --path=cache/bundler
14
+ - vendor/bundle
15
+
16
+ .ruby_2_3_cache: &ruby_2_3_cache
17
+ cache:
18
+ key: "$CI_COMMIT_REF_NAME-ruby_2_3"
19
+ paths:
20
+ - vendor/bundle
21
+
22
+ .pull_cache: &pull_cache
23
+ cache:
24
+ policy: pull
25
+
26
+ .push_cache: &push_cache
27
+ cache:
28
+ policy: push
29
+
30
+ .ruby_2_3: &ruby_2_3
31
+ image: "ruby:2.3"
32
+ <<: *ruby_2_3_cache
33
+
34
+ .ruby_2_4: &ruby_2_4
35
+ image: "ruby:2.4"
36
+ <<: *ruby_2_4_cache
37
+
38
+ .test_job: &test_job
39
+ <<: *pull_cache
40
+ variables:
41
+ BUNDLE_PATH: "vendor/bundle"
42
+ stage: test
43
+ environment: testing
44
+
45
+ .prepare_job: &prepare_job
46
+ <<: *push_cache
47
+ variables:
48
+ BUNDLE_PATH: "vendor/bundle"
49
+ stage: prepare
50
+ script:
51
+ - bundle install -j $(nproc)
8
52
  tags:
9
53
  - ruby
10
54
 
11
- .test_job_2_3: &test_job_2_3
12
- image: 'ruby:2.3'
13
- <<: *test_job
55
+ # Jobs: Prepare
14
56
 
15
- .test_job_2_4: &test_job_2_4
16
- image: 'ruby:2.4'
17
- <<: *test_job
57
+ prepare:bundler_2_4:
58
+ <<: *prepare_job
59
+ <<: *ruby_2_4
18
60
 
19
- test:rubocop_2_3:
20
- <<: *test_job_2_3
21
- script: bundle exec rubocop
22
- only:
23
- - dev
61
+ prepare:bundler_2_3:
62
+ <<: *prepare_job
63
+ <<: *ruby_2_3
64
+
65
+ # Jobs: Test
24
66
 
25
- test:rubocop_2_4:
26
- <<: *test_job_2_4
27
- script: bundle exec rubocop
67
+ test:rubocop:
68
+ <<: *test_job
69
+ <<: *ruby_2_4
70
+ script:
71
+ - bundle exec rubocop
28
72
  only:
29
73
  - dev
74
+ tags:
75
+ - ruby
30
76
 
31
77
  test:rspec_2_3:
32
- <<: *test_job_2_3
33
- script: bundle exec rspec
34
- artifacts:
35
- paths:
36
- - coverage/
78
+ <<: *test_job
79
+ <<: *ruby_2_3
80
+ script:
81
+ - bundle exec rspec
82
+ tags:
83
+ - ruby
37
84
 
38
85
  test:rspec_2_4:
39
- <<: *test_job_2_4
40
- script: bundle exec rspec
86
+ <<: *test_job
87
+ <<: *ruby_2_4
88
+ script:
89
+ - bundle exec rspec
41
90
  artifacts:
42
91
  paths:
43
92
  - coverage/
93
+ tags:
94
+ - ruby
95
+
96
+ # Jobs: deploy
44
97
 
45
98
  pages:
46
99
  stage: deploy
@@ -57,8 +110,6 @@ pages:
57
110
 
58
111
  deploy:rubygems:
59
112
  stage: deploy
60
- dependencies:
61
- - test:rspec_2_4
62
113
  before_script:
63
114
  - gem install dpl
64
115
  script:
@@ -1,14 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module JustimmoClient
3
+ module JustimmoClient::V1
4
4
  # Public employee query interface
5
- module Employee
5
+ module EmployeeInterface
6
6
  extend JustimmoClient::Utils
7
7
 
8
8
  module_function
9
9
 
10
- # Retrieve a list of employee data.
11
- # @return [Array<Object>]
10
+ # @return [Array<Employee>]
12
11
  def list
13
12
  xml_response = request(:employee).list
14
13
  model = Struct.new(:employees).new
@@ -17,9 +16,7 @@ module JustimmoClient
17
16
  []
18
17
  end
19
18
 
20
- # Retrieve detailed information about a single employee.
21
- # @param id [Integer] The ID of the employee
22
- # @return [Object]
19
+ # @return [Employee]
23
20
  def detail(id)
24
21
  xml_response = request(:employee).detail(id)
25
22
  model = model(:employee).new
@@ -28,7 +25,7 @@ module JustimmoClient
28
25
  nil
29
26
  end
30
27
 
31
- # @return [Array<Integer>] An array of employee IDs
28
+ # @return [Array<Integer>]
32
29
  def ids
33
30
  json_response = request(:employee).ids
34
31
  ::JSON.parse(json_response).map(&:to_i)
@@ -2,9 +2,9 @@
2
2
 
3
3
  require "json"
4
4
 
5
- module JustimmoClient
5
+ module JustimmoClient::V1
6
6
  # Public realty query interface
7
- module Realty
7
+ module RealtyInterface
8
8
  extend JustimmoClient::Utils
9
9
 
10
10
  module_function
@@ -53,9 +53,7 @@ module JustimmoClient
53
53
  # @option options [DateTime] :updated_at_min
54
54
  # @option options [DateTime] :updated_at_max
55
55
  # @option options [String] :location
56
- # @example Filter by zip code and limit to three results.
57
- # JustimmoClient::Realty.list(zip_code: 6800, limit: 3)
58
- # @return [Array<Object>] An array of basic realty objects, or an empty array on error.
56
+ # @return [Array<Realty>] An array of basic realty objects, or an empty array on error.
59
57
  def list(options = {})
60
58
  xml_response = request(:realty).list(options)
61
59
  model = Struct.new(:realties).new
@@ -66,7 +64,7 @@ module JustimmoClient
66
64
 
67
65
  # @param [Integer] id
68
66
  # @param [Symbol, String] lang
69
- # @return [Object, nil] A detailed realty object, or nil if it could not be found.
67
+ # @return [Realty, nil] A detailed realty object, or nil if it could not be found.
70
68
  def detail(id, lang: nil)
71
69
  xml_response = request(:realty).detail(id, lang: lang)
72
70
  model = Struct.new(:realty).new
@@ -76,12 +74,12 @@ module JustimmoClient
76
74
  end
77
75
 
78
76
  # @see list
79
- # @return [Array<Object>] An array of detailed realty objects, or an empty array on error.
77
+ # @return [Array<Realty>] An array of detailed realty objects, or an empty array on error.
80
78
  def details(options = {})
81
79
  ids(options).map { |id| detail(id) }
82
80
  end
83
81
 
84
- # @see list
82
+ # @option (see list)
85
83
  # @return [Array<Integer>] An array of realty ids, empty array if no results.
86
84
  def ids(options = {})
87
85
  json_response = request(:realty).ids(options)
@@ -91,7 +89,7 @@ module JustimmoClient
91
89
  end
92
90
 
93
91
  # @option options [Boolean] :all (false)
94
- # @return [Array<Object>]
92
+ # @return [Array<RealtyCategory>]
95
93
  def categories(options = {})
96
94
  xml_response = request(:realty).categories(options)
97
95
  representer(:realty_category).for_collection.new([]).from_xml(xml_response)
@@ -100,7 +98,7 @@ module JustimmoClient
100
98
  end
101
99
 
102
100
  # @option options [Boolean] :all (false)
103
- # @return [Array<Object>]
101
+ # @return [Array<RealtyType>]
104
102
  def types(options = {})
105
103
  xml_response = request(:realty).types(options)
106
104
  representer(:realty_type).for_collection.new([]).from_xml(xml_response)
@@ -109,7 +107,7 @@ module JustimmoClient
109
107
  end
110
108
 
111
109
  # @option options [Boolean] :all (false)
112
- # @return [Array<Object>]
110
+ # @return [Array<Country>]
113
111
  def countries(options = {})
114
112
  xml_response = request(:realty).countries(options)
115
113
  representer(:country).for_collection.new([]).from_xml(xml_response)
@@ -119,7 +117,7 @@ module JustimmoClient
119
117
 
120
118
  # @option options [Boolean] :all (false)
121
119
  # @option options [Integer] :country (nil)
122
- # @return [Array<Object>]
120
+ # @return [Array<FederalState>]
123
121
  def federal_states(options = {})
124
122
  xml_response = request(:realty).federal_states(options)
125
123
  representer(:federal_state).for_collection.new([]).from_xml(xml_response)
@@ -130,7 +128,7 @@ module JustimmoClient
130
128
  # @option options [Boolean] :all (false)
131
129
  # @option options [Integer] :country (nil)
132
130
  # @option options [Integer] :federal_state (nil)
133
- # @return [Array<Object>]
131
+ # @return [Array<Region>]
134
132
  def regions(options = {})
135
133
  xml_response = request(:realty).regions(options)
136
134
  representer(:region).for_collection.new([]).from_xml(xml_response)
@@ -141,7 +139,7 @@ module JustimmoClient
141
139
  # @option options [Boolean] :all (false)
142
140
  # @option options [Integer] :country (nil)
143
141
  # @option options [Integer] :federal_state (nil)
144
- # @return [Array<Object>]
142
+ # @return [Array<City>]
145
143
  def zip_codes_and_cities(options = {})
146
144
  xml_response = request(:realty).zip_codes_and_cities(options)
147
145
  representer(:city).for_collection.new([]).from_xml(xml_response)
@@ -176,7 +176,7 @@ module JustimmoClient::V1
176
176
  f.add :type do |key, *values|
177
177
  values = [values].flatten.map(&:to_sym)
178
178
  log.debug(values)
179
- types = JustimmoClient::Realty.types
179
+ types = RealtyInterface.types
180
180
  [:type_id, types.select { |x| values.include?(x.name) }.map(&:id)]
181
181
  end
182
182
  f.add :sub_type_id
@@ -209,7 +209,7 @@ module JustimmoClient::V1
209
209
  f.add :updated_at_min, as: :aktualisiert_am_von
210
210
  f.add :updated_at_max, as: :aktualisiert_am_bis
211
211
  f.add :location do |key, value|
212
- cities = JustimmoClient::Realty.zip_codes_and_cities
212
+ cities = RealtyInterface.zip_codes_and_cities
213
213
  [:zip_code, cities.select { |x| x.location == value }.first&.zip_code]
214
214
  end
215
215
  end
@@ -12,5 +12,6 @@ module JustimmoClient
12
12
  autoload_dir "#{API_PATH}/models/*.rb"
13
13
  autoload_dir "#{API_PATH}/representers/*.rb"
14
14
  autoload_dir "#{API_PATH}/requests/*_request.rb"
15
+ autoload_dir "#{API_PATH}/interfaces/*_interface.rb"
15
16
  end
16
17
  end
@@ -11,7 +11,5 @@ module JustimmoClient
11
11
  autoload :Logging, "justimmo_client/core/logging"
12
12
  autoload :Utils, "justimmo_client/core/utils"
13
13
  autoload :Caching, "justimmo_client/core/caching"
14
- autoload :Realty, "justimmo_client/realty"
15
- autoload :Employee, "justimmo_client/employee"
16
14
  autoload :OptionParser, "justimmo_client/option_parser"
17
15
  end
@@ -34,5 +34,9 @@ module JustimmoClient
34
34
  def request(name)
35
35
  versioned_api("#{name.to_s.classify}Request")
36
36
  end
37
+
38
+ def interface(name)
39
+ versioned_api("#{name.to_s.classify}Interface")
40
+ end
37
41
  end
38
42
  end
@@ -0,0 +1,98 @@
1
+ module JustimmoClient
2
+ extend JustimmoClient::Utils
3
+
4
+ module_function
5
+
6
+ # @!group Realty
7
+
8
+ # Get a list of realty objects with limited information.
9
+ # @see V1::RealtyInterface.list query parameters (API Version 1)
10
+ # @option (see V1::RealtyInterface.list)
11
+ # @example Filter by zip code and limit to three results.
12
+ # JustimmoClient.realties(zip_code: 6800, limit: 3)
13
+ # @return (see V1::RealtyInterface.list)
14
+ def realties(**options)
15
+ interface(:realty).list(options)
16
+ end
17
+
18
+ # Get detailed information about a single realty.
19
+ # @see V1::RealtyInterface.detail query parameters (API Version 1)
20
+ # @param (see V1::RealtyInterface.detail)
21
+ # @return (see V1::RealtyInterface.detail)
22
+ def realty(id, lang: nil)
23
+ interface(:realty).detail(id, lang: lang)
24
+ end
25
+
26
+ # Get a list of all realty ids.
27
+ # @see V1::RealtyInterface.ids query parameters (API Version 1)
28
+ # @option (see V1::RealtyInterface.ids)
29
+ # @return (see V1::RealtyInterface.ids)
30
+ def realty_ids(options = {})
31
+ interface(:realty).ids(options)
32
+ end
33
+
34
+ # @!group Employee
35
+
36
+ # Retrieve a list of employee data.
37
+ # @return (see V1::EmployeeInterface.list)
38
+ def employees
39
+ interface(:employee).list
40
+ end
41
+
42
+ # Retrieve detailed information about a single employee.
43
+ # @param (see V1::EmployeeInterface.detail)
44
+ # @return (see V1::EmployeeInterface.detail)
45
+ def employee(id)
46
+ interface(:employee).detail(id)
47
+ end
48
+
49
+ # Get a list of all employee IDs.
50
+ # @return (see V1::EmployeeInterface.ids)
51
+ def employee_ids
52
+ interface(:employee).ids
53
+ end
54
+
55
+ # @!group Basic Data
56
+
57
+ # Get a list of available categories.
58
+ # @see V1::RealtyInterface.categories query parameters (API Version 1)
59
+ # @return (see V1::RealtyInterface.categories)
60
+ def realty_categories(**options)
61
+ interface(:realty).categories(options)
62
+ end
63
+
64
+ # Get a list of available realty types.
65
+ # @see V1::RealtyInterface.types query parameters (API Version 1)
66
+ # @return (see V1::RealtyInterface.types)
67
+ def realty_types(**options)
68
+ interface(:realty).types(options)
69
+ end
70
+
71
+ # Get a list of countries.
72
+ # @see V1::RealtyInterface.countries query parameters (API Version 1)
73
+ # @return (see V1::RealtyInterface.countries)
74
+ def countries(**options)
75
+ interface(:realty).countries(options)
76
+ end
77
+
78
+ # Get a list of federal states.
79
+ # @see V1::RealtyInterface.federal_states query parameters (API Version 1)
80
+ # @return (see V1::RealtyInterface.federal_states)
81
+ def federal_states(**options)
82
+ interface(:realty).federal_states(options)
83
+ end
84
+
85
+ # Get a list of regions.
86
+ # @see V1::RealtyInterface.regions query parameters (API Version 1)
87
+ # @return (see V1::RealtyInterface.regions)
88
+ def regions(**options)
89
+ interface(:realty).regions(options)
90
+ end
91
+
92
+ # Get a list of cities and their zip codes.
93
+ # @see V1::RealtyInterface.zip_codes_and_cities query parameters (API Version 1)
94
+ # @return (see V1::RealtyInterface.zip_codes_and_cities)
95
+ def cities(**options)
96
+ interface(:realty).zip_codes_and_cities(options)
97
+ end
98
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JustimmoClient
4
- VERSION = "0.4.6"
4
+ VERSION = "0.5.0"
5
5
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "justimmo_client/autoload"
4
+ require "justimmo_client/interface"
4
5
 
5
6
  # The Justimmo API.
6
7
  module JustimmoClient
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: justimmo_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Auernig
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-15 00:00:00.000000000 Z
11
+ date: 2017-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -185,6 +185,8 @@ files:
185
185
  - justimmo_client.gemspec
186
186
  - lib/justimmo_client.rb
187
187
  - lib/justimmo_client/api/v1.rb
188
+ - lib/justimmo_client/api/v1/interfaces/employee_interface.rb
189
+ - lib/justimmo_client/api/v1/interfaces/realty_interface.rb
188
190
  - lib/justimmo_client/api/v1/models/city.rb
189
191
  - lib/justimmo_client/api/v1/models/country.rb
190
192
  - lib/justimmo_client/api/v1/models/employee.rb
@@ -236,11 +238,10 @@ files:
236
238
  - lib/justimmo_client/core/config.rb
237
239
  - lib/justimmo_client/core/logging.rb
238
240
  - lib/justimmo_client/core/utils.rb
239
- - lib/justimmo_client/employee.rb
240
241
  - lib/justimmo_client/errors.rb
242
+ - lib/justimmo_client/interface.rb
241
243
  - lib/justimmo_client/misc.rb
242
244
  - lib/justimmo_client/option_parser.rb
243
- - lib/justimmo_client/realty.rb
244
245
  - lib/justimmo_client/version.rb
245
246
  - notes.md
246
247
  homepage: https://gitlab.com/exacting/justimmo-client-ruby
@@ -263,7 +264,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
263
264
  version: '0'
264
265
  requirements: []
265
266
  rubyforge_project:
266
- rubygems_version: 2.6.12
267
+ rubygems_version: 2.6.14
267
268
  signing_key:
268
269
  specification_version: 4
269
270
  summary: API client for Justimmo