Class: MxHero::API::PSTConverter

Inherits:
Object
  • Object
show all
Includes:
Communication, Urls
Defined in:
lib/pst-converter.rb

Instance Method Summary collapse

Methods included from Urls

#domain_by_id_url, #domains_url, #service_url

Methods included from Communication

#call, #headers, #json_parse

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(, id)
  response = call(:delete, url_pst_id(, id))
  response.status == 200
end

#save(account, task) ⇒ Object



44
45
46
47
48
49
# File 'lib/pst-converter.rb', line 44

def save(, task)
  response = call(:post, url_pst_post(), task.to_json, throw_exception: false)
  parsed = parse_response(response)
  return parsed.msg[:id] if parsed.success?
  nil
end

#statusMxHero::API::Response

Retrieve all tasks for account in status #status

Parameters:

  • account (String)

    The account to search tasks for

Returns:



27
28
29
30
31
32
# File 'lib/pst-converter.rb', line 27

['active', 'inactive'].each do |status|
  define_method("#{status}_tasks") do |, limit = nil|
    response = call(:get, url_pst_status(, 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(, id)
  response = call(:get, url_pst_id(, id))
  parse_response(response)
end