Class: Clicksign::Resources::Notarial::Signer

Inherits:
Clicksign::Resource show all
Defined in:
lib/clicksign/resources/notarial/signer.rb

Instance Attribute Summary

Attributes inherited from Clicksign::Resource

#id, #relationships

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Clicksign::Resource

#[], auto_paging_each, client, #delete, each_page, fields, filter, filter_params, include, list, #method_missing, nested_list, order, page, per, #reload, #respond_to_missing?, validate_jsonapi_include_types!, with_includes

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Clicksign::Resource

Class Method Details

.create(envelope_id:, **attributes) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/clicksign/resources/notarial/signer.rb', line 15

def self.create(envelope_id:, **attributes)
  raw = client.post(
    "/envelopes/#{envelope_id}/signers",
    body: JsonApi::Serializer.dump(type: resource_type, attributes: attributes),
  )
  parsed = JsonApi::Parser.parse(raw)
  build_instance(parsed[:data].first, parent_id: envelope_id)
end

.notify(id, envelope_id:, message: nil, **email_customization) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/clicksign/resources/notarial/signer.rb', line 24

def self.notify(id, envelope_id:, message: nil, **email_customization)
  attributes = {}
  attributes[:message] = message if message
  unless email_customization.empty?
    attributes[:email_customization] =
      email_customization
  end
  body = { data: { type: 'notifications', attributes: attributes } }
  client.post("/envelopes/#{envelope_id}/signers/#{id}/notifications", body: body)
  nil
end

.retrieve(id, envelope_id:) ⇒ Object



9
10
11
12
13
# File 'lib/clicksign/resources/notarial/signer.rb', line 9

def self.retrieve(id, envelope_id:)
  raw    = client.get("/envelopes/#{envelope_id}/signers/#{id}")
  parsed = JsonApi::Parser.parse(raw)
  build_instance(parsed[:data].first, parent_id: envelope_id)
end

Instance Method Details

#base_pathObject



46
47
48
# File 'lib/clicksign/resources/notarial/signer.rb', line 46

def base_path
  "/envelopes/#{@_parent_id || envelope_id}/signers"
end

#envelope_idObject



50
51
52
# File 'lib/clicksign/resources/notarial/signer.rb', line 50

def envelope_id
  @_parent_id || relationships.dig('envelope', 'data', 'id')
end

#notify(message: nil, **email_customization) ⇒ Object



36
37
38
39
# File 'lib/clicksign/resources/notarial/signer.rb', line 36

def notify(message: nil, **email_customization)
  self.class.notify(@id, envelope_id: envelope_id, message: message,
                         **email_customization)
end

#updateObject

Raises:

  • (NotImplementedError)


41
42
43
44
# File 'lib/clicksign/resources/notarial/signer.rb', line 41

def update(**)
  raise NotImplementedError,
        'Signer does not support update (route: except: [:update])'
end