Class: SelfSDK::Services::Docs
- Inherits:
-
Object
- Object
- SelfSDK::Services::Docs
- Defined in:
- lib/services/docs.rb
Overview
Input class to handle document requests on self network.
Instance Attribute Summary collapse
-
#app_id ⇒ Object
Returns the value of attribute app_id.
Instance Method Summary collapse
-
#initialize(messaging, url) ⇒ SelfSDK::Services::Docs
constructor
Creates a new docs service.
-
#request_signature(recipient, body, objects, opts = {}) {|request| ... } ⇒ Object
Sends a signature request to the specified user.
-
#subscribe {|request| ... } ⇒ Object
Subscribes to all document sign responses.
Constructor Details
#initialize(messaging, url) ⇒ SelfSDK::Services::Docs
Creates a new docs service. Docs service mainly allows you to send document signature requests.
19 20 21 22 |
# File 'lib/services/docs.rb', line 19 def initialize(messaging, url) @messaging = messaging @self_url = url end |
Instance Attribute Details
#app_id ⇒ Object
Returns the value of attribute app_id.
11 12 13 |
# File 'lib/services/docs.rb', line 11 def app_id @app_id end |
Instance Method Details
#request_signature(recipient, body, objects, opts = {}) {|request| ... } ⇒ Object
Sends a signature request to the specified user.
you just want the body to be signed.
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 |
#subscribe {|request| ... } ⇒ Object
Subscribes to all document sign responses.
67 68 69 |
# File 'lib/services/docs.rb', line 67 def subscribe(&block) @messaging.subscribe(:document_sign_response, &block) end |