telcosms 0.0.4 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 0afe24f55d0a12aa9f4e19969a02bf83585aa228
4
- data.tar.gz: 856779e9152c010379b8f6fe44f5e1b288afce40
2
+ SHA256:
3
+ metadata.gz: 85d45dffa2b0a552ca474e0862a3411ad1465735157def71773025e7be443661
4
+ data.tar.gz: 85a5277888a400b5ea8ca5e77d9dcf73dd2a43147a22675d7e150f76f19efe7a
5
5
  SHA512:
6
- metadata.gz: ca204fb28128dd035dd48e96ca55c9142c1b95f99ef1b69b98bb7d3007c202bc300b1cb2932b3c6e95d4efede3566aed46b49da1fdbd817e69598609923e3535
7
- data.tar.gz: e306246dc2a7370ce2321bf5fa9bd25106fc7fdcdb42c0199659b03e2c30245c5b309b84a0f615c8b6bed1bab68eab45f7f7b6f60aa422767df96557b03a9f93
6
+ metadata.gz: 9dc01a28245e470c770da62d425810ddb714624017bdf6ff9fbe7a4eea18844b9cc2039654ddcdee7727d4b678d6533a9e654bdc55e4dc3b22cc1dfca8dca92a
7
+ data.tar.gz: 3c7afd6e6c5c8435bfd5c7a20af13f30faddad413496ba1c75d96c6424de6153a480811b7f66a381fb1f94e0daa079b731264fb242a7abcf4cc1ddcc55db5401
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.4)
47
+ - [RDOC](http://www.rubydoc.info/gems/telcosms/1.0.1)
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.4"
1
+ module TelcosmsModule
2
+ VERSION = "1.0.1"
3
3
  end
data/lib/telcosms.rb CHANGED
@@ -1,14 +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
-
8
- # send a message
9
- def self.new_sms(numbers, message, username, password, servico)
10
- numbers.each do |number|
11
- post("/api?action=sendmessage&username=#{username}&password=#{password}&recipient=#{number}&messagetype=SMS:TEXT&messagedata=#{message}&originator=#{servico}", :headers => {'Content-Type' => 'application/json'}).parsed_response
12
- end
13
- end
14
- 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
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
- spec.add_development_dependency "rake", "~> 10.0"
30
- spec.add_dependency 'httparty', "~> 0.13.7"
25
+ spec.add_development_dependency "rake", "~> 12.3.3"
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.4
4
+ version: 1.0.1
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
@@ -30,29 +30,29 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: 12.3.3
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: 12.3.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: httparty
43
43
  requirement: !ruby/object:Gem::Requirement
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,15 +70,13 @@ files:
70
70
  - bin/setup
71
71
  - lib/telcosms.rb
72
72
  - lib/telcosms/version.rb
73
- - telcosms-0.0.2.gem
74
- - telcosms-0.0.3.gem
73
+ - lib/telcosms_module.rb
75
74
  - telcosms.gemspec
76
75
  homepage: https://github.com/smaziano/telcosms
77
76
  licenses:
78
77
  - MIT
79
- metadata:
80
- allowed_push_host: https://rubygems.org
81
- post_install_message:
78
+ metadata: {}
79
+ post_install_message:
82
80
  rdoc_options: []
83
81
  require_paths:
84
82
  - lib
@@ -93,9 +91,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
91
  - !ruby/object:Gem::Version
94
92
  version: '0'
95
93
  requirements: []
96
- rubyforge_project:
97
- rubygems_version: 2.6.10
98
- signing_key:
94
+ rubygems_version: 3.1.4
95
+ signing_key:
99
96
  specification_version: 4
100
- summary: A Ruby gem for TelcoSMS API(http://telcosms.co.ao) made by SmartTechys(http://www.smarttechys.co.ao)
97
+ summary: A Ruby gem for TelcoSMS API(http://telcosms.co.ao) made by Sergio Maziano(http://github.com/smaziano)
101
98
  test_files: []
data/telcosms-0.0.2.gem DELETED
Binary file
data/telcosms-0.0.3.gem DELETED
Binary file