EskomSePush 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +69 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +109 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +21 -0
- data/README.md +68 -0
- data/Rakefile +10 -0
- data/bin/console +11 -0
- data/bin/setup +8 -0
- data/eskom_se_push.gemspec +38 -0
- data/lib/eskom_se_push/client.rb +142 -0
- data/lib/eskom_se_push/constants.rb +11 -0
- data/lib/eskom_se_push/version.rb +3 -0
- data/lib/eskom_se_push.rb +11 -0
- metadata +213 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f837ea468d05bc2d3e041d4fa0ad539491299b305b0c55d66565d5f3220e864e
|
4
|
+
data.tar.gz: 17859515a57ee59f75da694d1f1fcc965f99fb3d509b3b27eb566c1bc4a9230e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4bd48114aec74950b7be64322c85a737938823aa16ab803ff186e4dcd4b055edef930493a91ea5962a6198ca348b00429d7ae6d2511734844be14eb111cad13b
|
7
|
+
data.tar.gz: 5aa86b5b746f6159626559fe253794fc11d14e4e0ddc689d7edd0cf766fdf8a2c9e764207abb14eaa56c0de63e943e6b0a5b721fdc9fa27248f4666724999717
|
data/.gitignore
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
*.rbc
|
2
|
+
capybara-*.html
|
3
|
+
.rspec
|
4
|
+
/db/*.sqlite3
|
5
|
+
/db/*.sqlite3-journal
|
6
|
+
/db/*.sqlite3-[0-9]*
|
7
|
+
/public/system
|
8
|
+
/coverage/
|
9
|
+
/spec/tmp
|
10
|
+
*.orig
|
11
|
+
rerun.txt
|
12
|
+
pickle-email-*.html
|
13
|
+
|
14
|
+
# Ignore all logfiles and tempfiles.
|
15
|
+
/log/*
|
16
|
+
/tmp/*
|
17
|
+
!/log/.keep
|
18
|
+
!/tmp/.keep
|
19
|
+
|
20
|
+
# TODO Comment out this rule if you are OK with secrets being uploaded to the repo
|
21
|
+
config/initializers/secret_token.rb
|
22
|
+
config/master.key
|
23
|
+
|
24
|
+
# Only include if you have production secrets in this file, which is no longer a Rails default
|
25
|
+
# config/secrets.yml
|
26
|
+
|
27
|
+
# dotenv
|
28
|
+
# TODO Comment out this rule if environment variables can be committed
|
29
|
+
.env
|
30
|
+
|
31
|
+
## Environment normalization:
|
32
|
+
/.bundle
|
33
|
+
/vendor/bundle
|
34
|
+
|
35
|
+
# these should all be checked in to normalize the environment:
|
36
|
+
# Gemfile.lock, .ruby-version, .ruby-gemset
|
37
|
+
|
38
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
39
|
+
.rvmrc
|
40
|
+
|
41
|
+
# if using bower-rails ignore default bower_components path bower.json files
|
42
|
+
/vendor/assets/bower_components
|
43
|
+
*.bowerrc
|
44
|
+
bower.json
|
45
|
+
|
46
|
+
# Ignore pow environment settings
|
47
|
+
.powenv
|
48
|
+
|
49
|
+
# Ignore Byebug command history file.
|
50
|
+
.byebug_history
|
51
|
+
|
52
|
+
# Ignore node_modules
|
53
|
+
node_modules/
|
54
|
+
|
55
|
+
# Ignore precompiled javascript packs
|
56
|
+
/public/packs
|
57
|
+
/public/packs-test
|
58
|
+
/public/assets
|
59
|
+
|
60
|
+
# Ignore yarn files
|
61
|
+
/yarn-error.log
|
62
|
+
yarn-debug.log*
|
63
|
+
.yarn-integrity
|
64
|
+
|
65
|
+
# Ignore uploaded files in development
|
66
|
+
/storage/*
|
67
|
+
!/storage/.keep
|
68
|
+
|
69
|
+
*.gem
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at contact@jasonchalom.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
EskomSePush (0.0.1)
|
5
|
+
active_attr (~> 0.15.4)
|
6
|
+
httparty (~> 0.21.0)
|
7
|
+
nokogiri (~> 1.14.0.rc1)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
actionpack (7.0.4.3)
|
13
|
+
actionview (= 7.0.4.3)
|
14
|
+
activesupport (= 7.0.4.3)
|
15
|
+
rack (~> 2.0, >= 2.2.0)
|
16
|
+
rack-test (>= 0.6.3)
|
17
|
+
rails-dom-testing (~> 2.0)
|
18
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
19
|
+
actionview (7.0.4.3)
|
20
|
+
activesupport (= 7.0.4.3)
|
21
|
+
builder (~> 3.1)
|
22
|
+
erubi (~> 1.4)
|
23
|
+
rails-dom-testing (~> 2.0)
|
24
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
25
|
+
active_attr (0.15.4)
|
26
|
+
actionpack (>= 3.0.2, < 7.1)
|
27
|
+
activemodel (>= 3.0.2, < 7.1)
|
28
|
+
activesupport (>= 3.0.2, < 7.1)
|
29
|
+
activemodel (7.0.4.3)
|
30
|
+
activesupport (= 7.0.4.3)
|
31
|
+
activesupport (7.0.4.3)
|
32
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
33
|
+
i18n (>= 1.6, < 2)
|
34
|
+
minitest (>= 5.1)
|
35
|
+
tzinfo (~> 2.0)
|
36
|
+
addressable (2.8.1)
|
37
|
+
public_suffix (>= 2.0.2, < 6.0)
|
38
|
+
ansi (1.5.0)
|
39
|
+
builder (3.2.4)
|
40
|
+
coderay (1.1.3)
|
41
|
+
concurrent-ruby (1.2.2)
|
42
|
+
crack (0.4.5)
|
43
|
+
rexml
|
44
|
+
crass (1.0.6)
|
45
|
+
erubi (1.12.0)
|
46
|
+
hashdiff (1.0.1)
|
47
|
+
httparty (0.21.0)
|
48
|
+
mini_mime (>= 1.0.0)
|
49
|
+
multi_xml (>= 0.5.2)
|
50
|
+
i18n (1.12.0)
|
51
|
+
concurrent-ruby (~> 1.0)
|
52
|
+
loofah (2.19.1)
|
53
|
+
crass (~> 1.0.2)
|
54
|
+
nokogiri (>= 1.5.9)
|
55
|
+
method_source (1.0.0)
|
56
|
+
mini_mime (1.1.2)
|
57
|
+
minitest (5.15.0)
|
58
|
+
minitest-focus (1.3.1)
|
59
|
+
minitest (>= 4, < 6)
|
60
|
+
minitest-reporters (1.5.0)
|
61
|
+
ansi
|
62
|
+
builder
|
63
|
+
minitest (>= 5.0)
|
64
|
+
ruby-progressbar
|
65
|
+
mocha (1.13.0)
|
66
|
+
multi_xml (0.6.0)
|
67
|
+
nokogiri (1.14.2-arm64-darwin)
|
68
|
+
racc (~> 1.4)
|
69
|
+
pry (0.14.1)
|
70
|
+
coderay (~> 1.1)
|
71
|
+
method_source (~> 1.0)
|
72
|
+
public_suffix (5.0.1)
|
73
|
+
racc (1.6.2)
|
74
|
+
rack (2.2.6.4)
|
75
|
+
rack-test (2.1.0)
|
76
|
+
rack (>= 1.3)
|
77
|
+
rails-dom-testing (2.0.3)
|
78
|
+
activesupport (>= 4.2.0)
|
79
|
+
nokogiri (>= 1.6)
|
80
|
+
rails-html-sanitizer (1.5.0)
|
81
|
+
loofah (~> 2.19, >= 2.19.1)
|
82
|
+
rake (13.0.6)
|
83
|
+
rexml (3.2.5)
|
84
|
+
ruby-progressbar (1.11.0)
|
85
|
+
timecop (0.9.6)
|
86
|
+
tzinfo (2.0.6)
|
87
|
+
concurrent-ruby (~> 1.0)
|
88
|
+
webmock (3.14.0)
|
89
|
+
addressable (>= 2.8.0)
|
90
|
+
crack (>= 0.3.2)
|
91
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
92
|
+
|
93
|
+
PLATFORMS
|
94
|
+
arm64-darwin-20
|
95
|
+
arm64-darwin-22
|
96
|
+
|
97
|
+
DEPENDENCIES
|
98
|
+
EskomSePush!
|
99
|
+
minitest (~> 5.15.0)
|
100
|
+
minitest-focus (~> 1.3.1)
|
101
|
+
minitest-reporters (~> 1.5.0)
|
102
|
+
mocha (~> 1.13.0)
|
103
|
+
pry (~> 0.14.1)
|
104
|
+
rake (~> 13.0.6)
|
105
|
+
timecop (~> 0.9.1)
|
106
|
+
webmock (~> 3.14.0)
|
107
|
+
|
108
|
+
BUNDLED WITH
|
109
|
+
2.3.16
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2020 Jason Chalom
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 trex22
|
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,68 @@
|
|
1
|
+
# EskomSePush
|
2
|
+
A client for the EskomSePush API. See: https://documenter.getpostman.com/view/1296288/UzQuNk3E for documentation.
|
3
|
+
|
4
|
+
Visit https://eskomsepush.gumroad.com/l/api to get access to an API token.
|
5
|
+
|
6
|
+
This is an unofficial project and still a work in progress (WIP) ... more to come soon.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'eskom_se_push'
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install eskom_se_push
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
require 'eskom_se_push'
|
28
|
+
client = EskomSePush::Client.new(token: 'Your token here')
|
29
|
+
|
30
|
+
client.status
|
31
|
+
client.area_information(id: "eskde-10-fourwaysext10cityofjohannesburggauteng", test: "future")
|
32
|
+
client.areas_nearby(latitude: "-26.0269658", longitude: "28.0137339") # Can submit as a Float too
|
33
|
+
client.areas_search(text: "fourways")
|
34
|
+
client.topics_nearby(latitude: "-26.0269658", longitude: "28.0137339") # Can submit as a Float too
|
35
|
+
client.check_allowance
|
36
|
+
```
|
37
|
+
|
38
|
+
### Endpoints
|
39
|
+
- Status
|
40
|
+
- Area Information
|
41
|
+
- Areas Nearby (GPS)
|
42
|
+
- Areas Search (Text)
|
43
|
+
- Topics Nearby
|
44
|
+
- Check Allowance
|
45
|
+
- Constants
|
46
|
+
|
47
|
+
## Development
|
48
|
+
|
49
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
50
|
+
|
51
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
52
|
+
|
53
|
+
### Tests
|
54
|
+
To run tests execute:
|
55
|
+
|
56
|
+
$ rake test
|
57
|
+
|
58
|
+
## Contributing
|
59
|
+
|
60
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/trex22/EskomSePush. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
61
|
+
|
62
|
+
## License
|
63
|
+
|
64
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
65
|
+
|
66
|
+
## Code of Conduct
|
67
|
+
|
68
|
+
Everyone interacting in the EskomSePush: project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/trex22/EskomSePush/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "eskom_se_push"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
require "pry"
|
11
|
+
Pry.start
|
data/bin/setup
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "eskom_se_push/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "EskomSePush"
|
7
|
+
spec.version = EskomSePush::VERSION
|
8
|
+
spec.authors = ["trex22"]
|
9
|
+
spec.email = ["contact@jasonchalom.com"]
|
10
|
+
|
11
|
+
spec.summary = "A client for using the EskomSePush API in Ruby."
|
12
|
+
spec.description = "A client for using the EskomSePush API in Ruby. Built from their api documentation. This is an unofficial project."
|
13
|
+
spec.homepage = "https://github.com/TRex22/EskomSePush"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
# Specify which files should be added to the gem when it is released.
|
17
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
18
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
19
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
|
+
end
|
21
|
+
spec.bindir = "exe"
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
spec.add_dependency "httparty", "~> 0.21.0"
|
26
|
+
spec.add_dependency "active_attr", "~> 0.15.4"
|
27
|
+
spec.add_dependency "nokogiri", "~> 1.14.0.rc1"
|
28
|
+
|
29
|
+
# Development dependancies
|
30
|
+
spec.add_development_dependency "rake", "~> 13.0.6"
|
31
|
+
spec.add_development_dependency "minitest", "~> 5.15.0"
|
32
|
+
spec.add_development_dependency "minitest-focus", "~> 1.3.1"
|
33
|
+
spec.add_development_dependency "minitest-reporters", "~> 1.5.0"
|
34
|
+
spec.add_development_dependency "timecop", "~> 0.9.1"
|
35
|
+
spec.add_development_dependency "mocha", "~> 1.13.0"
|
36
|
+
spec.add_development_dependency "pry", "~> 0.14.1"
|
37
|
+
spec.add_development_dependency "webmock", "~> 3.14.0"
|
38
|
+
end
|
@@ -0,0 +1,142 @@
|
|
1
|
+
module EskomSePush
|
2
|
+
class Client
|
3
|
+
include ::EskomSePush::Constants
|
4
|
+
|
5
|
+
attr_reader :token, :base_path, :port
|
6
|
+
|
7
|
+
def initialize(token:, base_path: BASE_URI, port: BASE_PORT)
|
8
|
+
@token = token
|
9
|
+
@base_path = base_path
|
10
|
+
@port = port
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.compatible_api_version
|
14
|
+
'v2'
|
15
|
+
end
|
16
|
+
|
17
|
+
# This is the version of the API docs this client was built off-of
|
18
|
+
def self.api_version
|
19
|
+
'v2 2023-04-12'
|
20
|
+
end
|
21
|
+
|
22
|
+
def status
|
23
|
+
authorise_and_send(http_method: :get, path: 'status')
|
24
|
+
end
|
25
|
+
|
26
|
+
# test can be current or future to get back test data
|
27
|
+
def area_information(id:, test: nil)
|
28
|
+
params = { id: id }
|
29
|
+
params.merge!({ test: test }) if test
|
30
|
+
authorise_and_send(http_method: :get, path: 'area', params: params)
|
31
|
+
end
|
32
|
+
|
33
|
+
def areas_nearby(latitude:, longitude:)
|
34
|
+
params = { lat: latitude, lon: longitude }
|
35
|
+
authorise_and_send(http_method: :get, path: 'areas_nearby', params: params)
|
36
|
+
end
|
37
|
+
|
38
|
+
def areas_search(text:)
|
39
|
+
params = { text: text }
|
40
|
+
authorise_and_send(http_method: :get, path: 'areas_search', params: params)
|
41
|
+
end
|
42
|
+
|
43
|
+
def topics_nearby(latitude:, longitude:)
|
44
|
+
params = { lat: latitude, lon: longitude }
|
45
|
+
authorise_and_send(http_method: :get, path: 'topics_nearby', params: params)
|
46
|
+
end
|
47
|
+
|
48
|
+
def check_allowance
|
49
|
+
authorise_and_send(http_method: :get, path: 'api_allowance')
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def unauthorised_and_send(http_method:, path:, payload: {}, params: {})
|
55
|
+
start_time = get_micro_second_time
|
56
|
+
|
57
|
+
response = HTTParty.send(
|
58
|
+
http_method.to_sym,
|
59
|
+
construct_base_path(path, params),
|
60
|
+
body: payload,
|
61
|
+
headers: { 'Content-Type': 'application/json' },
|
62
|
+
port: port,
|
63
|
+
format: :json
|
64
|
+
)
|
65
|
+
|
66
|
+
end_time = get_micro_second_time
|
67
|
+
construct_response_object(response, path, start_time, end_time)
|
68
|
+
end
|
69
|
+
|
70
|
+
def authorise_and_send(http_method:, path:, payload: {}, params: {})
|
71
|
+
start_time = get_micro_second_time
|
72
|
+
|
73
|
+
response = HTTParty.send(
|
74
|
+
http_method.to_sym,
|
75
|
+
construct_base_path(path, params),
|
76
|
+
body: payload,
|
77
|
+
headers: { 'Content-Type': 'application/json', Token: token },
|
78
|
+
port: port,
|
79
|
+
format: :json
|
80
|
+
)
|
81
|
+
|
82
|
+
end_time = get_micro_second_time
|
83
|
+
construct_response_object(response, path, start_time, end_time)
|
84
|
+
end
|
85
|
+
|
86
|
+
def construct_response_object(response, path, start_time, end_time)
|
87
|
+
{
|
88
|
+
'body' => parse_body(response, path),
|
89
|
+
'headers' => response.headers,
|
90
|
+
'metadata' => construct_metadata(response, start_time, end_time)
|
91
|
+
}
|
92
|
+
end
|
93
|
+
|
94
|
+
def construct_metadata(response, start_time, end_time)
|
95
|
+
total_time = end_time - start_time
|
96
|
+
|
97
|
+
{
|
98
|
+
'start_time' => start_time,
|
99
|
+
'end_time' => end_time,
|
100
|
+
'total_time' => total_time
|
101
|
+
}
|
102
|
+
end
|
103
|
+
|
104
|
+
def body_is_present?(response)
|
105
|
+
!body_is_missing?(response)
|
106
|
+
end
|
107
|
+
|
108
|
+
def body_is_missing?(response)
|
109
|
+
response.body.nil? || response.body.empty?
|
110
|
+
end
|
111
|
+
|
112
|
+
def parse_body(response, path)
|
113
|
+
parsed_response = JSON.parse(response.body) # Purposely not using HTTParty
|
114
|
+
|
115
|
+
if parsed_response.dig(path.to_s)
|
116
|
+
parsed_response.dig(path.to_s)
|
117
|
+
else
|
118
|
+
parsed_response
|
119
|
+
end
|
120
|
+
rescue JSON::ParserError => _e
|
121
|
+
response.body
|
122
|
+
end
|
123
|
+
|
124
|
+
def get_micro_second_time
|
125
|
+
(Time.now.to_f * 1000000).to_i
|
126
|
+
end
|
127
|
+
|
128
|
+
def construct_base_path(path, params)
|
129
|
+
constructed_path = "#{base_path}/#{path}"
|
130
|
+
|
131
|
+
if params == {}
|
132
|
+
constructed_path
|
133
|
+
else
|
134
|
+
"#{constructed_path}?#{process_params(params)}"
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
def process_params(params)
|
139
|
+
params.keys.map { |key| "#{key}=#{params[key]}" }.join('&')
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
metadata
ADDED
@@ -0,0 +1,213 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: EskomSePush
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- trex22
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-04-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.21.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.21.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: active_attr
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.15.4
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.15.4
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: nokogiri
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.14.0.rc1
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.14.0.rc1
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 13.0.6
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 13.0.6
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: minitest
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 5.15.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 5.15.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: minitest-focus
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.3.1
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.3.1
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: minitest-reporters
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 1.5.0
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.5.0
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: timecop
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.9.1
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.9.1
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: mocha
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 1.13.0
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 1.13.0
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: pry
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 0.14.1
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 0.14.1
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: webmock
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 3.14.0
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 3.14.0
|
167
|
+
description: A client for using the EskomSePush API in Ruby. Built from their api
|
168
|
+
documentation. This is an unofficial project.
|
169
|
+
email:
|
170
|
+
- contact@jasonchalom.com
|
171
|
+
executables: []
|
172
|
+
extensions: []
|
173
|
+
extra_rdoc_files: []
|
174
|
+
files:
|
175
|
+
- ".gitignore"
|
176
|
+
- CODE_OF_CONDUCT.md
|
177
|
+
- Gemfile
|
178
|
+
- Gemfile.lock
|
179
|
+
- LICENSE
|
180
|
+
- LICENSE.txt
|
181
|
+
- README.md
|
182
|
+
- Rakefile
|
183
|
+
- bin/console
|
184
|
+
- bin/setup
|
185
|
+
- eskom_se_push.gemspec
|
186
|
+
- lib/eskom_se_push.rb
|
187
|
+
- lib/eskom_se_push/client.rb
|
188
|
+
- lib/eskom_se_push/constants.rb
|
189
|
+
- lib/eskom_se_push/version.rb
|
190
|
+
homepage: https://github.com/TRex22/EskomSePush
|
191
|
+
licenses:
|
192
|
+
- MIT
|
193
|
+
metadata: {}
|
194
|
+
post_install_message:
|
195
|
+
rdoc_options: []
|
196
|
+
require_paths:
|
197
|
+
- lib
|
198
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
199
|
+
requirements:
|
200
|
+
- - ">="
|
201
|
+
- !ruby/object:Gem::Version
|
202
|
+
version: '0'
|
203
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
204
|
+
requirements:
|
205
|
+
- - ">="
|
206
|
+
- !ruby/object:Gem::Version
|
207
|
+
version: '0'
|
208
|
+
requirements: []
|
209
|
+
rubygems_version: 3.3.4
|
210
|
+
signing_key:
|
211
|
+
specification_version: 4
|
212
|
+
summary: A client for using the EskomSePush API in Ruby.
|
213
|
+
test_files: []
|