telcosms 0.0.3 → 1.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 6c4544fd7ceb12fee8493a0ce38c9b849075b51b
4
- data.tar.gz: 89eed74c677ae9bfc4382d7d93fc05f82519790b
2
+ SHA256:
3
+ metadata.gz: 2624317950cb75a589877601dd428700135cc8e7e571579ebd167f1e1eb2d85f
4
+ data.tar.gz: 05a12a5c9344910a13c9e84b28ed1111b75b9790abb95279e922d948a62796f5
5
5
  SHA512:
6
- metadata.gz: f540b76a6268e549fa39b02454b39e1581dc21a27afe622f3502e51188dc94d7d1ebe2f7d037b598ab5366f9472899ddcf322d030edf9181e665f9e2ce7b2393
7
- data.tar.gz: 00c752cc852088aa03bf72e29e40a64144f4d1c66c65d0f9ff7b9c0d6b9d68d8a882aef919111207c741121a23bf4523762ee7cd90aabacb2b456f8d6d9a2a90
6
+ metadata.gz: 99af9ea663f6ab113f91f33c4cd75281c2960fc858b04a5f988c50f71fb8a2cdbbdd71c26bf26ccf169fe391cc384b716e9a0296e35ad55b05da1f15c8b61135
7
+ data.tar.gz: 0cbe8dc3c52d6db633d335bb18d8d664578db67a1602fc4d6dc3f029424e4458b3bdf4957ba9a37ee6ed24daec16ee3381f5709048645d6b51ae96af88efd623
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Telcosms
2
2
 
3
- A ruby gem createb by [SmartTechys](http://www.smarttechys.co.ao) for the [TelcoSMS](http://telcosms.co.ao) API that allows your application to send sms to Angolan Numbers.
3
+ A ruby gem created by [Sergio Maziano](http://github.com/smaziano) for the [TelcoSMS](http://telcosms.co.ao) API that allows your application to send sms to Angolan Numbers.
4
4
 
5
5
  ## Installation
6
6
 
@@ -19,28 +19,32 @@ Or install it yourself as:
19
19
  $ gem install telcosms
20
20
 
21
21
  ## Setup
22
- Make sure you have access to your username and password that can be requested to the TelcoSMS crew.
22
+ Make sure you have access to your username and password (can be requested to the TelcoSMS team)
23
+ and setup as your environment variables.
23
24
 
24
- ## Usage
25
+ ### Environment variables
26
+ |Env Variable|Value|
27
+ |-|-|
28
+ |TELCOSMS_USERNAME| The username provided by TelcoSMS|
29
+ |TELCOSMS_PASSWORD| The password provided by TelcoSMS|
25
30
 
31
+ ## Usage
32
+ You need to pass 3 arguments to make it work (number, message, service).
26
33
  ```ruby
27
- ## Use the class methods to get it going
28
-
29
- # New Message
30
- ## You need to pass 5 arguments to make it work (numbers, message, username, password, servico)
31
-
32
- Telcosms.new_sms(numbers, message, username, password, servico)
33
-
34
- ## numbers is an array of the numbers you want to send the sms.
35
- ## message is a string os characters that contain the message.
36
- ## username is a string with username given by the Telcosms crew(as best practive, use environment variable).
37
- ## password is a string with password given by the Telcosms crew(as best practive, use environment variable).
38
- ## servico is a string with the text that will show up as contact sender.
34
+ telco = Telcosms.new
35
+ telco.send(number: '+244923456789', message: 'Hello World\nNext line', service: 'TelcoSMS')
36
+ ```
37
+ ## Schema
38
+ |field |type|notes|
39
+ |-|-|-|
40
+ |number|string|number with or without a country code|
41
+ |message|string|the message content|
42
+ |service|string|sender identifier |
39
43
 
40
44
  ## Help and Docs
41
45
 
42
46
  - [TelcoSMS](http://telcosms.co.ao)
43
- - [RDOC](http://www.rubydoc.info/gems/telcosms/0.0.1)
47
+ - [RDOC](http://www.rubydoc.info/gems/telcosms/1.0.0)
44
48
 
45
49
  ## Development
46
50
 
@@ -58,5 +62,4 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/smazia
58
62
 
59
63
  ## License
60
64
 
61
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
62
-
65
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -1,3 +1,3 @@
1
- module Telcosms
2
- VERSION = "0.0.3"
1
+ module TelcosmsModule
2
+ VERSION = "1.0.0"
3
3
  end
data/lib/telcosms.rb CHANGED
@@ -1,15 +1,19 @@
1
- require "telcosms/version"
2
- require "httparty"
3
-
4
- module Telcosms
5
- include HTTParty
6
- #base_uri "196.216.53.194:9501"
7
- base_uri "41.210.223.124:9503"
8
-
9
- # send a message
10
- def self.new_sms(numbers, message, username, password, servico)
11
- numbers.each do |number|
12
- post("/api?action=sendmessage&username=#{username}&password=#{password}&recipient=#{number}&messagetype=SMS:TEXT&messagedata=#{message}&originator=#{servico}", :headers => {'Content-Type' => 'application/json'}).parsed_response
13
- end
14
- end
15
- end
1
+ require_relative "telcosms_module"
2
+
3
+ class Telcosms
4
+ include TelcosmsModule
5
+
6
+ def initialize(username: set_username, password: set_password, service: nil)
7
+ @username = username
8
+ @password = password
9
+ end
10
+
11
+ private
12
+ def set_username
13
+ ENV.fetch('TELCOSMS_USERNAME')
14
+ end
15
+
16
+ def set_password
17
+ ENV.fetch('TELCOSMS_PASSWORD')
18
+ end
19
+ end
@@ -0,0 +1,28 @@
1
+ require "telcosms/version"
2
+ require "httparty"
3
+
4
+ module TelcosmsModule
5
+ class Error < StandardError; end
6
+ include HTTParty
7
+ follow_redirects false
8
+ base_uri "196.216.53.194:9501"
9
+
10
+ def send(number:, message:, service:)
11
+ content = set_headers
12
+ text = URI::Parser.new
13
+ request = HTTParty.post("#{host}/api?action=sendmessage&username=#{@username}&password=#{@password}&recipient=#{number}&messagetype=SMS:TEXT&messagedata=#{text.escape(message)}&originator=#{service}", content)
14
+ return request
15
+ end
16
+
17
+ private
18
+ def set_headers
19
+ content = {}
20
+ headers = {'Content-Type' => "application/json"}
21
+ content[:headers] = headers
22
+ content
23
+ end
24
+
25
+ def host
26
+ "http://196.216.53.194:9501"
27
+ end
28
+ end
Binary file
data/telcosms.gemspec CHANGED
@@ -1,31 +1,27 @@
1
- # coding: utf-8
2
1
  lib = File.expand_path('../lib', __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'telcosms/version'
5
4
 
6
5
  Gem::Specification.new do |spec|
7
6
  spec.name = "telcosms"
8
- spec.version = Telcosms::VERSION
7
+ spec.version = TelcosmsModule::VERSION
9
8
  spec.authors = ["Sergio Maziano"]
10
9
  spec.email = ["sergio.maziano@gmail.com"]
11
10
 
12
- spec.summary = %q{A Ruby gem for TelcoSMS API(http://telcosms.co.ao) made by SmartTechys(http://www.smarttechys.co.ao)}
13
- spec.description = %q{A Ruby gem to connect your application with the TelcoSMS API(http://telcosms.co.ao) to allow your application to send sms through Angolan numbers}
11
+ spec.summary = %q{A Ruby gem for TelcoSMS API(http://telcosms.co.ao) made by Sergio Maziano(http://github.com/smaziano)}
12
+ spec.description = %q{A Ruby gem to connect your application with the TelcoSMS API's (http://telcosms.co.ao) to allow your application to send sms through Angolan numbers}
14
13
  spec.homepage = "https://github.com/smaziano/telcosms"
15
14
  spec.license = "MIT"
16
15
 
17
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
- # to allow pushing to a single host or delete this section to allow pushing to any host.
19
- #if spec.respond_to?(:metadata)
20
- spec.metadata['allowed_push_host'] = "https://rubygems.org"
16
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
17
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ end
21
19
 
22
-
23
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
20
  spec.bindir = "exe"
25
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
22
  spec.require_paths = ["lib"]
27
23
 
28
24
  spec.add_development_dependency "bundler", "~> 1.12"
29
25
  spec.add_development_dependency "rake", "~> 10.0"
30
- spec.add_dependency 'httparty', "~> 0.13.7"
26
+ spec.add_dependency 'httparty', "~> 0.18.1"
31
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: telcosms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergio Maziano
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-01-04 00:00:00.000000000 Z
11
+ date: 2022-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -44,15 +44,15 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.13.7
47
+ version: 0.18.1
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.13.7
55
- description: A Ruby gem to connect your application with the TelcoSMS API(http://telcosms.co.ao)
54
+ version: 0.18.1
55
+ description: A Ruby gem to connect your application with the TelcoSMS API's (http://telcosms.co.ao)
56
56
  to allow your application to send sms through Angolan numbers
57
57
  email:
58
58
  - sergio.maziano@gmail.com
@@ -70,14 +70,14 @@ files:
70
70
  - bin/setup
71
71
  - lib/telcosms.rb
72
72
  - lib/telcosms/version.rb
73
- - telcosms-0.0.2.gem
73
+ - lib/telcosms_module.rb
74
+ - telcosms-0.0.5.gem
74
75
  - telcosms.gemspec
75
76
  homepage: https://github.com/smaziano/telcosms
76
77
  licenses:
77
78
  - MIT
78
- metadata:
79
- allowed_push_host: https://rubygems.org
80
- post_install_message:
79
+ metadata: {}
80
+ post_install_message:
81
81
  rdoc_options: []
82
82
  require_paths:
83
83
  - lib
@@ -92,9 +92,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
92
  - !ruby/object:Gem::Version
93
93
  version: '0'
94
94
  requirements: []
95
- rubyforge_project:
96
- rubygems_version: 2.6.10
97
- signing_key:
95
+ rubygems_version: 3.1.4
96
+ signing_key:
98
97
  specification_version: 4
99
- summary: A Ruby gem for TelcoSMS API(http://telcosms.co.ao) made by SmartTechys(http://www.smarttechys.co.ao)
98
+ summary: A Ruby gem for TelcoSMS API(http://telcosms.co.ao) made by Sergio Maziano(http://github.com/smaziano)
100
99
  test_files: []
data/telcosms-0.0.2.gem DELETED
Binary file