Class: Anypost::Resources::Domains
- Defined in:
- lib/anypost/resources/domains.rb
Overview
Operations on the ‘/domains` endpoints.
Instance Method Summary collapse
-
#create(params) ⇒ Object
Add a sending domain.
-
#delete(id) ⇒ Object
Permanently delete a domain and its DKIM keys.
-
#get(id) ⇒ Object
Retrieve a single domain by id.
-
#list(params = {}) ⇒ Object
List the team’s domains, newest-first.
-
#update(id, params) ⇒ Object
Update a domain’s tracking configuration.
-
#verify(id) ⇒ Object
Trigger a verification check.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Anypost::Resources::Base
Instance Method Details
#create(params) ⇒ Object
Add a sending domain. The returned domain is ‘pending` until verified.
14 15 16 |
# File 'lib/anypost/resources/domains.rb', line 14 def create(params) request_object(:post, "/domains", body: params) end |
#delete(id) ⇒ Object
Permanently delete a domain and its DKIM keys.
29 30 31 32 |
# File 'lib/anypost/resources/domains.rb', line 29 def delete(id) @http.request(:delete, "/domains/#{encode(id)}") nil end |
#get(id) ⇒ Object
Retrieve a single domain by id.
19 20 21 |
# File 'lib/anypost/resources/domains.rb', line 19 def get(id) request_object(:get, "/domains/#{encode(id)}") end |
#list(params = {}) ⇒ Object
List the team’s domains, newest-first. Returns a Page; iterate it to walk every page, or follow ‘page.next_cursor` yourself.
9 10 11 |
# File 'lib/anypost/resources/domains.rb', line 9 def list(params = {}) paginate("/domains", {limit: params[:limit], after: params[:after]}) end |
#update(id, params) ⇒ Object
Update a domain’s tracking configuration. The domain ‘name` is immutable.
24 25 26 |
# File 'lib/anypost/resources/domains.rb', line 24 def update(id, params) request_object(:patch, "/domains/#{encode(id)}", body: params) end |
#verify(id) ⇒ Object
Trigger a verification check.
Always returns the current domain — read ‘status` and `verification_failure` to learn the outcome; a still-`pending` domain does not raise. Safe to poll while DNS propagates.
39 40 41 |
# File 'lib/anypost/resources/domains.rb', line 39 def verify(id) request_object(:post, "/domains/#{encode(id)}/verify") end |