arbetsformedlingen 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +5 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +138 -0
  8. data/Rakefile +6 -0
  9. data/arbetsformedlingen.gemspec +33 -0
  10. data/bin/console +14 -0
  11. data/bin/setup +8 -0
  12. data/config/locales/errors.yml +16 -0
  13. data/data/country-codes.csv +237 -0
  14. data/data/municipality-codes.csv +292 -0
  15. data/lib/arbetsformedlingen.rb +56 -0
  16. data/lib/arbetsformedlingen/client.rb +25 -0
  17. data/lib/arbetsformedlingen/codes/country_code.rb +24 -0
  18. data/lib/arbetsformedlingen/codes/drivers_license_code.rb +33 -0
  19. data/lib/arbetsformedlingen/codes/experience_required_code.rb +21 -0
  20. data/lib/arbetsformedlingen/codes/municipality_code.rb +31 -0
  21. data/lib/arbetsformedlingen/codes/salary_type_code.rb +21 -0
  22. data/lib/arbetsformedlingen/models/application_method.rb +20 -0
  23. data/lib/arbetsformedlingen/models/company.rb +50 -0
  24. data/lib/arbetsformedlingen/models/document.rb +28 -0
  25. data/lib/arbetsformedlingen/models/dry/predicates.rb +66 -0
  26. data/lib/arbetsformedlingen/models/dry/types.rb +34 -0
  27. data/lib/arbetsformedlingen/models/model.rb +25 -0
  28. data/lib/arbetsformedlingen/models/packet.rb +39 -0
  29. data/lib/arbetsformedlingen/models/position.rb +56 -0
  30. data/lib/arbetsformedlingen/models/publication.rb +30 -0
  31. data/lib/arbetsformedlingen/models/qualification.rb +23 -0
  32. data/lib/arbetsformedlingen/models/salary.rb +20 -0
  33. data/lib/arbetsformedlingen/models/schedule.rb +56 -0
  34. data/lib/arbetsformedlingen/output_builder.rb +226 -0
  35. data/lib/arbetsformedlingen/response.rb +34 -0
  36. data/lib/arbetsformedlingen/version.rb +3 -0
  37. metadata +178 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bf001fbd113b7eb4df3c4bdeddadcc8312bebac3
4
+ data.tar.gz: f84d1c4290a6247d68d9acfb203e9f0d75d743f1
5
+ SHA512:
6
+ metadata.gz: a01ae66f165038bda632ff287513997347dfbf4d6aee043693915d83d639ce89e2c9fceaa450eb9fc9aa9cec6e6923f6970803c49f9619ec5fdcf5ae23cea22b
7
+ data.tar.gz: f0537994a813c53e3f87520159edb0407e24a56fc8ce07b052a29eac55fbde6781d9e9ef33427302ec43bed0e5dc622762ca97c0e18ad5601209ecc56f247fdf
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
13
+
14
+ .byebug_history
15
+ example.rb
16
+ output.xml
17
+ test.xml
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.0
5
+ before_install: gem install bundler -v 1.14.3
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in arbetsformedlingen.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Jacob Burenstam
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,138 @@
1
+ # Arbetsförmedlingen
2
+
3
+ Post job ads to the Swedish employment agency (Arbetsförmedlingen).
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'arbetsformedlingen'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install arbetsformedlingen
20
+
21
+ ## Usage
22
+
23
+ __Complete example__
24
+
25
+ ```ruby
26
+ require 'date'
27
+ require 'arbetsformedlingen'
28
+
29
+ include Arbetsformedlingen
30
+
31
+ document = Document.new(
32
+ customer_id: 'XXXYYYZZZ',
33
+ email: 'a@example.com'
34
+ )
35
+
36
+ company = Company.new(
37
+ name: 'ACME AB',
38
+ cin: 'XXYYZZXXYY',
39
+ description: 'A company description',
40
+ address: {
41
+ country_code: 'SE',
42
+ zip: '11356',
43
+ municipality: 'Stockholm',
44
+ street: 'Birger Jarlsgatan 57',
45
+ city: 'stockholm'
46
+ }
47
+ )
48
+
49
+ publication = Publication.new(
50
+ publish_at_date: Date.today,
51
+ name: 'John Doe',
52
+ email: 'john@example.com'
53
+ )
54
+
55
+ schedule = Schedule.new(
56
+ full_time: false,
57
+ summary: '3 days a week 8.00-17.00',
58
+ start_date: Date.today,
59
+ end_date: nil
60
+ )
61
+
62
+ salary = Salary.new(
63
+ currency: 'SEK',
64
+ type: :fixed, # :fixed, :fixed_and_commission, :commission
65
+ summary: 'Your salary will be...'
66
+ )
67
+
68
+ qualifications = []
69
+ qualifications << Qualification.new(
70
+ summary: 'A summary', # optional, but recommended field
71
+ required: true,
72
+ experience: true,
73
+ drivers_license: 'B,C1',
74
+ car: true
75
+ )
76
+
77
+ qualifications << Qualification.new(
78
+ summary: 'A summary', # optional, but recommended field
79
+ required: false
80
+ )
81
+
82
+ application_method = ApplicationMethod.new(
83
+ external: true, # applications are not made through AF
84
+ url: 'https://example.com',
85
+ summary: 'Goto our website'
86
+ )
87
+
88
+ position = Position.new(
89
+ company: company,
90
+ schedule: schedule,
91
+ salary: salary,
92
+ qualifications: qualifications,
93
+ application_method: application_method,
94
+ attributes: {
95
+ title: 'A title',
96
+ purpose: 'A purpose'
97
+ }
98
+ )
99
+
100
+ packet = Packet.new(
101
+ publication: publication,
102
+ document: document,
103
+ position: position,
104
+ attributes: {
105
+ active: true,
106
+ job_id: 1,
107
+ number_to_fill: 1,
108
+ ssyk_id: '4896'
109
+ }
110
+ )
111
+
112
+ puts "salary.valid?: #{salary.valid?}"
113
+ puts "schedule.valid?: #{schedule.valid?}"
114
+ puts "publication.valid?: #{publication.valid?}"
115
+ puts "document.valid?: #{document.valid?}"
116
+ puts "company.valid?: #{company.valid?}"
117
+ puts "application_method.valid?: #{application_method.valid?}"
118
+ puts "position.valid?: #{position.valid?}"
119
+ puts "packet.valid?: #{packet.valid?}"
120
+
121
+ output = OutputBuilder.new(packet)
122
+ File.write('output.xml', output.to_xml)
123
+ ```
124
+
125
+ ## Development
126
+
127
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
128
+
129
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
130
+
131
+ ## Contributing
132
+
133
+ Bug reports and pull requests are welcome on GitHub at https://github.com/buren/arbetsformedlingen.
134
+
135
+
136
+ ## License
137
+
138
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'arbetsformedlingen/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'arbetsformedlingen'
9
+ spec.version = Arbetsformedlingen::VERSION
10
+ spec.authors = ['Jacob Burenstam']
11
+ spec.email = ['burenstam@gmail.com']
12
+
13
+ spec.summary = 'Arbetsförmedlingen API client'
14
+ spec.description = 'Arbetsförmedlingen API client (Swedish Public Employment Service)'
15
+ spec.homepage = 'https://github.com/buren/arbetsformedlingen'
16
+ spec.license = 'MIT'
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
+ f.match(%r{^(test|spec|features)/})
20
+ end
21
+ spec.bindir = 'exe'
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = %w[lib config]
24
+
25
+ spec.add_dependency 'httparty', '~> 0.13' # Easy HTTP requests
26
+ spec.add_dependency 'dry-validation', '~> 0.10'
27
+ spec.add_dependency 'builder', '~> 3.2'
28
+
29
+ spec.add_development_dependency 'bundler', '~> 1.14'
30
+ spec.add_development_dependency 'rake', '~> 10.0'
31
+ spec.add_development_dependency 'rspec', '~> 3.0'
32
+ spec.add_development_dependency 'byebug'
33
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'arbetsformedlingen'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,16 @@
1
+ en:
2
+ errors:
3
+ iso8601_date?: "must be an iso8601 formatted date string"
4
+ yyyy_mm_dd?: "must be a YYYY-MM-DD formatted date string"
5
+ email?: "must look like an email address"
6
+ currency?: "must be a valid 3 character currency string"
7
+ zip?: "must be a valid 5 character zip code"
8
+ cin?: "must be a valid 10 character (not counting spaces or dashes) Company Identification Numbers / Organisation Number"
9
+ drivers_license?: "must be a valid drivers license"
10
+ url?:: "must be a valid URL"
11
+ ssyk_id?: "must be a valid SSYK identifier"
12
+ country_code?: "must be a valid 2 character country code"
13
+ salary_type?: "must be a valid salary type code"
14
+ municipality?: "must be a valid municipality code"
15
+ url?: "must be a valid URL with leading http:// or https://"
16
+ experience_required?: must be either true of false
@@ -0,0 +1,237 @@
1
+ Afghanistan,AF
2
+ Albanien,AL
3
+ Algeriet,DZ
4
+ Amerikanska Jungfruöarna,VI
5
+ Amerikanska Samoa,AS
6
+ Andorra,AD
7
+ Angola,AO
8
+ Anguilla,AI
9
+ Antarktis,AQ
10
+ Antigua och Barbuda,AG
11
+ Argentina,AR
12
+ Armenien,AM
13
+ Aruba,AW
14
+ Australien,AU
15
+ Azerbajdzjan,AZ
16
+ Bahamas,BS
17
+ Bahrain,BH
18
+ Bangladesh,BD
19
+ Barbados,BB
20
+ Belgien,BE
21
+ Belize,BZ
22
+ Benin,BJ
23
+ Bermuda,BM
24
+ Bhutan,BT
25
+ Bolivia,BO
26
+ Bosnien och Hercegovina,BA
27
+ Botswana,BW
28
+ Bouvetön,BV
29
+ Brasilien,BR
30
+ Brittiska Jungfruöarna,VG
31
+ Brittiska Oceanöarna,IO
32
+ Brunei,BN
33
+ Bulgarien,BG
34
+ Burkina Faso,BF
35
+ Burundi,BI
36
+ Caymanöarna,KY
37
+ Centralafrikanska republiken,CF
38
+ Chile,CL
39
+ Colombia,CO
40
+ Cooköarna,CK
41
+ Costa Rica,CR
42
+ Cypern,CY
43
+ Danmark,DK
44
+ Djibouti,DJ
45
+ Dominica,DM
46
+ Dominikanska republiken,DO
47
+ Ecuador,EC
48
+ Egypten,EG
49
+ Ekvatorialguinea,GQ
50
+ El Salvador,SV
51
+ Elfenbenskusten,CI
52
+ Eritrea,ER
53
+ Estland,EE
54
+ Etiopien,ET
55
+ Falklandsöarna,FK
56
+ Fiji,FJ
57
+ Filippinerna,PH
58
+ Finland,FI
59
+ Frankrike,FR
60
+ Franska Guyana,GF
61
+ Franska Polynesien,PF
62
+ Franska Sydterritorierna,TF
63
+ Färöarna,FO
64
+ Förenade Arabemiraten,AE
65
+ Gabon,GA
66
+ Gambia,GM
67
+ Georgien,GE
68
+ Ghana,GH
69
+ Gibraltar,GI
70
+ Grekland,GR
71
+ Grenada,GD
72
+ Grönland,GL
73
+ Guadeloupe,GP
74
+ Guam,GU
75
+ Guatemala,GT
76
+ Guinea,GN
77
+ Guinea-Bissau,GW
78
+ Guyana,GY
79
+ Haiti,HT
80
+ Heardön och McDonaldöarna,HM
81
+ Honduras,HN
82
+ Hongkong,HK
83
+ Indien,IN
84
+ Indonesien,ID
85
+ Irak,IQ
86
+ Iran,IR
87
+ Irland,IE
88
+ Island,IS
89
+ Israel,IL
90
+ Italien,IT
91
+ Jamaica,JM
92
+ Japan,JP
93
+ Jordanien,JO
94
+ Julön,CX
95
+ Kambodja,KH
96
+ Kamerun,CM
97
+ Kanada,CA
98
+ Kap Verde,CV
99
+ Kazakstan,KZ
100
+ Kenya,KE
101
+ Kina,CN
102
+ Kirgizistan,KG
103
+ Kiribati,KI
104
+ Kokosöarna,CC
105
+ Komorerna,KM
106
+ Kongo,CG
107
+ "Kongo, demokratiska republiken",CD
108
+ Kroatien,HR
109
+ Kuba,CU
110
+ Kuwait,KW
111
+ Laos,LA
112
+ Lesotho,LS
113
+ Lettland,LV
114
+ Libanon,LB
115
+ Liberia,LR
116
+ Libyen,LY
117
+ Liechtenstein,LI
118
+ Litauen,LT
119
+ Luxemburg,LU
120
+ Macao,MO
121
+ Madagaskar,MG
122
+ "Makedonien, f d jugoslaviska republiken",MK
123
+ Malawi,MW
124
+ Malaysia,MY
125
+ Maldiverna,MV
126
+ Mali,ML
127
+ Malta,MT
128
+ Marocko,MA
129
+ Marshallöarna,MH
130
+ Martinique,MQ
131
+ Mauretanien,MR
132
+ Mauritius,MU
133
+ Mayotte,YT
134
+ Mexiko,MX
135
+ Mikronesien,FM
136
+ Moçambique,MZ
137
+ Moldavien,MD
138
+ Monaco,MC
139
+ Mongoliet,MN
140
+ Montserrat,MS
141
+ Myanmar,MM
142
+ Namibia,NA
143
+ Nauru,NR
144
+ Nederländerna,NL
145
+ Nederländska Antillerna,AN
146
+ Nepal,NP
147
+ Nicaragua,NI
148
+ Niger,NE
149
+ Nigeria,NG
150
+ Niue,NU
151
+ Nordkorea,KP
152
+ Nordmarianerna,MP
153
+ Norfolkön,NF
154
+ Norge,NO
155
+ Nya Kaledonien,NC
156
+ Nya Zeeland,NZ
157
+ Oman,OM
158
+ Pakistan,PK
159
+ Palau,PW
160
+ "Palestinskt område, ockuperat",PS
161
+ Panama,PA
162
+ Papua Nya Guinea,PG
163
+ Paraguay,PY
164
+ Peru,PE
165
+ Pitcairn,PN
166
+ Polen,PL
167
+ Portugal,PT
168
+ Puerto Rico,PR
169
+ Qatar,QA
170
+ Réunion,RE
171
+ Rumänien,RO
172
+ Rwanda,RW
173
+ Ryssland,RU
174
+ Saint Christopher och Nevis,KN
175
+ Saint Helena,SH
176
+ Saint Lucia,LC
177
+ Saint Pierre och Miquelon,PM
178
+ Saint Vincent och Grenadinerna,VC
179
+ Salomonöarna,SB
180
+ Samoa,WS
181
+ San Marino,SM
182
+ São Tomé och Príncipe,ST
183
+ Saudiarabien,SA
184
+ Schweiz,CH
185
+ Senegal,SN
186
+ Serbien och Montenegro,CS
187
+ Seychellerna,SC
188
+ Sierra Leone,SL
189
+ Singapore,SG
190
+ Slovakien,SK
191
+ Slovenien,SI
192
+ Somalia,SO
193
+ Spanien,ES
194
+ Sri Lanka,LK
195
+ Storbritannien och Nordirland,GB
196
+ Sudan,SD
197
+ Surinam,SR
198
+ Svalbard och Jan Mayen,SJ
199
+ Sverige,SE
200
+ Swaziland,SZ
201
+ Sydafrika,ZA
202
+ Sydgeorgien och Sydsandwichöarna,GS
203
+ Sydkorea,KR
204
+ Syrien,SY
205
+ Tadzjikistan,TJ
206
+ Taiwan,TW
207
+ Tanzania,TZ
208
+ Tchad,TD
209
+ Thailand,TH
210
+ Tjeckien,CZ
211
+ Togo,TG
212
+ Tokelau,TK
213
+ Tonga,TO
214
+ Trinidad och Tobago,TT
215
+ Tunisien,TN
216
+ Turkiet,TR
217
+ Turkmenistan,TM
218
+ Turks- och Caicosöarna,TC
219
+ Tuvalu,TV
220
+ Tyskland,DE
221
+ Uganda,UG
222
+ Ukraina,UA
223
+ Ungern,HU
224
+ Uruguay,UY
225
+ USA,US
226
+ USA mindre utliggande öar,UM
227
+ Uzbekistan,UZ
228
+ Vanuatu,VU
229
+ Vatikanstaten,VA
230
+ Venezuela,VE
231
+ Vietnam,VN
232
+ Vitryssland,BY
233
+ Västsahara,EH
234
+ Wallis och Futuna,WF
235
+ Yemen,YE
236
+ Zambia,ZM
237
+ Zimbabwe,ZW