raas-client-rails 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e6c4f44354fc42a8fe599680f73fef59c0120d9265a05661ae3eea7b8c527af4
4
- data.tar.gz: c83b4968c3f023ebd3cfcb2e2fb82e6eb12eb7126906a52bff7e7a869249c04b
3
+ metadata.gz: b7b6a84b9056a678c04d3ccda0b3e9e51f088ce762ff66f220290759dfa68581
4
+ data.tar.gz: 1078171ee29459bca2475b20b36e1aa4ec66ca12aeb1f6a9c261d3d325dedc25
5
5
  SHA512:
6
- metadata.gz: accb3436b7087aa5827111d34af8fc481f40ccd7b0ff71e3a506bccda38c0a2d078f5258664b9e280c04e73af6db8c5fe76d0aa7a27e928b38985cb3632fd492
7
- data.tar.gz: 32f79a1e62cedb106d5ac87671f9d59452732daf63a1dd700890b87d8de3d1700e4fe35ad525f23b657f9288e4a3e0e5637aad4062101d502cb4dc304eaa2096
6
+ metadata.gz: a29156150876b44a236747e93ed2a0cd7b673dc3db0d432edf1213fdf63045f1811932c8f398a7f73b9049fa7e3e52f5bdc7965e78da34213e96fb73d0597010
7
+ data.tar.gz: d8c97c5576fca515e38ac04ebcd17df908bff8d323c673f1d39293e7467f21b25136b197b4a1cb4b21e29ccac23ed88ff265651198abcce1de32e9d8d6e609ca
@@ -14,28 +14,29 @@ module Raas::Client::Rails
14
14
  end
15
15
 
16
16
  def prepare(params)
17
- # seven arguments are needed to make this work
18
- application = Raas::Client::Rails::Engine.config.raas_client_rails.application
19
- landscape = Raas::Client::Rails::Engine.config.raas_client_rails.landscape
20
- token = Raas::Client::Rails::Engine.config.raas_client_rails.token
21
17
  @backUrl = params[:backUrl]
22
18
  @subUrl = params[:subUrl]
19
+ prepare_tenant_and_sub()
20
+ @restClient = RestClient.new(@tenant, @sub)
21
+ end
22
+
23
+ def prepare_tenant_and_sub()
24
+ # For Overload
23
25
  @tenant = params[:tenant]
24
26
  @sub = params[:sub]
25
- @restClient = RestClient.new(application,landscape,token)
26
27
  end
27
28
 
28
29
  def report_session()
29
30
  Rails.logger.warn("session parameter=#{params}");
30
31
  prepare(params)
31
- response = @restClient.createExternalSession(MSA_REPORT,@backUrl,@subUrl,@tenant,@sub)
32
+ response = @restClient.createExternalSession(MSA_REPORT,@backUrl,@subUrl)
32
33
  render json: response.body
33
34
  end
34
35
 
35
36
  def datatraveler_session()
36
37
  Rails.logger.warn("session parameter=#{params}")
37
38
  prepare(params)
38
- response = @restClient.createExternalSession(MSA_DT,@backUrl,@subUrl,@tenant,@sub)
39
+ response = @restClient.createExternalSession(MSA_DT,@backUrl,@subUrl)
39
40
  render json: response.body
40
41
  end
41
42
 
@@ -69,7 +70,7 @@ module Raas::Client::Rails
69
70
  payload = parameters
70
71
  end
71
72
  Rails.logger.warn("get path=#{path} parameters=#{payload}");
72
- response = @restClient.get(path,payload,@tenant,@sub)
73
+ response = @restClient.get(path,payload)
73
74
  handleMime(mimeType, fileName, type, response)
74
75
  end
75
76
 
@@ -98,7 +99,7 @@ module Raas::Client::Rails
98
99
  payload = JSON.parse(parameters)
99
100
  end
100
101
  Rails.logger.warn("delete path=#{path} parameters=#{parameters}");
101
- return @restClient.delete(path,payload,@tenant,@sub)
102
+ return @restClient.delete(path,payload)
102
103
  end
103
104
 
104
105
  #/raas/post
@@ -112,7 +113,7 @@ module Raas::Client::Rails
112
113
  payload = JSON.parse(requestBody)
113
114
  end
114
115
  Rails.logger.warn("post path=#{path} requestBody=#{requestBody}");
115
- response = @restClient.post(path,payload,@tenant,@sub)
116
+ response = @restClient.post(path,payload)
116
117
  return response.body;
117
118
  end
118
119
 
@@ -127,7 +128,7 @@ module Raas::Client::Rails
127
128
  payload = JSON.parse(requestBody)
128
129
  end
129
130
  Rails.logger.warn("post path=#{path} requestBody=#{requestBody}");
130
- response = @restClient.put(path,payload,@tenant,@sub)
131
+ response = @restClient.put(path,payload)
131
132
  return response.body;
132
133
  end
133
134
 
@@ -12,21 +12,20 @@ module Raas::Client::Rails
12
12
  DELETE = "delete"
13
13
  APEX_DOMAIN = "functions.asaservice.inc";
14
14
 
15
- def initialize(application,landscape,token)
16
- @application = application
17
- @landscape = landscape
18
- @token = token
15
+ def initialize(tenant, sub)
16
+ @application = Raas::Client::Rails::Engine.config.raas_client_rails.application
17
+ @landscape = Raas::Client::Rails::Engine.config.raas_client_rails.landscape
18
+ @token = Raas::Client::Rails::Engine.config.raas_client_rails.token
19
+ @tenant = tenant
20
+ @sub = sub
19
21
  end
20
22
 
21
- # ResponseEntity<String> resp = raasClient.createExternalSession(Constant.MSA_REPORT,req.getBackUrl(),req.getSubUrl(), saasContextProvider.getTenant(), saasContextProvider.getSub());
22
-
23
-
24
- def createExternalSession(msa,backUrl,subUrl,tenant,sub)
23
+ def createExternalSession(msa,backUrl,subUrl)
25
24
  body = Hash.new
26
25
  body["backUrl"] = backUrl
27
26
  body["subUrl"] = subUrl
28
- body["tenant"] = tenant
29
- body["sub"] = sub
27
+ body["tenant"] = @tenant
28
+ body["sub"] = @sub
30
29
  return proxy(body,POST,"/#{msa}/external/session",nil,@token)
31
30
  end
32
31
 
@@ -36,51 +35,41 @@ module Raas::Client::Rails
36
35
  #Use Rails default cache system, this simply use cache otherwise fetch and store
37
36
  Rails.logger.debug("Attempt to recycle token");
38
37
  cacheName = "#{@tenant}+++#{@sub}"
39
- @@t = @tenant
40
- @@s = @sub
41
38
  Rails.logger.debug("Cache name is #{cacheName}")
42
39
  # p cacheName
43
40
  return token = Rails.cache.fetch(cacheName) do
44
41
  Rails.logger.debug("No cache found, fetch it by api");
45
- Rails.logger.debug("tenant #=> #{@@t} / sub #=> #{@@s}")
46
- response = getUserTokenImpl( "report" , @@t , @@s);
42
+ Rails.logger.debug("tenant #=> #{@tenant} / sub #=> #{@sub}")
43
+ response = getUserTokenImpl("report");
47
44
  Rails.logger.debug(response.body)
48
45
  return JSON.parse(response.body);
49
46
  end
50
47
  end
51
48
 
52
49
  # fetch token from RaaS because no cache
53
- def getUserTokenImpl(msa,tenant,sub)
50
+ def getUserTokenImpl(msa)
54
51
  body = Hash.new
55
- body["tenant"] = tenant
56
- body["sub"] = sub
52
+ body["tenant"] = @tenant
53
+ body["sub"] = @sub
57
54
  response = proxy(body,POST,"/#{msa}/external/token",nil,@token);
58
55
  end
59
56
 
60
- def get(requestUrl, params,tenant,sub)
61
- @tenant = tenant
62
- @sub = sub
57
+ def get(requestUrl, params)
63
58
  json = getUserToken()
64
59
  return proxy(nil, GET,requestUrl,params,json["token"]);
65
60
  end
66
61
 
67
- def delete(requestUrl, params,tenant,sub)
68
- @tenant = tenant
69
- @sub = sub
62
+ def delete(requestUrl, params)
70
63
  json = getUserToken()
71
64
  return proxy(nil, DELETE,requestUrl,params,json["token"]);
72
65
  end
73
66
 
74
- def put(requestUrl,body,tenant,sub)
75
- @tenant = tenant
76
- @sub = sub
67
+ def put(requestUrl,body)
77
68
  json = getUserToken()
78
69
  return proxy(body , PUT,requestUrl,nil,json["token"]);
79
70
  end
80
71
 
81
- def post(requestUrl,body,tenant,sub)
82
- @tenant = tenant
83
- @sub = sub
72
+ def post(requestUrl,body)
84
73
  json = getUserToken()
85
74
  return proxy(body , POST,requestUrl,nil,json["token"]);
86
75
  end
@@ -1,7 +1,7 @@
1
1
  module Raas
2
2
  module Client
3
3
  module Rails
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raas-client-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sunao Suzuki