skykick 0.1.1 → 0.2.1

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: c7eb504e67e460c967701af6aeee5480111a27080571dad031543cd2051d4aeb
4
- data.tar.gz: 2066d5b75aa42485f0e121b2921dcd826b2103374119f9cd75155a1e9fec2b9d
3
+ metadata.gz: 4e219c7c7f5e5af499eb2dfa75b4f26ec1b44a0feec1f388debf960f7c623e91
4
+ data.tar.gz: 2cec92749ffd33a36a0ea36d583dd025f304c8672c5bf1469146986642bd72f2
5
5
  SHA512:
6
- metadata.gz: d72996b30a489b055633198d433492e6d4ecc60382b6547b4d922dd42bc52f5d676c09903d575e72f23cd902175ba52756c180c70033abd55427e572972d5eda
7
- data.tar.gz: 75339902414d3ad99dbc346769471a1bb06d638f3f0cd0da0a0bc94080803d43573ad2595dba2b1bea1efb6c858616f57dfbd013965d41a41d61f871cb831033
6
+ metadata.gz: b152d1d931fd129b0c921c3d9634831c6037f0d5cca1eb10f9ea16daaae1d886c5234e8a736be2a1a13b76daa3eae0b196bc81eacdc45703d42f8595e35359b0
7
+ data.tar.gz: dda82313a9f6208348f1381ae01e08773591033cce4a90d2cc61d215bd8a189a9025d2bdf96aae5861b504c4de68432f230523c8309159b0c456fc643887e575
data/CHANGELOG.md CHANGED
@@ -5,3 +5,9 @@
5
5
 
6
6
  ## [0.1.1] - 2024-02-08
7
7
  - Update OData support
8
+
9
+ ## [0.2.0] - 2024-02-20
10
+ - Exception handling harmonized
11
+
12
+ ## [0.2.1] - 2024-03-06
13
+ - Upgrade faraday 2
data/Gemfile CHANGED
@@ -7,4 +7,5 @@ gemspec
7
7
 
8
8
  gem 'rake', '~> 13.0'
9
9
  gem 'rubocop', '~> 1.7'
10
- gem 'wrapi'
10
+ gem 'simplecov', require: false, group: :test
11
+ gem 'wrapi'
data/README.md CHANGED
@@ -1,4 +1,7 @@
1
1
  # Skykick Office365 backup API
2
+ [![Version](https://img.shields.io/gem/v/skykick.svg)](https://rubygems.org/gems/skykick)
3
+ [![Maintainability](https://api.codeclimate.com/v1/badges/a340908aaf944745eeda/maintainability)](https://codeclimate.com/github/jancotanis/skykick/maintainability)
4
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/a340908aaf944745eeda/test_coverage)](https://codeclimate.com/github/jancotanis/skykick/test_coverage)
2
5
 
3
6
  This is a wrapper for the Skykick Office365 backup API. You can see the API endpoints here https://developers.skykick.com/apis
4
7
 
@@ -24,7 +27,7 @@ Or install it yourself as:
24
27
 
25
28
  Before you start making the requests to API provide the client id and client secret and email/password using the configuration wrapping.
26
29
 
27
- ```
30
+ ```ruby
28
31
  require 'skykick'
29
32
 
30
33
  Skykick.configure do |config|
@@ -43,7 +46,7 @@ end
43
46
 
44
47
  ## Resources
45
48
  ### Authentication
46
- ```
49
+ ```ruby
47
50
  # setup configuration
48
51
  #
49
52
  client.login
@@ -55,7 +58,7 @@ client.login
55
58
 
56
59
  ### Backup
57
60
  Endpoint for backup related requests
58
- ```
61
+ ```ruby
59
62
  subscriptions = client.subscriptions
60
63
  ```
61
64
 
@@ -77,7 +80,7 @@ subscriptions = client.subscriptions
77
80
 
78
81
  ### Alerts
79
82
  Returns Alerts for a provided Email Migration Order ID or Backup service ID.
80
- ```
83
+ ```ruby
81
84
  subscriptions = client.subscriptions
82
85
  alerts = client.alerts(subscriptions.first.id)
83
86
 
@@ -89,7 +92,7 @@ alerts = client.alerts(subscriptions.first.id)
89
92
 
90
93
  ## Contributing
91
94
 
92
- Bug reports and pull requests are welcome on GitHub at https://github.com/jancotanis/integra365.
95
+ Bug reports and pull requests are welcome on GitHub at https://github.com/jancotanis/skykick.
93
96
 
94
97
  ## License
95
98
 
data/Rakefile CHANGED
@@ -1,12 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'bundler/gem_tasks'
4
+ require 'dotenv'
4
5
  require 'rake/testtask'
5
6
 
7
+ Dotenv.load
8
+
9
+ system './bin/cc-test-reporter before-build'
10
+
6
11
  Rake::TestTask.new(:test) do |t|
7
12
  t.libs << 'test'
8
13
  t.libs << 'lib'
9
14
  t.test_files = FileList['test/**/*_test.rb']
15
+ at_exit do
16
+ system './bin/cc-test-reporter after-build'
17
+ end
10
18
  end
11
19
 
12
20
  require 'rubocop/rake_task'
Binary file
@@ -1,4 +1,4 @@
1
- require 'json'
1
+ require File.expand_path('error', __dir__)
2
2
  require 'uri'
3
3
 
4
4
  module Skykick
@@ -7,14 +7,20 @@ module Skykick
7
7
  # Authorize to the Skykick portal and return access_token
8
8
  # @see https://developers.skykick.com/Guides/Authentication
9
9
  def auth_token(options = {})
10
+ raise ConfigurationError.new 'Client id and/or secret not configured' unless client_id && client_secret
11
+
10
12
  c = connection
11
- c.basic_auth(client_id, client_secret)
13
+ c.request :authorization, :basic, client_id, client_secret
12
14
  response = c.post('/auth/token') do |request|
13
15
  request.headers['Content-Type'] = 'application/x-www-form-urlencoded'
14
16
  request.body = URI.encode_www_form( api_access_token_params )
15
17
  end
16
18
 
17
19
  api_process_token(response.body)
20
+
21
+ self.access_token
22
+ rescue Faraday::ForbiddenError => e
23
+ raise AuthenticationError.new 'Unauthorized; response ' + e.to_s
18
24
  end
19
25
  alias login auth_token
20
26
 
@@ -28,13 +34,12 @@ module Skykick
28
34
  end
29
35
 
30
36
  def api_process_token(response)
31
- at = self.access_token = response['access_token']
32
- self.token_type = response['token_type']
33
- self.refresh_token = response['refresh_token']
34
- self.token_expires = response['expires_in']
35
- raise StandardError.new 'Could not find valid access_token; response ' + response.to_s if at.nil? || at.empty?
37
+ self.access_token = response['access_token']
38
+ self.token_type = response['token_type']
39
+ self.refresh_token = response['refresh_token']
40
+ self.token_expires = response['expires_in']
36
41
 
37
- at
42
+ raise AuthorizationError.new 'Could not find valid access_token; response ' + response.to_s if self.access_token.nil? || self.access_token.empty?
38
43
  end
39
44
  end
40
45
  end
@@ -0,0 +1,11 @@
1
+ module Skykick
2
+
3
+ # Generic error to be able to rescue all Skykick errors
4
+ class SkykickError < StandardError; end
5
+
6
+ # Error when configuration not sufficient
7
+ class ConfigurationError < SkykickError; end
8
+
9
+ # Error when authentication fails
10
+ class AuthenticationError < SkykickError; end
11
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Skykick
4
- VERSION = '0.1.1'
4
+ VERSION = '0.2.1'
5
5
  end
data/skykick.gemspec CHANGED
@@ -33,4 +33,5 @@ Gem::Specification.new do |s|
33
33
  s.add_development_dependency 'dotenv'
34
34
  s.add_development_dependency 'minitest'
35
35
  s.add_development_dependency 'rubocop'
36
+ s.add_development_dependency 'simplecov'
36
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skykick
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janco Tanis
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-02-08 00:00:00.000000000 Z
11
+ date: 2024-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  description:
84
98
  email: gems@jancology.com
85
99
  executables: []
@@ -92,6 +106,7 @@ files:
92
106
  - Gemfile
93
107
  - README.md
94
108
  - Rakefile
109
+ - bin/cc-test-reporter.exe
95
110
  - lib/skykick.rb
96
111
  - lib/skykick/api.rb
97
112
  - lib/skykick/authentication.rb
@@ -99,6 +114,7 @@ files:
99
114
  - lib/skykick/client/alerts.rb
100
115
  - lib/skykick/client/backup.rb
101
116
  - lib/skykick/connection.rb
117
+ - lib/skykick/error.rb
102
118
  - lib/skykick/pagination.rb
103
119
  - lib/skykick/version.rb
104
120
  - skykick.gemspec
@@ -123,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
139
  - !ruby/object:Gem::Version
124
140
  version: '0'
125
141
  requirements: []
126
- rubygems_version: 3.2.12
142
+ rubygems_version: 3.2.3
127
143
  signing_key:
128
144
  specification_version: 4
129
145
  summary: A Ruby wrapper for the Skykick backup Portal REST APIs (readonly)