ruby-swift 0.1.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -14
- data/lib/ruby-swift.rb +40 -11
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bcfefd7de34d0ee73b023d387e2fa6572ae1d56d
|
4
|
+
data.tar.gz: 6ba1002f1770ee1219147e6f7e029778e490460d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06981968173bb370b5280fc40b28dd530565ce67607ed05476e1d8cd08c7c53adca491ee65751f1d5aa0175ae6ae6ab31c9716f06ea50d65637b87f5b4d04c53
|
7
|
+
data.tar.gz: 76cb3ab38a76efa4acbe03165dc4c69727a59c4fa0eeec2591bef5e301ad57a7b725cfde92f16882cdae70f926dc17772a18c68e227fa8b876b9565a932abd88
|
data/README.md
CHANGED
@@ -26,77 +26,75 @@ swift = RubySwift.new("API_PASSWORD")
|
|
26
26
|
Does a person exist?
|
27
27
|
|
28
28
|
```ruby
|
29
|
-
swift.person_exists?("you@example.com") # -> true
|
29
|
+
swift.person_exists?("you@example.com") # -> {:status => 0, :response => true}
|
30
30
|
```
|
31
31
|
|
32
32
|
Read a person:
|
33
33
|
|
34
34
|
```ruby
|
35
|
-
person = swift.read_person("you@example.com")
|
35
|
+
person = swift.read_person("you@example.com") # -> {:status => 0, :response => {...}}
|
36
36
|
```
|
37
37
|
|
38
38
|
Add someone to a mail group:
|
39
39
|
|
40
40
|
```ruby
|
41
|
-
swift.add_group_member("you@example.com", "Group Name") # ->
|
41
|
+
swift.add_group_member("you@example.com", "Group Name") # -> {:status => 0, :response => true}
|
42
42
|
```
|
43
43
|
|
44
44
|
Remove someone from a mail group:
|
45
45
|
|
46
46
|
```ruby
|
47
|
-
swift.remove_group_member("you@example.com", "Group Name") # ->
|
47
|
+
swift.remove_group_member("you@example.com", "Group Name") # -> {:status => 0, :response => true}
|
48
48
|
```
|
49
49
|
|
50
50
|
Create a person:
|
51
51
|
|
52
52
|
```ruby
|
53
|
-
swift.write_person(email: "me@example.com", first_name: "Dennis", last_name: "Ritchie") # ->
|
53
|
+
swift.write_person(email: "me@example.com", first_name: "Dennis", last_name: "Ritchie") # -> {:status => 0, :response => true}
|
54
54
|
```
|
55
55
|
|
56
56
|
Update person:
|
57
57
|
|
58
58
|
```ruby
|
59
|
-
swift.update_person(email: "you@example.com", first_name: "Donald", last_name: "Knuth") # ->
|
59
|
+
swift.update_person(email: "you@example.com", first_name: "Donald", last_name: "Knuth") # -> {:status => 0, :response => true}
|
60
60
|
```
|
61
61
|
|
62
62
|
Create or update existing person:
|
63
63
|
|
64
64
|
```ruby
|
65
|
-
swift.write_or_update_person(email: "me@example.com", first_name: "Dennis", last_name: "Ritchie") # ->
|
65
|
+
swift.write_or_update_person(email: "me@example.com", first_name: "Dennis", last_name: "Ritchie") # -> {:status => 0, :response => true}
|
66
66
|
```
|
67
67
|
|
68
68
|
Create a group:
|
69
69
|
|
70
70
|
```ruby
|
71
|
-
swift.write_group("Group name") # ->
|
71
|
+
swift.write_group("Group name") # -> {:status => 0, :response => true}
|
72
72
|
```
|
73
73
|
|
74
74
|
Read all groups:
|
75
75
|
|
76
76
|
```ruby
|
77
|
-
groups = swift.read_groups
|
77
|
+
groups = swift.read_groups # -> {:status => 0, :response => ["group1", "group2", ...]}
|
78
78
|
```
|
79
79
|
|
80
80
|
Read all members of a group:
|
81
81
|
|
82
82
|
```ruby
|
83
|
-
people = swift.read_persons("Group Name")
|
83
|
+
people = swift.read_persons("Group Name") # -> {:status => 0, :response => [{...}, ...]}
|
84
84
|
```
|
85
85
|
|
86
86
|
Remove a group:
|
87
87
|
|
88
88
|
```ruby
|
89
|
-
swift.remove_group("Group Name") # ->
|
89
|
+
swift.remove_group("Group Name") # -> {:status => 0, :response => true}
|
90
90
|
```
|
91
91
|
|
92
92
|
Remove a person:
|
93
93
|
|
94
94
|
```ruby
|
95
|
-
swift.remove_person("you@example.com") # ->
|
95
|
+
swift.remove_person("you@example.com") # -> {:status => 0, :response => true}
|
96
96
|
```
|
97
97
|
|
98
98
|
TODO
|
99
99
|
----
|
100
|
-
* Tidy up responses (Hashie?)
|
101
|
-
* Return true/false instead of "0" for write actions
|
102
100
|
* Allow custom fields in write/update
|
data/lib/ruby-swift.rb
CHANGED
@@ -12,7 +12,7 @@ class RubySwift
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def person_exists?(email)
|
15
|
-
read_person(email)
|
15
|
+
read_person(email)[:status] == 0
|
16
16
|
end
|
17
17
|
|
18
18
|
def write_or_update_person(fields)
|
@@ -24,43 +24,53 @@ class RubySwift
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def read_person(email)
|
27
|
-
soap_request("read_person", {email: email})
|
27
|
+
return_response(soap_request("read_person", {email: email})) do |sr|
|
28
|
+
convert_to_person(sr)
|
29
|
+
end
|
28
30
|
end
|
29
31
|
|
30
32
|
def write_person(fields)
|
31
|
-
soap_request("write_person", fields)
|
33
|
+
return_response(soap_request("write_person", fields))
|
32
34
|
end
|
33
35
|
|
34
36
|
def read_groups
|
35
|
-
soap_request("read_groups")
|
37
|
+
return_response(soap_request("read_groups")) do |sr|
|
38
|
+
sr[:item].map do |group|
|
39
|
+
group[:item][:value]
|
40
|
+
end
|
41
|
+
end
|
36
42
|
end
|
37
43
|
|
38
44
|
def add_group_member(email, group_name)
|
39
|
-
soap_request("add_group_member", {email: email, group_name: group_name})
|
45
|
+
return_response(soap_request("add_group_member", {email: email, group_name: group_name}))
|
40
46
|
end
|
41
47
|
|
42
48
|
def remove_group_member(email, group_name)
|
43
|
-
soap_request("remove_group_member", {email: email, group_name: group_name})
|
49
|
+
return_response(soap_request("remove_group_member", {email: email, group_name: group_name}))
|
44
50
|
end
|
45
51
|
|
46
52
|
def read_persons(group_name)
|
47
|
-
soap_request("read_persons", {group_name: group_name})
|
53
|
+
return_response(soap_request("read_persons", {group_name: group_name})) do |sr|
|
54
|
+
sr[:item].map do |person|
|
55
|
+
convert_to_person(person)
|
56
|
+
end
|
57
|
+
end
|
48
58
|
end
|
49
59
|
|
50
60
|
def remove_group(group_name)
|
51
|
-
soap_request("remove_group", {group_name: group_name})
|
61
|
+
return_response(soap_request("remove_group", {group_name: group_name}))
|
52
62
|
end
|
53
63
|
|
54
64
|
def remove_person(email)
|
55
|
-
soap_request("remove_person", {
|
65
|
+
return_response(soap_request("remove_person", {group_name: group_name}))
|
56
66
|
end
|
57
67
|
|
58
68
|
def update_person(old_email, fields)
|
59
|
-
soap_request("update_person", {email_old: old_email}.merge(fields))
|
69
|
+
return_response(soap_request("update_person", {email_old: old_email}.merge(fields)))
|
60
70
|
end
|
61
71
|
|
62
72
|
def write_group(group_name)
|
63
|
-
soap_request("write_group", {group_name: group_name})
|
73
|
+
return_response(soap_request("write_group", {group_name: group_name}))
|
64
74
|
end
|
65
75
|
|
66
76
|
private
|
@@ -91,4 +101,23 @@ class RubySwift
|
|
91
101
|
def tidy_response(response)
|
92
102
|
response.to_a[0][1][:return]
|
93
103
|
end
|
104
|
+
|
105
|
+
def convert_to_person(soap_response)
|
106
|
+
Hash[*soap_response[:item].map { |line|
|
107
|
+
[line[:key].to_sym, (line[:value].is_a? Hash) ? nil : line[:value]]
|
108
|
+
}.flatten]
|
109
|
+
end
|
110
|
+
|
111
|
+
def return_response(soap_response, &block)
|
112
|
+
status = soap_response.to_s.to_i
|
113
|
+
resp = if status == 0
|
114
|
+
if block_given?
|
115
|
+
yield soap_response
|
116
|
+
else
|
117
|
+
true
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
return {:status => status, :response => resp}
|
122
|
+
end
|
94
123
|
end
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-swift
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Buntine
|
8
|
+
- Philip Castiglione
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2015-
|
12
|
+
date: 2015-09-03 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: savon
|
@@ -53,7 +54,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
54
|
version: '0'
|
54
55
|
requirements: []
|
55
56
|
rubyforge_project:
|
56
|
-
rubygems_version: 2.4.
|
57
|
+
rubygems_version: 2.4.6
|
57
58
|
signing_key:
|
58
59
|
specification_version: 4
|
59
60
|
summary: A ruby wrapper of the Swift Digital Suite API.
|