arbetsformedlingen 0.4.1 → 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
  SHA256:
3
- metadata.gz: 82e7c895eea69005d2e958c2f12571a6536b8a44896f6a421c2f45f309aea902
4
- data.tar.gz: 7cc8792a58d149091cf8e2f5fd4481d09cbdda3f484120c7732d73a0e6f0adb6
3
+ metadata.gz: e3a327d58c944a64b80dc83c3eb7d76975e2aef1420850196402399e13ef37d6
4
+ data.tar.gz: 5c4dc5b645841519b196715a395dd27bcf9cccac7780c6efa2d928edb6afca4f
5
5
  SHA512:
6
- metadata.gz: c7489eed85970fab8eed820938db13d7c644e0f84be0149c8813490620a6a390eeea0a2169a54941f8c6a99d94b61589903fb99b31f1e879f02c1bd09dd12ed8
7
- data.tar.gz: e2a52e929c49f20a380e033c7d4037f42a02f16f61327a8fb9b6f04c01546ed4292771f35dcd98de68d918f434e5404709411ef0202638632d094fcf940c5865
6
+ metadata.gz: e3711ebeb2278561d658203eb9ea3488110c047c71cc10aa84242d8b80d014af9248d3e8c14e7cdc0d75e91d348df3121eefc2d80d7c727979ca7f7bdf6dfc5c
7
+ data.tar.gz: 96ad25ccd528a702bc1e0f3a7c918a236e86e74560f297dcef3966e30b5501dfc249e350adbfdb8ff5310bcc1f777298a8c9814f00a0160ff4458e983a835d72
data/.gitignore CHANGED
@@ -15,5 +15,3 @@
15
15
  example.rb
16
16
  output.xml
17
17
  test.xml
18
-
19
- spec/cassettes
data/.travis.yml CHANGED
@@ -1,5 +1,7 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
+ - 2.3.0
4
5
  - 2.4.0
5
- before_install: gem install bundler -v 1.14.3
6
+ - 2.5.0
7
+ before_install: gem install bundler -v 1.6.1
data/CHANGELOG.md ADDED
@@ -0,0 +1,15 @@
1
+ # Change Log
2
+
3
+ # v0.5.0
4
+
5
+ * Upgrade `dry-valdation` dependency from `~> 0.11` to `~> 0.12`
6
+ * Commit test vcr cassettes & fix test suite
7
+ * Don't crash when no results are returned from API, return empty result
8
+ * Make Ad/matchning `sista_ansokningsdag` key optional
9
+ * Fix crash when ad data doesn't contain a `varaktighetsId` key
10
+
11
+ ---
12
+
13
+ ## v0.4.1..v0.1.0
14
+
15
+ Is history..
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Arbetsförmedlingen [![Build Status](https://travis-ci.org/buren/arbetsformedlingen.svg?branch=master)](https://travis-ci.org/buren/arbetsformedlingen)
1
+ # Arbetsförmedlingen [![Build Status](https://travis-ci.org/buren/arbetsformedlingen.svg?branch=master)](https://travis-ci.org/buren/arbetsformedlingen) [![Gem Version](https://badge.fury.io/rb/arbetsformedlingen.svg)](https://badge.fury.io/rb/arbetsformedlingen)
2
2
 
3
3
  Arbetsförmedlingen API client (Swedish Public Employment Service).
4
4
 
@@ -11,8 +11,8 @@ __Features__
11
11
  __Index__
12
12
  * [Installation](#installation)
13
13
  * [API Client](#api-client)
14
- * [Post job ad](#post-ad)
15
- * [WSOccupation Client API](#wsoccupation-client-api)
14
+ * [Post job ad](#post-job-ad)
15
+ * [WSOccupation API Client](#wsoccupation-api-client)
16
16
  * [RDoc](http://www.rubydoc.info/gems/arbetsformedlingen/).
17
17
 
18
18
  ## Installation
@@ -61,7 +61,7 @@ countries.map do |country|
61
61
  end
62
62
  ```
63
63
 
64
- ## Post ad
64
+ ## Post job ad
65
65
 
66
66
  __Complete example creating a packet__
67
67
 
@@ -174,7 +174,7 @@ client = API::Client.new(locale: 'sv')
174
174
  client.create_ad(packet)
175
175
  ```
176
176
 
177
- ## WSOccupation API
177
+ ## WSOccupation API Client
178
178
 
179
179
  There is some support for Arbetsförmedlingen's `WSOccupation` SOAP API. See [PR#3](https://github.com/buren/arbetsformedlingen/pull/3).
180
180
 
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.require_paths = %w[lib config]
24
24
 
25
25
  spec.add_dependency 'httparty', '~> 0.13' # Easy HTTP requests
26
- spec.add_dependency 'dry-validation', '~> 0.10'
26
+ spec.add_dependency 'dry-validation', '~> 0.12'
27
27
  spec.add_dependency 'builder', '~> 3.2'
28
28
 
29
29
  spec.add_development_dependency 'nokogiri', '~> 1.8'
@@ -69,7 +69,7 @@ module Arbetsformedlingen
69
69
  def areas
70
70
  response = request.get('soklista/omrade')
71
71
 
72
- SoklistaResult.build(response.json)
72
+ SoklistaResult.build(response.json, list_name: 'omrade')
73
73
  end
74
74
 
75
75
  # Fetch counties from API (countries => land)
@@ -81,7 +81,7 @@ module Arbetsformedlingen
81
81
  query = { omradeid: area_id }
82
82
  response = request.get('soklista/land', query: query)
83
83
 
84
- SoklistaResult.build(response.json)
84
+ SoklistaResult.build(response.json, list_name: 'land')
85
85
  end
86
86
 
87
87
  # Fetch municipalities from API (municipality => kommun)
@@ -95,7 +95,7 @@ module Arbetsformedlingen
95
95
  query = { lanid: county_id }
96
96
  response = request.get('soklista/kommuner', query: query)
97
97
 
98
- SoklistaResult.build(response.json)
98
+ SoklistaResult.build(response.json, list_name: 'kommuner')
99
99
  end
100
100
 
101
101
  # Fetch counties from API (county => län)
@@ -105,7 +105,7 @@ module Arbetsformedlingen
105
105
  def counties
106
106
  response = request.get('soklista/lan')
107
107
 
108
- SoklistaResult.build(response.json)
108
+ SoklistaResult.build(response.json, list_name: 'lan')
109
109
  end
110
110
 
111
111
  # Fetch counties2 from API (county2 => län2)
@@ -115,7 +115,7 @@ module Arbetsformedlingen
115
115
  def counties2
116
116
  response = request.get('soklista/lan2')
117
117
 
118
- SoklistaResult.build(response.json)
118
+ SoklistaResult.build(response.json, list_name: 'lan2')
119
119
  end
120
120
 
121
121
  # Fetch occupational fields from API (occupational_fields => yrkesområde)
@@ -125,7 +125,7 @@ module Arbetsformedlingen
125
125
  def occupational_fields
126
126
  response = request.get('soklista/yrkesomraden')
127
127
 
128
- SoklistaResult.build(response.json)
128
+ SoklistaResult.build(response.json, list_name: 'yrkesomraden')
129
129
  end
130
130
 
131
131
  # Fetch occupational group from API (occupational_group => yrkesgrupp)
@@ -141,7 +141,7 @@ module Arbetsformedlingen
141
141
  query = { yrkesomradeid: occupational_field_id }
142
142
  response = request.get('soklista/yrkesgrupper', query: query)
143
143
 
144
- SoklistaResult.build(response.json)
144
+ SoklistaResult.build(response.json, list_name: 'yrkesgrupper')
145
145
  end
146
146
 
147
147
  # Fetch occupation from API (occupation => yrkesnamn)
@@ -152,7 +152,7 @@ module Arbetsformedlingen
152
152
  def occupation(name:)
153
153
  response = request.get("soklista/yrken/#{URI.encode(name)}")
154
154
 
155
- SoklistaResult.build(response.json)
155
+ SoklistaResult.build(response.json, list_name: 'Yrken')
156
156
  end
157
157
 
158
158
  # Fetch occupations from API (occupation => yrkesnamn)
@@ -168,7 +168,7 @@ module Arbetsformedlingen
168
168
  query = { yrkesgruppid: occupational_group_id }
169
169
  response = request.get('soklista/yrken', query: query)
170
170
 
171
- SoklistaResult.build(response.json)
171
+ SoklistaResult.build(response.json, list_name: 'yrken')
172
172
  end
173
173
  end
174
174
  end
@@ -43,7 +43,7 @@ module Arbetsformedlingen
43
43
  reference: data['referens'],
44
44
  application_url: data.fetch('webbplats'),
45
45
  email: data['epostadress'],
46
- last_application_at: data.fetch('sista_ansokningsdag'),
46
+ last_application_at: data.fetch('sista_ansokningsdag', nil),
47
47
  application_comment: data.fetch('ovrigt_om_ansokan')
48
48
  )
49
49
  end
@@ -28,12 +28,12 @@ module Arbetsformedlingen
28
28
  municipalities: ad_data.fetch('kommunnamn'),
29
29
  municipality_id: ad_data.fetch('kommunkod'),
30
30
  published_at: ad_data.fetch('publiceraddatum'),
31
- last_application_at: ad_data.fetch('sista_ansokningsdag'),
31
+ last_application_at: ad_data.fetch('sista_ansokningsdag', nil),
32
32
  url: ad_data.fetch('annonsurl'),
33
33
  relevance: ad_data.fetch('relevans'),
34
34
  total_vacancies: ad_data.fetch('antalplatser'),
35
35
  total_vacancies_with_visa: ad_data.fetch('antalPlatserVisa'),
36
- duration_id: ad_data.fetch('varaktighetId'),
36
+ duration_id: ad_data.fetch('varaktighetId', nil),
37
37
  counties: ad_data.fetch('lan'),
38
38
  country_id: ad_data.fetch('lanid'),
39
39
  employment_type: ad_data.fetch('anstallningstyp')
@@ -3,24 +3,28 @@ require 'arbetsformedlingen/api/values/soklista_values'
3
3
  module Arbetsformedlingen
4
4
  module API
5
5
  module SoklistaResult
6
- def self.build(response_data)
7
- data = response_data.fetch('soklista')
6
+ def self.build(response_data, list_name: nil)
7
+ data = response_data.fetch('soklista', {})
8
8
 
9
9
  Values::SoklistaPage.new(
10
- list_name: data.fetch('listnamn'),
11
- total_ads: data.fetch('totalt_antal_platsannonser'),
12
- total_vacancies: data.fetch('totalt_antal_ledigajobb'),
10
+ list_name: data.fetch('listnamn', list_name),
11
+ total_ads: data.fetch('totalt_antal_platsannonser', 0),
12
+ total_vacancies: data.fetch('totalt_antal_ledigajobb', 0),
13
13
  raw_data: response_data,
14
- data: data.fetch('sokdata').map do |result|
15
- Values::SoklistaResult.new(
16
- id: result.fetch('id'),
17
- name: result.fetch('namn'),
18
- total_ads: result.fetch('antal_platsannonser'),
19
- total_vacancies: result.fetch('antal_ledigajobb')
20
- )
14
+ data: data.fetch('sokdata', []).map do |result|
15
+ build_search_result(result)
21
16
  end
22
17
  )
23
18
  end
19
+
20
+ def self.build_search_result(result)
21
+ Values::SoklistaResult.new(
22
+ id: result.fetch('id'),
23
+ name: result.fetch('namn'),
24
+ total_ads: result.fetch('antal_platsannonser'),
25
+ total_vacancies: result.fetch('antal_ledigajobb')
26
+ )
27
+ end
24
28
  end
25
29
  end
26
30
  end
@@ -1,5 +1,5 @@
1
1
  module Arbetsformedlingen
2
- ApplicationMethodSchema = Dry::Validation.Form do
2
+ ApplicationMethodSchema = Dry::Validation.Params do
3
3
  configure do
4
4
  config.type_specs = true
5
5
  config.messages_file = File.expand_path('../../../../config/locales/errors.yml', __FILE__)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Arbetsformedlingen
4
- CompanySchema = Dry::Validation.Form do
4
+ CompanySchema = Dry::Validation.Params do
5
5
  configure do
6
6
  config.type_specs = true
7
7
  config.messages_file = File.expand_path('../../../../config/locales/errors.yml', __FILE__)
@@ -1,7 +1,7 @@
1
1
  require 'securerandom'
2
2
 
3
3
  module Arbetsformedlingen
4
- DocumentSchema = Dry::Validation.Form do
4
+ DocumentSchema = Dry::Validation.Params do
5
5
  configure do
6
6
  config.type_specs = true
7
7
  config.messages_file = File.expand_path('../../../../config/locales/errors.yml', __FILE__)
@@ -23,7 +23,7 @@ module Arbetsformedlingen
23
23
  Occupation = Types::Strict::String.constructor do |string|
24
24
  OccupationCode.to_code(string)
25
25
  end
26
- PositionDuration = Types::Strict::Int
26
+ PositionDuration = Types::Strict::Integer
27
27
  DriversLicense = Types::Strict::String.constructor do |value|
28
28
  DriversLicenseCode.to_code(value)
29
29
  end
@@ -2,7 +2,7 @@ require 'builder'
2
2
  require 'arbetsformedlingen/models/packet_xml_builder'
3
3
 
4
4
  module Arbetsformedlingen
5
- PacketSchema = Dry::Validation.Form do
5
+ PacketSchema = Dry::Validation.Params do
6
6
  configure do
7
7
  config.type_specs = true
8
8
  config.messages_file = File.expand_path('../../../../config/locales/errors.yml', __FILE__)
@@ -13,7 +13,7 @@ module Arbetsformedlingen
13
13
  required(:active, Types::Bool).filled
14
14
  required(:job_id, Types::StrippedString).filled
15
15
  required(:id, Types::StrippedString).filled
16
- required(:number_to_fill, Types::Int).filled(gt?: 0)
16
+ required(:number_to_fill, Types::Integer).filled(gt?: 0)
17
17
  required(:occupation, Types::Occupation).filled(:occupation_code?)
18
18
  end
19
19
 
@@ -1,5 +1,5 @@
1
1
  module Arbetsformedlingen
2
- PositionSchema = Dry::Validation.Form do
2
+ PositionSchema = Dry::Validation.Params do
3
3
  configure do
4
4
  config.type_specs = true
5
5
  config.messages_file = File.expand_path('../../../../config/locales/errors.yml', __FILE__)
@@ -1,5 +1,5 @@
1
1
  module Arbetsformedlingen
2
- PublicationSchema = Dry::Validation.Form do
2
+ PublicationSchema = Dry::Validation.Params do
3
3
  configure do
4
4
  config.type_specs = true
5
5
  config.messages_file = File.expand_path('../../../../config/locales/errors.yml', __FILE__)
@@ -1,5 +1,5 @@
1
1
  module Arbetsformedlingen
2
- QualificationSchema = Dry::Validation.Form do
2
+ QualificationSchema = Dry::Validation.Params do
3
3
  configure do
4
4
  config.type_specs = true
5
5
  config.messages_file = File.expand_path('../../../../config/locales/errors.yml', __FILE__)
@@ -1,5 +1,5 @@
1
1
  module Arbetsformedlingen
2
- SalarySchema = Dry::Validation.Form do
2
+ SalarySchema = Dry::Validation.Params do
3
3
  configure do
4
4
  config.type_specs = true
5
5
  config.messages_file = File.expand_path('../../../../config/locales/errors.yml', __FILE__)
@@ -1,5 +1,5 @@
1
1
  module Arbetsformedlingen
2
- ScheduleSchema = Dry::Validation.Form do
2
+ ScheduleSchema = Dry::Validation.Params do
3
3
  configure do
4
4
  config.type_specs = true
5
5
  config.messages_file = File.expand_path('../../../../config/locales/errors.yml', __FILE__)
@@ -1,3 +1,3 @@
1
1
  module Arbetsformedlingen
2
- VERSION = '0.4.1'.freeze
2
+ VERSION = '0.5.0'.freeze
3
3
  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.1
4
+ version: 0.5.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-03-08 00:00:00.000000000 Z
11
+ date: 2018-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.10'
33
+ version: '0.12'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.10'
40
+ version: '0.12'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: builder
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -160,6 +160,7 @@ files:
160
160
  - ".gitignore"
161
161
  - ".rspec"
162
162
  - ".travis.yml"
163
+ - CHANGELOG.md
163
164
  - Gemfile
164
165
  - LICENSE.txt
165
166
  - README.md