omnievent-api 0.1.0.pre1 → 0.1.0.pre3

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: 941d3b6b19c8478a4b464277b0dc31902551edf2ab8145ef4747c04e738dbb50
4
+ data.tar.gz: d33a1365a9ee988d625824c8154ea71e343fbdbaeee332d4529cdd6e594f8832
5
5
  SHA512:
6
- metadata.gz: c983bb6b2ebc992a53b6255a82c47855f3efc7c3f1e7b708e13be021cd12c0a39b5622b5a8755bf68c56434c1edd2b70659d3f117d94b9e99984dafb35da1327
7
- data.tar.gz: a4397da4447fc5b319f048637c6ca4ad021ed9948de7881f05541eccba875a9519982a9f6b2dd2c82927654e7e2c1560b739cef2069b6e12f2e79f60c67b220c
6
+ metadata.gz: 7a3b6c202b6a908f08f4889ae9b2896a4cc7150556c86dfe5e9be3de0543bd8013925d236559f04327e713c2d1485a09dca2ee0fbeeab8492fd677b184c5feea
7
+ data.tar.gz: d7c05c829b4a20bcecd5b24bafdf313841ead51b88958e921f78c2011ed830297d7d6c5c443200182841848170a560789816a3d5d7d98c9ece6fed202d9bf7ab
data/.rubocop.yml CHANGED
@@ -15,7 +15,7 @@ Metrics/BlockLength:
15
15
 
16
16
  Metrics/MethodLength:
17
17
  CountComments: false
18
- Max: 25
18
+ Max: 30
19
19
 
20
20
  Metrics/ClassLength:
21
21
  Max: 150
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.pre3"
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,36 @@ 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
+ request_succeeded = [200, 201, 202, 204].include?(request_response.status)
58
+ unless request_succeeded
59
+ message = "Failed to retrieve events from #{options.name}"
60
+ message += ": #{request_response.body[0...300]}" if request_response.body
61
+ log(:error, message)
62
+ end
61
63
 
62
- begin
63
- JSON.parse(request_response.body)
64
- rescue JSON::ParserError
65
- request_error
64
+ if opts[:raw_response]
65
+ request_response
66
+ elsif !request_response.body.to_s.empty?
67
+ begin
68
+ parsed_request_body = JSON.parse(request_response.body)
69
+ rescue JSON::ParserError
70
+ log(:error, "Failed to parse response body from #{options.name}")
71
+ parsed_request_body = nil
72
+ end
73
+
74
+ parsed_request_body
75
+ else
76
+ request_succeeded
66
77
  end
67
78
  end
68
79
 
69
80
  def request_connection
70
81
  @request_connection ||= Excon.new(
71
82
  request_url,
72
- headers: request_headers
83
+ headers: request_headers,
84
+ debug: options.debug
73
85
  )
74
86
  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
87
  end
82
88
  end
83
89
  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.pre3
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: 2024-09-03 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: []
@@ -110,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
110
  - !ruby/object:Gem::Version
111
111
  version: 1.3.1
112
112
  requirements: []
113
- rubygems_version: 3.1.4
113
+ rubygems_version: 3.3.26
114
114
  signing_key:
115
115
  specification_version: 4
116
116
  summary: OmniEvent API strategy