omnievent-api 0.1.0.pre1 → 0.1.0.pre2

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
  SHA256:
3
- metadata.gz: 8cd3a2638b93100fa0db57f3744b070ac98ba3104f515c8204f6dbc61bc569dd
4
- data.tar.gz: 5b8bf5e53914b06c5058d64c6a5bc9486c2cb4d00c8649f91f04049c4d034238
3
+ metadata.gz: 5f03909646c8909dcac894d052609ec5b0a337b7ade88df690029f30866b1710
4
+ data.tar.gz: 2ad4e2d181f5bfd005f67515a123d276ed4852382d988844c836694decf0d010
5
5
  SHA512:
6
- metadata.gz: c983bb6b2ebc992a53b6255a82c47855f3efc7c3f1e7b708e13be021cd12c0a39b5622b5a8755bf68c56434c1edd2b70659d3f117d94b9e99984dafb35da1327
7
- data.tar.gz: a4397da4447fc5b319f048637c6ca4ad021ed9948de7881f05541eccba875a9519982a9f6b2dd2c82927654e7e2c1560b739cef2069b6e12f2e79f60c67b220c
6
+ metadata.gz: b7d06f35d21485b9a80e006dadff5cf3e3ee78966e501d12a1c2e50a20bd39ea5f25638f1488b030930a4ce883302c8d35d484974ff07e368b1fe4b94dd67fcc
7
+ data.tar.gz: 8fc5203c01d016483125eef12a3264d7cd5e15fec5b0fd97b7a36f8c88c23919e48228f0085ef28145fcc53db179429757e086fff494c36725a230ca6397f41d
data/CHANGELOG.md CHANGED
@@ -3,3 +3,9 @@
3
3
  ## [0.1.0.pre1] - 2022-10-03
4
4
 
5
5
  - Pre release
6
+
7
+ ## [0.1.0.pre2] - 2022-10-04
8
+
9
+ - Allow passing of method as an opt to perform_request
10
+ - Don't raise errors on failure to connect
11
+ - Support OmniEvent logger
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- omnievent-api (0.1.0.pre1)
4
+ omnievent-api (0.1.0.pre2)
5
5
  excon
6
6
  omnievent
7
7
 
@@ -16,7 +16,7 @@ GEM
16
16
  crack (0.4.5)
17
17
  rexml
18
18
  diff-lcs (1.5.0)
19
- excon (0.92.5)
19
+ excon (0.93.0)
20
20
  hashdiff (1.0.1)
21
21
  hashie (5.0.0)
22
22
  iso-639 (0.3.5)
data/README.md CHANGED
@@ -1,11 +1,11 @@
1
1
  # OmniEvent API (Pre Release)
2
2
 
3
+ > Please note that this gem is pre release and is not yet ready for production.
4
+
3
5
  This gem contains an generic API strategy for OmniEvent.
4
6
 
5
7
  ## Usage
6
8
 
7
- > Please note that this gem is pre release and is not yet ready for production.
8
-
9
9
  This gem is designed to be a base for other OmniEvent strategies.
10
10
 
11
11
  ## Development
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniEvent
4
4
  module API
5
- VERSION = "0.1.0.pre1"
5
+ VERSION = "0.1.0.pre2"
6
6
  end
7
7
  end
@@ -19,6 +19,7 @@ module OmniEvent
19
19
 
20
20
  option :name, "api"
21
21
  option :token, ""
22
+ option :debug, false
22
23
 
23
24
  REDIRECT_LIMIT = 5
24
25
 
@@ -38,17 +39,13 @@ module OmniEvent
38
39
  raise NotImplementedError
39
40
  end
40
41
 
41
- def request_path
42
- raise NotImplementedError
43
- end
44
-
45
42
  def request_headers
46
43
  raise NotImplementedError
47
44
  end
48
45
 
49
46
  def perform_request(opts = {})
50
- request_opts = { path: request_path }.merge(opts)
51
- request_response = request_connection.get(request_opts)
47
+ request_opts = { method: "GET" }.merge(opts)
48
+ request_response = request_connection.request(request_opts)
52
49
 
53
50
  redirect = 0
54
51
  while redirect < REDIRECT_LIMIT && [301, 302, 303, 307, 308].include?(request_response.status)
@@ -57,27 +54,33 @@ module OmniEvent
57
54
  request_response = request_connection.get(request_opts)
58
55
  end
59
56
 
60
- request_error unless request_response.status == 200
57
+ unless request_response.status == 200
58
+ message = "Failed to retrieve events from #{options.name}"
59
+ message += ": #{request_response.body[0...300]}" if request_response.body
60
+ log(:error, message)
61
+ end
61
62
 
62
- begin
63
- JSON.parse(request_response.body)
64
- rescue JSON::ParserError
65
- request_error
63
+ if opts[:raw_response]
64
+ request_response
65
+ else
66
+ begin
67
+ parsed_request_body = JSON.parse(request_response.body)
68
+ rescue JSON::ParserError
69
+ log(:error, "Failed to parse response body from #{options.name}")
70
+ parsed_request_body = nil
71
+ end
72
+
73
+ parsed_request_body
66
74
  end
67
75
  end
68
76
 
69
77
  def request_connection
70
78
  @request_connection ||= Excon.new(
71
79
  request_url,
72
- headers: request_headers
80
+ headers: request_headers,
81
+ debug: options.debug
73
82
  )
74
83
  end
75
-
76
- def request_error
77
- message = "Failed to retrieve events from #{options.name}"
78
- log(:error, message)
79
- raise Error, message
80
- end
81
84
  end
82
85
  end
83
86
  end
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.name = "omnievent-api"
9
9
  spec.version = OmniEvent::API::VERSION
10
10
  spec.authors = ["Angus McLeod"]
11
- spec.email = ["angus@pavilion.tech"]
11
+ spec.email = ["development@pavilion.tech"]
12
12
 
13
13
  spec.summary = "OmniEvent API strategy"
14
14
  spec.description = "A generic API strategy for OmniEvent"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omnievent-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre1
4
+ version: 0.1.0.pre2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Angus McLeod
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-03 00:00:00.000000000 Z
11
+ date: 2022-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon
@@ -68,7 +68,7 @@ dependencies:
68
68
  version: '0'
69
69
  description: A generic API strategy for OmniEvent
70
70
  email:
71
- - angus@pavilion.tech
71
+ - development@pavilion.tech
72
72
  executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []