Class: Arbetsformedlingen::API::Client
- Inherits:
-
Object
- Object
- Arbetsformedlingen::API::Client
- Defined in:
- lib/arbetsformedlingen/api/client.rb
Constant Summary collapse
- BASE_URL =
'http://api.arbetsformedlingen.se/af/v0/platsannonser/'.freeze
Instance Attribute Summary collapse
-
#locale ⇒ Object
readonly
Returns the value of attribute locale.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Instance Method Summary collapse
-
#ad(id:) ⇒ AdResult
Fetch ad from API (ad => annons).
-
#ads(**args) ⇒ MatchningResult
Fetch ads from API (areas => landområde/värdsdel).
-
#areas ⇒ AdResult
Fetch areas from API (areas => landområde/värdsdel).
-
#counties ⇒ AdResult
Fetch counties from API (county => län).
-
#counties2 ⇒ AdResult
Fetch counties2 from API (county2 => län2).
-
#countries(area_id:) ⇒ AdResult
Fetch counties from API (countries => land).
-
#create_ad(packet) ⇒ AdResult
Post ad to API (ad => annons).
-
#initialize(locale: 'sv') ⇒ Client
constructor
A new instance of Client.
-
#municipalities(county_id: nil) ⇒ AdResult
Fetch municipalities from API (municipality => kommun).
-
#occupation(name:) ⇒ AdResult
Fetch occupation from API (occupation => yrkesnamn).
-
#occupational_fields ⇒ AdResult
Fetch occupational fields from API (occupational_fields => yrkesområde).
-
#occupational_group(occupational_field_id: nil) ⇒ AdResult
Fetch occupational group from API (occupational_group => yrkesgrupp).
-
#occupations(occupational_group_id: nil) ⇒ AdResult
Fetch occupations from API (occupation => yrkesnamn).
-
#version ⇒ String
Get version of API.
Constructor Details
Instance Attribute Details
#locale ⇒ Object (readonly)
Returns the value of attribute locale.
20 21 22 |
# File 'lib/arbetsformedlingen/api/client.rb', line 20 def locale @locale end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
20 21 22 |
# File 'lib/arbetsformedlingen/api/client.rb', line 20 def request @request end |
Instance Method Details
#ad(id:) ⇒ AdResult
Fetch ad from API (ad => annons)
50 51 52 53 54 |
# File 'lib/arbetsformedlingen/api/client.rb', line 50 def ad(id:) response = request.get(id) AdResult.build(response.json) end |
#ads(**args) ⇒ MatchningResult
Fetch ads from API (areas => landområde/värdsdel)
60 61 62 63 |
# File 'lib/arbetsformedlingen/api/client.rb', line 60 def ads(**args) client = MatchningClient.new(request: request) client.ads(**args) end |
#areas ⇒ AdResult
Fetch areas from API (areas => landområde/värdsdel)
69 70 71 72 73 |
# File 'lib/arbetsformedlingen/api/client.rb', line 69 def areas response = request.get('soklista/omrade') SoklistaResult.build(response.json) end |
#counties ⇒ AdResult
Fetch counties from API (county => län)
105 106 107 108 109 |
# File 'lib/arbetsformedlingen/api/client.rb', line 105 def counties response = request.get('soklista/lan') SoklistaResult.build(response.json) end |
#counties2 ⇒ AdResult
Fetch counties2 from API (county2 => län2)
115 116 117 118 119 |
# File 'lib/arbetsformedlingen/api/client.rb', line 115 def counties2 response = request.get('soklista/lan2') SoklistaResult.build(response.json) end |
#countries(area_id:) ⇒ AdResult
Fetch counties from API (countries => land)
80 81 82 83 84 85 |
# File 'lib/arbetsformedlingen/api/client.rb', line 80 def countries(area_id:) query = { omradeid: area_id } response = request.get('soklista/land', query: query) SoklistaResult.build(response.json) end |
#create_ad(packet) ⇒ AdResult
Post ad to API (ad => annons)
40 41 42 43 |
# File 'lib/arbetsformedlingen/api/client.rb', line 40 def create_ad(packet) client = LedigtarbeteClient.new client.create_ad(packet) end |
#municipalities(county_id: nil) ⇒ AdResult
Fetch municipalities from API (municipality => kommun)
92 93 94 95 96 97 98 99 |
# File 'lib/arbetsformedlingen/api/client.rb', line 92 def municipalities(county_id: nil) # NOTE: Due to a quirck in the API the lanid-param # *must* be present though it *can* be nil query = { lanid: county_id } response = request.get('soklista/kommuner', query: query) SoklistaResult.build(response.json) end |
#occupation(name:) ⇒ AdResult
Fetch occupation from API (occupation => yrkesnamn)
152 153 154 155 156 |
# File 'lib/arbetsformedlingen/api/client.rb', line 152 def occupation(name:) response = request.get("soklista/yrken/#{URI.encode(name)}") SoklistaResult.build(response.json) end |
#occupational_fields ⇒ AdResult
Fetch occupational fields from API (occupational_fields => yrkesområde)
125 126 127 128 129 |
# File 'lib/arbetsformedlingen/api/client.rb', line 125 def occupational_fields response = request.get('soklista/yrkesomraden') SoklistaResult.build(response.json) end |
#occupational_group(occupational_field_id: nil) ⇒ AdResult
Fetch occupational group from API (occupational_group => yrkesgrupp)
138 139 140 141 142 143 144 145 |
# File 'lib/arbetsformedlingen/api/client.rb', line 138 def occupational_group(occupational_field_id: nil) # NOTE: Due to a quirck in the API the yrkesomradeid-param # *must* be present though it *can* be nil query = { yrkesomradeid: occupational_field_id } response = request.get('soklista/yrkesgrupper', query: query) SoklistaResult.build(response.json) end |
#occupations(occupational_group_id: nil) ⇒ AdResult
Fetch occupations from API (occupation => yrkesnamn)
165 166 167 168 169 170 171 172 |
# File 'lib/arbetsformedlingen/api/client.rb', line 165 def occupations(occupational_group_id: nil) # NOTE: Due to a quirck in the API the yrkesgruppid-param # *must* be present though it *can* be nil query = { yrkesgruppid: occupational_group_id } response = request.get('soklista/yrken', query: query) SoklistaResult.build(response.json) end |
#version ⇒ String
Get version of API
31 32 33 |
# File 'lib/arbetsformedlingen/api/client.rb', line 31 def version request.get('version').body end |