skykick 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -1
- data/README.md +22 -10
- data/lib/skykick/api.rb +31 -5
- data/lib/skykick/authentication.rb +40 -11
- data/lib/skykick/client.rb +11 -2
- data/lib/skykick/connection.rb +25 -12
- data/lib/skykick/error.rb +24 -5
- data/lib/skykick/pagination.rb +50 -14
- data/lib/skykick/version.rb +1 -1
- data/lib/skykick.rb +35 -4
- metadata +3 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e19ac5551a5eed6f335941a38736d4db275db2f296ae65e922f986755f5ca26
|
4
|
+
data.tar.gz: 103c52067a848103220e77b575b1a9faeb33312331ab3f8529b0c084b43e1ff6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90814f525c34d0970de21e27dca62e190fc2402596ed71052224a024d3b4bc1b5eb4f502255be8d4f2231b11a06bc432b1e29240eb6b6c791c09f8904d93b247
|
7
|
+
data.tar.gz: d4e4f31bd103929aa777b8c6d70f3bae5753fd51eed364d61173f9fcee7875d4ee67df88980c024d68f00f7d4efef704a8458cf726738a9871eb24763c4182e8
|
data/CHANGELOG.md
CHANGED
@@ -1,13 +1,21 @@
|
|
1
|
-
|
1
|
+
# Changelog
|
2
2
|
|
3
3
|
## [0.1.0] - 2024-02-05
|
4
|
+
|
4
5
|
- Initial release
|
5
6
|
|
6
7
|
## [0.1.1] - 2024-02-08
|
8
|
+
|
7
9
|
- Update OData support
|
8
10
|
|
9
11
|
## [0.2.0] - 2024-02-20
|
12
|
+
|
10
13
|
- Exception handling harmonized
|
11
14
|
|
12
15
|
## [0.2.1] - 2024-03-06
|
16
|
+
|
13
17
|
- Upgrade faraday 2
|
18
|
+
|
19
|
+
## [0.2.2] - 2025-03-21
|
20
|
+
|
21
|
+
- updated documentation, filter subscription key from logs
|
data/README.md
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
# Skykick Office365 backup API
|
2
|
+
|
2
3
|
[](https://rubygems.org/gems/skykick)
|
3
4
|
[](https://codeclimate.com/github/jancotanis/skykick/maintainability)
|
4
5
|
[](https://codeclimate.com/github/jancotanis/skykick/test_coverage)
|
5
6
|
|
6
|
-
This is a wrapper for the Skykick Office365 backup API.
|
7
|
+
This is a wrapper for the Skykick Office365 backup API.
|
8
|
+
You can see the [API endpoints](https://developers.skykick.com/apis)
|
7
9
|
|
8
10
|
Currently only the GET requests to endpoints /Backup and /Alerts are implemented (readonly).
|
9
11
|
|
@@ -17,15 +19,20 @@ gem 'skykick'
|
|
17
19
|
|
18
20
|
And then execute:
|
19
21
|
|
20
|
-
|
22
|
+
```console
|
23
|
+
> bundle install
|
24
|
+
```
|
21
25
|
|
22
26
|
Or install it yourself as:
|
23
27
|
|
24
|
-
|
28
|
+
```console
|
29
|
+
> gem install skykick
|
30
|
+
```
|
25
31
|
|
26
32
|
## Usage
|
27
33
|
|
28
|
-
Before you start making the requests to API provide the client id and client secret and
|
34
|
+
Before you start making the requests to API provide the client id and client secret and
|
35
|
+
email/password using the configuration wrapping.
|
29
36
|
|
30
37
|
```ruby
|
31
38
|
require 'skykick'
|
@@ -45,19 +52,23 @@ end
|
|
45
52
|
```
|
46
53
|
|
47
54
|
## Resources
|
55
|
+
|
48
56
|
### Authentication
|
57
|
+
|
49
58
|
```ruby
|
50
59
|
# setup configuration
|
51
60
|
#
|
52
61
|
client.login
|
53
62
|
```
|
54
|
-
|Resource|API endpoint|Description|
|
55
|
-
|:--|:--|:--|
|
56
|
-
|.auth_token or .login|https://apis.skykick.com/auth/token|
|
57
63
|
|
64
|
+
|Resource|API endpoint|
|
65
|
+
|:--|:--|
|
66
|
+
|.auth_token or .login|https://apis.skykick.com/auth/token|
|
58
67
|
|
59
68
|
### Backup
|
60
|
-
|
69
|
+
|
70
|
+
Endpoint for backup related requests
|
71
|
+
|
61
72
|
```ruby
|
62
73
|
subscriptions = client.subscriptions
|
63
74
|
```
|
@@ -77,9 +88,10 @@ subscriptions = client.subscriptions
|
|
77
88
|
|subscriptions |https://apis.skykick.com/Backup/ |
|
78
89
|
|partner_subscriptions(partner_id)|https://apis.skykick.com/Backup/{partner_id} |
|
79
90
|
|
80
|
-
|
81
91
|
### Alerts
|
92
|
+
|
82
93
|
Returns Alerts for a provided Email Migration Order ID or Backup service ID.
|
94
|
+
|
83
95
|
```ruby
|
84
96
|
subscriptions = client.subscriptions
|
85
97
|
alerts = client.alerts(subscriptions.first.id)
|
@@ -92,7 +104,7 @@ alerts = client.alerts(subscriptions.first.id)
|
|
92
104
|
|
93
105
|
## Contributing
|
94
106
|
|
95
|
-
Bug reports and pull requests are welcome on GitHub
|
107
|
+
Bug reports and pull requests are welcome on [GitHub](https://github.com/jancotanis/skykick).
|
96
108
|
|
97
109
|
## License
|
98
110
|
|
data/lib/skykick/api.rb
CHANGED
@@ -1,29 +1,55 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'wrapi'
|
2
4
|
require File.expand_path('connection', __dir__)
|
3
5
|
require File.expand_path('authentication', __dir__)
|
4
6
|
|
5
7
|
module Skykick
|
6
|
-
#
|
8
|
+
# The `Skykick::API` class manages the core configuration and settings for the API client.
|
9
|
+
# It allows customization of options like endpoint, user agent, and pagination handling.
|
10
|
+
# This class copies configuration settings from the Skykick singleton and provides methods to retrieve the client configuration.
|
7
11
|
class API
|
8
|
-
#
|
9
|
-
attr_accessor
|
12
|
+
# Dynamically create accessor methods for all valid configuration keys.
|
13
|
+
attr_accessor(*WrAPI::Configuration::VALID_OPTIONS_KEYS)
|
10
14
|
|
11
|
-
#
|
15
|
+
# Initializes a new `Skykick::API` instance with the given options.
|
16
|
+
# The options are merged with the global Skykick settings to allow both global and per-instance customization.
|
17
|
+
#
|
18
|
+
# @param options [Hash] A hash of configuration options.
|
19
|
+
# These options can override the global Skykick configuration.
|
20
|
+
#
|
21
|
+
# @example Create a new API instance with custom options:
|
22
|
+
# api = Skykick::API.new(endpoint: "https://custom-api.endpoint.com", user_agent: "MyApp UA/1.0")
|
23
|
+
#
|
24
|
+
# @return [Skykick::API] A new instance of the Skykick API with the specified options.
|
12
25
|
def initialize(options = {})
|
26
|
+
# Merge the provided options with the global Skykick configuration.
|
13
27
|
options = Skykick.options.merge(options)
|
28
|
+
|
29
|
+
# Set each configuration key dynamically using the merged options.
|
14
30
|
WrAPI::Configuration::VALID_OPTIONS_KEYS.each do |key|
|
15
31
|
send("#{key}=", options[key])
|
16
32
|
end
|
17
33
|
end
|
18
34
|
|
35
|
+
# Retrieves the current API configuration as a hash.
|
36
|
+
#
|
37
|
+
# @return [Hash] A hash containing the current configuration settings.
|
38
|
+
# The keys in the hash are the same as `VALID_OPTIONS_KEYS`.
|
39
|
+
#
|
40
|
+
# @example Retrieve the current API configuration:
|
41
|
+
# api = Skykick::API.new
|
42
|
+
# api.config # => { :endpoint => "https://apis.skykick.com", :user_agent => "Skykick API/1.0", ... }
|
19
43
|
def config
|
20
44
|
conf = {}
|
45
|
+
# Iterate over each valid configuration key and retrieve its current value.
|
21
46
|
WrAPI::Configuration::VALID_OPTIONS_KEYS.each do |key|
|
22
47
|
conf[key] = send key
|
23
48
|
end
|
24
49
|
conf
|
25
50
|
end
|
26
51
|
|
52
|
+
# Include core modules for API functionality, including HTTP connections, request handling, and authentication.
|
27
53
|
include Connection
|
28
54
|
include WrAPI::Request
|
29
55
|
include WrAPI::Authentication
|
@@ -1,31 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require File.expand_path('error', __dir__)
|
2
4
|
require 'uri'
|
3
5
|
|
4
6
|
module Skykick
|
5
|
-
#
|
7
|
+
# The `Skykick::Authentication` module handles the authentication flow for the Skykick API.
|
8
|
+
# It manages access tokens and stores them in the global configuration.
|
9
|
+
# This module provides methods to log in to the Skykick portal using client credentials.
|
10
|
+
#
|
11
|
+
# @see https://developers.skykick.com/Guides/Authentication
|
6
12
|
module Authentication
|
7
|
-
#
|
8
|
-
#
|
9
|
-
|
13
|
+
# Authenticates with the Skykick API and retrieves an access token.
|
14
|
+
#
|
15
|
+
# This method performs a client credentials flow to authenticate with the Skykick API.
|
16
|
+
# The access token is stored in the global configuration for subsequent API calls.
|
17
|
+
#
|
18
|
+
# @param _options [Hash] Options for the authentication request (currently unused).
|
19
|
+
# @return [String] The access token for authenticated API requests.
|
20
|
+
#
|
21
|
+
# @raise [ConfigurationError] If `client_id` or `client_secret` is not configured.
|
22
|
+
# @raise [AuthenticationError] If the authentication fails due to invalid credentials or other issues.
|
23
|
+
#
|
24
|
+
# @example Authenticate and retrieve an access token:
|
25
|
+
# token = Skykick::Authentication.auth_token
|
26
|
+
def auth_token(_options = {})
|
10
27
|
raise ConfigurationError.new 'Client id and/or secret not configured' unless client_id && client_secret
|
11
28
|
|
12
|
-
|
13
|
-
|
14
|
-
response =
|
29
|
+
con = connection
|
30
|
+
con.request :authorization, :basic, client_id, client_secret
|
31
|
+
response = con.post('/auth/token') do |request|
|
15
32
|
request.headers['Content-Type'] = 'application/x-www-form-urlencoded'
|
16
|
-
request.body = URI.encode_www_form(
|
33
|
+
request.body = URI.encode_www_form(api_access_token_params)
|
17
34
|
end
|
18
35
|
|
19
36
|
api_process_token(response.body)
|
20
37
|
|
21
38
|
self.access_token
|
22
39
|
rescue Faraday::ForbiddenError => e
|
23
|
-
raise AuthenticationError.new
|
40
|
+
raise AuthenticationError.new "Unauthorized; response #{e}"
|
24
41
|
end
|
25
42
|
alias login auth_token
|
26
43
|
|
27
|
-
|
44
|
+
private
|
28
45
|
|
46
|
+
# Prepares the parameters required for the authentication request.
|
47
|
+
#
|
48
|
+
# @return [Hash] The parameters for the API access token request.
|
29
49
|
def api_access_token_params
|
30
50
|
{
|
31
51
|
grant_type: 'client_credentials',
|
@@ -33,13 +53,22 @@ module Skykick
|
|
33
53
|
}
|
34
54
|
end
|
35
55
|
|
56
|
+
# Processes the response from the Skykick API and extracts authentication details.
|
57
|
+
#
|
58
|
+
# @param response [Hash] The parsed response body from the API.
|
59
|
+
#
|
60
|
+
# @return [void]
|
61
|
+
#
|
62
|
+
# @raise [AuthorizationError] If the response does not include a valid `access_token`.
|
36
63
|
def api_process_token(response)
|
37
64
|
self.access_token = response['access_token']
|
38
65
|
self.token_type = response['token_type']
|
39
66
|
self.refresh_token = response['refresh_token']
|
40
67
|
self.token_expires = response['expires_in']
|
41
68
|
|
42
|
-
|
69
|
+
if self.access_token.nil? || self.access_token.empty?
|
70
|
+
raise AuthorizationError.new "Could not find valid access_token; response #{response}"
|
71
|
+
end
|
43
72
|
end
|
44
73
|
end
|
45
74
|
end
|
data/lib/skykick/client.rb
CHANGED
@@ -1,11 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Skykick
|
2
|
-
#
|
4
|
+
# The `Skykick::Client` class acts as a wrapper for the Skykick REST API.
|
5
|
+
# This class inherits from the `Skykick::API` class and includes modules that group
|
6
|
+
# the API methods according to the structure in the Skykick API documentation.
|
3
7
|
#
|
4
|
-
# @note All methods
|
8
|
+
# @note All methods are grouped in separate modules for better organization and follow the structure provided in the official API documentation.
|
5
9
|
# @see https://developers.skykick.com/Guides/Authentication
|
6
10
|
class Client < API
|
11
|
+
# Dynamically require all files in the `client` directory.
|
12
|
+
# This will load additional API modules as separate files for better modularity and code organization.
|
7
13
|
Dir[File.expand_path('client/*.rb', __dir__)].each { |f| require f }
|
8
14
|
|
15
|
+
# Include API client modules for specific Skykick API functionalities.
|
16
|
+
# These modules provide methods for interacting with specific parts of the Skykick API,
|
17
|
+
# such as managing backups and handling alerts.
|
9
18
|
include Skykick::Client::Backup
|
10
19
|
include Skykick::Client::Alerts
|
11
20
|
end
|
data/lib/skykick/connection.rb
CHANGED
@@ -1,31 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'faraday'
|
2
4
|
|
3
5
|
module Skykick
|
4
|
-
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
# @private
|
6
|
+
# The `Skykick::Connection` module is responsible for establishing an API connection.
|
7
|
+
# It includes authorization and header setup and ensures that sensitive information
|
8
|
+
# (e.g., access tokens, client secrets, etc.) is filtered from logs for security purposes.
|
9
|
+
#
|
10
|
+
# @note This module is designed to extend and customize the `WrAPI::Connection` functionalities.
|
10
11
|
module Connection
|
11
12
|
include WrAPI::Connection
|
12
13
|
|
13
|
-
#
|
14
|
+
# Sets up API headers for the Skykick connection.
|
15
|
+
# If `client_secret` is present, it adds the `Ocp-Apim-Subscription-Key` header.
|
16
|
+
#
|
17
|
+
# @param connection [Faraday::Connection] The connection object used to configure headers.
|
18
|
+
# @return [void]
|
14
19
|
def setup_headers(connection)
|
15
20
|
connection.headers['Ocp-Apim-Subscription-Key'] = client_secret if client_secret
|
16
21
|
end
|
17
22
|
|
18
|
-
#
|
23
|
+
# Configures a logger with filters to redact sensitive data from logs.
|
24
|
+
# This method sets up a logger that captures and logs request headers and bodies while
|
25
|
+
# filtering sensitive information such as passwords, access tokens, and authorization headers.
|
26
|
+
#
|
27
|
+
# @param connection [Faraday::Connection] The connection object where the logger is applied.
|
28
|
+
# @param logger [Logger] The logger instance that records request and response information.
|
29
|
+
# @return [void]
|
19
30
|
def setup_logger_filtering(connection, logger)
|
20
31
|
connection.response :logger, logger, { headers: true, bodies: true } do |l|
|
21
|
-
#
|
32
|
+
# Filter sensitive data from JSON content
|
22
33
|
l.filter(/("password":")(.+?)(".*)/, '\1[REMOVED]\3')
|
23
34
|
l.filter(/("accessToken":")(.+?)(".*)/, '\1[REMOVED]\3')
|
24
|
-
|
35
|
+
|
36
|
+
# Filter sensitive data from request headers
|
25
37
|
l.filter(/(client-secret:.)([^&]+)/, '\1[REMOVED]')
|
26
38
|
l.filter(/(Authorization:.)([^&]+)/, '\1[REMOVED]')
|
27
|
-
|
28
|
-
|
39
|
+
|
40
|
+
# Filter Skykick-specific sensitive header and token information
|
41
|
+
l.filter(/(Ocp-Apim-Subscription-Key: ")(.+?)(")/, '\1[REMOVED]\3')
|
29
42
|
l.filter(/("access_token":")(.+?)(".*)/, '\1[REMOVED]\3')
|
30
43
|
end
|
31
44
|
end
|
data/lib/skykick/error.rb
CHANGED
@@ -1,11 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Skykick
|
2
|
-
|
3
|
-
#
|
4
|
+
# Base error class for all exceptions raised by the Skykick API.
|
5
|
+
# This allows rescuing all Skykick-related errors in a single block if desired.
|
6
|
+
# Example:
|
7
|
+
# begin
|
8
|
+
# # Code that interacts with the Skykick API
|
9
|
+
# rescue Skykick::SkykickError => e
|
10
|
+
# puts "An error occurred: #{e.message}"
|
11
|
+
# end
|
4
12
|
class SkykickError < StandardError; end
|
5
13
|
|
6
|
-
#
|
14
|
+
# Raised when the Skykick API configuration is incomplete or incorrect.
|
15
|
+
# This might occur if required configuration options such as `client_id`, `client_secret`,
|
16
|
+
# or `endpoint` are missing or improperly set.
|
17
|
+
#
|
18
|
+
# Example:
|
19
|
+
# raise Skykick::ConfigurationError, "Client ID and secret must be configured"
|
7
20
|
class ConfigurationError < SkykickError; end
|
8
21
|
|
9
|
-
#
|
22
|
+
# Raised when authentication to the Skykick API fails.
|
23
|
+
# This might be due to incorrect credentials, an expired token, or insufficient permissions.
|
24
|
+
#
|
25
|
+
# Example:
|
26
|
+
# raise Skykick::AuthenticationError, "Invalid client credentials"
|
27
|
+
#
|
28
|
+
# @see https://developers.skykick.com/Guides/Authentication
|
10
29
|
class AuthenticationError < SkykickError; end
|
11
|
-
end
|
30
|
+
end
|
data/lib/skykick/pagination.rb
CHANGED
@@ -1,43 +1,79 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'uri'
|
2
4
|
require 'json'
|
3
5
|
|
4
6
|
module Skykick
|
5
|
-
# Defines HTTP request methods
|
6
|
-
# required
|
7
|
+
# Defines HTTP request pagination methods for Skykick's API.
|
8
|
+
# This module handles the pagination strategy required when dealing with paginated
|
9
|
+
# API results. Skykick uses OData pagination, which supports parameters like `$top` but not `$skip`.
|
10
|
+
#
|
11
|
+
# Note: Using `$skip` in requests results in an error:
|
12
|
+
# "The query specified in the URI is not valid. Query option 'Skip' is not allowed.
|
13
|
+
# To allow it, set the 'AllowedQueryOptions' property on EnableQueryAttribute or QueryValidationSettings."
|
7
14
|
module RequestPagination
|
8
|
-
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
15
|
+
# Handles OData pagination.
|
16
|
+
# This class maintains pagination state, including the offset, limit (page size), and total results.
|
17
|
+
# Since skipping pages isn't allowed by Skykick, the pagination assumes a simplified logic with a single page.
|
18
|
+
#
|
19
|
+
# @example Pagination Initialization
|
20
|
+
# paginator = Skykick::RequestPagination::ODataPagination.new(100)
|
21
|
+
# options = paginator.page_options
|
22
|
+
#
|
23
|
+
# @see https://docs.oasis-open.org/odata/odata/v4.0/os/abnf/odata-abnf-construction-rules.html OData Query Parameters
|
13
24
|
class ODataPagination
|
14
25
|
attr_reader :offset, :limit, :total
|
26
|
+
|
27
|
+
# Initializes the pagination object with the specified page size.
|
28
|
+
# Assumes that pagination starts at the first page (offset 0).
|
29
|
+
#
|
30
|
+
# @param page_size [Integer] Number of results per page
|
15
31
|
def initialize(page_size)
|
16
32
|
@offset = 0
|
17
33
|
@limit = page_size
|
18
|
-
# we
|
34
|
+
# Assume we have at least one page initially
|
19
35
|
@total = @limit
|
20
36
|
end
|
37
|
+
|
38
|
+
# Returns the pagination options to be sent as query parameters.
|
39
|
+
# Due to Skykick's limitation, only the `$top` parameter is included.
|
40
|
+
#
|
41
|
+
# @return [Hash<Symbol, Integer>] Query parameters for pagination
|
21
42
|
def page_options
|
22
|
-
{ '$top': @limit, '$skip': @offset }
|
23
43
|
{ '$top': @limit }
|
24
44
|
end
|
45
|
+
|
46
|
+
# Updates the pagination state for the next page based on the current page's data.
|
47
|
+
# Skykick's API does not allow skipping, so the offset and total are adjusted
|
48
|
+
# based on the size of the current data.
|
49
|
+
#
|
50
|
+
# @param data [Array] The data array from the current page
|
25
51
|
def next_page!(data)
|
26
|
-
#
|
52
|
+
# Update the total number of results based on the size of the current data set.
|
27
53
|
if data.count
|
28
54
|
@total = data.count
|
29
55
|
else
|
30
|
-
@total = 1
|
56
|
+
@total = 1
|
31
57
|
end
|
32
58
|
@offset += @limit
|
33
59
|
end
|
34
60
|
|
35
|
-
|
61
|
+
# Processes the API response body and returns it unchanged.
|
62
|
+
# This method can be overridden to handle specific response parsing needs.
|
63
|
+
#
|
64
|
+
# @param body [Hash, Array, String] The response body from the API
|
65
|
+
# @return [Hash, Array, String] Processed data (unchanged)
|
66
|
+
def self.data(body)
|
36
67
|
body
|
37
68
|
end
|
38
|
-
|
69
|
+
|
70
|
+
# Checks if more pages are available.
|
71
|
+
# Since Skykick's API supports only a single page (no `$skip`), this method
|
72
|
+
# returns `true` only if the offset is at its initial value (indicating the first page).
|
73
|
+
#
|
74
|
+
# @return [Boolean] `true` if more pages are available, `false` otherwise
|
39
75
|
def more_pages?
|
40
|
-
@offset
|
76
|
+
@offset.zero?
|
41
77
|
end
|
42
78
|
end
|
43
79
|
end
|
data/lib/skykick/version.rb
CHANGED
data/lib/skykick.rb
CHANGED
@@ -1,19 +1,41 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'wrapi'
|
2
4
|
require File.expand_path('skykick/api', __dir__)
|
3
5
|
require File.expand_path('skykick/client', __dir__)
|
4
6
|
require File.expand_path('skykick/pagination', __dir__)
|
5
7
|
require File.expand_path('skykick/version', __dir__)
|
6
8
|
|
9
|
+
# The `Skykick` module is a wrapper around Skykick's API.
|
10
|
+
# It provides a client configuration, including default settings like endpoint URL, user agent,
|
11
|
+
# and pagination handling. This module extends `WrAPI::Configuration` to provide configuration
|
12
|
+
# options and `WrAPI::RespondTo` for dynamic response handling.
|
7
13
|
module Skykick
|
8
14
|
extend WrAPI::Configuration
|
9
15
|
extend WrAPI::RespondTo
|
10
16
|
|
11
|
-
|
12
|
-
|
17
|
+
# Default API endpoint for the Skykick service.
|
18
|
+
DEFAULT_ENDPOINT = 'https://apis.skykick.com'
|
19
|
+
|
20
|
+
# Default User-Agent header sent with API requests, including gem version information.
|
21
|
+
DEFAULT_UA = "Skykick Ruby API wrapper #{Skykick::VERSION}"
|
22
|
+
|
23
|
+
# Default pagination class used for handling paginated API responses.
|
13
24
|
DEFAULT_PAGINATION = Skykick::RequestPagination::ODataPagination
|
14
25
|
|
26
|
+
# Creates and returns a new Skykick API client with the given options.
|
27
|
+
#
|
28
|
+
# @param options [Hash] A hash of configuration options to initialize the client.
|
29
|
+
# This method merges the provided options with default values such as endpoint, user agent, and pagination class.
|
15
30
|
#
|
16
|
-
# @
|
31
|
+
# @option options [String] :endpoint The base URL for the Skykick API (default: `DEFAULT_ENDPOINT`).
|
32
|
+
# @option options [String] :user_agent The User-Agent header to send with each API request (default: `DEFAULT_UA`).
|
33
|
+
# @option options [Class] :pagination_class The pagination class to handle paginated responses (default: `DEFAULT_PAGINATION`).
|
34
|
+
#
|
35
|
+
# @return [Skykick::Client] A new instance of the Skykick API client.
|
36
|
+
#
|
37
|
+
# @example Create a Skykick client:
|
38
|
+
# client = Skykick.client(endpoint: "https://api.custom-endpoint.com", user_agent: "Custom UA/1.0")
|
17
39
|
def self.client(options = {})
|
18
40
|
Skykick::Client.new({
|
19
41
|
endpoint: DEFAULT_ENDPOINT,
|
@@ -22,6 +44,15 @@ module Skykick
|
|
22
44
|
}.merge(options))
|
23
45
|
end
|
24
46
|
|
47
|
+
# Resets the Skykick configuration to default values.
|
48
|
+
#
|
49
|
+
# This method resets the configuration values to their defaults:
|
50
|
+
# - `DEFAULT_ENDPOINT` for the API endpoint
|
51
|
+
# - `DEFAULT_UA` for the User-Agent
|
52
|
+
# - `DEFAULT_PAGINATION` for the pagination handling class
|
53
|
+
#
|
54
|
+
# @example Reset the Skykick configuration:
|
55
|
+
# Skykick.reset
|
25
56
|
def self.reset
|
26
57
|
super
|
27
58
|
self.endpoint = DEFAULT_ENDPOINT
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: skykick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Janco Tanis
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-03-21 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: faraday
|
@@ -94,7 +93,6 @@ dependencies:
|
|
94
93
|
- - ">="
|
95
94
|
- !ruby/object:Gem::Version
|
96
95
|
version: '0'
|
97
|
-
description:
|
98
96
|
email: gems@jancology.com
|
99
97
|
executables: []
|
100
98
|
extensions: []
|
@@ -124,7 +122,6 @@ licenses:
|
|
124
122
|
metadata:
|
125
123
|
homepage_uri: https://rubygems.org/gems/skykick
|
126
124
|
source_code_uri: https://github.com/jancotanis/skykick
|
127
|
-
post_install_message:
|
128
125
|
rdoc_options: []
|
129
126
|
require_paths:
|
130
127
|
- lib
|
@@ -139,8 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
136
|
- !ruby/object:Gem::Version
|
140
137
|
version: '0'
|
141
138
|
requirements: []
|
142
|
-
rubygems_version: 3.2
|
143
|
-
signing_key:
|
139
|
+
rubygems_version: 3.6.2
|
144
140
|
specification_version: 4
|
145
141
|
summary: A Ruby wrapper for the Skykick backup Portal REST APIs (readonly)
|
146
142
|
test_files: []
|