/
main.go
66 lines (49 loc) · 1.56 KB
/
main.go
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
// Copyright 2018 The ClientSDK Team Authors. All rights reserved.
// Use of this source code is governed by a Apache 2.0-style
// license that can be found in the LICENSE file.
// Author: ClientSDK Team (muharihar)
package main
import (
"log"
"net/http"
"net/url"
"github.com/ClientSDK/kai-train-ws-client-go/kaiwsdkv2"
)
const (
kaiServer = "https://railticket.kereta-api.co.id/" // Production Server
// kaiServer = "http://ws.demo.kai.sqiva.com/" // Demo Server
kaiRQID = "YOUR-KAI-AGENT-CREDENTIAL-RQID"
)
func makeHTTPClient() *http.Client {
// Access via proxy if needed
proxyURL, _ := url.Parse("http://proxy-ip-address:proxy-port")
//proxyURL, _ := url.Parse("http://proxy-user:proxy-password@proxy-ip-address:proxy-port")
// Initiate http client with transport
// httpClient := &http.Client{Transport: &http.Transport{}}
// Using Proxy if needed
httpClient := &http.Client{Transport: &http.Transport{Proxy: http.ProxyURL(proxyURL)}}
return httpClient
}
func main() {
// init http client
httpClient := makeHTTPClient()
// Initiate NewKAIHttpClient version 2
kaiClient, err := kaiwsdkv2.NewKAIHttpClient(httpClient, kaiServer, kaiRQID)
if err != nil {
log.Fatal(err)
}
// call KAI web service method
callF(kaiClient)
}
func callF(kaiClient *kaiwsdkv2.KAIHttpClient) {
// params := make(map[string]string)
// vRS, err := kaiClient.Call...(false)
//if err != nil {
// log.Fatal(err)
//}
// sample how to Access Response
// fmt.Println(vRS.ErrCode)
// fmt.Println(vRS.ErrMsg)
// json, _ := json.Marshal(vRS)
// fmt.Println(string(json))
}