Class: MxHero::API::PSTConverter
Instance Method Summary
collapse
Methods included from Urls
#domain_by_id_url, #domains_url, #service_url
#call, #headers, #json_parse
Constructor Details
#initialize(config = {}) ⇒ 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
|
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
|