-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpost_job_ad.rb
107 lines (93 loc) · 2.34 KB
/
post_job_ad.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# frozen_string_literal: true
require 'date'
require 'arbetsformedlingen'
AF = Arbetsformedlingen # for brevity
document = AF::Document.new(
customer_id: 'XXXYYYZZZ',
email: '[email protected]'
)
company = AF::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 = AF::Publication.new(
publish_at: Date.today,
unpublish_at: Date.today + 21,
name: 'John Doe',
email: '[email protected]'
)
schedule = AF::Schedule.new(
full_time: false,
summary: '3 days a week 8.00-17.00',
start_date: Date.today,
end_date: nil
)
salary = AF::Salary.new(
currency: 'SEK',
type: :fixed, # :fixed, :fixed_and_commission, :commission
summary: 'Your salary will be...'
)
qualifications = []
qualifications << AF::Qualification.new(
summary: 'A summary', # optional, but recommended field
required: true,
experience: true,
drivers_license: 'B,C1',
car: true
)
qualifications << AF::Qualification.new(
summary: 'A summary', # optional, but recommended field
required: false
)
application_method = AF::ApplicationMethod.new(
external: true, # applications are not made through AF
url: 'https://example.com',
summary: 'Goto our website'
)
position = AF::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 = AF::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::AF::Client.new(locale: 'sv')
client.create_ad(packet)