africansms 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +38 -0
- data/LICENSE.txt +21 -0
- data/README.md +79 -0
- data/Rakefile +1 -0
- data/africansms.gemspec +20 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/africansms.rb +20 -0
- data/lib/africansms/client.rb +45 -0
- data/lib/africansms/configuration.rb +23 -0
- data/lib/africansms/version.rb +3 -0
- metadata +101 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 59a614038234ea1d68582630a7b3996a372e6bcfae5b62fe2915ce6ee89ff532
|
4
|
+
data.tar.gz: f1c2f065145ee580e4040d194c4ac8b9a4dee0013ce3fa5c3e77e8525b9ca0fc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 49d0ecc4955dbc39f032e3a2d2daea7f37080b6fdf45b01231336197b77e9a5817d363e5fc52b4893ce5a9113d514a68f2e3613d71ea2c782f8a836620e0258f
|
7
|
+
data.tar.gz: 0006f5775ffae2c6bf2cbd4607d755db2aea65b88fb668f2ad6090c66c173e0794df7c32b6bc58887fea0bcd6c73e875afd3fcd5379d815b335fc0320172ea92
|
data/.gitignore
ADDED
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 rtejra@gammastack.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 [https://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: https://contributor-covenant.org
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
africansms (0.1.0)
|
5
|
+
rest-client (~> 2.1)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
domain_name (0.5.20190701)
|
11
|
+
unf (>= 0.0.5, < 1.0.0)
|
12
|
+
http-accept (1.7.0)
|
13
|
+
http-cookie (1.0.4)
|
14
|
+
domain_name (~> 0.5)
|
15
|
+
mime-types (3.3.1)
|
16
|
+
mime-types-data (~> 3.2015)
|
17
|
+
mime-types-data (3.2021.0704)
|
18
|
+
netrc (0.11.0)
|
19
|
+
rake (13.0.6)
|
20
|
+
rest-client (2.1.0)
|
21
|
+
http-accept (>= 1.7.0, < 2.0)
|
22
|
+
http-cookie (>= 1.0.2, < 2.0)
|
23
|
+
mime-types (>= 1.16, < 4.0)
|
24
|
+
netrc (~> 0.8)
|
25
|
+
unf (0.1.4)
|
26
|
+
unf_ext
|
27
|
+
unf_ext (0.0.7.7)
|
28
|
+
|
29
|
+
PLATFORMS
|
30
|
+
x86_64-linux
|
31
|
+
|
32
|
+
DEPENDENCIES
|
33
|
+
africansms!
|
34
|
+
bundler (~> 2.2.23)
|
35
|
+
rake (~> 13.0)
|
36
|
+
|
37
|
+
BUNDLED WITH
|
38
|
+
2.2.23
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021 Rakesh Tejra
|
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,79 @@
|
|
1
|
+
# Africansms
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/africansms`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'africansms'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install africansms
|
22
|
+
|
23
|
+
### Overview
|
24
|
+
|
25
|
+
Africansms is a gem which is an integration of Africastalking SMS service. Before using the gem please take a look on Africastalking SMS service documentation "https://developers.africastalking.com/docs/sms/overview" to get the required configration credentials (api_key, username & shortcode)
|
26
|
+
|
27
|
+
### Configuration
|
28
|
+
|
29
|
+
Add below configuration in initializer
|
30
|
+
|
31
|
+
``` ruby
|
32
|
+
# config/initializers/africansms.rb
|
33
|
+
|
34
|
+
Africansms.configure do |config|
|
35
|
+
config.api_key = 'Africas talking API Key'
|
36
|
+
config.username = 'Africas talking username'
|
37
|
+
config.shortcode = 'Africas talking shortcode'
|
38
|
+
end
|
39
|
+
```
|
40
|
+
### Uses
|
41
|
+
|
42
|
+
##### Send message
|
43
|
+
|
44
|
+
Africansms provides an API send message (Africastalking integration) using which you can Send and receive SMS to more than 300 million mobile subscribers across Africa.
|
45
|
+
|
46
|
+
.
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
request_params = {
|
50
|
+
to: 'A comma separated string of recipients’ phone numbers (required)',
|
51
|
+
message: 'The message to be sent. (required)',
|
52
|
+
mode: 'live'
|
53
|
+
}
|
54
|
+
|
55
|
+
response = Africansms::Client.new(request_params).send_message
|
56
|
+
|
57
|
+
```
|
58
|
+
Note: By default mode is sandbox. 'live' should be given for live endpoint of Africas talking.
|
59
|
+
|
60
|
+
In response you will get a XML response in the case of success & error in the case of Failed.
|
61
|
+
|
62
|
+
## Development
|
63
|
+
|
64
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
65
|
+
|
66
|
+
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).
|
67
|
+
|
68
|
+
## Contributing
|
69
|
+
|
70
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/africansms. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/africansms/blob/master/CODE_OF_CONDUCT.md).
|
71
|
+
|
72
|
+
|
73
|
+
## License
|
74
|
+
|
75
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
76
|
+
|
77
|
+
## Code of Conduct
|
78
|
+
|
79
|
+
Everyone interacting in the Africansms project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/africansms/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'rake'
|
data/africansms.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'africansms/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'africansms'
|
7
|
+
spec.version = Africansms::VERSION
|
8
|
+
spec.authors = ['Ayush Agrawal']
|
9
|
+
spec.email = ['ayagrawal@grepruby.io']
|
10
|
+
spec.summary = 'AfricasTalking SMS service integration'
|
11
|
+
spec.description = 'Integration of Africastalking SMS service for sending SMS in African regions'
|
12
|
+
spec.homepage = 'https://github.com/ayushagrawal134/africansms'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
spec.required_ruby_version = '>= 2.3.0'
|
15
|
+
spec.files = `git ls-files`.split("\n")
|
16
|
+
|
17
|
+
spec.add_dependency 'rest-client', '~> 2.1'
|
18
|
+
spec.add_development_dependency 'bundler', '~> 2.2.23'
|
19
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
20
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "africansms"
|
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
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/africansms.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'africansms/configuration'
|
2
|
+
require 'africansms/client'
|
3
|
+
|
4
|
+
module Africansms
|
5
|
+
class AfricansmsError < StandardError; end
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def configure
|
9
|
+
yield configuration
|
10
|
+
end
|
11
|
+
|
12
|
+
def configuration
|
13
|
+
@configuration ||= Configuration.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def reset
|
17
|
+
@configuration = Configuration.new
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
|
3
|
+
module Africansms
|
4
|
+
class Client
|
5
|
+
attr_reader :params
|
6
|
+
|
7
|
+
def initialize(params)
|
8
|
+
@params = params
|
9
|
+
end
|
10
|
+
|
11
|
+
def send_message
|
12
|
+
raise(AfricansmsError, 'The message to send should not be empty') unless valid_message?
|
13
|
+
response = RestClient.post(base_url, request_params, request_header)
|
14
|
+
response.body
|
15
|
+
rescue StandardError => error
|
16
|
+
error
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def request_params
|
22
|
+
params.merge(
|
23
|
+
username: Africansms.configuration.username!,
|
24
|
+
shortcode: Africansms.configuration.shortcode!,
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
def request_header
|
29
|
+
{
|
30
|
+
content_type: 'application/x-www-form-urlencoded',
|
31
|
+
apiKey: Africansms.configuration.api_key!
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
def base_url
|
36
|
+
params.dig(:mode).eql?('live') ?
|
37
|
+
'https://api.africastalking.com/version1/messaging' :
|
38
|
+
'https://api.sandbox.africastalking.com/version1/messaging'
|
39
|
+
end
|
40
|
+
|
41
|
+
def valid_message?
|
42
|
+
params[:message] && !params[:message].empty?
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Africansms
|
2
|
+
class Configuration
|
3
|
+
attr_accessor :api_key, :username, :shortcode
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@api_key = nil
|
7
|
+
@username = nil
|
8
|
+
@shortcode = nil
|
9
|
+
end
|
10
|
+
|
11
|
+
def api_key!
|
12
|
+
api_key || raise(AfricansmsError, 'No api key specified.')
|
13
|
+
end
|
14
|
+
|
15
|
+
def username!
|
16
|
+
username || raise(AfricansmsError, 'No username specified.')
|
17
|
+
end
|
18
|
+
|
19
|
+
def shortcode!
|
20
|
+
shortcode || raise(AfricansmsError, 'No shortcode specified.')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: africansms
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.5
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ayush Agrawal
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-07-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.2.23
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.2.23
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '13.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '13.0'
|
55
|
+
description: Integration of Africastalking SMS service for sending SMS in African
|
56
|
+
regions
|
57
|
+
email:
|
58
|
+
- ayagrawal@grepruby.io
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- CODE_OF_CONDUCT.md
|
65
|
+
- Gemfile
|
66
|
+
- Gemfile.lock
|
67
|
+
- LICENSE.txt
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- africansms.gemspec
|
71
|
+
- bin/console
|
72
|
+
- bin/setup
|
73
|
+
- lib/africansms.rb
|
74
|
+
- lib/africansms/client.rb
|
75
|
+
- lib/africansms/configuration.rb
|
76
|
+
- lib/africansms/version.rb
|
77
|
+
homepage: https://github.com/ayushagrawal134/africansms
|
78
|
+
licenses:
|
79
|
+
- MIT
|
80
|
+
metadata: {}
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 2.3.0
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
requirements: []
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 2.7.7
|
98
|
+
signing_key:
|
99
|
+
specification_version: 4
|
100
|
+
summary: AfricasTalking SMS service integration
|
101
|
+
test_files: []
|