symgate 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4b8844223c94a355ea8ad0d294d75bfa31127a27
4
- data.tar.gz: 822d5a227b81ac8e4e22c6a62b07d5c813b40640
3
+ metadata.gz: 12436506bf7e48ebfa25ea79387998a601865c19
4
+ data.tar.gz: fff6e307bd114d356a4b0f3ad032313ecaa86e97
5
5
  SHA512:
6
- metadata.gz: d1e6978cf81fb2f10922d9fdb3eb13c86163cc5e95a5b75e428363ecd4fe6435bbd02809c66074a8fa8df5849b82f627af7f03a87caa54286105dff6ad8a1a9b
7
- data.tar.gz: a4f344a61d6cd9d6c08a7e7f3d2bc0b82a4641dc26a1cc7a2da28504e5e45b5075093e1b11ce1d632ae4c08da238e61276ab9632e586a8461b5db835e6e7af61
6
+ metadata.gz: ce0b1024bc72b857cab52ae2895949b050016cbf1f9d0d00d1f61c2757ae83f46e958a3307f3e7643e721fe2e21fb42dd0a149a0bec0d21e8fbde97afd2e94b1
7
+ data.tar.gz: 40a7d276dda83fe6407fde8855a80736177b0217a2b72460d2a7007edd91781811ef6167f60f0533559bfb8c343b5eddfd9dac8923ade5e09a7e2793e68aedc0
data/.rubocop.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.2
2
+ TargetRubyVersion: 2.1
3
3
  Exclude:
4
4
  - 'vendor/**/*'
5
5
  - '.chef/**/*'
data/.travis.yml ADDED
@@ -0,0 +1,14 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.10
4
+ - 2.2.5
5
+ - 2.3.1
6
+
7
+ git:
8
+ submodules: false
9
+
10
+ before_install:
11
+ - gem install bundler
12
+
13
+ script:
14
+ - bundle exec rake test
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ ## 0.2.0 (2016-09-13)
2
+
3
+ Updated hash syntax to be compatible with Ruby 2.1
4
+
5
+ ## 0.1.0 (2016-09-09)
6
+
7
+ Initial release
data/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2016 Symbols Worldwide Ltd.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
data/README.md CHANGED
@@ -1,15 +1,33 @@
1
- # Symgate::Gem
1
+ # Symgate - Ruby client for the Widgit symbolisation service
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/symgate/gem`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ [![Build Status](https://travis-ci.org/symbols-worldwide/symgate-gem.svg?branch=master)](https://travis-ci.org/symbols-worldwide/symgate-gem)
4
+ [![Code Climate](https://codeclimate.com/github/symbols-worldwide/symgate-gem.svg)](https://codeclimate.com/github/symbols-worldwide/symgate-gem)
5
+ [![codecov.io](http://codecov.io/github/symbols-worldwide/symgate-gem/coverage.svg?branch=master)](http://codecov.io/github/symbols-worldwide/symgate-gem?branch=master)
6
+ [![Dependency Status](https://gemnasium.com/badges/github.com/symbols-worldwide/symgate-gem.svg)](https://gemnasium.com/github.com/symbols-worldwide/symgate-gem)
7
+ [![Gem Version](https://badge.fury.io/rb/symgate.svg)](https://badge.fury.io/rb/symgate)
8
+ [![Apache License](https://img.shields.io/github/license/symbols-worldwide/symgate-gem.svg)](https://www.apache.org/licenses/LICENSE-2.0)
4
9
 
5
- TODO: Delete this and the text above, and describe your gem
10
+ This gem provides a wrapper around the [Symgate SOAP API](https://ws.widgitonline.com/schema/symboliser.wsdl),
11
+ providing a simple Ruby interface that matches the remote API as much as possible.
12
+
13
+ The API provides a client for each of the sections of API functionality. These are:
14
+
15
+ * `Symgate::Auth::Client` for authentication, user and group management
16
+ * `Symgate::Wordlist::Client` for per-user/group metadata storage
17
+ * `Symgate::Metadata::Client` for per-user/group wordlist management
18
+
19
+ Please note that a symbolisation client is scheduled for a future release.
20
+
21
+ ## Prerequisites
22
+
23
+ This gem works with Ruby 2.1 and above
6
24
 
7
25
  ## Installation
8
26
 
9
27
  Add this line to your application's Gemfile:
10
28
 
11
29
  ```ruby
12
- gem 'symgate-gem'
30
+ gem 'symgate'
13
31
  ```
14
32
 
15
33
  And then execute:
@@ -18,21 +36,108 @@ And then execute:
18
36
 
19
37
  Or install it yourself as:
20
38
 
21
- $ gem install symgate-gem
39
+ $ gem install symgate
22
40
 
23
41
  ## Usage
24
42
 
25
- TODO: Write usage instructions here
43
+ ### Initialisation
44
+
45
+ To call any Symgate methods you must create a client of the relevant type. These can
46
+ be instantiated in the following ways:
47
+
48
+ #### Account/key
49
+
50
+ ```ruby
51
+ require 'symgate/auth'
52
+
53
+ auth_client = Symgate::Auth::Client.new(account: 'my_account', key: 'secret')
54
+ ```
55
+
56
+ #### User/password
57
+
58
+ ```ruby
59
+ require 'symgate/wordlist'
60
+
61
+ wordlist_client = Symgate::Wordlist::Client.new(account: 'my_account',
62
+ user: 'group/user',
63
+ password: 'secret')
64
+ ```
65
+
66
+ #### User/token
67
+
68
+ You need to call the `authenticate` method in order to obtain a token:
69
+
70
+ ```ruby
71
+ require 'symgate/auth'
72
+ require 'symgate/metadata'
73
+
74
+ # obtain a token from the authentication client
75
+
76
+ auth_client = Symgate::Auth::Client.new(account: 'my_account',
77
+ user: 'group/user',
78
+ password: 'secret')
79
+
80
+ begin
81
+ token = auth_client.authenticate
82
+ rescue Symgate::Error => e
83
+ puts "Authentication failed with the following error: #{e.message}"
84
+ end
85
+
86
+ metadata_client = Symgate::Metadata::Client.new(account: 'my_account',
87
+ user: 'group/user',
88
+ token: token)
89
+ ```
90
+
91
+ #### Other initialisation options
92
+
93
+ You can also initialise a client with the following options:
94
+
95
+ | Option | |
96
+ | ----------- | --- |
97
+ | :endpoint | Specifies the symbolisation SOAP endpoint to use, if not the public symbolisation server. |
98
+ | :savon_opts | Specifies options to pass to the underlying savon engine. e.g. `{ log_level: :debug }` |
99
+
100
+ ### Errors
101
+
102
+ If any method call fails, it will raise a `Symgate::Error` exception. Examine the exception for further information
103
+ on what went wrong.
104
+
105
+ ### Further documentation
106
+
107
+ For more information, see the documentation at:
108
+
109
+ <http://www.rubydoc.info/github/symbols-worldwide/symgate-gem/>
26
110
 
27
111
  ## Development
28
112
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
113
+ After checking out the repository, run `bundle install` to obtain the necessary development gems.
114
+
115
+ Run `rake test` to run the tests, which consist of
116
+ * rubocop
117
+ * rspec (with coverage)
118
+
119
+ Successful PRs require 100% code coverage and all tests and cops passing.
120
+
121
+ ### Integration tests
122
+
123
+ If you want to run the integration tests (test the gem against a running server):
124
+ 1. Install Vagrant 1.8 or later, if not already installed
125
+ 2. Run `rake vagrant:up` to set up a local VM running the latest symboliser.
126
+ 3. Run `rake spec:integration` to run the integration tests.
127
+
128
+ To pause testing until later, run `rake vagrant:halt` which will suspend your virtual machine. To resume testing run `rake vagrant:up` again.
129
+
130
+ To shut down and destroy the VM completely, run `rake vagrant:destroy`
131
+
132
+ Note that you need access to the Widgit CI server for this to work.
133
+
134
+ ## License
30
135
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
136
+ This project is licensed under the Apache License 2.0.
32
137
 
33
138
  ## Contributing
34
139
 
35
- 1. Fork it ( https://github.com/[my-github-username]/symgate-gem/fork )
140
+ 1. Fork it ( https://github.com/symbols-worldwide/symgate-gem/fork )
36
141
  2. Create your feature branch (`git checkout -b my-new-feature`)
37
142
  3. Commit your changes (`git commit -am 'Add some feature'`)
38
143
  4. Push to the branch (`git push origin my-new-feature`)
@@ -5,7 +5,15 @@ module Symgate
5
5
  module Auth
6
6
  # client for the Symgate authentication system
7
7
  class Client < Symgate::Client
8
- # returns a list of groups for the current symgate account
8
+ # Returns a list of groups for the current symgate account
9
+ #
10
+ # ==== Returns
11
+ #
12
+ # An array of group ids, as strings
13
+ #
14
+ # ==== Supported authentication types
15
+ #
16
+ # * account/key
9
17
  def enumerate_groups
10
18
  Symgate::Client.savon_array(
11
19
  savon_request(:enumerate_groups).body[:enumerate_groups_response],
@@ -13,28 +21,77 @@ module Symgate
13
21
  )
14
22
  end
15
23
 
16
- # creates a new group
24
+ # Creates a new group.
25
+ #
26
+ # Raises a Symgate::Error on failure
27
+ #
28
+ # ==== Attributes
29
+ #
30
+ # * +group_id+ - The ID of the new group to create (String)
31
+ #
32
+ # ==== Supported authentication types
33
+ #
34
+ # * account/key
17
35
  def create_group(group_id)
18
36
  savon_request(:create_group, returns_error_string: true) do |soap|
19
37
  soap.message(groupid: group_id)
20
38
  end
21
39
  end
22
40
 
23
- # destroys an existing group
41
+ # Destroys an existing group
42
+ #
43
+ # *IMPORTANT*: This will permanently delete the group, along with all
44
+ # associated users, wordlists and metadata. Can't be undone.
45
+ #
46
+ # Raises a Symgate::Error on failure
47
+ #
48
+ # ==== Attributes
49
+ #
50
+ # * +group_id+ - The ID of the new group to create (String)
51
+ #
52
+ # ==== Supported authentication types
53
+ #
54
+ # * account/key
24
55
  def destroy_group(group_id)
25
56
  savon_request(:destroy_group, returns_error_string: true) do |soap|
26
57
  soap.message(groupid: group_id)
27
58
  end
28
59
  end
29
60
 
30
- # renames a group
61
+ # Renames a group
62
+ #
63
+ # This will require all users to use the new group_id as part of their
64
+ # login username in future.
65
+ #
66
+ # Raises a Symgate::Error on failure (e.g. the +new_group_id+ is invalid)
67
+ #
68
+ # ==== Attributes
69
+ #
70
+ # * +old_group_id+ - The ID of the group to rename (String)
71
+ # * +new_group_id+ - The new ID for the renamed group (String)
72
+ #
73
+ # ==== Supported authentication types
74
+ #
75
+ # * account/key
31
76
  def rename_group(old_group_id, new_group_id)
32
77
  savon_request(:rename_group, returns_error_string: true) do |soap|
33
78
  soap.message(old_groupid: old_group_id, new_groupid: new_group_id)
34
79
  end
35
80
  end
36
81
 
37
- # returns a list of users for the specified group
82
+ # Returns a list of users for the specified group)
83
+ #
84
+ # ==== Attributes
85
+ #
86
+ # * +group_id+ - The ID of the group (String)
87
+ #
88
+ # ==== Returns
89
+ #
90
+ # An array of Symgate::Auth::User objects
91
+ #
92
+ # ==== Supported authentication types
93
+ #
94
+ # * account/key
38
95
  def enumerate_users(group_id)
39
96
  resp = savon_request(:enumerate_users) { |soap| soap.message(groupid: group_id) }
40
97
 
@@ -45,7 +102,20 @@ module Symgate
45
102
  )
46
103
  end
47
104
 
48
- # creates a new user from a Symgate::Auth::User, with the specified password
105
+ # Creates a new user
106
+ #
107
+ # Raises a Symgate::Error on failure (e.g. the +user+ is invalid, or the group
108
+ # specified in the User object does not exist)
109
+ #
110
+ # ==== Attributes
111
+ #
112
+ # * +user+ - A Symgate::Auth::User describing the new user
113
+ # * +password+ - The password for the new user (String)
114
+ #
115
+ # ==== Supported authentication types
116
+ #
117
+ # * account/key
118
+ # * user (with +is_group_admin+)
49
119
  def create_user(user, password)
50
120
  savon_request(:create_user, returns_error_string: true) do |soap|
51
121
  soap.message(password: password)
@@ -53,7 +123,19 @@ module Symgate
53
123
  end
54
124
  end
55
125
 
56
- # updates a user (sets the is_group_admin member)
126
+ # Updates a user
127
+ #
128
+ # Currently this can only be used to set the +is_group_admin+ member of
129
+ # the +user+ object
130
+ #
131
+ # ==== Attributes
132
+ #
133
+ # * +user+ - The updated Symgate::Auth::User object
134
+ #
135
+ # ==== Supported authentication types
136
+ #
137
+ # * account/key
138
+ # * user (with +is_group_admin+)
57
139
  def update_user(user)
58
140
  savon_request(:update_user, returns_error_string: true) do |soap|
59
141
  soap.message({})
@@ -61,35 +143,113 @@ module Symgate
61
143
  end
62
144
  end
63
145
 
64
- # renames a user (must be within the same group)
146
+ # Renames a user
147
+ #
148
+ # The user cannot be renamed from one group to another - the group part of
149
+ # the user id should remain the same.
150
+ #
151
+ # Raises a Symgate::Error on failure (e.g. the +new_user_id+ is already taken
152
+ # or the user with +old_user_id+ does not exist)
153
+ #
154
+ # ==== Attributes
155
+ #
156
+ # * +old_user_id+ - The ID of the user to rename, in 'group_id/username' format (String)
157
+ # * +new_user_id+ - The new ID of the renamed user (String)
158
+ #
159
+ # ==== Supported authentication types
160
+ #
161
+ # * account/key
162
+ # * user (with +is_group_admin+)
65
163
  def rename_user(old_user_id, new_user_id)
66
164
  savon_request(:rename_user, returns_error_string: true) do |soap|
67
165
  soap.message(old_user_id: old_user_id, new_user_id: new_user_id)
68
166
  end
69
167
  end
70
168
 
71
- # moves a user between groups
169
+ # Moves a user between groups
170
+ #
171
+ # Moves a user from one group to another. The group part of the user ID should
172
+ # be changed.
173
+ #
174
+ # Raises a Symgate::Error on failure (e.g. the +new_user_id+ is already taken
175
+ # or the user with +old_user_id+ does not exist)
176
+ #
177
+ # ==== Attributes
178
+ #
179
+ # * +old_user_id+ - The ID of the user to move, in 'group_id/username' format (String)
180
+ # * +new_user_id+ - The new ID of the renamed user (String)
181
+ #
182
+ # ==== Example
183
+ #
184
+ # auth_client.move_user('group_1/username', 'group_2/username')
185
+ #
186
+ # ==== Supported authentication types
187
+ #
188
+ # * account/key
72
189
  def move_user(old_user_id, new_user_id)
73
190
  savon_request(:move_user, returns_error_string: true) do |soap|
74
191
  soap.message(old_user_id: old_user_id, new_user_id: new_user_id)
75
192
  end
76
193
  end
77
194
 
78
- # sets the password for a user
195
+ # Sets the password for a user
196
+ #
197
+ # Note that when authenticating as a user without the +is_group_admin+ permission
198
+ # you can only change the password for yourself.
199
+ #
200
+ # Raises a Symgate::Error on failure (e.g. the user identified by +user_id+
201
+ # does not exist, or you do not have sufficient permissions to update the password.)
202
+ #
203
+ # ==== Attributes
204
+ #
205
+ # * +user_id+ - The ID of the user for whom the password is to be changed
206
+ #
207
+ # ==== Supported authentication types
208
+ #
209
+ # * account/key
210
+ # * user
79
211
  def set_user_password(user_id, password)
80
212
  savon_request(:set_user_password, returns_error_string: true) do |soap|
81
213
  soap.message(userid: user_id, password: password)
82
214
  end
83
215
  end
84
216
 
85
- # destroys a user
217
+ # Destroys a user
218
+ #
219
+ # *IMPORTANT*: This will irreversibly destroy all wordlists and metadata
220
+ # belonging to the user
221
+ #
222
+ # ==== Attributes
223
+ #
224
+ # * +user_id+ - The ID of the user for whom the password is to be changed
225
+ #
226
+ # ==== Supported authentication types
227
+ #
228
+ # * account/key
229
+ # * user (with +is_group_admin+)
86
230
  def destroy_user(user_id)
87
231
  savon_request(:destroy_user, returns_error_string: true) do |soap|
88
232
  soap.message(userid: user_id)
89
233
  end
90
234
  end
91
235
 
92
- # authenticates a user and returns a token, optionally with a user to impersonate
236
+ # Authenticates a user and returns a token
237
+ #
238
+ # This optionally provides a token which allows you to 'impersonate' a user
239
+ # (i.e. use the API as if you were logged on as that user)
240
+ #
241
+ # Raises a Symgate::Error on error (e.g. authentication fails)
242
+ #
243
+ # ==== Attributes
244
+ #
245
+ # * +user_to_impersonate+ (optional) - The ID (String) of the user to impersonate
246
+ #
247
+ # ==== Returns
248
+ #
249
+ # A token, used for further calls to the client (String)
250
+ #
251
+ # * account/key (requires +user_to_impersonate+)
252
+ # * user (cannot use +user_to_impersonate+)
93
253
  def authenticate(user_to_impersonate = nil)
94
254
  r = savon_request(:authenticate) do |soap|
95
255
  soap.message(userid: user_to_impersonate) if user_to_impersonate
@@ -98,23 +258,65 @@ module Symgate
98
258
  r ? r[:authtoken] : nil
99
259
  end
100
260
 
101
- # adds a language to the specified group and returns 'OK' if successful or
102
- # 'Exists' if the language is already assigned to the account
261
+ # Adds a language to the specified group
262
+ #
263
+ # This enables users within the group to use the Symboliser in that language.
264
+ #
265
+ # ==== Attributes
266
+ #
267
+ # * +group+ - The ID of the group to add the language to (String)
268
+ # * +language+ - The cml language to enable (String)
269
+ #
270
+ # ==== Returns
271
+ #
272
+ # Returns 'OK' if successful or 'Exists' if the language is already assigned
273
+ # to the account (String)
274
+ #
275
+ # ==== Supported authentication types
276
+ #
277
+ # * account/key
103
278
  def add_group_language(group, language)
104
279
  savon_request(:add_group_language) do |soap|
105
280
  soap.message(groupid: group, language: language)
106
281
  end.body[:add_group_language_response]
107
282
  end
108
283
 
109
- # removes a language from the specified group and returns 'OK' if successful or
110
- # 'NotExist' if the language is not assigned to the account
284
+ # Removes a language from the specified group
285
+ #
286
+ # This prevents users within the group to use the Symboliser in that language.
287
+ #
288
+ # ==== Attributes
289
+ #
290
+ # * +group+ - The ID of the group to remove the language from(String)
291
+ # * +language+ - The cml language to disable (String)
292
+ #
293
+ # ==== Returns
294
+ #
295
+ # Returns 'OK' if successful or 'NotExist' if the language is not assigned
296
+ # to the account (String)
297
+ #
298
+ # ==== Supported authentication types
299
+ #
300
+ # * account/key
111
301
  def remove_group_language(group, language)
112
302
  savon_request(:remove_group_language) do |soap|
113
303
  soap.message(groupid: group, language: language)
114
304
  end.body[:remove_group_language_response]
115
305
  end
116
306
 
117
- # lists the languages assigned to a group
307
+ # Lists the allowed languages for the specified group
308
+ #
309
+ # ==== Attributes
310
+ #
311
+ # * +group_id+ - The ID of the group (String)
312
+ #
313
+ # ==== Returns
314
+ #
315
+ # Returns an array of cml languages as strings
316
+ #
317
+ # ==== Supported authentication types
318
+ #
319
+ # * account/key
118
320
  def enumerate_group_languages(group_id)
119
321
  resp = savon_request(:enumerate_group_languages) { |soap| soap.message(groupid: group_id) }
120
322
 
@@ -124,14 +326,35 @@ module Symgate
124
326
  )
125
327
  end
126
328
 
127
- # queries whether a language is available for a group
329
+ # Queries whether a language is assigned to a group
330
+ #
331
+ # ==== Attributes
332
+ #
333
+ # * +group+ - The ID of the group (String)
334
+ # * +language+ - The cml language to query (String)
335
+ #
336
+ # ==== Returns
337
+ #
338
+ # Returns true if the user has the language assigned, otherwise false (Boolean)
339
+ #
340
+ # ==== Supported authentication types
341
+ #
342
+ # * account/key
128
343
  def query_group_language(group_id, language)
129
344
  savon_request(:query_group_language) do |soap|
130
345
  soap.message(groupid: group_id, language: language)
131
346
  end.body[:query_group_language_response]
132
347
  end
133
348
 
134
- # lists the language for the currently authenticated user
349
+ # Lists the allowed languages for the currently authenticated user
350
+ #
351
+ # ==== Returns
352
+ #
353
+ # Returns an array of cml languages as strings
354
+ #
355
+ # ==== Supported authentication types
356
+ #
357
+ # * user
135
358
  def enumerate_languages
136
359
  resp = savon_request(:enumerate_languages)
137
360
 
@@ -141,7 +364,19 @@ module Symgate
141
364
  )
142
365
  end
143
366
 
144
- # queries whether a language is available for the currently authenticated user
367
+ # Queries whether a language is assigned to the currently authenticated user
368
+ #
369
+ # ==== Attributes
370
+ #
371
+ # * +language+ - The cml language to query (String)
372
+ #
373
+ # ==== Returns
374
+ #
375
+ # Returns true if the user has the language assigned, otherwise false (Boolean)
376
+ #
377
+ # ==== Supported authentication types
378
+ #
379
+ # * user
145
380
  def query_language(language)
146
381
  savon_request(:query_language) { |soap| soap.message(language: language) }
147
382
  .body[:query_language_response]
@@ -66,15 +66,15 @@ module Symgate
66
66
 
67
67
  # builds a credentials object - required for all requests
68
68
  def savon_creds
69
- creds = { 'auth:account': @account }
69
+ creds = { %s(auth:account) => @account }
70
70
  creds[:'auth:key'] = @key if @key
71
71
  creds[:'auth:user'] = savon_user if @user
72
72
 
73
- { 'auth:creds': creds }
73
+ { %s(auth:creds) => creds }
74
74
  end
75
75
 
76
76
  def savon_user
77
- user = { 'auth:id': @user }
77
+ user = { %s(auth:id) => @user }
78
78
  user[:'auth:password'] = @password if @password
79
79
  user[:'auth:authtoken'] = @token if @token
80
80
 
@@ -21,16 +21,16 @@ module Symgate
21
21
 
22
22
  def to_soap
23
23
  {
24
- 'cml:symset': symset,
25
- 'cml:main': main,
26
- 'cml:top_left': top_left,
27
- 'cml:top_right': top_right,
28
- 'cml:bottom_left': bottom_left,
29
- 'cml:bottom_right': bottom_right,
30
- 'cml:full_left': full_left,
31
- 'cml:full_right': full_right,
32
- 'cml:top': top,
33
- 'cml:extra': extra
24
+ %s(cml:symset) => symset,
25
+ %s(cml:main) => main,
26
+ %s(cml:top_left) => top_left,
27
+ %s(cml:top_right) => top_right,
28
+ %s(cml:bottom_left) => bottom_left,
29
+ %s(cml:bottom_right) => bottom_right,
30
+ %s(cml:full_left) => full_left,
31
+ %s(cml:full_right) => full_right,
32
+ %s(cml:top) => top,
33
+ %s(cml:extra) => extra
34
34
  }.delete_if { |_, v| v.nil? }
35
35
  end
36
36
 
@@ -43,7 +43,7 @@ module Symgate
43
43
  raise Symgate::Error, 'No items supplied' if i.empty?
44
44
 
45
45
  savon_request(:set_metadata, returns_error_string: true) do |soap|
46
- soap.message('auth:data_item': i.map(&:to_soap))
46
+ soap.message(%s(auth:data_item) => i.map(&:to_soap))
47
47
  end
48
48
  end
49
49
 
@@ -14,9 +14,9 @@ module Symgate
14
14
 
15
15
  def to_soap
16
16
  {
17
- '@key': key,
18
- '@scope': scope,
19
- 'auth:value': value
17
+ %s(@key) => key,
18
+ %s(@scope) => scope,
19
+ %s(auth:value) => value
20
20
  }
21
21
  end
22
22
 
@@ -1,9 +1,9 @@
1
1
  module Symgate
2
2
  NAMESPACES = {
3
- 'xmlns:auth': 'http://ws.widgit.com/schema/auth/1.2',
4
- 'xmlns:wl': 'http://ws.widgit.com/schema/wordlist/1.2',
5
- 'xmlns:cml': 'http://ws.widgit.com/schema/cml/2.0',
6
- 'xmlns:gt': 'http://ws.widgit.com/schema/globaltypes/1.2',
7
- 'xmlns:symboliser': 'http://ws.widgit.com/schema/symboliser/1.2'
3
+ %s(xmlns:auth) => 'http://ws.widgit.com/schema/auth/1.2',
4
+ %s(xmlns:wl) => 'http://ws.widgit.com/schema/wordlist/1.2',
5
+ %s(xmlns:cml) => 'http://ws.widgit.com/schema/cml/2.0',
6
+ %s(xmlns:gt) => 'http://ws.widgit.com/schema/globaltypes/1.2',
7
+ %s(xmlns:symboliser) => 'http://ws.widgit.com/schema/symboliser/1.2'
8
8
  }.freeze
9
9
  end
@@ -1,3 +1,3 @@
1
1
  module Symgate
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
@@ -93,7 +93,7 @@ module Symgate
93
93
  end
94
94
 
95
95
  savon_request(:insert_wordlist_entry, returns_error_string: true) do |soap|
96
- soap.message(wordlistid: uuid, 'wl:wordlistentry': entry.to_soap)
96
+ soap.message(wordlistid: uuid, %s(wl:wordlistentry) => entry.to_soap)
97
97
  end
98
98
  end
99
99
 
@@ -102,7 +102,7 @@ module Symgate
102
102
  check_array_for_type(entries, Symgate::Wordlist::Entry)
103
103
 
104
104
  savon_request(:overwrite_wordlist, returns_error_string: true) do |soap|
105
- soap.message(wordlistid: uuid, 'wl:wordlistentry': entries.map(&:to_soap))
105
+ soap.message(wordlistid: uuid, %s(wl:wordlistentry) => entries.map(&:to_soap))
106
106
  end
107
107
  end
108
108
 
@@ -158,7 +158,7 @@ module Symgate
158
158
  context: context,
159
159
  scope: scope_for_context(context)
160
160
  }.merge(
161
- entries ? { 'wl:wordlistentry': entries.map(&:to_soap) } : {}
161
+ entries ? { %s(wl:wordlistentry) => entries.map(&:to_soap) } : {}
162
162
  )
163
163
  end
164
164
  end
@@ -24,13 +24,13 @@ module Symgate
24
24
 
25
25
  def to_soap
26
26
  {
27
- 'wl:word': word,
28
- 'wl:uuid': uuid,
29
- 'wl:priority': priority,
30
- 'wl:conceptcode': value_or_nil(concept_code),
31
- 'cml:symbol': @symbols.tryit { map(&:to_soap) },
32
- 'wl:customgraphic': @custom_graphics.tryit { map(&:to_soap) },
33
- 'wl:lastchange': last_change.to_s
27
+ %s(wl:word) => word,
28
+ %s(wl:uuid) => uuid,
29
+ %s(wl:priority) => priority,
30
+ %s(wl:conceptcode) => value_or_nil(concept_code),
31
+ %s(cml:symbol) => @symbols.tryit { map(&:to_soap) },
32
+ %s(wl:customgraphic) => @custom_graphics.tryit { map(&:to_soap) },
33
+ %s(wl:lastchange) => last_change.to_s
34
34
  }.delete_if { |_, v| v.nil? }
35
35
  end
36
36
 
@@ -17,9 +17,9 @@ module Symgate
17
17
 
18
18
  def to_soap
19
19
  {
20
- 'wl:type': @type,
21
- 'wl:uuid': @uuid,
22
- 'wl:data': @data ? Base64.encode64(@data) : nil
20
+ %s(wl:type) => @type,
21
+ %s(wl:uuid) => @uuid,
22
+ %s(wl:data) => @data ? Base64.encode64(@data) : nil
23
23
  }
24
24
  end
25
25
 
data/symgate-gem.gemspec CHANGED
@@ -28,6 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency 'mysql2', '~> 0.4.1'
29
29
  spec.add_development_dependency 'simplecov', '~> 0.12.0'
30
30
  spec.add_development_dependency 'simplecov-teamcity-summary', '~> 0.1.2'
31
+ spec.add_development_dependency 'codecov'
31
32
 
32
33
  spec.add_dependency 'savon', '~> 2.11.0'
33
34
  spec.add_dependency 'tryit', '~> 0.0.1'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: symgate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Detheridge
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-09 00:00:00.000000000 Z
11
+ date: 2016-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -150,6 +150,20 @@ dependencies:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
152
  version: 0.1.2
153
+ - !ruby/object:Gem::Dependency
154
+ name: codecov
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
153
167
  - !ruby/object:Gem::Dependency
154
168
  name: savon
155
169
  requirement: !ruby/object:Gem::Requirement
@@ -190,7 +204,10 @@ files:
190
204
  - ".junit/.git-keep"
191
205
  - ".rubocop.yml"
192
206
  - ".ruby-version"
207
+ - ".travis.yml"
208
+ - CHANGELOG.md
193
209
  - Gemfile
210
+ - LICENSE
194
211
  - README.md
195
212
  - Rakefile
196
213
  - lib/symgate.rb