Class: ClickSign::Signer
- Inherits:
-
Object
- Object
- ClickSign::Signer
- Defined in:
- lib/click_sign/signer.rb
Instance Attribute Summary collapse
-
#auths ⇒ Object
readonly
Returns the value of attribute auths.
-
#birthday ⇒ Object
readonly
Returns the value of attribute birthday.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#documentation ⇒ Object
readonly
Returns the value of attribute documentation.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#has_documentation ⇒ Object
readonly
Returns the value of attribute has_documentation.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#phone_number ⇒ Object
readonly
Returns the value of attribute phone_number.
-
#raw_data ⇒ Object
readonly
Returns the value of attribute raw_data.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
Class Method Summary collapse
-
.build_payload(**args) ⇒ Object
. - .create(**args) ⇒ Object
- .default_auths ⇒ Object
- .default_delivery ⇒ Object
- .default_has_documentation ⇒ Object
- .find(signer_key: nil) ⇒ Object
Instance Method Summary collapse
-
#add_to_document(document_key: nil, sign_as: nil, group: nil) ⇒ Object
. -
#initialize(args) ⇒ Signer
constructor
A new instance of Signer.
- #remove_from_document(list_key: nil) ⇒ Object
Constructor Details
#initialize(args) ⇒ Signer
Returns a new instance of Signer.
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/click_sign/signer.rb', line 6 def initialize(args) @raw_data = args @key = clean_key(args['key']) if args['key'].present? @email = clean_email(args['email']) if args['email'].present? @auths = clean_auths(args['auths']) if args['auths'].present? @name = clean_name(args['name']) if args['name'].present? @documentation = clean_documentation(args['documentation']) if args['documentation'].present? @birthday = clean_birthday(args['birthday']) if args['birthday'].present? @phone_number = clean_phone_number(args['phone_number']) if args['phone_number'].present? @has_documentation = clean_has_documentation(args['has_documentation']) if args['has_documentation'].present? @created_at = clean_created_at(args['created_at']) if args['created_at'].present? @updated_at = clean_updated_at(args['updated_at']) if args['updated_at'].present? end |
Instance Attribute Details
#auths ⇒ Object (readonly)
Returns the value of attribute auths.
4 5 6 |
# File 'lib/click_sign/signer.rb', line 4 def auths @auths end |
#birthday ⇒ Object (readonly)
Returns the value of attribute birthday.
4 5 6 |
# File 'lib/click_sign/signer.rb', line 4 def birthday @birthday end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
4 5 6 |
# File 'lib/click_sign/signer.rb', line 4 def created_at @created_at end |
#documentation ⇒ Object (readonly)
Returns the value of attribute documentation.
4 5 6 |
# File 'lib/click_sign/signer.rb', line 4 def documentation @documentation end |
#email ⇒ Object (readonly)
Returns the value of attribute email.
4 5 6 |
# File 'lib/click_sign/signer.rb', line 4 def email @email end |
#has_documentation ⇒ Object (readonly)
Returns the value of attribute has_documentation.
4 5 6 |
# File 'lib/click_sign/signer.rb', line 4 def has_documentation @has_documentation end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
4 5 6 |
# File 'lib/click_sign/signer.rb', line 4 def key @key end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/click_sign/signer.rb', line 4 def name @name end |
#phone_number ⇒ Object (readonly)
Returns the value of attribute phone_number.
4 5 6 |
# File 'lib/click_sign/signer.rb', line 4 def phone_number @phone_number end |
#raw_data ⇒ Object (readonly)
Returns the value of attribute raw_data.
4 5 6 |
# File 'lib/click_sign/signer.rb', line 4 def raw_data @raw_data end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
4 5 6 |
# File 'lib/click_sign/signer.rb', line 4 def updated_at @updated_at end |
Class Method Details
.build_payload(**args) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/click_sign/signer.rb', line 21 def self.build_payload(**args) payload = {} payload['email'] = parse_email(args['email']) if args['email'].present? payload['phone_number'] = parse_phone_number(args['phone_number']) if args['phone_number'].present? payload['name'] = parse_name(args['name']) if args['name'].present? payload['documentation'] = parse_documentation(args['documentation']) if args['documentation'].present? payload['birthday'] = parse_birthday(args['birthday']) if args['birthday'].present? payload['has_documentation'] = args['has_documentation'].present? ? parse_has_documentation(args['has_documentation']) : default_has_documentation payload['auths'] = args['auths'].present? ? parse_auths(args['auths']) : default_auths payload['delivery'] = args['delivery'].present? ? parse_delivery(args['delivery']) : default_delivery {signer: payload} end |
.create(**args) ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/click_sign/signer.rb', line 48 def self.create(**args) payload = build_payload(args) response = ClickSign::Service.post( url: 'signers', payload: payload ) if response.created? new_signer = ClickSign::Signer.new(response.body['signer']) end end |
.default_auths ⇒ Object
44 45 46 |
# File 'lib/click_sign/signer.rb', line 44 def self.default_auths ['email'] end |
.default_delivery ⇒ Object
36 37 38 |
# File 'lib/click_sign/signer.rb', line 36 def self.default_delivery ClickSign::Constants::Delivery::EMAIL end |
.default_has_documentation ⇒ Object
40 41 42 |
# File 'lib/click_sign/signer.rb', line 40 def self.default_has_documentation true end |
.find(signer_key: nil) ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/click_sign/signer.rb', line 59 def self.find(signer_key: nil) response = ClickSign::Service.get( url: ['signers', signer_key] ) if response.success? signer = ClickSign::Signer.new(response.body['signer']) end end |
Instance Method Details
#add_to_document(document_key: nil, sign_as: nil, group: nil) ⇒ Object
70 71 72 |
# File 'lib/click_sign/signer.rb', line 70 def add_to_document document_key: nil, sign_as: nil, group: nil ClickSign::List.create document_key: document_key, signer_key: self.key, sign_as: sign_as, group: group end |
#remove_from_document(list_key: nil) ⇒ Object
74 75 76 |
# File 'lib/click_sign/signer.rb', line 74 def remove_from_document list_key: nil ClickSign::List.delete list_key: list_key end |