arbetsformedlingen 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +6 -0
  3. data/.ruby-style-guide.yml +270 -0
  4. data/.travis.yml +0 -1
  5. data/CHANGELOG.md +12 -0
  6. data/Gemfile +2 -0
  7. data/LICENSE.txt +1 -1
  8. data/README.md +1 -1
  9. data/Rakefile +2 -0
  10. data/arbetsformedlingen.gemspec +10 -9
  11. data/bin/console +1 -0
  12. data/lib/arbetsformedlingen/api/client.rb +48 -30
  13. data/lib/arbetsformedlingen/api/ledigtarbete_client.rb +6 -1
  14. data/lib/arbetsformedlingen/api/matchning_client.rb +16 -10
  15. data/lib/arbetsformedlingen/api/request.rb +10 -13
  16. data/lib/arbetsformedlingen/api/response.rb +71 -0
  17. data/lib/arbetsformedlingen/api/results/ad_result.rb +36 -18
  18. data/lib/arbetsformedlingen/api/results/matchning_result.rb +42 -3
  19. data/lib/arbetsformedlingen/api/results/soklista_result.rb +16 -2
  20. data/lib/arbetsformedlingen/api/soap_request.rb +11 -10
  21. data/lib/arbetsformedlingen/api/values/ad_result_values.rb +6 -1
  22. data/lib/arbetsformedlingen/api/values/create_ad_page.rb +3 -1
  23. data/lib/arbetsformedlingen/api/values/matchning_result_values.rb +9 -1
  24. data/lib/arbetsformedlingen/api/values/soklista_values.rb +17 -1
  25. data/lib/arbetsformedlingen/api/ws_occupation_client.rb +26 -1
  26. data/lib/arbetsformedlingen/codes/country_code.rb +3 -1
  27. data/lib/arbetsformedlingen/codes/drivers_license_code.rb +6 -3
  28. data/lib/arbetsformedlingen/codes/experience_required_code.rb +3 -1
  29. data/lib/arbetsformedlingen/codes/municipality_code.rb +3 -1
  30. data/lib/arbetsformedlingen/codes/occupation_code.rb +3 -1
  31. data/lib/arbetsformedlingen/codes/salary_type_code.rb +3 -1
  32. data/lib/arbetsformedlingen/key_struct.rb +5 -3
  33. data/lib/arbetsformedlingen/models/application_method.rb +3 -1
  34. data/lib/arbetsformedlingen/models/company.rb +2 -2
  35. data/lib/arbetsformedlingen/models/document.rb +4 -2
  36. data/lib/arbetsformedlingen/models/dry/predicates.rb +2 -0
  37. data/lib/arbetsformedlingen/models/dry/types.rb +5 -3
  38. data/lib/arbetsformedlingen/models/model.rb +2 -0
  39. data/lib/arbetsformedlingen/models/packet.rb +3 -1
  40. data/lib/arbetsformedlingen/models/packet_xml_builder.rb +8 -3
  41. data/lib/arbetsformedlingen/models/position.rb +5 -3
  42. data/lib/arbetsformedlingen/models/publication.rb +3 -1
  43. data/lib/arbetsformedlingen/models/qualification.rb +3 -1
  44. data/lib/arbetsformedlingen/models/salary.rb +3 -1
  45. data/lib/arbetsformedlingen/models/schedule.rb +4 -2
  46. data/lib/arbetsformedlingen/soap_builder.rb +3 -1
  47. data/lib/arbetsformedlingen/version.rb +3 -1
  48. metadata +43 -25
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e3a327d58c944a64b80dc83c3eb7d76975e2aef1420850196402399e13ef37d6
4
- data.tar.gz: 5c4dc5b645841519b196715a395dd27bcf9cccac7780c6efa2d928edb6afca4f
3
+ metadata.gz: 12c4c0e865fa8cc5a666fbc8089cb02fff2e1e95050e97ee2de84a47728e1aa3
4
+ data.tar.gz: 2a44cd44d1c8586067b181d3c2ff5e404cb2abb91d09c566465bb5fda09d6a1f
5
5
  SHA512:
6
- metadata.gz: e3711ebeb2278561d658203eb9ea3488110c047c71cc10aa84242d8b80d014af9248d3e8c14e7cdc0d75e91d348df3121eefc2d80d7c727979ca7f7bdf6dfc5c
7
- data.tar.gz: 96ad25ccd528a702bc1e0f3a7c918a236e86e74560f297dcef3966e30b5501dfc249e350adbfdb8ff5310bcc1f777298a8c9814f00a0160ff4458e983a835d72
6
+ metadata.gz: 887828b878412c4ebfec3130c910f1030e58f15367254298f160addbed4c6f81b4f4df48963cb2045179af5b87573e447fddd2fcd6010a42906e04de71eff1c5
7
+ data.tar.gz: de32a1fd18c3de44f1cddf677f20c47f79b96e01d5cc4c797256d11832e777d05ff5974713222574d7101d63ff1b856111a45fd7b029ca81b6cf91d8e86d1590
data/.rubocop.yml ADDED
@@ -0,0 +1,6 @@
1
+ inherit_from: .ruby-style-guide.yml
2
+ AllCops:
3
+ UseCache: true
4
+ CacheRootDirectory: tmp
5
+ Exclude:
6
+ - 'tmp/*.rb'
@@ -0,0 +1,270 @@
1
+ Rails:
2
+ Enabled: false
3
+ AllCops:
4
+ TargetRubyVersion: 2.3
5
+ Exclude:
6
+ - "vendor/**/*"
7
+ UseCache: true
8
+ Style/CollectionMethods:
9
+ Description: Preferred collection methods.
10
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#map-find-select-reduce-size
11
+ Enabled: true
12
+ PreferredMethods:
13
+ collect: map
14
+ collect!: map!
15
+ find: detect
16
+ find_all: select
17
+ reduce: inject
18
+ Style/RedundantFreeze:
19
+ Description: "Checks usages of Object#freeze on immutable objects."
20
+ Enabled: false
21
+ Layout/DotPosition:
22
+ Description: Checks the position of the dot in multi-line method calls.
23
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains
24
+ Enabled: true
25
+ EnforcedStyle: trailing
26
+ SupportedStyles:
27
+ - leading
28
+ - trailing
29
+ Naming/FileName:
30
+ Description: Use snake_case for source file names.
31
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-files
32
+ Enabled: false
33
+ Exclude: []
34
+ Naming/MemoizedInstanceVariableName:
35
+ Description: Memoized method name should match memo instance variable name.
36
+ Enabled: false
37
+ Naming/UncommunicativeMethodParamName:
38
+ Description: >-
39
+ Checks for method parameter names that contain capital letters,
40
+ end in numbers, or do not meet a minimal length.
41
+ Enabled: false
42
+ Style/AsciiComments:
43
+ Description: This cop checks for non-ascii (non-English) characters in comments.
44
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals
45
+ AllowedChars:
46
+ - å
47
+ - ä
48
+ - ö
49
+ Enabled: true
50
+ Style/GuardClause:
51
+ Description: Check for conditionals that can be replaced with guard clauses
52
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals
53
+ Enabled: true
54
+ MinBodyLength: 3
55
+ Style/IfUnlessModifier:
56
+ Description: Favor modifier if/unless usage when you have a single-line body.
57
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier
58
+ Enabled: false
59
+ Style/OptionHash:
60
+ Description: Don't use option hashes when you can use keyword arguments.
61
+ Enabled: false
62
+ Style/PercentLiteralDelimiters:
63
+ Description: Use `%`-literal delimiters consistently
64
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-literal-braces
65
+ Enabled: false
66
+ PreferredDelimiters:
67
+ "%": "()"
68
+ "%i": "()"
69
+ "%q": "()"
70
+ "%Q": "()"
71
+ "%r": "{}"
72
+ "%s": "()"
73
+ "%w": "()"
74
+ "%W": "()"
75
+ "%x": "()"
76
+ Naming/PredicateName:
77
+ Description: Check the names of predicate methods.
78
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark
79
+ Enabled: true
80
+ NamePrefix:
81
+ - is_
82
+ - has_
83
+ - have_
84
+ NamePrefixBlacklist:
85
+ - is_
86
+ Exclude:
87
+ - spec/**/*
88
+ Style/RaiseArgs:
89
+ Description: Checks the arguments passed to raise/fail.
90
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#exception-class-messages
91
+ Enabled: false
92
+ EnforcedStyle: exploded
93
+ SupportedStyles:
94
+ - compact
95
+ - exploded
96
+ Style/SignalException:
97
+ Description: Checks for proper usage of fail and raise.
98
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#fail-method
99
+ Enabled: false
100
+ EnforcedStyle: semantic
101
+ SupportedStyles:
102
+ - only_raise
103
+ - only_fail
104
+ - semantic
105
+ Style/SingleLineBlockParams:
106
+ Description: Enforces the names of some block params.
107
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#reduce-blocks
108
+ Enabled: false
109
+ Methods:
110
+ - reduce:
111
+ - a
112
+ - e
113
+ - inject:
114
+ - a
115
+ - e
116
+ Style/TrivialAccessors:
117
+ Enabled: false
118
+ Style/SingleLineMethods:
119
+ Description: Avoid single-line methods.
120
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-single-line-methods
121
+ Enabled: false
122
+ AllowIfMethodIsEmpty: true
123
+ Style/StringLiterals:
124
+ Description: Checks if uses of quotes match the configured preference.
125
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
126
+ Enabled: true
127
+ EnforcedStyle: single_quotes
128
+ SupportedStyles:
129
+ - single_quotes
130
+ - double_quotes
131
+ Style/MixinUsage:
132
+ Enabled: true
133
+ Exclude:
134
+ - exe/*
135
+ Style/StringLiteralsInInterpolation:
136
+ Description: Checks if uses of quotes inside expressions in interpolated strings
137
+ match the configured preference.
138
+ Enabled: true
139
+ EnforcedStyle: single_quotes
140
+ SupportedStyles:
141
+ - single_quotes
142
+ - double_quotes
143
+ Style/TrailingCommaInArrayLiteral:
144
+ Description: Checks for trailing comma in parameter lists and literals.
145
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas
146
+ Enabled: true
147
+ EnforcedStyleForMultiline: comma
148
+ Style/TrailingCommaInHashLiteral:
149
+ Description: Checks for trailing comma in parameter lists and literals.
150
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas
151
+ Enabled: true
152
+ EnforcedStyleForMultiline: comma
153
+ Metrics/AbcSize:
154
+ Description: A calculated magnitude based on number of assignments, branches, and
155
+ conditions.
156
+ Enabled: false
157
+ Max: 15
158
+ Metrics/ClassLength:
159
+ Description: Avoid classes longer than 100 lines of code.
160
+ Enabled: false
161
+ CountComments: false
162
+ Max: 100
163
+ Metrics/ModuleLength:
164
+ CountComments: false
165
+ Max: 100
166
+ Description: Avoid modules longer than 100 lines of code.
167
+ Enabled: false
168
+ Metrics/CyclomaticComplexity:
169
+ Description: A complexity metric that is strongly correlated to the number of test
170
+ cases needed to validate a method.
171
+ Enabled: false
172
+ Max: 6
173
+ Metrics/MethodLength:
174
+ Description: Avoid methods longer than 10 lines of code.
175
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#short-methods
176
+ Enabled: false
177
+ CountComments: false
178
+ Max: 10
179
+ Metrics/ParameterLists:
180
+ Description: Avoid parameter lists longer than three or four parameters.
181
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#too-many-params
182
+ Enabled: false
183
+ Max: 5
184
+ CountKeywordArgs: true
185
+ Metrics/PerceivedComplexity:
186
+ Description: A complexity metric geared towards measuring complexity for a human
187
+ reader.
188
+ Enabled: false
189
+ Max: 7
190
+ Metrics/LineLength:
191
+ Description: Maximum line length
192
+ Enabled: true
193
+ Max: 95
194
+ Exclude:
195
+ - Gemfile
196
+ - arbetsformedlingen.gemspec
197
+ - spec/**/*
198
+ Metrics/BlockLength:
199
+ Enabled: true
200
+ Exclude:
201
+ - spec/**/*
202
+ Lint/AssignmentInCondition:
203
+ Description: Don't use assignment in conditions.
204
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition
205
+ Enabled: false
206
+ AllowSafeAssignment: true
207
+ Style/InlineComment:
208
+ Description: Avoid inline comments.
209
+ Enabled: false
210
+ Naming/AccessorMethodName:
211
+ Description: Check the naming of accessor methods for get_/set_.
212
+ Enabled: false
213
+ Style/Alias:
214
+ Description: Use alias_method instead of alias.
215
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#alias-method
216
+ Enabled: false
217
+ Style/Documentation:
218
+ Description: Document classes and non-namespace modules.
219
+ Enabled: false
220
+ Style/DoubleNegation:
221
+ Description: Checks for uses of double negation (!!).
222
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-bang-bang
223
+ Enabled: false
224
+ Style/EachWithObject:
225
+ Description: Prefer `each_with_object` over `inject` or `reduce`.
226
+ Enabled: false
227
+ Style/EmptyLiteral:
228
+ Description: Prefer literals to Array.new/Hash.new/String.new.
229
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#literal-array-hash
230
+ Enabled: false
231
+ Style/ModuleFunction:
232
+ Description: Checks for usage of `extend self` in modules.
233
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#module-function
234
+ Enabled: false
235
+ Style/OneLineConditional:
236
+ Description: Favor the ternary operator(?:) over if/then/else/end constructs.
237
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#ternary-operator
238
+ Enabled: false
239
+ Style/PerlBackrefs:
240
+ Description: Avoid Perl-style regex back references.
241
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers
242
+ Enabled: false
243
+ Style/Send:
244
+ Description: Prefer `Object#__send__` or `Object#public_send` to `send`, as `send`
245
+ may overlap with existing methods.
246
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#prefer-public-send
247
+ Enabled: false
248
+ Style/SpecialGlobalVars:
249
+ Description: Avoid Perl-style global variables.
250
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms
251
+ Enabled: false
252
+ Style/VariableInterpolation:
253
+ Description: Don't interpolate global, instance and class variables directly in
254
+ strings.
255
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#curlies-interpolate
256
+ Enabled: false
257
+ Style/WhenThen:
258
+ Description: Use when x then ... for one-line cases.
259
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#one-line-cases
260
+ Enabled: false
261
+ Lint/EachWithObjectArgument:
262
+ Description: Check for immutable argument given to each_with_object.
263
+ Enabled: true
264
+ Lint/HandleExceptions:
265
+ Description: Don't suppress exception.
266
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions
267
+ Enabled: false
268
+ Lint/LiteralInInterpolation:
269
+ Description: Checks for literals used in interpolation.
270
+ Enabled: false
data/.travis.yml CHANGED
@@ -2,6 +2,5 @@ sudo: false
2
2
  language: ruby
3
3
  rvm:
4
4
  - 2.3.0
5
- - 2.4.0
6
5
  - 2.5.0
7
6
  before_install: gem install bundler -v 1.6.1
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Change Log
2
2
 
3
+ # v0.6.0
4
+
5
+ * Return "empty result" object when no results are found
6
+ * Fix `workplace.contacts` - [PR #14](https://github.com/buren/arbetsformedlingen/pull/14)
7
+ * Fix crashes when ad data doesn't contain some keys - [PR #15](https://github.com/buren/arbetsformedlingen/pull/15), [PR #11](https://github.com/buren/arbetsformedlingen/pull/11)
8
+ * Replace `URI#encode` with `#encode_www_form_component`
9
+ * Add `WSOccupationClient` docs
10
+ * Refactor `SOAPRequest` to use new `API::Reponse#xml` method
11
+ * Add `#response` to `SoklistaPage`, `MatchningPage`, `AdResult` and `Values::Ad`
12
+ * Proper `API::Response` class
13
+ * Introduce `MatchningPage` `#success?` and `#response`
14
+
3
15
  # v0.5.0
4
16
 
5
17
  * Upgrade `dry-valdation` dependency from `~> 0.11` to `~> 0.12`
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in arbetsformedlingen.gemspec
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2017 Jacob Burenstam
3
+ Copyright (c) 2018 Jacob Burenstam Linder
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -201,7 +201,7 @@ This gem has translated the attribute names in Arbetsförmedlingens (AF) API fro
201
201
 
202
202
  | Arbetsförmedlingen Term | Gem term |
203
203
  |------------------------ |--------------------|
204
- | landområde/värdsdel | areas |
204
+ | landområde/värdsdel | areas |
205
205
  | kommun | municipality |
206
206
  | län | counties |
207
207
  | län2 | counties2 |
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
  require 'rspec/core/rake_task'
3
5
 
@@ -1,6 +1,6 @@
1
- # coding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
- lib = File.expand_path('../lib', __FILE__)
3
+ lib = File.expand_path('lib', __dir__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
  require 'arbetsformedlingen/version'
6
6
 
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.email = ['burenstam@gmail.com']
12
12
 
13
13
  spec.summary = 'Arbetsförmedlingen API client'
14
- spec.description = 'Arbetsförmedlingen API client (Swedish Public Employment Service)'
14
+ spec.description = 'Arbetsförmedlingen API client (Swedish Public Employment Service). Post job ads, Platsannons (ads) API client and WSOccupation SOAP API client.'
15
15
  spec.homepage = 'https://github.com/buren/arbetsformedlingen'
16
16
  spec.license = 'MIT'
17
17
 
@@ -22,15 +22,16 @@ Gem::Specification.new do |spec|
22
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
23
  spec.require_paths = %w[lib config]
24
24
 
25
- spec.add_dependency 'httparty', '~> 0.13' # Easy HTTP requests
26
- spec.add_dependency 'dry-validation', '~> 0.12'
27
25
  spec.add_dependency 'builder', '~> 3.2'
26
+ spec.add_dependency 'dry-validation', '~> 0.12'
27
+ spec.add_dependency 'httparty', '~> 0.13' # Easy HTTP requests
28
28
 
29
- spec.add_development_dependency 'nokogiri', '~> 1.8'
30
29
  spec.add_development_dependency 'bundler', '~> 1.14'
30
+ spec.add_development_dependency 'byebug'
31
+ spec.add_development_dependency 'nokogiri', '~> 1.8'
31
32
  spec.add_development_dependency 'rake', '~> 10.0'
32
- spec.add_development_dependency 'rspec', '~> 3.0'
33
- spec.add_development_dependency 'webmock', '~> 3.1'
33
+ spec.add_development_dependency 'rspec', '~> 3.8'
34
+ spec.add_development_dependency 'rubocop', '~> 0.59'
34
35
  spec.add_development_dependency 'vcr', '~> 3.0'
35
- spec.add_development_dependency 'byebug'
36
+ spec.add_development_dependency 'webmock', '~> 3.1'
36
37
  end
data/bin/console CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'bundler/setup'
4
5
  require 'arbetsformedlingen'
@@ -1,6 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'uri'
2
- require 'net/http'
3
- require 'json'
4
4
 
5
5
  require 'arbetsformedlingen/api/request'
6
6
 
@@ -14,11 +14,14 @@ require 'arbetsformedlingen/api/ledigtarbete_client'
14
14
 
15
15
  module Arbetsformedlingen
16
16
  module API
17
+ # Main API client
17
18
  class Client
19
+ # Base URL for platsannonser
18
20
  BASE_URL = 'http://api.arbetsformedlingen.se/af/v0/platsannonser/'.freeze
19
21
 
20
22
  attr_reader :request, :locale
21
23
 
24
+ # Initialize client
22
25
  def initialize(locale: 'sv')
23
26
  @request = Request.new(base_url: BASE_URL, locale: locale)
24
27
  @locale = locale
@@ -33,7 +36,7 @@ module Arbetsformedlingen
33
36
  end
34
37
 
35
38
  # Post ad to API (ad => annons)
36
- # @return [AdResult] the result.
39
+ # @return [Values::CreateAdPage] the result.
37
40
  # @param [Arbetsformedlingen::Packet] Packet object.
38
41
  # @example Post ad
39
42
  # client.ad(packet)
@@ -43,132 +46,147 @@ module Arbetsformedlingen
43
46
  end
44
47
 
45
48
  # Fetch ad from API (ad => annons)
46
- # @return [AdResult] the result.
49
+ # @return [Values::Ad] the result.
47
50
  # @param id [String] Ad ID.
48
51
  # @example Get ad
49
52
  # client.ad(id: id)
53
+ # @see Values::Ad
50
54
  def ad(id:)
51
55
  response = request.get(id)
52
56
 
53
- AdResult.build(response.json)
57
+ AdResult.build(response)
54
58
  end
55
59
 
56
- # Fetch ads from API (areas => landområde/värdsdel)
57
- # @return [MatchningResult] the result.
58
- # @see MatchningClient#ads
59
- # @see MatchningResult#build
60
+ # Fetch ads from API (areas => landområde/värdsdel)
61
+ # @return [Values::MatchningPage] the result.
62
+ # @see Values::MatchningPage
60
63
  def ads(**args)
61
64
  client = MatchningClient.new(request: request)
62
65
  client.ads(**args)
63
66
  end
64
67
 
65
- # Fetch areas from API (areas => landområde/värdsdel)
66
- # @return [AdResult] the result.
68
+ # Fetch areas from API (areas => landområde/värdsdel)
69
+ # @return [Values::SoklistaPage] the result.
67
70
  # @example Get areas
68
71
  # client.areas
72
+ # @see Values::SoklistaPage
69
73
  def areas
70
74
  response = request.get('soklista/omrade')
71
75
 
72
- SoklistaResult.build(response.json, list_name: 'omrade')
76
+ SoklistaResult.build(response, list_name: 'omrade')
73
77
  end
74
78
 
75
79
  # Fetch counties from API (countries => land)
76
- # @return [AdResult] the result.
80
+ # @return [Values::SoklistaPage] the result.
77
81
  # @param area_id [String] Area ID.
78
82
  # @example Get countries within area
79
83
  # client.countries(area_id: id)
84
+ # @see Values::SoklistaPage
80
85
  def countries(area_id:)
81
86
  query = { omradeid: area_id }
82
87
  response = request.get('soklista/land', query: query)
83
88
 
84
- SoklistaResult.build(response.json, list_name: 'land')
89
+ SoklistaResult.build(response, list_name: 'land')
85
90
  end
86
91
 
87
92
  # Fetch municipalities from API (municipality => kommun)
88
- # @return [AdResult] the result.
93
+ # @return [Values::SoklistaPage] the result.
89
94
  # @param county_id [String] County ID.
90
95
  # @example Get counties
91
96
  # client.counties
97
+ # @see Values::SoklistaPage
92
98
  def municipalities(county_id: nil)
93
99
  # NOTE: Due to a quirck in the API the lanid-param
94
100
  # *must* be present though it *can* be nil
95
101
  query = { lanid: county_id }
96
102
  response = request.get('soklista/kommuner', query: query)
97
103
 
98
- SoklistaResult.build(response.json, list_name: 'kommuner')
104
+ SoklistaResult.build(response, list_name: 'kommuner')
99
105
  end
100
106
 
101
107
  # Fetch counties from API (county => län)
102
- # @return [AdResult] the result.
108
+ # @return [Values::SoklistaPage] the result.
103
109
  # @example Get counties
104
110
  # client.counties
111
+ # @see Values::SoklistaPage
105
112
  def counties
106
113
  response = request.get('soklista/lan')
107
114
 
108
- SoklistaResult.build(response.json, list_name: 'lan')
115
+ SoklistaResult.build(response, list_name: 'lan')
109
116
  end
110
117
 
111
118
  # Fetch counties2 from API (county2 => län2)
112
- # @return [AdResult] the result.
119
+ # @return [Values::SoklistaPage] the result.
113
120
  # @example Get counties2
114
121
  # client.counties2
122
+ # @see Values::SoklistaPage
115
123
  def counties2
116
124
  response = request.get('soklista/lan2')
117
125
 
118
- SoklistaResult.build(response.json, list_name: 'lan2')
126
+ SoklistaResult.build(response, list_name: 'lan2')
119
127
  end
120
128
 
121
- # Fetch occupational fields from API (occupational_fields => yrkesområde)
122
- # @return [AdResult] the result.
129
+ # Fetch occupational fields from API (occupational_fields => yrkesområde)
130
+ # @return [Values::SoklistaPage] the result.
123
131
  # @example Get occupational fields
124
132
  # client.occupational_field
133
+ # @see Values::SoklistaPage
125
134
  def occupational_fields
126
135
  response = request.get('soklista/yrkesomraden')
127
136
 
128
- SoklistaResult.build(response.json, list_name: 'yrkesomraden')
137
+ SoklistaResult.build(response, list_name: 'yrkesomraden')
129
138
  end
130
139
 
131
140
  # Fetch occupational group from API (occupational_group => yrkesgrupp)
132
- # @return [AdResult] the result.
141
+ # @return [Values::SoklistaPage] the result.
133
142
  # @param occupational_field_id [String] Occupational field ID.
134
143
  # @example Get all occupational group
135
144
  # client.occupational_group
136
145
  # @example Get occupational group within occupational field
137
146
  # client.occupational_group(occupational_field_id: id)
147
+ # @see Values::SoklistaPage
138
148
  def occupational_group(occupational_field_id: nil)
139
149
  # NOTE: Due to a quirck in the API the yrkesomradeid-param
140
150
  # *must* be present though it *can* be nil
141
151
  query = { yrkesomradeid: occupational_field_id }
142
152
  response = request.get('soklista/yrkesgrupper', query: query)
143
153
 
144
- SoklistaResult.build(response.json, list_name: 'yrkesgrupper')
154
+ SoklistaResult.build(response, list_name: 'yrkesgrupper')
145
155
  end
146
156
 
147
157
  # Fetch occupation from API (occupation => yrkesnamn)
148
- # @return [AdResult] the result.
158
+ # @return [Values::SoklistaPage] the result.
149
159
  # @param name [String] Name of the occupation.
150
160
  # @example Get occupation
151
161
  # client.occupation(name: 'Marknadskommunikatör')
162
+ # @see Values::SoklistaPage
152
163
  def occupation(name:)
153
- response = request.get("soklista/yrken/#{URI.encode(name)}")
164
+ response = request.get("soklista/yrken/#{uri_escape(name)}")
154
165
 
155
- SoklistaResult.build(response.json, list_name: 'Yrken')
166
+ SoklistaResult.build(response, list_name: 'Yrken')
156
167
  end
157
168
 
158
169
  # Fetch occupations from API (occupation => yrkesnamn)
159
- # @return [AdResult] the result.
170
+ # @return [Values::SoklistaPage] the result.
160
171
  # @param occupational_group_id [String] Occupational group ID.
161
172
  # @example Get stats of available positions for all occupations
162
173
  # client.occupations
163
174
  # @example Get stats of available positions for some occupations
164
175
  # client.occupations(occupational_group_id: id)
176
+ # @see Values::SoklistaPage
165
177
  def occupations(occupational_group_id: nil)
166
178
  # NOTE: Due to a quirck in the API the yrkesgruppid-param
167
179
  # *must* be present though it *can* be nil
168
180
  query = { yrkesgruppid: occupational_group_id }
169
181
  response = request.get('soklista/yrken', query: query)
170
182
 
171
- SoklistaResult.build(response.json, list_name: 'yrken')
183
+ SoklistaResult.build(response, list_name: 'yrken')
184
+ end
185
+
186
+ private
187
+
188
+ def uri_escape(string)
189
+ URI.encode_www_form_component(string)
172
190
  end
173
191
  end
174
192
  end