Class: Broadcast::Resources::EmailServers
- Defined in:
- lib/broadcast/resources/email_servers.rb
Constant Summary collapse
- REDACTED_FIELDS =
Fields the API returns redacted (bullet-masked). When updating, never round-trip these values back from a fetch — the gem strips them out of the payload (with a logger warning) to prevent corrupting credentials.
%i[ smtp_password aws_access_key_id aws_secret_access_key outbound_aws_access_key_id outbound_aws_secret_access_key postmark_api_token inboxroad_api_token smtp_com_api_key ].freeze
- REDACTED_PATTERN =
Matches the API’s redaction shape: 8 bullets, OR 4-char prefix + bullets + 4-char suffix.
/\A(?:•{8}|.{0,4}•+.{0,4})\z/
Instance Method Summary collapse
-
#copy_to_channel(id, target_channel_id:) ⇒ Object
Copy an email server to another channel.
- #create(**attrs) ⇒ Object
- #delete(id) ⇒ Object
- #get_email_server(id) ⇒ Object
- #list(limit: nil, offset: nil) ⇒ Object
- #test_connection(id) ⇒ Object
-
#update(id, **attrs) ⇒ Object
Update an email server.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Broadcast::Resources::Base
Instance Method Details
#copy_to_channel(id, target_channel_id:) ⇒ Object
Copy an email server to another channel. Requires an admin/system token. In SaaS mode, target_channel_id is scoped to the token creator’s account.
59 60 61 |
# File 'lib/broadcast/resources/email_servers.rb', line 59 def copy_to_channel(id, target_channel_id:) post("/api/v1/email_servers/#{id}/copy_to_channel", { target_channel_id: target_channel_id }) end |
#create(**attrs) ⇒ Object
34 35 36 |
# File 'lib/broadcast/resources/email_servers.rb', line 34 def create(**attrs) post('/api/v1/email_servers', { email_server: attrs }) end |
#delete(id) ⇒ Object
49 50 51 |
# File 'lib/broadcast/resources/email_servers.rb', line 49 def delete(id) @client.request(:delete, "/api/v1/email_servers/#{id}") end |
#get_email_server(id) ⇒ Object
30 31 32 |
# File 'lib/broadcast/resources/email_servers.rb', line 30 def get_email_server(id) get("/api/v1/email_servers/#{id}") end |
#list(limit: nil, offset: nil) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/broadcast/resources/email_servers.rb', line 23 def list(limit: nil, offset: nil) params = {} params[:limit] = limit unless limit.nil? params[:offset] = offset unless offset.nil? get('/api/v1/email_servers', params) end |
#test_connection(id) ⇒ Object
53 54 55 |
# File 'lib/broadcast/resources/email_servers.rb', line 53 def test_connection(id) post("/api/v1/email_servers/#{id}/test_connection") end |
#update(id, **attrs) ⇒ Object
Update an email server. Attrs are wrapped under ‘email_server:` on the wire.
CAUTION: API responses redact credential fields (e.g. ‘smtp_password`) with bullet characters. Never echo a fetched response back into update —this method scrubs values that match the redaction pattern, but you should pass only the fields you actually want to change.
44 45 46 47 |
# File 'lib/broadcast/resources/email_servers.rb', line 44 def update(id, **attrs) scrubbed = scrub_redacted(attrs) patch("/api/v1/email_servers/#{id}", { email_server: scrubbed }) end |