glimr-api-client 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.3.1
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
data/Gemfile.lock ADDED
@@ -0,0 +1,252 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ glimr-api-client (0.1.1)
5
+ excon (~> 0.51)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ abstract_type (0.0.7)
11
+ actioncable (5.0.0)
12
+ actionpack (= 5.0.0)
13
+ nio4r (~> 1.2)
14
+ websocket-driver (~> 0.6.1)
15
+ actionmailer (5.0.0)
16
+ actionpack (= 5.0.0)
17
+ actionview (= 5.0.0)
18
+ activejob (= 5.0.0)
19
+ mail (~> 2.5, >= 2.5.4)
20
+ rails-dom-testing (~> 2.0)
21
+ actionpack (5.0.0)
22
+ actionview (= 5.0.0)
23
+ activesupport (= 5.0.0)
24
+ rack (~> 2.0)
25
+ rack-test (~> 0.6.3)
26
+ rails-dom-testing (~> 2.0)
27
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
28
+ actionview (5.0.0)
29
+ activesupport (= 5.0.0)
30
+ builder (~> 3.1)
31
+ erubis (~> 2.7.0)
32
+ rails-dom-testing (~> 2.0)
33
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
34
+ activejob (5.0.0)
35
+ activesupport (= 5.0.0)
36
+ globalid (>= 0.3.6)
37
+ activemodel (5.0.0)
38
+ activesupport (= 5.0.0)
39
+ activerecord (5.0.0)
40
+ activemodel (= 5.0.0)
41
+ activesupport (= 5.0.0)
42
+ arel (~> 7.0)
43
+ activesupport (5.0.0)
44
+ concurrent-ruby (~> 1.0, >= 1.0.2)
45
+ i18n (~> 0.7)
46
+ minitest (~> 5.1)
47
+ tzinfo (~> 1.1)
48
+ adamantium (0.2.0)
49
+ ice_nine (~> 0.11.0)
50
+ memoizable (~> 0.4.0)
51
+ addressable (2.4.0)
52
+ anima (0.3.0)
53
+ abstract_type (~> 0.0.7)
54
+ adamantium (~> 0.2)
55
+ equalizer (~> 0.0.11)
56
+ arel (7.0.0)
57
+ ast (2.3.0)
58
+ builder (3.2.2)
59
+ byebug (9.0.5)
60
+ capybara (2.7.1)
61
+ addressable
62
+ mime-types (>= 1.16)
63
+ nokogiri (>= 1.3.3)
64
+ rack (>= 1.0.0)
65
+ rack-test (>= 0.5.4)
66
+ xpath (~> 2.0)
67
+ codeclimate-test-reporter (0.6.0)
68
+ simplecov (>= 0.7.1, < 1.0.0)
69
+ coderay (1.1.1)
70
+ concord (0.1.5)
71
+ adamantium (~> 0.2.0)
72
+ equalizer (~> 0.0.9)
73
+ concurrent-ruby (1.0.2)
74
+ diff-lcs (1.2.5)
75
+ docile (1.1.5)
76
+ equalizer (0.0.11)
77
+ erubis (2.7.0)
78
+ excon (0.52.0)
79
+ fuubar (2.0.0)
80
+ rspec (~> 3.0)
81
+ ruby-progressbar (~> 1.4)
82
+ globalid (0.3.6)
83
+ activesupport (>= 4.1.0)
84
+ i18n (0.7.0)
85
+ ice_nine (0.11.2)
86
+ json (1.8.3)
87
+ loofah (2.0.3)
88
+ nokogiri (>= 1.5.9)
89
+ mail (2.6.4)
90
+ mime-types (>= 1.16, < 4)
91
+ memoizable (0.4.2)
92
+ thread_safe (~> 0.3, >= 0.3.1)
93
+ method_source (0.8.2)
94
+ mime-types (3.1)
95
+ mime-types-data (~> 3.2015)
96
+ mime-types-data (3.2016.0521)
97
+ mini_portile2 (2.1.0)
98
+ minitest (5.9.0)
99
+ morpher (0.2.6)
100
+ abstract_type (~> 0.0.7)
101
+ adamantium (~> 0.2.0)
102
+ anima (~> 0.3.0)
103
+ ast (~> 2.2)
104
+ concord (~> 0.1.5)
105
+ equalizer (~> 0.0.9)
106
+ ice_nine (~> 0.11.0)
107
+ procto (~> 0.0.2)
108
+ mutant (0.8.11)
109
+ abstract_type (~> 0.0.7)
110
+ adamantium (~> 0.2.0)
111
+ anima (~> 0.3.0)
112
+ ast (~> 2.2)
113
+ concord (~> 0.1.5)
114
+ diff-lcs (~> 1.2)
115
+ equalizer (~> 0.0.9)
116
+ ice_nine (~> 0.11.1)
117
+ memoizable (~> 0.4.2)
118
+ morpher (~> 0.2.6)
119
+ parallel (~> 1.3)
120
+ parser (~> 2.3.0, >= 2.3.0.2)
121
+ procto (~> 0.0.2)
122
+ regexp_parser (~> 0.3.6)
123
+ unparser (~> 0.2.5)
124
+ mutant-rspec (0.8.11)
125
+ mutant (~> 0.8.11)
126
+ rspec-core (>= 3.4.0, < 3.6.0)
127
+ nio4r (1.2.1)
128
+ nokogiri (1.6.8)
129
+ mini_portile2 (~> 2.1.0)
130
+ pkg-config (~> 1.1.7)
131
+ parallel (1.9.0)
132
+ parser (2.3.1.2)
133
+ ast (~> 2.2)
134
+ pkg-config (1.1.7)
135
+ powerpack (0.1.1)
136
+ procto (0.0.3)
137
+ pry (0.10.3)
138
+ coderay (~> 1.1.0)
139
+ method_source (~> 0.8.1)
140
+ slop (~> 3.4)
141
+ pry-byebug (3.4.0)
142
+ byebug (~> 9.0)
143
+ pry (~> 0.10)
144
+ rack (2.0.1)
145
+ rack-test (0.6.3)
146
+ rack (>= 1.0)
147
+ rails (5.0.0)
148
+ actioncable (= 5.0.0)
149
+ actionmailer (= 5.0.0)
150
+ actionpack (= 5.0.0)
151
+ actionview (= 5.0.0)
152
+ activejob (= 5.0.0)
153
+ activemodel (= 5.0.0)
154
+ activerecord (= 5.0.0)
155
+ activesupport (= 5.0.0)
156
+ bundler (>= 1.3.0, < 2.0)
157
+ railties (= 5.0.0)
158
+ sprockets-rails (>= 2.0.0)
159
+ rails-dom-testing (2.0.1)
160
+ activesupport (>= 4.2.0, < 6.0)
161
+ nokogiri (~> 1.6.0)
162
+ rails-html-sanitizer (1.0.3)
163
+ loofah (~> 2.0)
164
+ railties (5.0.0)
165
+ actionpack (= 5.0.0)
166
+ activesupport (= 5.0.0)
167
+ method_source
168
+ rake (>= 0.8.7)
169
+ thor (>= 0.18.1, < 2.0)
170
+ rainbow (2.1.0)
171
+ rake (10.4.2)
172
+ regexp_parser (0.3.6)
173
+ rspec (3.5.0)
174
+ rspec-core (~> 3.5.0)
175
+ rspec-expectations (~> 3.5.0)
176
+ rspec-mocks (~> 3.5.0)
177
+ rspec-core (3.5.0)
178
+ rspec-support (~> 3.5.0)
179
+ rspec-expectations (3.5.0)
180
+ diff-lcs (>= 1.2.0, < 2.0)
181
+ rspec-support (~> 3.5.0)
182
+ rspec-mocks (3.5.0)
183
+ diff-lcs (>= 1.2.0, < 2.0)
184
+ rspec-support (~> 3.5.0)
185
+ rspec-rails (3.5.0)
186
+ actionpack (>= 3.0)
187
+ activesupport (>= 3.0)
188
+ railties (>= 3.0)
189
+ rspec-core (~> 3.5.0)
190
+ rspec-expectations (~> 3.5.0)
191
+ rspec-mocks (~> 3.5.0)
192
+ rspec-support (~> 3.5.0)
193
+ rspec-support (3.5.0)
194
+ rubocop (0.41.1)
195
+ parser (>= 2.3.1.1, < 3.0)
196
+ powerpack (~> 0.1)
197
+ rainbow (>= 1.99.1, < 3.0)
198
+ ruby-progressbar (~> 1.7)
199
+ unicode-display_width (~> 1.0, >= 1.0.1)
200
+ ruby-progressbar (1.8.1)
201
+ simplecov (0.11.2)
202
+ docile (~> 1.1.0)
203
+ json (~> 1.8)
204
+ simplecov-html (~> 0.10.0)
205
+ simplecov-html (0.10.0)
206
+ slop (3.6.0)
207
+ sprockets (3.6.3)
208
+ concurrent-ruby (~> 1.0)
209
+ rack (> 1, < 3)
210
+ sprockets-rails (3.1.1)
211
+ actionpack (>= 4.0)
212
+ activesupport (>= 4.0)
213
+ sprockets (>= 3.0.0)
214
+ sqlite3 (1.3.11)
215
+ thor (0.19.1)
216
+ thread_safe (0.3.5)
217
+ tzinfo (1.2.2)
218
+ thread_safe (~> 0.1)
219
+ unicode-display_width (1.1.0)
220
+ unparser (0.2.5)
221
+ abstract_type (~> 0.0.7)
222
+ adamantium (~> 0.2.0)
223
+ concord (~> 0.1.5)
224
+ diff-lcs (~> 1.2.5)
225
+ equalizer (~> 0.0.9)
226
+ parser (~> 2.3.0)
227
+ procto (~> 0.0.2)
228
+ websocket-driver (0.6.4)
229
+ websocket-extensions (>= 0.1.0)
230
+ websocket-extensions (0.1.2)
231
+ xpath (2.0.0)
232
+ nokogiri (~> 1.3)
233
+
234
+ PLATFORMS
235
+ ruby
236
+
237
+ DEPENDENCIES
238
+ bundler (~> 1.10)
239
+ capybara (~> 2.7)
240
+ codeclimate-test-reporter (~> 0.2)
241
+ fuubar (~> 2.0)
242
+ glimr-api-client!
243
+ mutant-rspec (~> 0.8)
244
+ pry-byebug (~> 3.4)
245
+ rails (~> 5.0)
246
+ rake (~> 10.0)
247
+ rspec-rails (~> 3.5)
248
+ rubocop (~> 0.41)
249
+ sqlite3 (~> 1.3)
250
+
251
+ BUNDLED WITH
252
+ 1.12.5
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2016 Todd Tyree
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,141 @@
1
+ [![CircleCI](https://circleci.com/gh/ministryofjustice/glimr-api-client.svg?style=svg&circle-token=1d291c45a14d48ef123ffd904169e10b7f47411f)](https://circleci.com/gh/ministryofjustice/glimr-api-client)
2
+
3
+ # GlimrApiClient
4
+
5
+ A simple client to integrate with the GLiMR case management system in
6
+ use in various UK tribunals.
7
+
8
+ ## Usage
9
+
10
+ ### Check Availablity
11
+
12
+ ```ruby
13
+ GlimrApiClient::Available.call.available?
14
+ ```
15
+
16
+ Check if the GLiMR API is available. Raises
17
+ `GlimrApiClient::Unavailable` if anything other than a positive response
18
+ is received; this includes network errors and timeouts.
19
+
20
+ ### Find a case
21
+
22
+ ```ruby
23
+ GlimrApiClient::Case.find(<case reference>)
24
+ ```
25
+
26
+ Find a case on GLiMR using the case reference (‘TT/2012/00001’ in Tax
27
+ Tribunals, for example). `#title` returns case title from GLiMR, and `#fees`
28
+ returns an array of anonymous objects (OpenStructs) detailing any
29
+ outstanding fees. Each fee object responds to `#glimr_id`,
30
+ `#description`, and `#amount`.
31
+
32
+ Please note that `#amount` returns the amount in pence.
33
+
34
+ If a case is not found, the client will raise `GlimrApiClient::CaseNotFound`.
35
+
36
+ ### Update a case, mark as paid
37
+
38
+ ```ruby
39
+ GlimrApiClient::Update.call(<Fee object>)
40
+ ```
41
+
42
+ Update a GLiMR case to indicate that payment has been received for a
43
+ fee. The fee object passed must respond to `#glimr_id`,
44
+ `#govpay_reference`, `#govpay_payment_id`, and `#amount`. `#amount`
45
+ must be the amount in pence. The client will validate the request and raise
46
+ `GlimrApiClient::RequestError` if any of these methods are missing.
47
+
48
+ Network errors or API failures will raise
49
+ `GlimrApiClient::PaymentNotificationFailure`.
50
+
51
+ ### Examples
52
+
53
+ See the dummy Rails app in `/spec/dummy` for examples of how the gem might
54
+ be used in a production environment.
55
+
56
+ ## Installation
57
+
58
+ Add this line to your application’s Gemfile:
59
+
60
+ ```ruby
61
+ gem 'glimr-api-client'
62
+ ```
63
+
64
+ And then execute:
65
+ ```bash
66
+ $ bundle
67
+ ```
68
+
69
+ Or install it yourself as:
70
+ ```bash
71
+ $ gem install glimr-api-client
72
+ ```
73
+
74
+ ## Testing
75
+
76
+ Run `bundle rake` in the gem source directory for a full set of specs,
77
+ mutation tests and rubocop checks.
78
+
79
+ ### Shared examples
80
+
81
+ The gem can install a set of shared examples in your app that will stub
82
+ a sensible set of API calls using Excon’s stubbing functionality. To
83
+ install these, install the gem, make sure you have the `spec/support`
84
+ subdirectory then run:
85
+
86
+ ```ruby
87
+ bundle exec rake rake glimr_api_client:install_shared_examples
88
+ ```
89
+
90
+ This will install `spec/support/shared_examples_for_glimr.rb`.
91
+
92
+ Lastly, add these lines to `spec/rails_helper`:
93
+
94
+ ```ruby
95
+ config.before(:all) do
96
+ Excon.defaults[:mock] = true
97
+ end
98
+
99
+ config.after(:each) do
100
+ Excon.stubs.clear
101
+ end
102
+ ```
103
+
104
+ ## Contributing
105
+
106
+ Fork, then clone the repo:
107
+
108
+ ```bash
109
+ git clone git@github.com:your-username/glimr-api-client.git
110
+ ```
111
+
112
+ Make sure the tests pass:
113
+
114
+ ```bash
115
+ bundle
116
+ bundle exec rake
117
+ ```
118
+
119
+ Make your change. Add specs for your change. Make the specs pass:
120
+
121
+ ```bash
122
+ bundle exec rake
123
+ ```
124
+
125
+ Push to your fork and [submit a pull request][pr].
126
+
127
+ [pr]: https://github.com/ministryofjustice/glimr-api-client/compare
128
+
129
+ Some things that will increase the chance that your pull request is
130
+ accepted:
131
+
132
+ * Write specs.
133
+ * Make sure you don’t have any mutants (part of total test suite).
134
+ * Write a [good commit message][commit].
135
+
136
+ [commit]: https://github.com/alphagov/styleguides/blob/master/git.md
137
+
138
+ ## License
139
+ Released under the [MIT License](http://opensource.org/licenses/MIT).
140
+ Copyright (c) 2015-2016 Ministry of Justice.
141
+
data/Rakefile ADDED
@@ -0,0 +1,36 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'GlimrApiClient'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+ load 'rails/tasks/statistics.rake'
21
+
22
+ require 'bundler/gem_tasks'
23
+
24
+ require 'rspec/core/rake_task'
25
+
26
+ RSpec::Core::RakeTask.new(:spec)
27
+
28
+ # Get rid of rspec background noise.
29
+ task(:spec).clear
30
+ RSpec::Core::RakeTask.new(:spec) do |t|
31
+ t.verbose = false
32
+ end
33
+ task default: :spec
34
+
35
+ load 'tasks/mutant.rake'
36
+ load 'tasks/rubocop.rake'