Sha256: 110b75451a96d1a9f91fe02428c50fe48c354c992bc501eb563c54cff638edcb

Contents?: true

Size: 1.5 KB

Versions: 3

Compression:

Stored size: 1.5 KB

Contents

require 'arbetsformedlingen/soap_builder'
require 'arbetsformedlingen/api/soap_request'

module Arbetsformedlingen
  module API
    class WSOccupationClient
      attr_reader :request

      SERVICE_URL = 'https://api.arbetsformedlingen.se/af/v0/Occupation/wsoccupation.asmx'.freeze

      def initialize
        @request = request || SOAPRequest.new(SERVICE_URL)
      end

      def occupation(id)
        soap_body = SOAPBuilder.wrap do |body|
          body.GetOccupationById(xmlns: 'urn:ams.se:wsoccupation') do |node|
            node.occupationId(id)
          end
        end

        request.post(soap_body.to_xml)
      end

      def find_occupations(name)
        soap_body = SOAPBuilder.wrap do |body|
          body.FindOccupation(xmlns: 'urn:ams.se:wsoccupation') do |node|
            node.name(name)
          end
        end

        request.post(soap_body.to_xml)
      end

      def occupations
        soap_body = SOAPBuilder.wrap do |body|
          body.GetAllOccupations(xmlns: 'urn:ams.se:wsoccupation')
        end

        request.post(soap_body.to_xml)
      end

      def occupations_short
        soap_body = SOAPBuilder.wrap do |body|
          body.GetAllOccupationsShort(xmlns: 'urn:ams.se:wsoccupation')
        end

        request.post(soap_body.to_xml)
      end

      def occupations_detailed
        soap_body = SOAPBuilder.wrap do |body|
          body.GetAllOccupationsDetailed(xmlns: 'urn:ams.se:wsoccupation')
        end

        request.post(soap_body.to_xml)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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