Class: MxHero::API::EmailSync
- Inherits:
-
Object
- Object
- MxHero::API::EmailSync
- Includes:
- Communication, Urls
- Defined in:
- lib/email-sync.rb
Instance Method Summary collapse
- #all(domain, params = {}) ⇒ Object
- #delete(domain, id) ⇒ Object
-
#initialize(config = {}) ⇒ EmailSync
constructor
A new instance of EmailSync.
-
#request(domain, method, path = '/', more = {}) ⇒ HTTP::Message
Make a request in the endpoin /emailsync/#domain.
- #task_by_id(domain, id) ⇒ Object
Methods included from Urls
#domain_by_id_url, #domains_url, #service_url
Methods included from Communication
Constructor Details
#initialize(config = {}) ⇒ EmailSync
Returns a new instance of EmailSync.
20 21 22 23 24 25 26 |
# File 'lib/email-sync.rb', line 20 def initialize(config = {}) @service_url = config[:api_url] @username = config[:username] @password = config[:password] @verbose = config[:verbose] || false @as_user = config[:as_user] end |
Instance Method Details
#all(domain, params = {}) ⇒ Object
28 29 30 |
# File 'lib/email-sync.rb', line 28 def all(domain, params = {}) wrap_response_from call(:get, url(domain, params)) end |
#delete(domain, id) ⇒ Object
37 38 39 40 |
# File 'lib/email-sync.rb', line 37 def delete(domain, id) return if id.nil? || id.empty? wrap_response_from call(:delete, "#{url(domain)}#{id}") end |
#request(domain, method, path = '/', more = {}) ⇒ HTTP::Message
Make a request in the endpoin /emailsync/#domain
51 52 53 54 |
# File 'lib/email-sync.rb', line 51 def request(domain, method, path = '/', more = {}) url = "#{@service_url}/emailsync/#{domain}#{path}#{parse_params(more[:params])}" call(method, url, more[:body]) end |
#task_by_id(domain, id) ⇒ Object
32 33 34 35 |
# File 'lib/email-sync.rb', line 32 def task_by_id(domain, id) return if id.nil? || id.empty? wrap_response_from call(:get, "#{url(domain)}#{id}") end |