Class: Nylas::Outbox
- Inherits:
-
Object
- Object
- Nylas::Outbox
- Defined in:
- lib/nylas/outbox.rb
Overview
Methods for Outbox functionality
Instance Attribute Summary collapse
-
#api ⇒ Object
Returns the value of attribute api.
Instance Method Summary collapse
-
#delete(job_status_id) ⇒ void
Delete a scheduled Outbox message.
-
#delete_send_grid_sub_user(email) ⇒ void
SendGrid - Delete SendGrid Subuser and UAS Grant.
-
#initialize(api:) ⇒ Outbox
constructor
A new instance of Outbox.
- #outbox_path ⇒ Object
-
#send(draft, send_at: nil, retry_limit_datetime: nil) ⇒ OutboxJobStatus
rubocop:disable Layout/LineLength Send a message via Outbox rubocop:enable Layout/LineLength.
-
#send_grid_verification_status ⇒ SendGridVerifiedStatus
SendGrid - Check Authentication and Verification Status.
-
#update(job_status_id, message: nil, send_at: nil, retry_limit_datetime: nil) ⇒ OutboxJobStatus
rubocop:disable Layout/LineLength Update a scheduled Outbox message rubocop:enable Layout/LineLength.
Constructor Details
#initialize(api:) ⇒ Outbox
Returns a new instance of Outbox.
9 10 11 |
# File 'lib/nylas/outbox.rb', line 9 def initialize(api:) self.api = api end |
Instance Attribute Details
#api ⇒ Object
Returns the value of attribute api.
7 8 9 |
# File 'lib/nylas/outbox.rb', line 7 def api @api end |
Instance Method Details
#delete(job_status_id) ⇒ void
This method returns an undefined value.
Delete a scheduled Outbox message
60 61 62 63 64 65 |
# File 'lib/nylas/outbox.rb', line 60 def delete(job_status_id) api.execute( method: :delete, path: "#{outbox_path}/#{job_status_id}" ) end |
#delete_send_grid_sub_user(email) ⇒ void
This method returns an undefined value.
SendGrid - Delete SendGrid Subuser and UAS Grant
83 84 85 86 87 88 89 |
# File 'lib/nylas/outbox.rb', line 83 def delete_send_grid_sub_user(email) api.execute( method: :delete, path: "#{outbox_path}/onboard/subuser", payload: JSON.dump({ email: email }) ) end |
#outbox_path ⇒ Object
13 14 15 |
# File 'lib/nylas/outbox.rb', line 13 def outbox_path @outbox_path ||= "/v2/outbox" end |
#send(draft, send_at: nil, retry_limit_datetime: nil) ⇒ OutboxJobStatus
rubocop:disable Layout/LineLength Send a message via Outbox rubocop:enable Layout/LineLength
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/nylas/outbox.rb', line 24 def send(draft, send_at: nil, retry_limit_datetime: nil) = draft.to_h(enforce_read_only: true) .merge!(validate_set_date_time(send_at, retry_limit_datetime)) outbox_response = api.execute( method: :post, path: outbox_path, payload: JSON.dump() ) OutboxJobStatus.new(**outbox_response) end |
#send_grid_verification_status ⇒ SendGridVerifiedStatus
SendGrid - Check Authentication and Verification Status
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/nylas/outbox.rb', line 69 def send_grid_verification_status response = api.execute( method: :get, path: "#{outbox_path}/onboard/verified_status" ) raise "Verification status not present in response" if response.key?("results") SendGridVerifiedStatus.new(**response[:results]) end |
#update(job_status_id, message: nil, send_at: nil, retry_limit_datetime: nil) ⇒ OutboxJobStatus
rubocop:disable Layout/LineLength Update a scheduled Outbox message rubocop:enable Layout/LineLength
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/nylas/outbox.rb', line 44 def update(job_status_id, message: nil, send_at: nil, retry_limit_datetime: nil) payload = {} payload.merge!(.to_h(enforce_read_only: true)) if payload.merge!(validate_set_date_time(send_at, retry_limit_datetime)) outbox_response = api.execute( method: :patch, path: "#{outbox_path}/#{job_status_id}", payload: JSON.dump(payload) ) OutboxJobStatus.new(**outbox_response) end |