Module: Universign::Sign

Defined in:
lib/universign.rb

Defined Under Namespace

Modules: Status Classes: Client

Constant Summary collapse

SANDBOX_URL =
'sign.test.cryptolog.com'.freeze
PROD_URL =
'ws.universign.eu'.freeze
PATH =
'/sign/rpc'.freeze

Class Method Summary collapse

Class Method Details

.clientObject



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/universign.rb', line 47

def client
  fail 'You need to set config options' if Universign.configuration.nil?
  host = Universign.configuration.production ? PROD_URL : SANDBOX_URL
  client = Universign::Sign::Client.new(
      host, PATH, nil, nil, nil,
      Universign.configuration.user,
      Universign.configuration.password, true
  )
  client.set_debug if Universign.configuration.debug
  client
end

.list_transactions(status: Universign::Sign::Status::COMPLETED, not_before: nil, not_after: nil, start_range: 0, res: []) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/universign.rb', line 68

def list_transactions(
    status: Universign::Sign::Status::COMPLETED,
    not_before: nil, not_after: nil, start_range: 0, res: []
)
  options = { status: status, startRange: start_range }
  options[:notBefore] = not_before if not_before.is_a? Date
  options[:notAfter] = not_after if not_after.is_a? Date
  r = client.call('requester.listTransactions', options)
  return res unless r.count > 0
  res += r
  list_transactions(
      status: status,
      not_before: not_before,
      not_after: not_after,
      start_range: start_range + r.count,
      res: res
  )
end

.transaction_document(content, name, options = {}) ⇒ Object



64
65
66
# File 'lib/universign.rb', line 64

def transaction_document(content, name, options = {})
  { content: XMLRPC::Base64.new(content), name: name }.merge options
end

.transaction_signer(options = {}) ⇒ Object



59
60
61
62
# File 'lib/universign.rb', line 59

def transaction_signer(options = {})
  validate_transaction_signer_argument options
  options
end