MxHero API client
A ruby client to interact with the MxHero API
Instalation
gem install mxhero-api
or in your Gemfile:
gem 'mxhero-api'
Example of uses
Some examples, complete documentation in the API client documentation
Instanciate a client
client = MxHero::API::Client.new(username: 'api username', password: 'api password', api_url: 'http://api-url-example.mxhero.com/api')
Retrieve all the domains
# Retrieve all the domains
domains = client.domains
# Return a hash, example:
#
# { :elements => [
# { :domain=>"tesla.com", :server=>"tesla.com", :creationDate=>1369837819000, :updatedDate=>1369837819000, :aliases=>nil, :ldap=>nil }
# ],
# :totalElements=>1,
# :totalPages=>1,
# :actualPage=>1
# }
Retrieve all rules for one domain
rules = client.rules_for_domain('tesla.com')
Create a rule for one domain
# The representation of a rule is a Hash.
# Example:
rule = {
domain: 'test.com',
twoWays: false,
enabled: true,
name: 'Rule name',
created: DateTime.now.strftime('%Q'), # epoch time for now
fromDirection: { directionType: 'domain', domain: 'test.com', freeValue: 'test.com' },
toDirection: { directionType: 'domain', domain: 'test.com', freeValue: 'test.com' },
properties: [
{ propertyKey: 'return.message', propertyValue: 'footer content' }
],
component: 'org.mxhero.feature.disclaimer'
}
# Create a rule for one domain
client.create_rule_for_domain('test.com', rule)
Update a rule
client.update_rule(rule)
find a rule for one domain
client.domain_rule('tesla.com', 12)
Complete documentation
Complete documentation in the API client documentation
Run test
Run all test
rake test
Run specific method
ruby test/test_emailsync.rb --name=test_delete -v
Or:
rake test TEST=test/test_foobar.rb TESTOPTS="--name=test_foobar1 -v"
Build a new version
rake version:bump
gem build mxhero-api.gemspec
gem push mxhero-api-{{ version }}.gem