Class: Libis::Services::Rosetta::ProducerHandler
- Inherits:
-
Client
- Object
- Client
- Libis::Services::Rosetta::ProducerHandler
show all
- Defined in:
- lib/libis/services/rosetta/producer_handler.rb
Instance Attribute Summary
Attributes included from SoapClient
#client
Instance Method Summary
collapse
-
#agent(agent_id, agent_info = nil) ⇒ Object
-
#agent_producers(agent_id, institution = nil) ⇒ Object
-
#contact(contact_id, contact_info = nil) ⇒ Object
-
#delete_agent(agent_id) ⇒ Object
-
#delete_contact(contact_id) ⇒ Object
-
#delete_producer(producer_id) ⇒ Object
-
#initialize(base_url = 'https://repository.teneo.libis.be', options = {}) ⇒ ProducerHandler
constructor
A new instance of ProducerHandler.
-
#is_user?(user_id) ⇒ Boolean
-
#link_agent(agent_id, producer_id) ⇒ Object
-
#link_contact(contact_id, producer_id, primary = true) ⇒ Object
-
#material_flows(producer_id) ⇒ Object
-
#new_agent(agent_info) ⇒ Object
-
#new_contact(contact_info) ⇒ Object
-
#new_producer(producer_info) ⇒ Object
-
#producer(producer_id, producer_info = nil) ⇒ Object
-
#unlink_agent(agent_id, producer_id) ⇒ Object
-
#unlink_contact(contact_id, producer_id) ⇒ Object
-
#user_id(external_id) ⇒ Object
Methods inherited from Client
#authenticate, #get_heart_bit, #pds_handle=
Methods included from SoapClient
#configure, #operations, #request
Constructor Details
#initialize(base_url = 'https://repository.teneo.libis.be', options = {}) ⇒ ProducerHandler
Returns a new instance of ProducerHandler.
16
17
18
|
# File 'lib/libis/services/rosetta/producer_handler.rb', line 16
def initialize(base_url = 'https://repository.teneo.libis.be', options = {})
super 'backoffice', 'ProducerWebServices', {url: base_url}.merge(options)
end
|
Instance Method Details
#agent(agent_id, agent_info = nil) ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/libis/services/rosetta/producer_handler.rb', line 52
def agent(agent_id, agent_info = nil)
if agent_info
info = agent(agent_id)
return nil if info.nil?
(agent_info.is_a?(Rosetta::ProducerAgent) ? agent_info.attributes : agent_info).each do |name, value|
info[name] = value
end
call :update_producer_agent, arg0: @pds_handle, arg1: agent_id, arg2: info.to_xml
else
request_object :get_producer_agent, Rosetta::ProducerAgent, arg0: @pds_handle, arg1: agent_id
end
end
|
#agent_producers(agent_id, institution = nil) ⇒ Object
83
84
85
86
87
88
89
|
# File 'lib/libis/services/rosetta/producer_handler.rb', line 83
def agent_producers(agent_id, institution = nil)
if institution
request_array :get_producers_of_producer_agent_with_ins, arg0: agent_id, arg1: institution
else
request_array :get_producers_of_producer_agent, arg0: agent_id
end
end
|
91
92
93
94
95
96
97
98
99
100
101
102
|
# File 'lib/libis/services/rosetta/producer_handler.rb', line 91
def contact(contact_id, contact_info = nil)
if contact_info
info = contact(contact_id)
return nil if info.nil?
(contact_info.is_a?(Rosetta::User) ? contact_info.attributes : contact_info).each do |name, value|
info[name] = value
end
call :update_contact, arg0: @pds_handle, arg1: contact_id, arg2: info.to_xml
else
request_object :get_contact, Rosetta::User, arg0: @pds_handle, arg1: contact_id
end
end
|
#delete_agent(agent_id) ⇒ Object
71
72
73
|
# File 'lib/libis/services/rosetta/producer_handler.rb', line 71
def delete_agent(agent_id)
call :remove_producer_agent, arg0: @pds_handle, arg1: agent_id
end
|
110
111
112
|
# File 'lib/libis/services/rosetta/producer_handler.rb', line 110
def delete_contact(contact_id)
call :remove_contact, arg0: @pds_handle, arg1: contact_id
end
|
#delete_producer(producer_id) ⇒ Object
48
49
50
|
# File 'lib/libis/services/rosetta/producer_handler.rb', line 48
def delete_producer(producer_id)
call :remove_producer, arg0: @pds_handle, arg1: producer_id
end
|
#is_user?(user_id) ⇒ Boolean
24
25
26
27
|
# File 'lib/libis/services/rosetta/producer_handler.rb', line 24
def is_user?(user_id)
data = call :is_user_exists, arg0: @pds_handle, arg1: user_id
data == "User name #{user_id} already exists"
end
|
#link_agent(agent_id, producer_id) ⇒ Object
75
76
77
|
# File 'lib/libis/services/rosetta/producer_handler.rb', line 75
def link_agent(agent_id, producer_id)
call :link_producer_agent_to_producer, arg0: @pds_handle, arg1: producer_id, arg2: agent_id
end
|
114
115
116
117
|
# File 'lib/libis/services/rosetta/producer_handler.rb', line 114
def link_contact(contact_id, producer_id, primary = true)
call :link_contact_to_producer, arg0: @pds_handle, arg1: producer_id, arg2: contact_id, arg3: (!!primary).to_s.upcase
end
|
#material_flows(producer_id) ⇒ Object
123
124
125
|
# File 'lib/libis/services/rosetta/producer_handler.rb', line 123
def material_flows(producer_id)
request_array :get_material_flows_of_producer, arg0: producer_id
end
|
#new_agent(agent_info) ⇒ Object
65
66
67
68
69
|
# File 'lib/libis/services/rosetta/producer_handler.rb', line 65
def new_agent(agent_info)
agent_info = Rosetta::ProducerAgent.new(agent_info) unless agent_info.is_a?(Rosetta::ProducerAgent)
call :create_producer_agent, arg0: @pds_handle, arg1: agent_info.to_xml
end
|
104
105
106
107
108
|
# File 'lib/libis/services/rosetta/producer_handler.rb', line 104
def new_contact(contact_info)
contact_info = Rosetta::User.new(contact_info) unless contact_info.is_a?(Rosetta::User)
call :create_contact, arg0: @pds_handle, arg1: contact_info.to_xml
end
|
#new_producer(producer_info) ⇒ Object
42
43
44
45
46
|
# File 'lib/libis/services/rosetta/producer_handler.rb', line 42
def new_producer(producer_info)
producer_info = Rosetta::Producer.new(producer_info) unless producer_info.is_a?(Rosetta::Producer)
call :create_producer, arg0: @pds_handle, arg1: producer_info.to_xml
end
|
#producer(producer_id, producer_info = nil) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/libis/services/rosetta/producer_handler.rb', line 29
def producer(producer_id, producer_info = nil)
if producer_info
info = producer(producer_id)
return nil if info.nil?
(producer_info.is_a?(Rosetta::Producer) ? producer_info.attributes : producer_info).each do |name, value|
info[name] = value
end
call :update_producer, arg0: @pds_handle, arg1: producer_id, arg2: info.to_xml
else
request_object :get_producer_details, Rosetta::Producer, arg0: @pds_handle, arg1: producer_id
end
end
|
#unlink_agent(agent_id, producer_id) ⇒ Object
79
80
81
|
# File 'lib/libis/services/rosetta/producer_handler.rb', line 79
def unlink_agent(agent_id, producer_id)
call :unlink_producer_agent_from_producer, arg0: @pds_handle, arg1: producer_id, arg2: agent_id
end
|
119
120
121
|
# File 'lib/libis/services/rosetta/producer_handler.rb', line 119
def unlink_contact(contact_id, producer_id)
call :unlink_contact_from_producer, arg0: @pds_handle, arg1: producer_id, arg2: contact_id
end
|
#user_id(external_id) ⇒ Object
20
21
22
|
# File 'lib/libis/services/rosetta/producer_handler.rb', line 20
def user_id(external_id)
call :get_internal_user_id_by_external_id, arg0: external_id
end
|