Sha256: 27aab08f930697581ff5ab1e3502316c9cbeb42e0d9a129888298dd62bc6ac77

Contents?: true

Size: 847 Bytes

Versions: 4

Compression:

Stored size: 847 Bytes

Contents

require 'arbetsformedlingen/api/request'
require 'arbetsformedlingen/api/values/create_ad_page'

module Arbetsformedlingen
  module API
    class LedigtarbeteClient
      BASE_URL = 'http://api.arbetsformedlingen.se/ledigtarbete'.freeze

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

      # Post ad to API
      # @param [Arbetsformedlingen::Packet, #to_xml] the data to be sent
      # @return [Values::CreateAdPage] the API result
      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
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
arbetsformedlingen-0.5.0 lib/arbetsformedlingen/api/ledigtarbete_client.rb
arbetsformedlingen-0.4.1 lib/arbetsformedlingen/api/ledigtarbete_client.rb
arbetsformedlingen-0.4.0 lib/arbetsformedlingen/api/ledigtarbete_client.rb
arbetsformedlingen-0.3.0 lib/arbetsformedlingen/api/ledigtarbete_client.rb