Class: Arbetsformedlingen::API::LedigtarbeteClient

Inherits:
Object
  • Object
show all
Defined in:
lib/arbetsformedlingen/api/ledigtarbete_client.rb

Overview

API client for ledigtarbete

Constant Summary collapse

BASE_URL =

Base URL for ledigtarbete

'http://api.arbetsformedlingen.se/ledigtarbete'.freeze
HEADERS =

HTTP headers

{
  'Content-type' => 'text/xml',
}.freeze

Instance Method Summary collapse

Instance Method Details

#create_ad(packet) ⇒ Values::CreateAdPage

Post ad to API

Parameters:

Returns:



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/arbetsformedlingen/api/ledigtarbete_client.rb', line 21

def create_ad(packet)
  xml = packet.to_xml

  url = if Arbetsformedlingen.config.test
          'apiledigtarbete/test/hrxml'
        else
          'apiledigtarbete/hrxml'
        end

  response = HTTParty.post("#{BASE_URL}/#{url}", body: xml, headers: HEADERS)
  Values::CreateAdPage.new(response, xml)
end