Class: Yandex360::MailSettingsResource
- Includes:
- ParamBuilder
- Defined in:
- lib/yandex360/resources/mail_settings.rb
Overview
Per-employee mail settings: automatic contact collection, the sender name and signatures, and the auto-reply and forwarding rules.
All three live under /admin/v1/org/orgId/mail/users/userId/settings.
See https://yandex.ru/dev/api360/doc/ru/ref/MailUserSettingsService/
Instance Attribute Summary
Attributes inherited from Resource
Instance Method Summary collapse
- #address_book(org_id:, user_id:) ⇒ Object
-
#create_rule(org_id:, user_id:, **params) ⇒ Object
One rule per call, and of one kind: an auto-reply takes rule_name and text, a forward takes rule_name, address and with_store.
- #delete_rule(org_id:, user_id:, rule_id:) ⇒ Object
-
#rules(org_id:, user_id:) ⇒ Object
Auto-reply and forwarding rules arrive together, under separate keys.
- #sender_info(org_id:, user_id:) ⇒ Object
- #update_address_book(org_id:, user_id:, collect_addresses:) ⇒ Object
-
#update_sender_info(org_id:, user_id:, **params) ⇒ Object
Accepts from_name, default_from, signs and sign_position; the API documents them in camelCase, so they are converted here.
Methods inherited from Resource
Constructor Details
This class inherits a constructor from Yandex360::Resource
Instance Method Details
#address_book(org_id:, user_id:) ⇒ Object
13 14 15 |
# File 'lib/yandex360/resources/mail_settings.rb', line 13 def address_book(org_id:, user_id:) MailAddressBook.new get(settings_path(org_id, user_id, "address_book")).body end |
#create_rule(org_id:, user_id:, **params) ⇒ Object
One rule per call, and of one kind: an auto-reply takes rule_name and text, a forward takes rule_name, address and with_store.
43 44 45 46 47 48 49 |
# File 'lib/yandex360/resources/mail_settings.rb', line 43 def create_rule(org_id:, user_id:, **params) validate_required_params({org_id: org_id, user_id: user_id}, %i[org_id user_id]) raise ArgumentError, "Provide the rule attributes" if params.empty? body = camelize(build_params({}, params)) MailRule.new post(settings_path(org_id, user_id, "user_rules"), body: body).body end |
#delete_rule(org_id:, user_id:, rule_id:) ⇒ Object
51 52 53 54 55 |
# File 'lib/yandex360/resources/mail_settings.rb', line 51 def delete_rule(org_id:, user_id:, rule_id:) required = {org_id: org_id, user_id: user_id, rule_id: rule_id} validate_required_params(required, %i[org_id user_id rule_id]) Response.new delete_request("#{settings_path(org_id, user_id, 'user_rules')}/#{rule_id}").body end |
#rules(org_id:, user_id:) ⇒ Object
Auto-reply and forwarding rules arrive together, under separate keys.
37 38 39 |
# File 'lib/yandex360/resources/mail_settings.rb', line 37 def rules(org_id:, user_id:) MailUserRules.new get(settings_path(org_id, user_id, "user_rules")).body end |
#sender_info(org_id:, user_id:) ⇒ Object
24 25 26 |
# File 'lib/yandex360/resources/mail_settings.rb', line 24 def sender_info(org_id:, user_id:) MailSenderInfo.new get(settings_path(org_id, user_id, "sender_info")).body end |
#update_address_book(org_id:, user_id:, collect_addresses:) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/yandex360/resources/mail_settings.rb', line 17 def update_address_book(org_id:, user_id:, collect_addresses:) required = {org_id: org_id, user_id: user_id} validate_required_params(required, %i[org_id user_id]) body = {collectAddresses: collect_addresses} MailAddressBook.new post(settings_path(org_id, user_id, "address_book"), body: body).body end |
#update_sender_info(org_id:, user_id:, **params) ⇒ Object
Accepts from_name, default_from, signs and sign_position; the API documents them in camelCase, so they are converted here.
30 31 32 33 34 |
# File 'lib/yandex360/resources/mail_settings.rb', line 30 def update_sender_info(org_id:, user_id:, **params) validate_required_params({org_id: org_id, user_id: user_id}, %i[org_id user_id]) body = camelize(build_params({}, params)) MailSenderInfo.new post(settings_path(org_id, user_id, "sender_info"), body: body).body end |