arbetsformedlingen 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +2 -2
- data/arbetsformedlingen.gemspec +1 -0
- data/lib/arbetsformedlingen/api/matchning_client.rb +4 -0
- data/lib/arbetsformedlingen/api/request.rb +1 -6
- data/lib/arbetsformedlingen/api/results/ad_result.rb +1 -1
- data/lib/arbetsformedlingen/api/soap_request.rb +49 -0
- data/lib/arbetsformedlingen/api/ws_occupation_client.rb +60 -0
- data/lib/arbetsformedlingen/soap_builder.rb +34 -0
- data/lib/arbetsformedlingen/version.rb +1 -1
- metadata +20 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b2eac8d60cee1157e1d0f8ff6f436e4af26d9b12761577edaf0593490487dd9e
|
4
|
+
data.tar.gz: 3026994403965b85670d69d74dd4f828c376bff2342823aad11dacb9c61afcda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a9de52e5906afecff66c7cdbba74f0227643a3a99b8efc5ee2890b3eee83d3deeb13957beb5fa2528c0996b2de6e073f719c1d0442fd4897086c61350753ce2
|
7
|
+
data.tar.gz: 88a9ab08e8e78d7404a47153946aa50ec9ab1e7779d5bf49348bbe2237e69f414f93a3d4b5b4298556a0d0347d12665de2ee45b6e862bd06a31e0809d301f537
|
data/README.md
CHANGED
@@ -181,8 +181,8 @@ Some requests had to be made to Arbetsförmedlingens TaxonomyService in order to
|
|
181
181
|
|
182
182
|
This gem has translated the attribute names in Arbetsförmedlingens (AF) API from Swedish to English. You can find the translations below.
|
183
183
|
|
184
|
-
|
|
185
|
-
|
184
|
+
| Arbetsförmedlingen Term | Gem term |
|
185
|
+
|------------------------ |--------------------|
|
186
186
|
| landområde/värdsdel | areas |
|
187
187
|
| kommun | municipality |
|
188
188
|
| län | counties |
|
data/arbetsformedlingen.gemspec
CHANGED
@@ -26,6 +26,7 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_dependency 'dry-validation', '~> 0.10'
|
27
27
|
spec.add_dependency 'builder', '~> 3.2'
|
28
28
|
|
29
|
+
spec.add_development_dependency 'nokogiri', '~> 1.8'
|
29
30
|
spec.add_development_dependency 'bundler', '~> 1.14'
|
30
31
|
spec.add_development_dependency 'rake', '~> 10.0'
|
31
32
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
@@ -60,6 +60,10 @@ module Arbetsformedlingen
|
|
60
60
|
end
|
61
61
|
|
62
62
|
# TODO: Should we validate the IDs passed? What if they're invalid? Do we crash?
|
63
|
+
#
|
64
|
+
# Currently when an invalid value is passed MatchningResult::build returns
|
65
|
+
# => KeyError: key not found: "matchningslista"
|
66
|
+
# which isn't really helpful..
|
63
67
|
|
64
68
|
query = {
|
65
69
|
lanid: county_id,
|
@@ -7,11 +7,6 @@ module Arbetsformedlingen
|
|
7
7
|
class Request
|
8
8
|
Response = KeyStruct.new(:code, :body, :json)
|
9
9
|
|
10
|
-
HEADERS = {
|
11
|
-
'Content-Type' => 'application/json',
|
12
|
-
'Accept-Language' => 'sv'
|
13
|
-
}.freeze
|
14
|
-
|
15
10
|
attr_reader :locale, :base_url
|
16
11
|
|
17
12
|
def initialize(base_url: '', locale: 'sv')
|
@@ -25,7 +20,7 @@ module Arbetsformedlingen
|
|
25
20
|
http = Net::HTTP.new(uri.host, uri.port)
|
26
21
|
|
27
22
|
request = Net::HTTP::Get.new(uri)
|
28
|
-
request['Content-Type'] =
|
23
|
+
request['Content-Type'] = 'application/json'
|
29
24
|
request['Accept-Language'] = locale
|
30
25
|
|
31
26
|
response = http.request(request)
|
@@ -40,7 +40,7 @@ module Arbetsformedlingen
|
|
40
40
|
|
41
41
|
def self.build_application(data)
|
42
42
|
Values::Application.new(
|
43
|
-
reference: data
|
43
|
+
reference: data['referens'],
|
44
44
|
application_url: data.fetch('webbplats'),
|
45
45
|
email: data['epostadress'],
|
46
46
|
last_application_at: data.fetch('sista_ansokningsdag'),
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'net/http'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'nokogiri'
|
6
|
+
rescue LoadError
|
7
|
+
end
|
8
|
+
|
9
|
+
module Arbetsformedlingen
|
10
|
+
module API
|
11
|
+
class SOAPRequest
|
12
|
+
Response = KeyStruct.new(:code, :body, :xml)
|
13
|
+
|
14
|
+
attr_reader :locale, :uri, :url
|
15
|
+
|
16
|
+
def initialize(url, locale: nil)
|
17
|
+
unless Object.const_defined?(:Nokogiri)
|
18
|
+
raise(ArgumentError, "unable to require 'nokogiri' gem, please install it")
|
19
|
+
end
|
20
|
+
|
21
|
+
@url = url
|
22
|
+
@uri = URI(url)
|
23
|
+
@locale = locale
|
24
|
+
end
|
25
|
+
|
26
|
+
def post(body)
|
27
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
28
|
+
http.use_ssl = true if uri.scheme == 'https'
|
29
|
+
|
30
|
+
request = Net::HTTP::Post.new(uri)
|
31
|
+
request['Content-Type'] = 'text/xml'
|
32
|
+
request['Accept-Language'] = locale if locale
|
33
|
+
request.body = body
|
34
|
+
|
35
|
+
response = http.request(request)
|
36
|
+
|
37
|
+
Response.new(
|
38
|
+
code: response.code,
|
39
|
+
body: response.read_body,
|
40
|
+
xml: parse_xml(response.read_body)
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
44
|
+
def parse_xml(string)
|
45
|
+
Nokogiri::XML(string).tap { |doc| doc.remove_namespaces! }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'arbetsformedlingen/soap_builder'
|
2
|
+
require 'arbetsformedlingen/api/soap_request'
|
3
|
+
|
4
|
+
module Arbetsformedlingen
|
5
|
+
module API
|
6
|
+
class WSOccupationClient
|
7
|
+
attr_reader :request
|
8
|
+
|
9
|
+
SERVICE_URL = 'https://api.arbetsformedlingen.se/af/v0/Occupation/wsoccupation.asmx'.freeze
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@request = request || SOAPRequest.new(SERVICE_URL)
|
13
|
+
end
|
14
|
+
|
15
|
+
def occupation(id)
|
16
|
+
soap_body = SOAPBuilder.wrap do |body|
|
17
|
+
body.GetOccupationById(xmlns: 'urn:ams.se:wsoccupation') do |node|
|
18
|
+
node.occupationId(id)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
request.post(soap_body.to_xml)
|
23
|
+
end
|
24
|
+
|
25
|
+
def find_occupations(name)
|
26
|
+
soap_body = SOAPBuilder.wrap do |body|
|
27
|
+
body.FindOccupation(xmlns: 'urn:ams.se:wsoccupation') do |node|
|
28
|
+
node.name(name)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
request.post(soap_body.to_xml)
|
33
|
+
end
|
34
|
+
|
35
|
+
def occupations
|
36
|
+
soap_body = SOAPBuilder.wrap do |body|
|
37
|
+
body.GetAllOccupations(xmlns: 'urn:ams.se:wsoccupation')
|
38
|
+
end
|
39
|
+
|
40
|
+
request.post(soap_body.to_xml)
|
41
|
+
end
|
42
|
+
|
43
|
+
def occupations_short
|
44
|
+
soap_body = SOAPBuilder.wrap do |body|
|
45
|
+
body.GetAllOccupationsShort(xmlns: 'urn:ams.se:wsoccupation')
|
46
|
+
end
|
47
|
+
|
48
|
+
request.post(soap_body.to_xml)
|
49
|
+
end
|
50
|
+
|
51
|
+
def occupations_detailed
|
52
|
+
soap_body = SOAPBuilder.wrap do |body|
|
53
|
+
body.GetAllOccupationsDetailed(xmlns: 'urn:ams.se:wsoccupation')
|
54
|
+
end
|
55
|
+
|
56
|
+
request.post(soap_body.to_xml)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'builder'
|
2
|
+
|
3
|
+
module Arbetsformedlingen
|
4
|
+
class SOAPBuilder
|
5
|
+
SOAP_ATTRIBUTES = {
|
6
|
+
'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
|
7
|
+
'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema',
|
8
|
+
'xmlns:soap12' => 'http://www.w3.org/2003/05/soap-envelope'
|
9
|
+
}.freeze
|
10
|
+
|
11
|
+
def self.wrap(&block)
|
12
|
+
new.wrap(&block)
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
@builder = Builder::XmlMarkup.new(indent: 2)
|
17
|
+
@builder.instruct!
|
18
|
+
|
19
|
+
yield self if block_given?
|
20
|
+
end
|
21
|
+
|
22
|
+
def wrap
|
23
|
+
@builder.soap12(:Envelope, SOAP_ATTRIBUTES) do |envelope|
|
24
|
+
envelope.soap12(:Body) { |body| yield(body) }
|
25
|
+
end
|
26
|
+
|
27
|
+
self
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_xml
|
31
|
+
@builder.target!
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arbetsformedlingen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jacob Burenstam
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.2'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: nokogiri
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.8'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.8'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: bundler
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -165,10 +179,12 @@ files:
|
|
165
179
|
- lib/arbetsformedlingen/api/results/ad_result.rb
|
166
180
|
- lib/arbetsformedlingen/api/results/matchning_result.rb
|
167
181
|
- lib/arbetsformedlingen/api/results/soklista_result.rb
|
182
|
+
- lib/arbetsformedlingen/api/soap_request.rb
|
168
183
|
- lib/arbetsformedlingen/api/values/ad_result_values.rb
|
169
184
|
- lib/arbetsformedlingen/api/values/create_ad_page.rb
|
170
185
|
- lib/arbetsformedlingen/api/values/matchning_result_values.rb
|
171
186
|
- lib/arbetsformedlingen/api/values/soklista_values.rb
|
187
|
+
- lib/arbetsformedlingen/api/ws_occupation_client.rb
|
172
188
|
- lib/arbetsformedlingen/codes/country_code.rb
|
173
189
|
- lib/arbetsformedlingen/codes/drivers_license_code.rb
|
174
190
|
- lib/arbetsformedlingen/codes/experience_required_code.rb
|
@@ -189,6 +205,7 @@ files:
|
|
189
205
|
- lib/arbetsformedlingen/models/qualification.rb
|
190
206
|
- lib/arbetsformedlingen/models/salary.rb
|
191
207
|
- lib/arbetsformedlingen/models/schedule.rb
|
208
|
+
- lib/arbetsformedlingen/soap_builder.rb
|
192
209
|
- lib/arbetsformedlingen/version.rb
|
193
210
|
homepage: https://github.com/buren/arbetsformedlingen
|
194
211
|
licenses:
|
@@ -211,7 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
211
228
|
version: '0'
|
212
229
|
requirements: []
|
213
230
|
rubyforge_project:
|
214
|
-
rubygems_version: 2.6
|
231
|
+
rubygems_version: 2.7.6
|
215
232
|
signing_key:
|
216
233
|
specification_version: 4
|
217
234
|
summary: Arbetsförmedlingen API client
|