mxhero-api 0.1.11 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. data/VERSION +1 -1
  2. data/lib/communication.rb +35 -0
  3. data/lib/groups.rb +178 -0
  4. data/lib/mxhero-api.rb +288 -312
  5. data/lib/urls.rb +19 -0
  6. data/mxhero-api.gemspec +4 -4
  7. data/test/fixtures/api/account_properties.yml +12 -13
  8. data/test/fixtures/api/account_properties_not_found.yml +9 -9
  9. data/test/fixtures/api/accounts.yml +39 -0
  10. data/test/fixtures/api/accounts_filtered.yml +57 -42
  11. data/test/fixtures/api/accounts_from_domain.yml +10 -10
  12. data/test/fixtures/api/accounts_from_domain_paginated.yml +10 -10
  13. data/test/fixtures/api/accounts_without_group.yml +75 -0
  14. data/test/fixtures/api/add_an_inexistent_account_to_group.yml +39 -0
  15. data/test/fixtures/api/add_and_remove_account.yml +219 -0
  16. data/test/fixtures/api/all_groups.yml +39 -0
  17. data/test/fixtures/api/create_rule_for_domain.yml +95 -21
  18. data/test/fixtures/api/delete_group.yml +75 -0
  19. data/test/fixtures/api/delete_rule.yml +21 -61
  20. data/test/fixtures/api/domain_by_id.yml +10 -10
  21. data/test/fixtures/api/domain_by_id_not_found.yml +9 -9
  22. data/test/fixtures/api/domain_rule.yml +62 -76
  23. data/test/fixtures/api/domains.yml +10 -10
  24. data/test/fixtures/api/remove_account_from_group_twice.yml +150 -0
  25. data/test/fixtures/api/remove_inexistente_account_from_group.yml +39 -0
  26. data/test/fixtures/api/rules_for_domain.yml +11 -57
  27. data/test/fixtures/api/rules_for_domain_by_component.yml +6 -8
  28. data/test/fixtures/api/save_group.yml +119 -0
  29. data/test/fixtures/api/update_account_properties.yml +35 -33
  30. data/test/fixtures/api/update_rule.yml +35 -76
  31. data/test/helper.rb +1 -1
  32. data/test/test_groups.rb +104 -0
  33. data/test/test_mxhero_api.rb +49 -27
  34. metadata +26 -7
  35. data/test/fixtures/api/create_rule_alredy_exist.yml +0 -81
  36. data/test/fixtures/api/create_rule_success.yml +0 -41
@@ -0,0 +1,39 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://admin:password@test.mxhero.com/webapi/api/v1/domains/tesla.com/groups/development/accounts/account.is.not.exist/add
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: 404
19
+ message: !binary |-
20
+ Tm90IEZvdW5k
21
+ headers:
22
+ !binary "RGF0ZQ==":
23
+ - !binary |-
24
+ RnJpLCAxMyBTZXAgMjAxMyAxOTo0NzoxMyBHTVQ=
25
+ !binary "U2VydmVy":
26
+ - !binary |-
27
+ QXBhY2hlLzIuMi4xNCAoVWJ1bnR1KQ==
28
+ !binary "Q29udGVudC1MZW5ndGg=":
29
+ - !binary |-
30
+ MTUw
31
+ !binary "Q29udGVudC1UeXBl":
32
+ - !binary |-
33
+ YXBwbGljYXRpb24vanNvbg==
34
+ body:
35
+ encoding: US-ASCII
36
+ string: ! '{"status":404,"code":404,"message":"domain.account.not.found","developerMessage":"domain.account.not.found","moreInfoUrl":"mailto:support@mxhero.com"}'
37
+ http_version:
38
+ recorded_at: Fri, 13 Sep 2013 19:47:12 GMT
39
+ recorded_with: VCR 2.5.0
@@ -0,0 +1,219 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://admin:password@test.mxhero.com/webapi/api/v1/domains/tesla.com/groups/development/accounts
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
+ RnJpLCAxMyBTZXAgMjAxMyAxOTo1MDowNyBHTVQ=
25
+ !binary "U2VydmVy":
26
+ - !binary |-
27
+ QXBhY2hlLzIuMi4xNCAoVWJ1bnR1KQ==
28
+ !binary "Q29udGVudC1MZW5ndGg=":
29
+ - !binary |-
30
+ Mjgx
31
+ !binary "Q29udGVudC1UeXBl":
32
+ - !binary |-
33
+ YXBwbGljYXRpb24vanNvbg==
34
+ body:
35
+ encoding: US-ASCII
36
+ string: ! '{"elements":[{"account":"john.doe","domain":"tesla.com","createdDate":1378759081000,"updatedDate":1379098913000,"group":"development","aliases":[{"name":"john.doe","domain":"tesla.com","dataSource":"manual"}],"dataSource":"manual"}],"totalElements":1,"totalPages":1,"actualPage":1}'
37
+ http_version:
38
+ recorded_at: Fri, 13 Sep 2013 19:50:06 GMT
39
+ - request:
40
+ method: delete
41
+ uri: http://admin:password@test.mxhero.com/webapi/api/v1/domains/tesla.com/groups/development/accounts/john.doe/remove
42
+ body:
43
+ encoding: US-ASCII
44
+ string: ''
45
+ headers:
46
+ Accept:
47
+ - application/json
48
+ Content-Type:
49
+ - application/json
50
+ Authorization:
51
+ - Basic YWRtaW46cGFzc3dvcmQ=
52
+ response:
53
+ status:
54
+ code: 200
55
+ message: !binary |-
56
+ T0s=
57
+ headers:
58
+ !binary "RGF0ZQ==":
59
+ - !binary |-
60
+ RnJpLCAxMyBTZXAgMjAxMyAxOTo1MDowNyBHTVQ=
61
+ !binary "U2VydmVy":
62
+ - !binary |-
63
+ QXBhY2hlLzIuMi4xNCAoVWJ1bnR1KQ==
64
+ !binary "Q29udGVudC1MZW5ndGg=":
65
+ - !binary |-
66
+ MA==
67
+ !binary "Q29udGVudC1UeXBl":
68
+ - !binary |-
69
+ dGV4dC9wbGFpbg==
70
+ body:
71
+ encoding: US-ASCII
72
+ string: ''
73
+ http_version:
74
+ recorded_at: Fri, 13 Sep 2013 19:50:07 GMT
75
+ - request:
76
+ method: post
77
+ uri: http://admin:password@test.mxhero.com/webapi/api/v1/domains/tesla.com/groups/development/accounts/john.doe/add
78
+ body:
79
+ encoding: US-ASCII
80
+ string: ''
81
+ headers:
82
+ Accept:
83
+ - application/json
84
+ Content-Type:
85
+ - application/json
86
+ Authorization:
87
+ - Basic YWRtaW46cGFzc3dvcmQ=
88
+ response:
89
+ status:
90
+ code: 201
91
+ message: !binary |-
92
+ Q3JlYXRlZA==
93
+ headers:
94
+ !binary "RGF0ZQ==":
95
+ - !binary |-
96
+ RnJpLCAxMyBTZXAgMjAxMyAxOTo1MDowNyBHTVQ=
97
+ !binary "U2VydmVy":
98
+ - !binary |-
99
+ QXBhY2hlLzIuMi4xNCAoVWJ1bnR1KQ==
100
+ !binary "Q29udGVudC1MZW5ndGg=":
101
+ - !binary |-
102
+ MjE4
103
+ !binary "Q29udGVudC1UeXBl":
104
+ - !binary |-
105
+ YXBwbGljYXRpb24vanNvbg==
106
+ body:
107
+ encoding: US-ASCII
108
+ string: ! '{"account":"john.doe","domain":"tesla.com","createdDate":1378759081000,"updatedDate":1379101807000,"group":"development","aliases":[{"name":"john.doe","domain":"tesla.com","dataSource":"manual"}],"dataSource":"manual"}'
109
+ http_version:
110
+ recorded_at: Fri, 13 Sep 2013 19:50:07 GMT
111
+ - request:
112
+ method: get
113
+ uri: http://admin:password@test.mxhero.com/webapi/api/v1/domains/tesla.com/groups/development/accounts
114
+ body:
115
+ encoding: US-ASCII
116
+ string: ''
117
+ headers:
118
+ Accept:
119
+ - application/json
120
+ Content-Type:
121
+ - application/json
122
+ Authorization:
123
+ - Basic YWRtaW46cGFzc3dvcmQ=
124
+ response:
125
+ status:
126
+ code: 200
127
+ message: !binary |-
128
+ T0s=
129
+ headers:
130
+ !binary "RGF0ZQ==":
131
+ - !binary |-
132
+ RnJpLCAxMyBTZXAgMjAxMyAxOTo1MDowOCBHTVQ=
133
+ !binary "U2VydmVy":
134
+ - !binary |-
135
+ QXBhY2hlLzIuMi4xNCAoVWJ1bnR1KQ==
136
+ !binary "Q29udGVudC1MZW5ndGg=":
137
+ - !binary |-
138
+ Mjgx
139
+ !binary "Q29udGVudC1UeXBl":
140
+ - !binary |-
141
+ YXBwbGljYXRpb24vanNvbg==
142
+ body:
143
+ encoding: US-ASCII
144
+ string: ! '{"elements":[{"account":"john.doe","domain":"tesla.com","createdDate":1378759081000,"updatedDate":1379101807000,"group":"development","aliases":[{"name":"john.doe","domain":"tesla.com","dataSource":"manual"}],"dataSource":"manual"}],"totalElements":1,"totalPages":1,"actualPage":1}'
145
+ http_version:
146
+ recorded_at: Fri, 13 Sep 2013 19:50:08 GMT
147
+ - request:
148
+ method: delete
149
+ uri: http://admin:password@test.mxhero.com/webapi/api/v1/domains/tesla.com/groups/development/accounts/john.doe/remove
150
+ body:
151
+ encoding: US-ASCII
152
+ string: ''
153
+ headers:
154
+ Accept:
155
+ - application/json
156
+ Content-Type:
157
+ - application/json
158
+ Authorization:
159
+ - Basic YWRtaW46cGFzc3dvcmQ=
160
+ response:
161
+ status:
162
+ code: 200
163
+ message: !binary |-
164
+ T0s=
165
+ headers:
166
+ !binary "RGF0ZQ==":
167
+ - !binary |-
168
+ RnJpLCAxMyBTZXAgMjAxMyAxOTo1MDowOCBHTVQ=
169
+ !binary "U2VydmVy":
170
+ - !binary |-
171
+ QXBhY2hlLzIuMi4xNCAoVWJ1bnR1KQ==
172
+ !binary "Q29udGVudC1MZW5ndGg=":
173
+ - !binary |-
174
+ MA==
175
+ !binary "Q29udGVudC1UeXBl":
176
+ - !binary |-
177
+ dGV4dC9wbGFpbg==
178
+ body:
179
+ encoding: US-ASCII
180
+ string: ''
181
+ http_version:
182
+ recorded_at: Fri, 13 Sep 2013 19:50:08 GMT
183
+ - request:
184
+ method: get
185
+ uri: http://admin:password@test.mxhero.com/webapi/api/v1/domains/tesla.com/groups/development/accounts
186
+ body:
187
+ encoding: US-ASCII
188
+ string: ''
189
+ headers:
190
+ Accept:
191
+ - application/json
192
+ Content-Type:
193
+ - application/json
194
+ Authorization:
195
+ - Basic YWRtaW46cGFzc3dvcmQ=
196
+ response:
197
+ status:
198
+ code: 200
199
+ message: !binary |-
200
+ T0s=
201
+ headers:
202
+ !binary "RGF0ZQ==":
203
+ - !binary |-
204
+ RnJpLCAxMyBTZXAgMjAxMyAxOTo1MDowOSBHTVQ=
205
+ !binary "U2VydmVy":
206
+ - !binary |-
207
+ QXBhY2hlLzIuMi4xNCAoVWJ1bnR1KQ==
208
+ !binary "Q29udGVudC1MZW5ndGg=":
209
+ - !binary |-
210
+ NjM=
211
+ !binary "Q29udGVudC1UeXBl":
212
+ - !binary |-
213
+ YXBwbGljYXRpb24vanNvbg==
214
+ body:
215
+ encoding: US-ASCII
216
+ string: ! '{"elements":[],"totalElements":0,"totalPages":0,"actualPage":0}'
217
+ http_version:
218
+ recorded_at: Fri, 13 Sep 2013 19:50:09 GMT
219
+ recorded_with: VCR 2.5.0
@@ -0,0 +1,39 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://admin:password@test.mxhero.com/webapi/api/v1/domains/tesla.com/groups
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
+ VGh1LCAxMiBTZXAgMjAxMyAyMToyMTowMiBHTVQ=
25
+ !binary "U2VydmVy":
26
+ - !binary |-
27
+ QXBhY2hlLzIuMi4xNCAoVWJ1bnR1KQ==
28
+ !binary "Q29udGVudC1MZW5ndGg=":
29
+ - !binary |-
30
+ MTc0
31
+ !binary "Q29udGVudC1UeXBl":
32
+ - !binary |-
33
+ YXBwbGljYXRpb24vanNvbg==
34
+ body:
35
+ encoding: US-ASCII
36
+ string: ! '{"elements":[{"name":"test","domain":"tesla.com","description":null,"createdDate":1379020748000,"updatedDate":1379020748000}],"totalElements":1,"totalPages":1,"actualPage":1}'
37
+ http_version:
38
+ recorded_at: Thu, 12 Sep 2013 21:21:02 GMT
39
+ recorded_with: VCR 2.5.0
@@ -1,8 +1,82 @@
1
1
  ---
2
2
  http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://admin:password@test.mxhero.com/webapi/api/v1/domains/tesla.com/rules
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
+ VGh1LCAxMiBTZXAgMjAxMyAyMToyMToxNSBHTVQ=
25
+ !binary "U2VydmVy":
26
+ - !binary |-
27
+ QXBhY2hlLzIuMi4xNCAoVWJ1bnR1KQ==
28
+ !binary "Q29udGVudC1MZW5ndGg=":
29
+ - !binary |-
30
+ Nzg3
31
+ !binary "Q29udGVudC1UeXBl":
32
+ - !binary |-
33
+ YXBwbGljYXRpb24vanNvbg==
34
+ body:
35
+ encoding: US-ASCII
36
+ string: ! '[{"id":194,"domain":"tesla.com","name":"The rules for sales","created":1379020870000,"updated":1379020870000,"enabled":true,"twoWays":false,"adminOrder":null,"component":"org.mxhero.feature.disclaimer","fromDirection":{"id":376,"directionType":"domain","freeValue":"tesla.com","domain":"tesla.com","account":null,"group":null},"toDirection":{"id":377,"directionType":"anyone","freeValue":"Anyone","domain":"tesla.com","account":null,"group":null},"properties":[{"propertyKey":"return.message","propertyValue":"<hr
37
+ /><p><em><span style=\"color:green\">Think before you print and save a tree.</span></em></p>"},{"propertyKey":"return.message.plain","propertyValue":"\n----------------\nThink
38
+ before you print and save a tree.r\n\n"},{"propertyKey":"interParsing","propertyValue":"true"}]}]'
39
+ http_version:
40
+ recorded_at: Thu, 12 Sep 2013 21:21:14 GMT
41
+ - request:
42
+ method: delete
43
+ uri: http://admin:password@test.mxhero.com/webapi/api/v1/domains/tesla.com/rules/194
44
+ body:
45
+ encoding: US-ASCII
46
+ string: ''
47
+ headers:
48
+ Accept:
49
+ - application/json
50
+ Content-Type:
51
+ - application/json
52
+ Authorization:
53
+ - Basic YWRtaW46cGFzc3dvcmQ=
54
+ response:
55
+ status:
56
+ code: 200
57
+ message: !binary |-
58
+ T0s=
59
+ headers:
60
+ !binary "RGF0ZQ==":
61
+ - !binary |-
62
+ VGh1LCAxMiBTZXAgMjAxMyAyMToyMToxNSBHTVQ=
63
+ !binary "U2VydmVy":
64
+ - !binary |-
65
+ QXBhY2hlLzIuMi4xNCAoVWJ1bnR1KQ==
66
+ !binary "Q29udGVudC1MZW5ndGg=":
67
+ - !binary |-
68
+ MA==
69
+ !binary "Q29udGVudC1UeXBl":
70
+ - !binary |-
71
+ dGV4dC9wbGFpbg==
72
+ body:
73
+ encoding: US-ASCII
74
+ string: ''
75
+ http_version:
76
+ recorded_at: Thu, 12 Sep 2013 21:21:15 GMT
3
77
  - request:
4
78
  method: post
5
- uri: http://admin:password@localhost:8080/webapi/api/v1/domains/tesla.com/rules
79
+ uri: http://admin:password@test.mxhero.com/webapi/api/v1/domains/tesla.com/rules
6
80
  body:
7
81
  encoding: UTF-8
8
82
  string: ! '{"domain":"tesla.com","twoWays":false,"enabled":true,"name":"The
@@ -22,28 +96,28 @@ http_interactions:
22
96
  message: !binary |-
23
97
  Q3JlYXRlZA==
24
98
  headers:
99
+ !binary "RGF0ZQ==":
100
+ - !binary |-
101
+ VGh1LCAxMiBTZXAgMjAxMyAyMToyMToxNiBHTVQ=
25
102
  !binary "U2VydmVy":
26
103
  - !binary |-
27
- QXBhY2hlLUNveW90ZS8xLjE=
104
+ QXBhY2hlLzIuMi4xNCAoVWJ1bnR1KQ==
105
+ !binary "Q29udGVudC1MZW5ndGg=":
106
+ - !binary |-
107
+ Nzg1
28
108
  !binary "Q29udGVudC1UeXBl":
29
109
  - !binary |-
30
110
  YXBwbGljYXRpb24vanNvbg==
31
- !binary "VHJhbnNmZXItRW5jb2Rpbmc=":
32
- - !binary |-
33
- Y2h1bmtlZA==
34
- !binary "RGF0ZQ==":
35
- - !binary |-
36
- RnJpLCAwOSBBdWcgMjAxMyAwNzo0MToxOCBHTVQ=
37
111
  body:
38
112
  encoding: US-ASCII
39
- string: ! '{"id":120,"domain":"tesla.com","name":"The rules for sales","created":1376034078000,"updated":1376034078000,"enabled":true,"twoWays":false,"adminOrder":null,"component":"org.mxhero.feature.disclaimer","fromDirection":{"id":225,"directionType":"domain","freeValue":"tesla.com","domain":"tesla.com","account":null,"group":null},"toDirection":{"id":226,"directionType":"anyone","freeValue":"Anyone","domain":"tesla.com","account":null,"group":null},"properties":[{"propertyKey":"return.message","propertyValue":"<hr
113
+ string: ! '{"id":195,"domain":"tesla.com","name":"The rules for sales","created":1379020876000,"updated":1379020876000,"enabled":true,"twoWays":false,"adminOrder":null,"component":"org.mxhero.feature.disclaimer","fromDirection":{"id":378,"directionType":"domain","freeValue":"tesla.com","domain":"tesla.com","account":null,"group":null},"toDirection":{"id":379,"directionType":"anyone","freeValue":"Anyone","domain":"tesla.com","account":null,"group":null},"properties":[{"propertyKey":"return.message","propertyValue":"<hr
40
114
  /><p><em><span style=\"color:green\">Think before you print and save a tree.</span></em></p>"},{"propertyKey":"return.message.plain","propertyValue":"\n----------------\nThink
41
115
  before you print and save a tree.r\n\n"},{"propertyKey":"interParsing","propertyValue":"true"}]}'
42
116
  http_version:
43
- recorded_at: Tue, 13 Aug 2013 18:24:57 GMT
117
+ recorded_at: Thu, 12 Sep 2013 21:21:15 GMT
44
118
  - request:
45
119
  method: post
46
- uri: http://admin:password@localhost:8080/webapi/api/v1/domains/tesla.com/rules
120
+ uri: http://admin:password@test.mxhero.com/webapi/api/v1/domains/tesla.com/rules
47
121
  body:
48
122
  encoding: UTF-8
49
123
  string: ! '{"domain":"tesla.com","twoWays":false,"enabled":true,"name":"The
@@ -63,24 +137,24 @@ http_interactions:
63
137
  message: !binary |-
64
138
  SW50ZXJuYWwgU2VydmVyIEVycm9y
65
139
  headers:
66
- !binary "U2VydmVy":
67
- - !binary |-
68
- QXBhY2hlLUNveW90ZS8xLjE=
69
- !binary "Q29udGVudC1UeXBl":
140
+ !binary "RGF0ZQ==":
70
141
  - !binary |-
71
- YXBwbGljYXRpb24vanNvbg==
72
- !binary "VHJhbnNmZXItRW5jb2Rpbmc=":
142
+ VGh1LCAxMiBTZXAgMjAxMyAyMToyMToxNiBHTVQ=
143
+ !binary "U2VydmVy":
73
144
  - !binary |-
74
- Y2h1bmtlZA==
75
- !binary "RGF0ZQ==":
145
+ QXBhY2hlLzIuMi4xNCAoVWJ1bnR1KQ==
146
+ !binary "Q29udGVudC1MZW5ndGg=":
76
147
  - !binary |-
77
- RnJpLCAwOSBBdWcgMjAxMyAwNzo0MToxOCBHTVQ=
148
+ MTIz
78
149
  !binary "Q29ubmVjdGlvbg==":
79
150
  - !binary |-
80
151
  Y2xvc2U=
152
+ !binary "Q29udGVudC1UeXBl":
153
+ - !binary |-
154
+ YXBwbGljYXRpb24vanNvbg==
81
155
  body:
82
156
  encoding: US-ASCII
83
157
  string: ! '{"status":500,"code":500,"developerMessage":"rules.already.exists.for.component","moreInfoUrl":"mailto:support@mxhero.com"}'
84
158
  http_version:
85
- recorded_at: Tue, 13 Aug 2013 18:24:57 GMT
159
+ recorded_at: Thu, 12 Sep 2013 21:21:16 GMT
86
160
  recorded_with: VCR 2.5.0