glimr-api-client 0.1.6 → 0.1.7

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: a6227c85a28a324ce1b0250fe3000ad2fce7080d
4
- data.tar.gz: e4fe570d9a80974f73798ceb39152cde80235e3d
3
+ metadata.gz: ae6cac11acea900354d83e6e83736e94dd5a7446
4
+ data.tar.gz: 7c7437169b1a20828ebc7431dc2362fc08116ed6
5
5
  SHA512:
6
- metadata.gz: 9f9cdb0f5b8877cec32b95e87308795af9383ee6c664fe9f1172191952b68e7b204947412b43dab7b9ac2c4776a3c3217275ca89c08f0fd3a1eee0ef22b1fa0a
7
- data.tar.gz: 827cf52ac0204fabdbec791ff500ae617a0170c8069346c87e6066c63c910465b97de01864a13181866421975f9e982eadb57a295c0b4cec69acfcb64738684c
6
+ metadata.gz: af13affc2d1a54efef826da670f85bacab6dbd528c9a16eb1e3edc032617d706f336e733a3b6629a6a80dfc57ee59f4896d4736e5b9ce5cf4568142ab6e40433
7
+ data.tar.gz: 98451c6d7cf92180503074eba16b1b5edc11a4f205ba3ba8a91082b5875f994dacf3070c437f817b270824efd813f86a04b7db92e6af195a1edda8ca4bf118c5
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- glimr-api-client (0.1.6)
4
+ glimr-api-client (0.1.7)
5
5
  activesupport (~> 5.0)
6
6
  excon (~> 0.51)
7
7
 
@@ -250,4 +250,4 @@ DEPENDENCIES
250
250
  sqlite3 (~> 1.3)
251
251
 
252
252
  BUNDLED WITH
253
- 1.13.3
253
+ 1.13.6
@@ -1,13 +1,16 @@
1
1
  require 'json'
2
2
  require 'glimr_api_client/version'
3
3
  require 'glimr_api_client/api'
4
+ require 'glimr_api_client/base'
4
5
  require 'glimr_api_client/available'
5
6
  require 'glimr_api_client/case'
6
7
  require 'glimr_api_client/update'
8
+ require 'glimr_api_client/register_new_case'
7
9
 
8
10
 
9
11
  module GlimrApiClient
10
12
  class PaymentNotificationFailure < StandardError; end
13
+ class RegisterNewCaseFailure < StandardError; end
11
14
  class Unavailable < StandardError; end
12
15
  class CaseNotFound < StandardError; end
13
16
  class RequestError < StandardError; end;
@@ -17,11 +17,7 @@ module GlimrApiClient
17
17
  @body = resp.body
18
18
  }
19
19
  rescue Excon::Error => e
20
- if endpoint.eql?('/paymenttaken')
21
- raise PaymentNotificationFailure, e
22
- else
23
- raise Unavailable, e
24
- end
20
+ re_raise_error(endpoint, e)
25
21
  end
26
22
 
27
23
  def response_body
@@ -34,11 +30,18 @@ module GlimrApiClient
34
30
  if (!endpoint.eql?('/paymenttaken') && resp.status.equal?(404))
35
31
  raise CaseNotFound, resp.status
36
32
  elsif (400..599).cover?(resp.status)
37
- if endpoint.eql?('/paymenttaken')
38
- raise PaymentNotificationFailure, resp.status
39
- else
40
- raise Unavailable, resp.status
41
- end
33
+ re_raise_error(endpoint, resp.status)
34
+ end
35
+ end
36
+
37
+ def re_raise_error(docpath, e)
38
+ case docpath
39
+ when '/paymenttaken'
40
+ raise PaymentNotificationFailure, e
41
+ when '/registernewcase'
42
+ raise RegisterNewCaseFailure, e
43
+ else
44
+ raise Unavailable, e
42
45
  end
43
46
  end
44
47
 
@@ -46,10 +49,10 @@ module GlimrApiClient
46
49
  Excon.new(
47
50
  uri,
48
51
  headers: {
49
- 'Content-Type' => 'application/json',
50
- 'Accept' => 'application/json'
51
- },
52
- persistent: true
52
+ 'Content-Type' => 'application/json',
53
+ 'Accept' => 'application/json'
54
+ },
55
+ persistent: true
53
56
  )
54
57
  end
55
58
  end
@@ -0,0 +1,17 @@
1
+ module GlimrApiClient
2
+ class Base
3
+ include GlimrApiClient::Api
4
+
5
+ def self.call(*args)
6
+ new(*args).call
7
+ end
8
+
9
+ def call
10
+ check_request!
11
+ post
12
+ self
13
+ end
14
+
15
+ end
16
+ end
17
+
@@ -0,0 +1,28 @@
1
+ module GlimrApiClient
2
+ class RegisterNewCase < Base
3
+ def initialize(params)
4
+ @params = params
5
+ end
6
+
7
+ private
8
+
9
+ def check_request!
10
+ errors = []
11
+ [
12
+ :jurisdictionId,
13
+ :onlineMappingCode
14
+ ].each do |required|
15
+ errors << required if request_body.key?(required).blank?
16
+ end
17
+ raise RequestError, errors unless errors.blank?
18
+ end
19
+
20
+ def endpoint
21
+ '/registernewcase'
22
+ end
23
+
24
+ def request_body
25
+ @params
26
+ end
27
+ end
28
+ end
@@ -1,21 +1,9 @@
1
1
  module GlimrApiClient
2
- class Update
3
- include GlimrApiClient::Api
4
-
5
- def self.call(*args)
6
- new(*args).call
7
- end
8
-
2
+ class Update < Base
9
3
  def initialize(fee)
10
4
  @fee = fee
11
5
  end
12
6
 
13
- def call
14
- check_request!
15
- post
16
- self
17
- end
18
-
19
7
  private
20
8
 
21
9
  def check_request!
@@ -1,3 +1,3 @@
1
1
  module GlimrApiClient
2
- VERSION = '0.1.6'
2
+ VERSION = '0.1.7'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimr-api-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Todd Tyree
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-25 00:00:00.000000000 Z
11
+ date: 2016-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -214,7 +214,9 @@ files:
214
214
  - lib/glimr_api_client.rb
215
215
  - lib/glimr_api_client/api.rb
216
216
  - lib/glimr_api_client/available.rb
217
+ - lib/glimr_api_client/base.rb
217
218
  - lib/glimr_api_client/case.rb
219
+ - lib/glimr_api_client/register_new_case.rb
218
220
  - lib/glimr_api_client/update.rb
219
221
  - lib/glimr_api_client/version.rb
220
222
  - lib/tasks/mutant.rake