Class: Dtmcli::Dtm

Inherits:
Object
  • Object
show all
Defined in:
lib/dtmcli/dtm.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dtm_url) ⇒ Dtm

Returns a new instance of Dtm.



24
25
26
# File 'lib/dtmcli/dtm.rb', line 24

def initialize(dtm_url)
  @dtm_url = dtm_url
end

Instance Attribute Details

#dtm_urlObject (readonly)

Returns the value of attribute dtm_url.



3
4
5
# File 'lib/dtmcli/dtm.rb', line 3

def dtm_url
  @dtm_url
end

Class Method Details

.new_gid(dtm_url) ⇒ Object



18
19
20
21
# File 'lib/dtmcli/dtm.rb', line 18

def new_gid(dtm_url)
  data = Proxy.execute(:get, dtm_url + '/newGid', {}, &parse)
  return data["gid"]
end

.parseObject



10
11
12
13
14
15
16
# File 'lib/dtmcli/dtm.rb', line 10

def parse
  lambda do |resp|
    body = JSON.parse(resp.body)
    raise DtmSvrError, "dtm server error: data = #{body}" if !succ?(body)
    body
  end
end

.succ?(data) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/dtmcli/dtm.rb', line 6

def succ?(data)
  data['dtm_result'] == 'SUCCESS'
end

Instance Method Details

#abort(body) ⇒ Object



36
37
38
# File 'lib/dtmcli/dtm.rb', line 36

def abort(body)
  Proxy.execute(:post, dtm_url + '/abort', {body: body}, &Dtm::parse)
end

#prepare(body) ⇒ Object



28
29
30
# File 'lib/dtmcli/dtm.rb', line 28

def prepare(body)
  Proxy.execute(:post, dtm_url + '/prepare', {body: body}, &Dtm::parse)
end

#query(params) ⇒ Object



48
49
50
# File 'lib/dtmcli/dtm.rb', line 48

def query(params)
  Proxy.execute(:get, dtm_url + '/query',{params: params}, &Dtm::parse)
end

#register_tcc_branch(body) ⇒ Object



44
45
46
# File 'lib/dtmcli/dtm.rb', line 44

def register_tcc_branch(body)
  Proxy.execute(:post, dtm_url + '/registerTccBranch',{body: body}, &Dtm::parse)
end

#register_xa_branch(body) ⇒ Object



40
41
42
# File 'lib/dtmcli/dtm.rb', line 40

def register_xa_branch(body)
  Proxy.execute(:post, dtm_url + '/registerXaBranch',{body: body}, &Dtm::parse)
end

#submit(body) ⇒ Object



32
33
34
# File 'lib/dtmcli/dtm.rb', line 32

def submit(body)
  Proxy.execute(:post, dtm_url + '/submit', {body: body}, &Dtm::parse)
end