Class: MxHero::API::PSTConverter
- Inherits:
-
Object
- Object
- MxHero::API::PSTConverter
- Includes:
- Communication, Urls
- Defined in:
- lib/pst-converter.rb
Instance Method Summary collapse
- #delete(account, id) ⇒ Object
-
#initialize(config = {}) ⇒ PSTConverter
constructor
A new instance of PSTConverter.
- #save(account, task) ⇒ Object
-
#status ⇒ MxHero::API::Response
Retrieve all tasks for account in status #status.
- #task(account, id) ⇒ Object
Methods included from Urls
#domain_by_id_url, #domains_url, #service_url
Methods included from Communication
Constructor Details
#initialize(config = {}) ⇒ PSTConverter
Returns a new instance of PSTConverter.
15 16 17 18 19 20 21 |
# File 'lib/pst-converter.rb', line 15 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
#delete(account, id) ⇒ Object
34 35 36 37 |
# File 'lib/pst-converter.rb', line 34 def delete(account, id) response = call(:delete, url_pst_id(account, id)) response.status == 200 end |
#save(account, task) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/pst-converter.rb', line 44 def save(account, task) response = call(:post, url_pst_post(account), task.to_json, throw_exception: false) parsed = parse_response(response) return parsed.msg[:id] if parsed.success? nil end |
#status ⇒ MxHero::API::Response
Retrieve all tasks for account in status #status
27 28 29 30 31 32 |
# File 'lib/pst-converter.rb', line 27 ['active', 'inactive'].each do |status| define_method("#{status}_tasks") do |account, limit = nil| response = call(:get, url_pst_status(account, status, limit)) parse_response(response, on_empty: []) end end |
#task(account, id) ⇒ Object
39 40 41 42 |
# File 'lib/pst-converter.rb', line 39 def task(account, id) response = call(:get, url_pst_id(account, id)) parse_response(response) end |