mxhero-api 0.1.9 → 0.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.9
1
+ 0.1.10
@@ -153,10 +153,14 @@ module MxHero
153
153
 
154
154
  # Retrieve all the rules for one domain
155
155
  #
156
+ # @param [String] domain
157
+ # @param [String] component Filter the list of rules by this component [optional]
158
+ #
156
159
  # @return [MxHero::API::Response] reponse
157
160
  # the key :msg contains an array of rules for the domain.
158
- def rules_for_domain(domain)
161
+ def rules_for_domain(domain, component = nil)
159
162
  url = rules_for_domain_url(domain)
163
+ url << "?component=#{component}" if component
160
164
  response = call(:get, url)
161
165
  parse_response(response, on_empty: [])
162
166
  end
@@ -2,20 +2,20 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "mxhero-api"
5
- s.version = "0.1.9"
5
+ s.version = "0.1.10"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Maximiliano Dello Russo", "Juan Pablo Royo", "mxHero"]
9
9
  s.date = "2013-08-17"
10
10
  s.description = "A gem to provide easy access to the API of MxHero platform (http://www.mxhero.com/)"
11
11
  s.email = ["maxidr@mxhero.com", "juanpablo.royo@gmail.com", "mxhero@mxhero.com"]
12
- s.files = [".gitignore", ".rvmrc", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "VERSION", "lib/mxhero-api.rb", "mxhero-api.gemspec", "test/fixtures/api/account_properties.yml", "test/fixtures/api/account_properties_not_found.yml", "test/fixtures/api/accounts_from_domain.yml", "test/fixtures/api/accounts_from_domain_paginated.yml", "test/fixtures/api/create_rule_alredy_exist.yml", "test/fixtures/api/create_rule_for_domain.yml", "test/fixtures/api/create_rule_success.yml", "test/fixtures/api/delete_rule.yml", "test/fixtures/api/domain_by_id.yml", "test/fixtures/api/domain_by_id_not_found.yml", "test/fixtures/api/domain_rule.yml", "test/fixtures/api/domains.yml", "test/fixtures/api/rules_for_domain.yml", "test/fixtures/api/update_account_properties.yml", "test/fixtures/api/update_rule.yml", "test/helper.rb", "test/test_mxhero_api.rb", "test/test_mxhero_api_response.rb"]
12
+ s.files = [".gitignore", ".rvmrc", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "VERSION", "lib/mxhero-api.rb", "mxhero-api.gemspec", "test/fixtures/api/account_properties.yml", "test/fixtures/api/account_properties_not_found.yml", "test/fixtures/api/accounts_from_domain.yml", "test/fixtures/api/accounts_from_domain_paginated.yml", "test/fixtures/api/create_rule_alredy_exist.yml", "test/fixtures/api/create_rule_for_domain.yml", "test/fixtures/api/create_rule_success.yml", "test/fixtures/api/delete_rule.yml", "test/fixtures/api/domain_by_id.yml", "test/fixtures/api/domain_by_id_not_found.yml", "test/fixtures/api/domain_rule.yml", "test/fixtures/api/domains.yml", "test/fixtures/api/rules_for_domain.yml", "test/fixtures/api/rules_for_domain_by_component.yml", "test/fixtures/api/update_account_properties.yml", "test/fixtures/api/update_rule.yml", "test/helper.rb", "test/test_mxhero_api.rb", "test/test_mxhero_api_response.rb"]
13
13
  s.homepage = "http://github.com/mxhero/mxhero-api"
14
14
  s.licenses = ["GPL-3"]
15
15
  s.require_paths = ["lib"]
16
16
  s.rubygems_version = "1.8.25"
17
17
  s.summary = "A MxHero API client for ruby"
18
- s.test_files = ["test/fixtures/api/account_properties.yml", "test/fixtures/api/account_properties_not_found.yml", "test/fixtures/api/accounts_from_domain.yml", "test/fixtures/api/accounts_from_domain_paginated.yml", "test/fixtures/api/create_rule_alredy_exist.yml", "test/fixtures/api/create_rule_for_domain.yml", "test/fixtures/api/create_rule_success.yml", "test/fixtures/api/delete_rule.yml", "test/fixtures/api/domain_by_id.yml", "test/fixtures/api/domain_by_id_not_found.yml", "test/fixtures/api/domain_rule.yml", "test/fixtures/api/domains.yml", "test/fixtures/api/rules_for_domain.yml", "test/fixtures/api/update_account_properties.yml", "test/fixtures/api/update_rule.yml", "test/helper.rb", "test/test_mxhero_api.rb", "test/test_mxhero_api_response.rb"]
18
+ s.test_files = ["test/fixtures/api/account_properties.yml", "test/fixtures/api/account_properties_not_found.yml", "test/fixtures/api/accounts_from_domain.yml", "test/fixtures/api/accounts_from_domain_paginated.yml", "test/fixtures/api/create_rule_alredy_exist.yml", "test/fixtures/api/create_rule_for_domain.yml", "test/fixtures/api/create_rule_success.yml", "test/fixtures/api/delete_rule.yml", "test/fixtures/api/domain_by_id.yml", "test/fixtures/api/domain_by_id_not_found.yml", "test/fixtures/api/domain_rule.yml", "test/fixtures/api/domains.yml", "test/fixtures/api/rules_for_domain.yml", "test/fixtures/api/rules_for_domain_by_component.yml", "test/fixtures/api/update_account_properties.yml", "test/fixtures/api/update_rule.yml", "test/helper.rb", "test/test_mxhero_api.rb", "test/test_mxhero_api_response.rb"]
19
19
 
20
20
  if s.respond_to? :specification_version then
21
21
  s.specification_version = 3
@@ -0,0 +1,41 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://admin:password@localhost:8080/webapi/api/v1/domains/tesla.com/rules?component=org.mxhero.feature.signature
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ Content-Type:
13
+ - application/json
14
+ Authorization:
15
+ - Basic YWRtaW46cGFzc3dvcmQ=
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: !binary |-
20
+ T0s=
21
+ headers:
22
+ !binary "RGF0ZQ==":
23
+ - !binary |-
24
+ U2F0LCAxNyBBdWcgMjAxMyAxNTowMDo0OSBHTVQ=
25
+ !binary "U2VydmVy":
26
+ - !binary |-
27
+ QXBhY2hlLzIuMi4xNCAoVWJ1bnR1KQ==
28
+ !binary "Q29udGVudC1MZW5ndGg=":
29
+ - !binary |-
30
+ Nzk0
31
+ !binary "Q29udGVudC1UeXBl":
32
+ - !binary |-
33
+ YXBwbGljYXRpb24vanNvbg==
34
+ body:
35
+ encoding: US-ASCII
36
+ string: ! '[{"id":141,"domain":"tesla.com","name":"a test rule for auto signature","created":1376751456000,"updated":1376751456000,"enabled":true,"twoWays":false,"adminOrder":null,"component":"org.mxhero.feature.signature","fromDirection":{"id":280,"directionType":"domain","freeValue":"tesla.com","domain":"tesla.com","account":null,"group":null},"toDirection":{"id":281,"directionType":"anyoneelse","freeValue":"anyoneelse","domain":null,"account":null,"group":null},"properties":[{"propertyKey":"return.message","propertyValue":"<hr
37
+ />${firstname} ${lastname}<br />Email: ${email}<br />My Company Example"},{"propertyKey":"return.message.plain","propertyValue":"\n----------------\n${firstname}
38
+ ${lastname}\nEmail: ${email}\nMy Company Example"},{"propertyKey":"interParsing","propertyValue":"true"}]}]'
39
+ http_version:
40
+ recorded_at: Sat, 17 Aug 2013 15:00:49 GMT
41
+ recorded_with: VCR 2.5.0
@@ -10,6 +10,14 @@ class MxHeroAPITest < MiniTest::Unit::TestCase
10
10
  TEST_API_DOMAIN
11
11
  end
12
12
 
13
+ def test_verbose
14
+ api = MxHero::API::Client.new
15
+ assert ! api.verbose?, 'Verbose is false by default'
16
+
17
+ api.verbose = true
18
+ assert api.verbose?, 'Verbose state must be changed'
19
+ end
20
+
13
21
  def test_update_rule
14
22
  VCR.use_cassette('update_rule') do
15
23
  rules = obtain_rules(domain)
@@ -47,6 +55,16 @@ class MxHeroAPITest < MiniTest::Unit::TestCase
47
55
  end
48
56
  end
49
57
 
58
+ def test_rules_for_domain_filter_component
59
+ VCR.use_cassette('rules_for_domain_by_component') do
60
+ component = 'org.mxhero.feature.signature'
61
+ response = @api.rules_for_domain(domain, component)
62
+ assert response.code == 200
63
+ rules = response.msg
64
+ assert rules.all? { |rule| rule[:component] == component }, "All the rules must be of component type #{component}"
65
+ end
66
+ end
67
+
50
68
  def test_domains
51
69
  VCR.use_cassette('domains') do
52
70
  domains = @api.domains
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mxhero-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -92,6 +92,7 @@ files:
92
92
  - test/fixtures/api/domain_rule.yml
93
93
  - test/fixtures/api/domains.yml
94
94
  - test/fixtures/api/rules_for_domain.yml
95
+ - test/fixtures/api/rules_for_domain_by_component.yml
95
96
  - test/fixtures/api/update_account_properties.yml
96
97
  - test/fixtures/api/update_rule.yml
97
98
  - test/helper.rb
@@ -112,7 +113,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
112
113
  version: '0'
113
114
  segments:
114
115
  - 0
115
- hash: 2905145132655348938
116
+ hash: -400696915372951367
116
117
  required_rubygems_version: !ruby/object:Gem::Requirement
117
118
  none: false
118
119
  requirements:
@@ -139,6 +140,7 @@ test_files:
139
140
  - test/fixtures/api/domain_rule.yml
140
141
  - test/fixtures/api/domains.yml
141
142
  - test/fixtures/api/rules_for_domain.yml
143
+ - test/fixtures/api/rules_for_domain_by_component.yml
142
144
  - test/fixtures/api/update_account_properties.yml
143
145
  - test/fixtures/api/update_rule.yml
144
146
  - test/helper.rb