idi_sms 0.2.1
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 +7 -0
- data/README.md +67 -0
- data/Rakefile +4 -0
- data/idi_sms-0.0.1.gem +0 -0
- data/idi_sms-0.1.0.gem +0 -0
- data/idi_sms-0.2.0.gem +0 -0
- data/idi_sms.gemspec +42 -0
- data/lib/generators/idi_sms/config/config_generator.rb +14 -0
- data/lib/generators/idi_sms/config/templates/idi_sms.yml +7 -0
- data/lib/idi_sms/version.rb +5 -0
- data/lib/idi_sms.rb +53 -0
- data/sig/idi_sms.rbs +4 -0
- metadata +55 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 0b9ac811f9479457ec7a9863cb36ab9b5ef0def7a3342a92a57e0c4f761039d7
|
|
4
|
+
data.tar.gz: '0953700738f16a2db48266c782bf959afd1a0a212b636e0352a94020a3e8d1e8'
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 6c4be92901ad301b8fbfacddceabc04057cd090635cb872fda01003bc275c48058d04bc231f79d971dd6b77ee32e37e384b989a5bd0219e56c9d0b1c03df172f
|
|
7
|
+
data.tar.gz: d1b07ee85e568706994b04e34af7ed89a97132fc19bba9ca53bf71172dcceed72b502eef14352404026d6deb79622d98a2b9caaae6ffd1d4fd020918c1c8b07a
|
data/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# idi_sms Gem
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
The `idi_sms` gem is a Ruby library that simplifies the process of sending SMS messages using the 8070 short code SMS-Gateway API. This gem is specifically designed for integration with the PITB Dengue Tracking System, allowing you to send SMS messages efficiently and seamlessly.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
To use the `idi_sms` gem in your project, follow these steps:
|
|
10
|
+
|
|
11
|
+
1. Add the gem to your project's Gemfile:
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
gem 'idi_sms'
|
|
15
|
+
|
|
16
|
+
Run bundle install to install the gem and its dependencies.
|
|
17
|
+
|
|
18
|
+
2. Run Command to generate yml file for setting key:
|
|
19
|
+
|
|
20
|
+
```ruby
|
|
21
|
+
$ rails generate idi_sms:config
|
|
22
|
+
|
|
23
|
+
it will create a file on config/idi_sms.yml
|
|
24
|
+
|
|
25
|
+
3. Set your api_url and secret_key as per your envionrment
|
|
26
|
+
1. api_url: https://gatewayurl.sms
|
|
27
|
+
2. secret_key: your_secret_key
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
```ruby
|
|
31
|
+
Require the gem in your Ruby code:
|
|
32
|
+
require 'idi_sms'
|
|
33
|
+
|
|
34
|
+
sms_sender = IdiSms::SmsSender.new
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
Customize your SMS details, including the phone number, SMS text, and SMS language:
|
|
38
|
+
|
|
39
|
+
phone_no = 'xxxxxxxxxx'(allow number only)
|
|
40
|
+
sms_text = 'This gem created by idi'
|
|
41
|
+
sms_language = 'english'
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
Send an SMS using the send_sms method and handle the response:
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
result = sms_sender.send_sms(phone_no, sms_text, sms_language)
|
|
48
|
+
puts result
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Contributing
|
|
53
|
+
|
|
54
|
+
Pull requests are welcome. For major changes, please open an issue first
|
|
55
|
+
to discuss what you would like to change.
|
|
56
|
+
|
|
57
|
+
Please make sure to update tests as appropriate.
|
|
58
|
+
|
|
59
|
+
## License
|
|
60
|
+
|
|
61
|
+
The idi_sms gem is released under the MIT License. See the LICENSE file for details.
|
|
62
|
+
|
|
63
|
+
Contact
|
|
64
|
+
If you have any questions or encounter issues with the idi_sms gem, feel free to contact idrees.ibrahim009@gmail.com.
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
In the provided text, I added instructions for generating an API key and setting environment variables. Please customize it further with the actual URLs, environment variable names, and any additional details specific to your gem.
|
data/Rakefile
ADDED
data/idi_sms-0.0.1.gem
ADDED
|
Binary file
|
data/idi_sms-0.1.0.gem
ADDED
|
Binary file
|
data/idi_sms-0.2.0.gem
ADDED
|
Binary file
|
data/idi_sms.gemspec
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "lib/idi_sms/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
## info
|
|
7
|
+
spec.name = "idi_sms"
|
|
8
|
+
spec.version = IdiSms::VERSION
|
|
9
|
+
spec.authors = ["idrees ibrahim"]
|
|
10
|
+
spec.email = ["idrees.ibrahim@pitv.gov.pk"]
|
|
11
|
+
|
|
12
|
+
## summary
|
|
13
|
+
spec.summary = "Send Sms by using PITB apis it can be send in urdu and english both"
|
|
14
|
+
spec.description = "SMS-Gateway API DETAILS For SMS API FOR DENGUE TRACKING SYSTEM NEW. Short Code 8070"
|
|
15
|
+
spec.homepage = "https://rubygems.org/gems/idi_sms"
|
|
16
|
+
spec.required_ruby_version = ">= 2.6.0"
|
|
17
|
+
|
|
18
|
+
## meta information
|
|
19
|
+
# spec.metadata["allowed_push_host"] = "https://rubygems.org/gems/idi_sms"
|
|
20
|
+
# spec.metadata["homepage_uri"] = spec.homepage
|
|
21
|
+
# spec.metadata["source_code_uri"] = "https://github.com/idreesibrahim/idi_sms"
|
|
22
|
+
# spec.metadata["changelog_uri"] = "https://github.com/idreesibrahim/idi_sms/blob/main/CHANGELOG.md"
|
|
23
|
+
|
|
24
|
+
# Specify which files should be added to the gem when it is released.
|
|
25
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
26
|
+
spec.files = Dir.chdir(__dir__) do
|
|
27
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
|
28
|
+
(File.expand_path(f) == __FILE__) ||
|
|
29
|
+
f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor Gemfile])
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
spec.bindir = "exe"
|
|
33
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
|
34
|
+
spec.require_paths = ["lib"]
|
|
35
|
+
spec.license = "Nonstandard"
|
|
36
|
+
|
|
37
|
+
# Uncomment to register a new dependency of your gem
|
|
38
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
|
39
|
+
|
|
40
|
+
# For more information and examples about making a new gem, check out our
|
|
41
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
|
42
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Create a generator at lib/generators/idi_sms/config/config_generator.rb
|
|
2
|
+
require 'rails/generators'
|
|
3
|
+
|
|
4
|
+
module IdiSms
|
|
5
|
+
module Generators
|
|
6
|
+
class ConfigGenerator < Rails::Generators::Base
|
|
7
|
+
source_root File.expand_path('templates', __dir__)
|
|
8
|
+
|
|
9
|
+
def create_config_file
|
|
10
|
+
template 'idi_sms.yml', 'config/idi_sms.yml'
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
data/lib/idi_sms.rb
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'net/http'
|
|
4
|
+
require 'json'
|
|
5
|
+
require 'yaml'
|
|
6
|
+
|
|
7
|
+
module IdiSms
|
|
8
|
+
class SmsSender
|
|
9
|
+
def initialize(environment = :development)
|
|
10
|
+
config = load_config(environment)
|
|
11
|
+
@api_url = config['api_url']
|
|
12
|
+
@secret_key = config['secret_key']
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def send_sms(phone_no, sms_text, sms_language)
|
|
16
|
+
response = send_sms_request(phone_no, sms_text, sms_language)
|
|
17
|
+
process_response(response)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def load_config(environment)
|
|
23
|
+
config_file = File.expand_path('config/idi_sms.yml')
|
|
24
|
+
YAML.load_file(config_file)[environment.to_s]
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def send_sms_request(phone_no, sms_text, sms_language)
|
|
28
|
+
url = URI.parse(@api_url)
|
|
29
|
+
http = Net::HTTP.new(url.host, url.port)
|
|
30
|
+
http.use_ssl = true
|
|
31
|
+
|
|
32
|
+
request = Net::HTTP::Post.new(url)
|
|
33
|
+
request['Content-Type'] = 'application/json'
|
|
34
|
+
request.body = {
|
|
35
|
+
sec_key: @secret_key,
|
|
36
|
+
phone_no: phone_no,
|
|
37
|
+
sms_text: sms_text,
|
|
38
|
+
sms_language: sms_language
|
|
39
|
+
}.to_json
|
|
40
|
+
|
|
41
|
+
http.request(request)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def process_response(response)
|
|
45
|
+
if response.code == '200'
|
|
46
|
+
response_body = JSON.parse(response.body)
|
|
47
|
+
response_body['status'] == 'success' ? 'SMS sent successfully.' : "Error: #{response_body['message']}"
|
|
48
|
+
else
|
|
49
|
+
'Failed to send SMS.'
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
data/sig/idi_sms.rbs
ADDED
metadata
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: idi_sms
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.2.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- idrees ibrahim
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2023-10-24 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: SMS-Gateway API DETAILS For SMS API FOR DENGUE TRACKING SYSTEM NEW. Short
|
|
14
|
+
Code 8070
|
|
15
|
+
email:
|
|
16
|
+
- idrees.ibrahim@pitv.gov.pk
|
|
17
|
+
executables: []
|
|
18
|
+
extensions: []
|
|
19
|
+
extra_rdoc_files: []
|
|
20
|
+
files:
|
|
21
|
+
- README.md
|
|
22
|
+
- Rakefile
|
|
23
|
+
- idi_sms-0.0.1.gem
|
|
24
|
+
- idi_sms-0.1.0.gem
|
|
25
|
+
- idi_sms-0.2.0.gem
|
|
26
|
+
- idi_sms.gemspec
|
|
27
|
+
- lib/generators/idi_sms/config/config_generator.rb
|
|
28
|
+
- lib/generators/idi_sms/config/templates/idi_sms.yml
|
|
29
|
+
- lib/idi_sms.rb
|
|
30
|
+
- lib/idi_sms/version.rb
|
|
31
|
+
- sig/idi_sms.rbs
|
|
32
|
+
homepage: https://rubygems.org/gems/idi_sms
|
|
33
|
+
licenses:
|
|
34
|
+
- Nonstandard
|
|
35
|
+
metadata: {}
|
|
36
|
+
post_install_message:
|
|
37
|
+
rdoc_options: []
|
|
38
|
+
require_paths:
|
|
39
|
+
- lib
|
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
41
|
+
requirements:
|
|
42
|
+
- - ">="
|
|
43
|
+
- !ruby/object:Gem::Version
|
|
44
|
+
version: 2.6.0
|
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
46
|
+
requirements:
|
|
47
|
+
- - ">="
|
|
48
|
+
- !ruby/object:Gem::Version
|
|
49
|
+
version: '0'
|
|
50
|
+
requirements: []
|
|
51
|
+
rubygems_version: 3.1.2
|
|
52
|
+
signing_key:
|
|
53
|
+
specification_version: 4
|
|
54
|
+
summary: Send Sms by using PITB apis it can be send in urdu and english both
|
|
55
|
+
test_files: []
|