Class: Dtmcli::Dtm
- Inherits:
-
Object
- Object
- Dtmcli::Dtm
- Defined in:
- lib/dtmcli/dtm.rb
Instance Attribute Summary collapse
-
#dtm_url ⇒ Object
readonly
Returns the value of attribute dtm_url.
Class Method Summary collapse
Instance Method Summary collapse
- #abort(body) ⇒ Object
-
#initialize(dtm_url) ⇒ Dtm
constructor
A new instance of Dtm.
- #prepare(body) ⇒ Object
- #query(params) ⇒ Object
- #register_tcc_branch(body) ⇒ Object
- #register_xa_branch(body) ⇒ Object
- #submit(body) ⇒ Object
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_url ⇒ Object (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 |
.parse ⇒ Object
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
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 |