eskomsepush_ruby 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +13 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +10 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +68 -0
- data/LICENSE.txt +21 -0
- data/README.md +74 -0
- data/Rakefile +12 -0
- data/lib/eskomsepush/client.rb +165 -0
- data/lib/eskomsepush/exception.rb +73 -0
- data/lib/eskomsepush/version.rb +6 -0
- data/lib/eskomsepush_ruby.rb +19 -0
- data/sig/eskomsepush.rbs +4 -0
- metadata +76 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2f1266710ca4484bed1a1be1995ac817892e94a4f1d079981176100b7841b650
|
4
|
+
data.tar.gz: ce9a6fdf5cefa43d87bceb864f36b79c4e8ab6e9e9e3dee1b13c629018bd3236
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5e99613d71c9d0d2ef40ae3940e1335af7668aeadda4d79388e9f86f36ce3051a3995eac1cbf8d4c6e836b692a0db40b19f83da4cc10b43927bf51169e848939
|
7
|
+
data.tar.gz: 68edc0cd79cf9e61cffeb8e9dc5d97c0ebcc02ac75c228c494e792d09f0c3306fec9104ece85ae8fa8cf104ff93907da8c3550e2f195613427c79c32c0d4a0db
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.1.3
|
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at christiaannel9@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
eskomsepush_ruby (0.1.3)
|
5
|
+
faraday (~> 2.7.7)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
ast (2.4.2)
|
11
|
+
diff-lcs (1.5.0)
|
12
|
+
faraday (2.7.10)
|
13
|
+
faraday-net_http (>= 2.0, < 3.1)
|
14
|
+
ruby2_keywords (>= 0.0.4)
|
15
|
+
faraday-net_http (3.0.2)
|
16
|
+
json (2.6.3)
|
17
|
+
parallel (1.23.0)
|
18
|
+
parser (3.2.2.3)
|
19
|
+
ast (~> 2.4.1)
|
20
|
+
racc
|
21
|
+
racc (1.7.1)
|
22
|
+
rainbow (3.1.1)
|
23
|
+
rake (13.0.6)
|
24
|
+
regexp_parser (2.8.1)
|
25
|
+
rexml (3.2.5)
|
26
|
+
rspec (3.12.0)
|
27
|
+
rspec-core (~> 3.12.0)
|
28
|
+
rspec-expectations (~> 3.12.0)
|
29
|
+
rspec-mocks (~> 3.12.0)
|
30
|
+
rspec-core (3.12.2)
|
31
|
+
rspec-support (~> 3.12.0)
|
32
|
+
rspec-expectations (3.12.3)
|
33
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
34
|
+
rspec-support (~> 3.12.0)
|
35
|
+
rspec-mocks (3.12.5)
|
36
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
37
|
+
rspec-support (~> 3.12.0)
|
38
|
+
rspec-support (3.12.0)
|
39
|
+
rubocop (1.52.1)
|
40
|
+
json (~> 2.3)
|
41
|
+
parallel (~> 1.10)
|
42
|
+
parser (>= 3.2.2.3)
|
43
|
+
rainbow (>= 2.2.2, < 4.0)
|
44
|
+
regexp_parser (>= 1.8, < 3.0)
|
45
|
+
rexml (>= 3.2.5, < 4.0)
|
46
|
+
rubocop-ast (>= 1.28.0, < 2.0)
|
47
|
+
ruby-progressbar (~> 1.7)
|
48
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
49
|
+
rubocop-ast (1.29.0)
|
50
|
+
parser (>= 3.2.1.0)
|
51
|
+
ruby-progressbar (1.13.0)
|
52
|
+
ruby2_keywords (0.0.5)
|
53
|
+
unicode-display_width (2.4.2)
|
54
|
+
yard (0.9.34)
|
55
|
+
|
56
|
+
PLATFORMS
|
57
|
+
arm64-darwin-22
|
58
|
+
x86_64-linux
|
59
|
+
|
60
|
+
DEPENDENCIES
|
61
|
+
eskomsepush_ruby!
|
62
|
+
rake (~> 13.0)
|
63
|
+
rspec (~> 3.0)
|
64
|
+
rubocop (~> 1.21)
|
65
|
+
yard (~> 0.9)
|
66
|
+
|
67
|
+
BUNDLED WITH
|
68
|
+
2.3.26
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2023 stiaannel
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# eskomsepush_ruby API Wrapper
|
2
|
+
|
3
|
+
A Ruby wrapper for the EskomSePush API V2. This gem provides a simple and intuitive interface to interact with the EskomSePush services.
|
4
|
+
|
5
|
+
## Important Notice
|
6
|
+
|
7
|
+
Users of this library are bound by the terms in the EskomSePush's license agreement. Please review their [terms of service](https://sepush.co.za/license-agreement) before using this gem.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'eskom_se_push_ruby'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
```bash
|
20
|
+
$ bundle install
|
21
|
+
```
|
22
|
+
|
23
|
+
Or install it yourself as:
|
24
|
+
|
25
|
+
```bash
|
26
|
+
$ gem install eskom_se_push_ruby
|
27
|
+
```
|
28
|
+
|
29
|
+
## Usage
|
30
|
+
|
31
|
+
### Configuration
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
esp = EskomSePush.client('your-api-key')
|
35
|
+
```
|
36
|
+
|
37
|
+
### Examples
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
# Example of checking your quota
|
41
|
+
quota = esp.quota.allowance
|
42
|
+
puts quota
|
43
|
+
|
44
|
+
area_schedule = esp.area_information('area_id')
|
45
|
+
puts area_schedule
|
46
|
+
```
|
47
|
+
|
48
|
+
### Error Handling
|
49
|
+
|
50
|
+
This gem will raise specific errors for different API responses:
|
51
|
+
|
52
|
+
- `YourGemName::BadRequestError` - HTTP 400
|
53
|
+
- `YourGemName::AuthenticationError` - HTTP 403
|
54
|
+
- `YourGemName::NotFoundError` - HTTP 404
|
55
|
+
- `YourGemName::RequestTimeoutError` - HTTP 408
|
56
|
+
- `YourGemName::RateLimitError` - HTTP 429
|
57
|
+
- `YourGemName::ServerError` - HTTP 500-599
|
58
|
+
- `YourGemName::UnexpectedError` - Other errors
|
59
|
+
|
60
|
+
## Development
|
61
|
+
|
62
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
63
|
+
|
64
|
+
## Contributing
|
65
|
+
|
66
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/stiaannel/eskomsepush_ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](CODE_OF_CONDUCT.md).
|
67
|
+
|
68
|
+
## License
|
69
|
+
|
70
|
+
The gem is available as open source under the terms of the [MIT License](LICENSE.txt).
|
71
|
+
|
72
|
+
## Code of Conduct
|
73
|
+
|
74
|
+
Everyone interacting in this project's codebase, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
# Includes
|
2
|
+
require "faraday"
|
3
|
+
require "uri"
|
4
|
+
require "date"
|
5
|
+
require "time"
|
6
|
+
require "json"
|
7
|
+
require "ostruct"
|
8
|
+
|
9
|
+
# Error classes
|
10
|
+
require_relative "exception"
|
11
|
+
|
12
|
+
# Returns a new instance of API
|
13
|
+
#
|
14
|
+
# == Parameters:
|
15
|
+
# token::
|
16
|
+
# Your API token
|
17
|
+
# options::
|
18
|
+
# A hash of options
|
19
|
+
#
|
20
|
+
# == Returns:
|
21
|
+
# A new instance of API
|
22
|
+
module EskomSePush
|
23
|
+
class Client
|
24
|
+
def initialize(token, options = {})
|
25
|
+
raise EskomSePushError::InvalidTokenError, "Invalid token" if token.nil?
|
26
|
+
|
27
|
+
@token = token
|
28
|
+
@options = options
|
29
|
+
@quota = {}
|
30
|
+
|
31
|
+
begin
|
32
|
+
@connection = Faraday.new("https://developer.sepush.co.za")
|
33
|
+
@connection.headers["token"] = @token
|
34
|
+
rescue Faraday::ConnectionFailed
|
35
|
+
raise EskomSePushError::UnexpectedError
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Method to get your remaining API Quota/Allowance
|
40
|
+
#
|
41
|
+
# == Parameters:
|
42
|
+
# None
|
43
|
+
#
|
44
|
+
# == Returns:
|
45
|
+
# OpenStruct object with the quota information
|
46
|
+
#
|
47
|
+
def check_allowance
|
48
|
+
response = @connection.get("/business/2.0/api_allowance")
|
49
|
+
handle_response(response)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Method to get the current status of the Eskom Loadshedding
|
53
|
+
#
|
54
|
+
# == Parameters:
|
55
|
+
# None
|
56
|
+
def status
|
57
|
+
response = @connection.get("/business/2.0/status")
|
58
|
+
handle_response(response)
|
59
|
+
end
|
60
|
+
|
61
|
+
# Search for the areaID of a specific area
|
62
|
+
#
|
63
|
+
# == Parameters:
|
64
|
+
# text::
|
65
|
+
# The name of the area you want to search for
|
66
|
+
#
|
67
|
+
# == Returns:
|
68
|
+
# Response object from handle_response
|
69
|
+
def areas_search(text = nil)
|
70
|
+
raise EskomSePushError::BadRequestError if text.nil?
|
71
|
+
|
72
|
+
response = @connection.get("/business/2.0/areas_search?text=#{text}")
|
73
|
+
puts response
|
74
|
+
handle_response(response)
|
75
|
+
end
|
76
|
+
|
77
|
+
# Get the area information for a specific area
|
78
|
+
#
|
79
|
+
# == Parameters:
|
80
|
+
# area_id::String
|
81
|
+
# The areaID of the area you want to get information for
|
82
|
+
# test::String
|
83
|
+
# Whether you would like to use test data or not, valid options
|
84
|
+
# are current and future
|
85
|
+
def area_information(area_id = nil, _test = nil)
|
86
|
+
raise EskomSePushError::BadRequestError if area_id.nil?
|
87
|
+
|
88
|
+
url = "/business/2.0/area?id=#{area_id}" + (_test.nil? ? "" : "&test=#{_test}")
|
89
|
+
response = @connection.get(url)
|
90
|
+
handle_response(response)
|
91
|
+
end
|
92
|
+
|
93
|
+
# Get a list of all nearby areas
|
94
|
+
#
|
95
|
+
# == Parameters:
|
96
|
+
# lat::String
|
97
|
+
# The latitude of the area you want to get nearby areas for
|
98
|
+
# long::String
|
99
|
+
# The longitude of the area you want to get nearby areas for
|
100
|
+
#
|
101
|
+
# == Returns:
|
102
|
+
# Response object from handle_response
|
103
|
+
def areas_nearby(lat = nil, long = nil)
|
104
|
+
raise EskomSePushError::BadRequestError if lat.nil? || long.nil?
|
105
|
+
|
106
|
+
response = @connection.get("/business/2.0/areas_nearby?lat=#{lat}&long=#{long}")
|
107
|
+
handle_response(response)
|
108
|
+
end
|
109
|
+
|
110
|
+
# Get a list of all nearby topics
|
111
|
+
#
|
112
|
+
# == Parameters:
|
113
|
+
# lat::String
|
114
|
+
# The latitude of the area you want to get nearby topics for
|
115
|
+
# long::String
|
116
|
+
# The longitude of the area you want to get nearby topics for
|
117
|
+
#
|
118
|
+
# == Returns:
|
119
|
+
# Response object from handle_response
|
120
|
+
def topics_nearby(lat = nil, long = nil)
|
121
|
+
raise EskomSePushError::BadRequestError if lat.nil? || long.nil?
|
122
|
+
|
123
|
+
response = @connection.get("/business/2.0/topics_nearby?lat=#{lat}&long=#{long}")
|
124
|
+
handle_response(response)
|
125
|
+
end
|
126
|
+
|
127
|
+
private
|
128
|
+
|
129
|
+
# Private Method to handle the responses from the API
|
130
|
+
#
|
131
|
+
# == Parameters:
|
132
|
+
# response::
|
133
|
+
# The response object from the API
|
134
|
+
#
|
135
|
+
# == Returns:
|
136
|
+
# Parsed response object. Will raise errors if the API returns an unsucessful response.
|
137
|
+
#
|
138
|
+
def handle_response(response)
|
139
|
+
return EskomSePushError::UnexpectedError if response.nil?
|
140
|
+
|
141
|
+
if response.status != 200 || response.body["error"]
|
142
|
+
case response.status
|
143
|
+
when 400
|
144
|
+
raise EskomSePushError::BadRequestError
|
145
|
+
when 403
|
146
|
+
raise EskomSePushError::AuthenticationError
|
147
|
+
when 404
|
148
|
+
raise EskomSePushError::NotFoundError
|
149
|
+
when 408
|
150
|
+
raise EskomSePushError::RequestTimeoutError
|
151
|
+
when 429
|
152
|
+
raise EskomSePushError::RateLimitError
|
153
|
+
when 500..599
|
154
|
+
raise EskomSePushError::ServerError
|
155
|
+
else
|
156
|
+
raise EskomSePushError::UnexpectedError
|
157
|
+
end
|
158
|
+
else
|
159
|
+
JSON.parse(response.body, object_class: OpenStruct)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
alias quota check_allowance
|
164
|
+
end
|
165
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EskomSePush
|
4
|
+
# EskomSePush Error Class, subclass from StandardError to host
|
5
|
+
# all the errors from the EskomSePush API
|
6
|
+
class EskomSePushError < StandardError
|
7
|
+
# Error class that will be raised when the auth token is invalid
|
8
|
+
class InvalidTokenError < EskomSePushError
|
9
|
+
def message
|
10
|
+
"The Auth Token you provided was invalid."
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# Error class that will be raised when the API returns a 429
|
15
|
+
# Implying that you have been rate limited, or you have exceeded
|
16
|
+
# your API quota/allowance
|
17
|
+
class RateLimitError < EskomSePushError
|
18
|
+
def message
|
19
|
+
"You have exceeded your API quota/allowance."
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# Error class that will be raised when the API returns a 400
|
24
|
+
# Implying that the request you sent was invalid
|
25
|
+
class BadRequestError < EskomSePushError
|
26
|
+
def message
|
27
|
+
"The request you sent was invalid."
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# Error class that will be raised when the API returns a 403
|
32
|
+
# Implying that the request you sent was not authenticated.
|
33
|
+
# Check your API token. And ensure it is valid during initialization.
|
34
|
+
class AuthenticationError < EskomSePushError
|
35
|
+
def message
|
36
|
+
"Authentication Error, check your credentials."
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Error class that will be raised when the API returns a 404
|
41
|
+
# Implying that the resource you requested was not found.
|
42
|
+
# Check the URL you are trying to access.
|
43
|
+
class NotFoundError < EskomSePushError
|
44
|
+
def message
|
45
|
+
"The resource you requested was not found."
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# Error class that will be raised when the API returns a 408
|
50
|
+
# Implying that the request you sent timed out.
|
51
|
+
class RequestTimeoutError < EskomSePushError
|
52
|
+
def message
|
53
|
+
"The request you sent timed out."
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# Error class that will be raised when the API returns a 5xx error
|
58
|
+
# Implying that the API returned a server error and you should try again later.
|
59
|
+
class ServerError < EskomSePushError
|
60
|
+
def message
|
61
|
+
"The SePush API returned a server error."
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# Error class that will be raised for unexpected errors
|
66
|
+
# Implying that something went wrong while parsing the response data.
|
67
|
+
class UnexpectedError < EskomSePushError
|
68
|
+
def message
|
69
|
+
"Something went wrong while parsing your response data."
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "eskomsepush/version"
|
4
|
+
require_relative "eskomsepush/client"
|
5
|
+
|
6
|
+
# EskomSePush API Wrapper Rubygem
|
7
|
+
#
|
8
|
+
# This is a Rubygem that wraps the EskomSePush API. It allows you to easily integrate the
|
9
|
+
# EskomSePush API into your Ruby applications.
|
10
|
+
#
|
11
|
+
# == Usage:
|
12
|
+
# require 'eskomsepush_ruby'
|
13
|
+
# esp = EskomSePush.client("{{token}}")
|
14
|
+
# esp.get_quota
|
15
|
+
module EskomSePush
|
16
|
+
def self.client(api_key)
|
17
|
+
Client.new(api_key)
|
18
|
+
end
|
19
|
+
end
|
data/sig/eskomsepush.rbs
ADDED
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: eskomsepush_ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- stiaannel
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-11-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.7.7
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.7.7
|
27
|
+
description: EskomSePush API Wrapper Rubygem
|
28
|
+
email:
|
29
|
+
- christiaannel9@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".rspec"
|
35
|
+
- ".rubocop.yml"
|
36
|
+
- ".ruby-version"
|
37
|
+
- CHANGELOG.md
|
38
|
+
- CODE_OF_CONDUCT.md
|
39
|
+
- Gemfile
|
40
|
+
- Gemfile.lock
|
41
|
+
- LICENSE.txt
|
42
|
+
- README.md
|
43
|
+
- Rakefile
|
44
|
+
- lib/eskomsepush/client.rb
|
45
|
+
- lib/eskomsepush/exception.rb
|
46
|
+
- lib/eskomsepush/version.rb
|
47
|
+
- lib/eskomsepush_ruby.rb
|
48
|
+
- sig/eskomsepush.rbs
|
49
|
+
homepage: https://github.com/stiaannel/eskomsepush_ruby
|
50
|
+
licenses:
|
51
|
+
- MIT
|
52
|
+
metadata:
|
53
|
+
homepage_uri: https://github.com/stiaannel/eskomsepush_ruby
|
54
|
+
source_code_uri: https://github.com/stiaannel/eskomsepush_ruby
|
55
|
+
changelog_uri: https://github.com/stiaannel/eskomsepush_ruby/blob/master/CHANGELOG.md
|
56
|
+
documentation_uri: https://stiaannel.co.za/eskomsepush_ruby/
|
57
|
+
post_install_message:
|
58
|
+
rdoc_options: []
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 2.6.0
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
requirements: []
|
72
|
+
rubygems_version: 3.3.26
|
73
|
+
signing_key:
|
74
|
+
specification_version: 4
|
75
|
+
summary: EskomSePush API Wrapper Rubygem
|
76
|
+
test_files: []
|