weborcacloud_demo.rb

金 基鐘, 2024/06/04 09:22

다운로드 (1.757 KB)

 
1
#!/usr/bin/ruby
2
# coding:utf-8
3
require 'uri'
4
require 'net/https'
5

    
6
CA_CERT = "D:\\_RCLSJOB\\_orcakey\\064158__JP_u00008979\\ca.crt"
7
CERT    = "D:\\_RCLSJOB\\_orcakey\\064158__JP_u00008979\\064158__JP_u00008979_client53513.crt"
8
CERTKEY = "D:\\_RCLSJOB\\_orcakey\\064158__JP_u00008979\\064158__JP_u00008979_client53513.pem"
9
KEYPASS = "8eut49nev1"
10
APIUSER = "u00008979"
11
#APIUSER = "ormaster"
12
APIKEY  = "4b21c3618eeea587d7f0dc8d4ad5f9dd0ed778ca5ca4e07ba7291ac671a257ab"
13

    
14

    
15
Net::HTTP.version_1_2
16
# 本番環境
17
#https = Net::HTTP.new("weborca.cloud.orcamo.jp","443")
18
# デモ環境
19
https = Net::HTTP.new("demo-weborca.cloud.orcamo.jp","443")
20
https.use_ssl = true
21
https.ca_file = CA_CERT
22
https.cert = OpenSSL::X509::Certificate.new(File.read(CERT))
23
https.key = OpenSSL::PKey::RSA.new(File.read(CERTKEY),KEYPASS)
24
https.verify_mode = OpenSSL::SSL::VERIFY_PEER
25
https.verify_depth = 5
26

    
27
https.start do
28
  req = Net::HTTP::Post.new("/api/orca44/receiptdatamakev3")
29
  req.body = <<-EOF
30
<data>
31
        <receiptdata_makev3req type="record">
32
                <Request_Number type="string">01</Request_Number>
33
                <Karte_Uid type="string">1234567</Karte_Uid>
34
                <Orca_Uid type="string"></Orca_Uid>
35
                <Perform_Date type="string">2024-04-30</Perform_Date>
36
                <Perform_Month type="string">2024-04</Perform_Month>
37
                <Ac_Date type="string">2024-04-30</Ac_Date>
38
                <Receipt_Mode type="string">02</Receipt_Mode>
39
                <InOut type="string">OI</InOut>
40
                <Create_Mode type="string"></Create_Mode>
41
                <Submission_Mode type="string">02</Submission_Mode>
42
                <Check_Mode type="string"></Check_Mode>
43
        </receiptdata_makev3req>
44
</data>
45
  EOF
46

    
47
  req.content_type = "application/xml"
48
  req.content_length = req.body.size
49
  req.basic_auth(APIUSER,APIKEY)
50

    
51
  res = https.request(req)
52

    
53
  unless res.code == "200"
54
   raise "http error:#{res.code}"
55
  end
56

    
57
  puts res.body
58
end
클립보드 이미지 추가 (최대 크기: 50 MB)