Class: JaLC::Registration::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/jalc/registration/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Client

Returns a new instance of Client.



15
16
17
# File 'lib/jalc/registration/client.rb', line 15

def initialize(config)
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



13
14
15
# File 'lib/jalc/registration/client.rb', line 13

def config
  @config
end

Instance Method Details

#get_result(exec_id) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/jalc/registration/client.rb', line 31

def get_result(exec_id)
  response = conn.post(
    '/jalc/infoRegistry/registDataResult/index',
    {
      login_id: Faraday::Multipart::ParamPart.new(config.id, 'text/plain'),
      login_passwd: Faraday::Multipart::ParamPart.new(config.password, 'text/plain'),
      exec_id: Faraday::Multipart::ParamPart.new(exec_id, 'text/plain'),
    },
  )
  response.body
end

#post(xml_file) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/jalc/registration/client.rb', line 19

def post(xml_file)
  response = conn.post(
    '/jalc/infoRegistry/registDataReceive/index',
    {
      login_id: Faraday::Multipart::ParamPart.new(config.id, 'text/plain'),
      login_passwd: Faraday::Multipart::ParamPart.new(config.password, 'text/plain'),
      fname: Faraday::Multipart::FilePart.new(xml_file, 'text/xml'),
    },
  )
  response.body
end