class MxHero::API::PSTConverter
Public Class Methods
new(config = {})
click to toggle source
# 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
Public Instance Methods
delete(account, id)
click to toggle source
# 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)
click to toggle source
# 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
task(account, id)
click to toggle source
# File lib/pst-converter.rb, line 39 def task(account, id) response = call(:get, url_pst_id(account, id)) parse_response(response) end
Private Instance Methods
parse_response(response, opts = { on_empty: nil })
click to toggle source
@return [MxHero::API::Response] a response object
# File lib/pst-converter.rb, line 70 def parse_response(response, opts = { on_empty: nil }) json = response.content hash = json.nil? || json.empty? ? opts[:on_empty] : json_parse(json) Response.new(response.code, hash) end
url_pst(account)
click to toggle source
# File lib/pst-converter.rb, line 57 def url_pst(account) "#{service_url}/pst/#{account}" end
url_pst_id(account, id)
click to toggle source
# File lib/pst-converter.rb, line 61 def url_pst_id(account, id) "#{url_pst(account)}/#{id}" end
url_pst_post(account)
click to toggle source
# File lib/pst-converter.rb, line 53 def url_pst_post(account) url_pst(account) + "/" end
url_pst_status(account, status, limit)
click to toggle source
# File lib/pst-converter.rb, line 65 def url_pst_status(account, status, limit) "#{url_pst(account)}/#{status}" + (limit ? "?limit=#{limit}" : "") end