arbetsformedlingen 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,84 +1,100 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'arbetsformedlingen/soap_builder'
4
- require 'arbetsformedlingen/api/soap_request'
3
+ require 'arbetsformedlingen/api/base_soap_client'
5
4
 
6
5
  module Arbetsformedlingen
7
6
  module API
8
7
  # WsOccupation API client
9
- class WSOccupationClient
10
- attr_reader :request
11
-
8
+ # @see https://api.arbetsformedlingen.se/af/v0/Occupation/wsoccupation.asmx
9
+ class WSOccupationClient < BaseSOAPClient
12
10
  # Service URL
13
11
  SERVICE_URL = 'https://api.arbetsformedlingen.se/af/v0/Occupation/wsoccupation.asmx'.freeze
14
12
 
13
+ # Namespace
14
+ NAMESPACE = 'urn:ams.se:wsoccupation'
15
+
15
16
  # Initialize client
16
17
  def initialize
17
- @request = SOAPRequest.new(SERVICE_URL)
18
+ super(SERVICE_URL, NAMESPACE)
18
19
  end
19
20
 
20
- # Returns occupation response with specified id
21
+ # Returns occupation with specified id
21
22
  # @return [Response] the response
22
23
  # @see Response
23
- # @see Response#xml
24
+ # @see https://api.arbetsformedlingen.se/af/v0/Occupation/wsoccupation.asmx?op=GetOccupationById
24
25
  def occupation(id)
25
- soap_body = SOAPBuilder.wrap do |body|
26
- body.GetOccupationById(xmlns: 'urn:ams.se:wsoccupation') do |node|
27
- node.occupationId(id)
28
- end
29
- end
30
-
31
- request.post(soap_body.to_xml)
26
+ client_request('GetOccupationById', args: { occupationId: id })
32
27
  end
33
28
 
34
- # Returns occupations response with specified name
29
+ # Returns occupations
35
30
  # @return [Response] the response
36
31
  # @see Response
37
- # @see Response#xml
32
+ # @see https://api.arbetsformedlingen.se/af/v0/Occupation/wsoccupation.asmx?op=FindOccupation
38
33
  def find_occupations(name)
39
- soap_body = SOAPBuilder.wrap do |body|
40
- body.FindOccupation(xmlns: 'urn:ams.se:wsoccupation') do |node|
41
- node.name(name)
42
- end
43
- end
44
-
45
- request.post(soap_body.to_xml)
34
+ client_request('FindOccupation', args: { name: name })
46
35
  end
47
36
 
48
37
  # Returns occupations response
49
38
  # @return [Response] the response
50
39
  # @see Response
51
- # @see Response#xml
40
+ # @see https://api.arbetsformedlingen.se/af/v0/Occupation/wsoccupation.asmx?op=GetAllOccupations
52
41
  def occupations
53
- soap_body = SOAPBuilder.wrap do |body|
54
- body.GetAllOccupations(xmlns: 'urn:ams.se:wsoccupation')
55
- end
56
-
57
- request.post(soap_body.to_xml)
42
+ client_request('GetAllOccupations')
58
43
  end
59
44
 
60
- # Returns occupations short response with specified id
45
+ # Returns occupations short
61
46
  # @return [Response] the response
62
47
  # @see Response
63
- # @see Response#xml
48
+ # @see https://api.arbetsformedlingen.se/af/v0/Occupation/wsoccupation.asmx?op=GetAllOccupationsShort
64
49
  def occupations_short
65
- soap_body = SOAPBuilder.wrap do |body|
66
- body.GetAllOccupationsShort(xmlns: 'urn:ams.se:wsoccupation')
67
- end
68
-
69
- request.post(soap_body.to_xml)
50
+ client_request('GetAllOccupationsShort')
70
51
  end
71
52
 
72
- # Returns occupations detailed response with specified id
53
+ # Returns occupations detailed
73
54
  # @return [Response] the response
74
55
  # @see Response
75
- # @see Response#xml
76
56
  def occupations_detailed
77
- soap_body = SOAPBuilder.wrap do |body|
78
- body.GetAllOccupationsDetailed(xmlns: 'urn:ams.se:wsoccupation')
79
- end
57
+ client_request('GetAllOccupationsDetailed')
58
+ end
80
59
 
81
- request.post(soap_body.to_xml)
60
+ # Returns locale groups
61
+ # @return [Response] the response
62
+ # @see Response
63
+ # @see https://api.arbetsformedlingen.se/af/v0/Occupation/wsoccupation.asmx?op=GetLocaleGroups
64
+ def locale_groups(id)
65
+ client_request('GetLocaleGroups', args: { occupationId: id })
66
+ end
67
+
68
+ # Returns platsbanken link for specified locale group id
69
+ # @return [Response] the response
70
+ # @see Response
71
+ # @see https://api.arbetsformedlingen.se/af/v0/Occupation/wsoccupation.asmx?op=GetPlatsbankenLink
72
+ def platsbanken_link(id)
73
+ client_request('GetPlatsbankenLink', args: { localegroupid: id })
74
+ end
75
+
76
+ # Returns education connections
77
+ # @return [Response] the response
78
+ # @see Response
79
+ # @see https://api.arbetsformedlingen.se/af/v0/Occupation/wsoccupation.asmx?op=LoadAllEducationConnections
80
+ def education_connections
81
+ client_request('LoadAllEducationConnections')
82
+ end
83
+
84
+ # Returns occupations containing id and name information
85
+ # @return [Response] the response
86
+ # @see Response
87
+ # @see https://api.arbetsformedlingen.se/af/v0/Occupation/wsoccupation.asmx?op=LoadAllOccupationIdAndName
88
+ def occupations_id_and_name
89
+ client_request('LoadAllOccupationIdAndName')
90
+ end
91
+
92
+ # Returns article
93
+ # @return [Response] the response
94
+ # @see Response
95
+ # @see https://api.arbetsformedlingen.se/af/v0/Occupation/wsoccupation.asmx?op=GetArticle
96
+ def article(id)
97
+ client_request('GetArticle', args: { articleId: id })
82
98
  end
83
99
  end
84
100
  end
@@ -4,9 +4,8 @@ require 'csv'
4
4
 
5
5
  module Arbetsformedlingen
6
6
  class OccupationCode
7
- CODE_MAP = CSV.read(
8
- File.expand_path('../../../data/occupation-codes.csv', __dir__)
9
- ).to_h.invert.freeze
7
+ DATA_PATH = File.expand_path('../../../data/occupation-codes.csv', __dir__)
8
+ CODE_MAP = CSV.read(DATA_PATH).to_h.invert.freeze
10
9
  CODES_MAP_INVERTED = CODE_MAP.invert.freeze
11
10
 
12
11
  def self.to_code(name)
@@ -3,17 +3,22 @@
3
3
  require 'builder'
4
4
 
5
5
  module Arbetsformedlingen
6
+ # SOAP Envelope XML builder
6
7
  class SOAPBuilder
8
+ # SOAP attributes
7
9
  SOAP_ATTRIBUTES = {
8
10
  'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
9
11
  'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema',
10
12
  'xmlns:soap12' => 'http://www.w3.org/2003/05/soap-envelope',
11
13
  }.freeze
12
14
 
15
+ # Wrap block
16
+ # @see #wrap
13
17
  def self.wrap(&block)
14
18
  new.wrap(&block)
15
19
  end
16
20
 
21
+ # Initialize object
17
22
  def initialize
18
23
  @builder = Builder::XmlMarkup.new(indent: 2)
19
24
  @builder.instruct!
@@ -21,6 +26,8 @@ module Arbetsformedlingen
21
26
  yield self if block_given?
22
27
  end
23
28
 
29
+ # Wrap block in SOAP envelope
30
+ # @return [SOAPBuilder]
24
31
  def wrap
25
32
  @builder.soap12(:Envelope, SOAP_ATTRIBUTES) do |envelope|
26
33
  envelope.soap12(:Body) { |body| yield(body) }
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Arbetsformedlingen
4
- VERSION = '0.6.0'.freeze
4
+ # Gem version
5
+ VERSION = '0.7.0'.freeze
5
6
  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.6.0
4
+ version: 0.7.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: 2018-09-18 00:00:00.000000000 Z
11
+ date: 2018-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: builder
@@ -173,6 +173,7 @@ extensions: []
173
173
  extra_rdoc_files: []
174
174
  files:
175
175
  - ".gitignore"
176
+ - ".hound.yml"
176
177
  - ".rspec"
177
178
  - ".rubocop.yml"
178
179
  - ".ruby-style-guide.yml"
@@ -184,21 +185,26 @@ files:
184
185
  - Rakefile
185
186
  - arbetsformedlingen.gemspec
186
187
  - bin/console
188
+ - bin/seed
187
189
  - bin/setup
188
190
  - config/locales/errors.yml
189
191
  - data/country-codes.csv
190
192
  - data/municipality-codes.csv
191
193
  - data/occupation-codes.csv
194
+ - examples/post_job_ad.rb
192
195
  - lib/arbetsformedlingen.rb
196
+ - lib/arbetsformedlingen/api/base_soap_client.rb
193
197
  - lib/arbetsformedlingen/api/client.rb
194
198
  - lib/arbetsformedlingen/api/ledigtarbete_client.rb
195
199
  - lib/arbetsformedlingen/api/matchning_client.rb
200
+ - lib/arbetsformedlingen/api/ontology_client.rb
196
201
  - lib/arbetsformedlingen/api/request.rb
197
202
  - lib/arbetsformedlingen/api/response.rb
198
203
  - lib/arbetsformedlingen/api/results/ad_result.rb
199
204
  - lib/arbetsformedlingen/api/results/matchning_result.rb
200
205
  - lib/arbetsformedlingen/api/results/soklista_result.rb
201
206
  - lib/arbetsformedlingen/api/soap_request.rb
207
+ - lib/arbetsformedlingen/api/taxonomy_client.rb
202
208
  - lib/arbetsformedlingen/api/values/ad_result_values.rb
203
209
  - lib/arbetsformedlingen/api/values/create_ad_page.rb
204
210
  - lib/arbetsformedlingen/api/values/matchning_result_values.rb