scmx / arbetsformedlingen

API Client & Post job ads to the Swedish employment agency (Arbetsförmedlingen)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Arbetsförmedlingen Build Status Gem Version

Arbetsförmedlingen API client (Swedish Public Employment Service).

Features

  • Post job ad (a.k.a Direktöverförda annonser)
  • Platsannons API Client
  • WSOccupation SOAP API Client

Index

Installation

Add this line to your application's Gemfile:

gem 'arbetsformedlingen'

And then execute:

$ bundle

Or install it yourself as:

$ gem install arbetsformedlingen

API Client

Create a client:

client = Arbetsformedlingen::API::Client.new(locale: 'en')

Fetch all ads containing specified keyword:

ads = client.ads(keywords: 'ruby')
ads.map(&:title)

Fetch one ad:

ad = client.ad(id: 7408089)
ad.title
ad.occupation
ad.application.last_application_at

Fetch countries in area:

countries = client.countries(area_id: 2)
countries.map do |country|
  "#{country.name} has #{country.total_vacancies} total vacancies."
end

Post job ad

⚠️ In order to post live job ads to Arbetsförmedlingen you need to contact them and go through a test procedure. You can find their own documentation and some additional notes here.

You can find Arbetsförmedlingens own documentation and some additional notes here. Note that the documentation provided by Arbetsförmedlingen can be pretty hard to follow.

Complete example creating a packet

There's a lot of data you can/must send to the API when creating an ad. See files in lib/arbetsformedlingen/models for details.

require 'date'
require 'arbetsformedlingen'

include Arbetsformedlingen # just for brevity

document = Document.new(
  customer_id: 'XXXYYYZZZ',
  email: 'a@example.com'
)

company = Company.new(
  name: 'ACME AB',
  cin: 'XXYYZZXXYY',
  description: 'A company description',
  address: {
    country_code: 'SE',
    zip: '11356',
    municipality: 'Stockholm',
    street: 'Birger Jarlsgatan 57',
    city: 'stockholm'
  }
)

publication = Publication.new(
  publish_at_date: Date.today,
  name: 'John Doe',
  email: 'john@example.com'
)

schedule = Schedule.new(
  full_time: false,
  summary: '3 days a week 8.00-17.00',
  start_date: Date.today,
  end_date: nil
)

salary = Salary.new(
  currency: 'SEK',
  type: :fixed, # :fixed, :fixed_and_commission, :commission
  summary: 'Your salary will be...'
)

qualifications = []
qualifications << Qualification.new(
  summary: 'A summary', # optional, but recommended field
  required: true,
  experience: true,
  drivers_license: 'B,C1',
  car: true
)

qualifications << Qualification.new(
  summary: 'A summary', # optional, but recommended field
  required: false
)

application_method = ApplicationMethod.new(
  external: true, # applications are not made through AF
  url: 'https://example.com',
  summary: 'Goto our website'
)

position = Position.new(
  company: company,
  schedule: schedule,
  salary: salary,
  qualifications: qualifications,
  application_method: application_method,
  attributes: {
    title: 'A title',
    purpose: 'A purpose',
    address: {
      country_code: 'SE',
      zip: '11356',
      municipality: 'Stockholm',
      street: 'Birger Jarlsgatan 57',
      city: 'stockholm'
    }
  }
)

packet = Packet.new(
  publication: publication,
  document: document,
  position: position,
  attributes: {
    active: true,
    job_id: 1,
    number_to_fill: 1,
    occupation: '4896'
  }
)

puts "salary.valid?: #{salary.valid?}"
puts "schedule.valid?: #{schedule.valid?}"
puts "publication.valid?: #{publication.valid?}"
puts "document.valid?: #{document.valid?}"
puts "company.valid?: #{company.valid?}"
puts "application_method.valid?: #{application_method.valid?}"
puts "position.valid?: #{position.valid?}"
puts "packet.valid?: #{packet.valid?}"

client = API::Client.new(locale: 'sv')
client.create_ad(packet)

WSOccupation API Client

There is some support for Arbetsförmedlingen's WSOccupation SOAP API. See PR#3.

client = Arbetsformedlingen::API::WSOccupationClient.new
response = client.occupations
response.xml.css('Name').first.text
# => "Landskapsarkitekter och landskapsingenjörer"

WSOccupationClient documentation.

Notes

Arbetsförmedlingen TaxonomyService

Some requests had to be made to Arbetsförmedlingens TaxonomyService in order to fetch the data for the occupation codes. You can find that (plus some more) here 👇 Postman.

Postman

Terms translation table

This gem has translated the attribute names in Arbetsförmedlingens (AF) API from Swedish to English. You can find the translations below.

Arbetsförmedlingen Term Gem term
landområde/värdsdel areas
kommun municipality
län counties
län2 counties2
yrkesområde occupational_fields
yrkesgrupp occupational_group
yrkesgrupp occupational_group
yrkesnamn occupation

Development

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.

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.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/buren/arbetsformedlingen.

License

The gem is available as open source under the terms of the MIT License.

About

API Client & Post job ads to the Swedish employment agency (Arbetsförmedlingen)

License:MIT License


Languages

Language:Ruby 99.8%Language:Shell 0.2%