Method: SelfSDK::Services::Docs#request_signature

Defined in:
lib/services/docs.rb

#request_signature(recipient, body, objects, opts = {}) {|request| ... } ⇒ Object

Sends a signature request to the specified user.

you just want the body to be signed.

Parameters:

  • recipient (string)

    the recipient of the request.

  • body (string)

    the message to be displayed to the user.

  • objects (Array)

    array of objects to be signed. provide an empty array if

Yields:

  • (request)

    Invokes the given block when a response is received.


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
# File 'lib/services/docs.rb', line 31

def request_signature(recipient, body, objects, opts = {}, &block)
  jti = SecureRandom.uuid
  req = {
    jti: jti,
    typ: "document.sign.req",
    aud: recipient,
    msg: body,
    objects: [],
  }

  auth_token = @messaging.client.jwt.auth_token
  objects.each do |o|
    req[:objects] << SelfSDK::Chat::FileObject.new(auth_token, @self_url).build_from_data(
      o[:name],
      o[:data],
      o[:mime],
      opts
    ).to_payload
  end

  if block_given?
    @messaging.client.set_observer(OpenStruct.new({
      id: jti,
      to: recipient,
      from: @messaging.client.jwt.id
    }), timeout: 60 * 60 * 10, &block)

    return @messaging.send(recipient, req)
  end

  @messaging.send(recipient, req)
end