promotexter 0.1.3 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.env.sample +4 -0
- data/.gitignore +16 -0
- data/.rspec +3 -0
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +192 -0
- data/.travis.yml +22 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +14 -0
- data/LICENSE.txt +21 -0
- data/README.md +59 -0
- data/Rakefile +4 -40
- data/lib/promotexter.rb +1 -27
- data/lib/promotexter/client.rb +56 -0
- data/lib/promotexter/version.rb +1 -1
- data/promotexter.gemspec +39 -0
- metadata +74 -22
- data/MIT-LICENSE +0 -20
- data/README.rdoc +0 -17
- data/lib/promotexter/base.rb +0 -24
- data/lib/promotexter/http_client.rb +0 -16
- data/lib/promotexter/messenger.rb +0 -27
- data/lib/tasks/promotexter_tasks.rake +0 -4
- data/test/promotexter_test.rb +0 -20
- data/test/sms_test.rb +0 -19
- data/test/test_helper.rb +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4d4c0b227950260b42734726e893e36a4e022f06d835e00587700cae21fd3829
|
4
|
+
data.tar.gz: e8537cc531c6cc6729efd9e21b663961bcc11b700be030b0510a40345f37768f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 240d8c193c701508b96e3e4046d599f6e9f688057848eeb0844ffb094a56ea7e2aec898a5dcf7c194ed7a4166c63eb4b7abb98a8a822f9c39a0e56ab77b416cc
|
7
|
+
data.tar.gz: 85065e96c9c97641a4eafbc39b7adada742b0954bb9c7e7b1dacc75885594ff191108afd2e9e5576ad09e4f9dc6f03c3b22fbfd7dc20d818eadf1ac31093d59c
|
data/.env.sample
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,192 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2018-07-27 21:28:57 +0800 using RuboCop version 0.58.2.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 1
|
10
|
+
# Cop supports --auto-correct.
|
11
|
+
# Configuration parameters: Include, TreatCommentsAsGroupSeparators.
|
12
|
+
# Include: **/*.gemspec
|
13
|
+
Gemspec/OrderedDependencies:
|
14
|
+
Exclude:
|
15
|
+
# - 'promotexter.gemspec'
|
16
|
+
|
17
|
+
# Offense count: 1
|
18
|
+
# Cop supports --auto-correct.
|
19
|
+
Layout/EmptyLines:
|
20
|
+
Exclude:
|
21
|
+
# - 'spec/promotexter_spec.rb'
|
22
|
+
|
23
|
+
# Offense count: 1
|
24
|
+
# Cop supports --auto-correct.
|
25
|
+
# Configuration parameters: EnforcedStyle.
|
26
|
+
# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines
|
27
|
+
Layout/EmptyLinesAroundModuleBody:
|
28
|
+
Exclude:
|
29
|
+
# - 'lib/promotexter/client.rb'
|
30
|
+
|
31
|
+
# Offense count: 4
|
32
|
+
# Cop supports --auto-correct.
|
33
|
+
# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment.
|
34
|
+
Layout/ExtraSpacing:
|
35
|
+
Exclude:
|
36
|
+
# - 'lib/promotexter/client.rb'
|
37
|
+
|
38
|
+
# Offense count: 1
|
39
|
+
# Cop supports --auto-correct.
|
40
|
+
# Configuration parameters: AllowForAlignment.
|
41
|
+
Layout/SpaceAroundOperators:
|
42
|
+
Exclude:
|
43
|
+
# - 'lib/promotexter/client.rb'
|
44
|
+
|
45
|
+
# Offense count: 3
|
46
|
+
# Cop supports --auto-correct.
|
47
|
+
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
|
48
|
+
# SupportedStyles: space, no_space
|
49
|
+
# SupportedStylesForEmptyBraces: space, no_space
|
50
|
+
Layout/SpaceInsideBlockBraces:
|
51
|
+
Exclude:
|
52
|
+
# - 'Gemfile'
|
53
|
+
# - 'spec/promotexter_spec.rb'
|
54
|
+
|
55
|
+
# Offense count: 20
|
56
|
+
# Cop supports --auto-correct.
|
57
|
+
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
|
58
|
+
# SupportedStyles: space, no_space, compact
|
59
|
+
# SupportedStylesForEmptyBraces: space, no_space
|
60
|
+
Layout/SpaceInsideHashLiteralBraces:
|
61
|
+
Exclude:
|
62
|
+
# - 'spec/promotexter_spec.rb'
|
63
|
+
|
64
|
+
# Offense count: 3
|
65
|
+
# Cop supports --auto-correct.
|
66
|
+
# Configuration parameters: EnforcedStyle.
|
67
|
+
# SupportedStyles: final_newline, final_blank_line
|
68
|
+
Layout/TrailingBlankLines:
|
69
|
+
Exclude:
|
70
|
+
# - 'Gemfile'
|
71
|
+
# - 'lib/promotexter.rb'
|
72
|
+
# - 'lib/promotexter/client.rb'
|
73
|
+
|
74
|
+
# Offense count: 6
|
75
|
+
# Cop supports --auto-correct.
|
76
|
+
# Configuration parameters: AllowInHeredoc.
|
77
|
+
Layout/TrailingWhitespace:
|
78
|
+
Exclude:
|
79
|
+
# - 'lib/promotexter/client.rb'
|
80
|
+
# - 'promotexter.gemspec'
|
81
|
+
# - 'spec/promotexter_spec.rb'
|
82
|
+
|
83
|
+
# Offense count: 2
|
84
|
+
Lint/LiteralAsCondition:
|
85
|
+
Exclude:
|
86
|
+
# - 'lib/promotexter/client.rb'
|
87
|
+
|
88
|
+
# Offense count: 5
|
89
|
+
Lint/UselessAssignment:
|
90
|
+
Exclude:
|
91
|
+
# - 'spec/promotexter_spec.rb'
|
92
|
+
|
93
|
+
# Offense count: 1
|
94
|
+
Metrics/AbcSize:
|
95
|
+
Max: 21
|
96
|
+
|
97
|
+
# Offense count: 2
|
98
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
99
|
+
# ExcludedMethods: refine
|
100
|
+
Metrics/BlockLength:
|
101
|
+
Max: 89
|
102
|
+
|
103
|
+
# Offense count: 1
|
104
|
+
# Configuration parameters: CountComments.
|
105
|
+
Metrics/MethodLength:
|
106
|
+
Max: 18
|
107
|
+
|
108
|
+
# Offense count: 10
|
109
|
+
# Cop supports --auto-correct.
|
110
|
+
# Configuration parameters: EnforcedStyle.
|
111
|
+
# SupportedStyles: braces, no_braces, context_dependent
|
112
|
+
Style/BracesAroundHashParameters:
|
113
|
+
Exclude:
|
114
|
+
# - 'spec/promotexter_spec.rb'
|
115
|
+
|
116
|
+
# Offense count: 2
|
117
|
+
Style/Documentation:
|
118
|
+
Exclude:
|
119
|
+
- 'spec/**/*'
|
120
|
+
- 'test/**/*'
|
121
|
+
- 'lib/promotexter/client.rb'
|
122
|
+
|
123
|
+
# Offense count: 1
|
124
|
+
# Cop supports --auto-correct.
|
125
|
+
Style/EmptyCaseCondition:
|
126
|
+
Exclude:
|
127
|
+
# - 'lib/promotexter/client.rb'
|
128
|
+
|
129
|
+
# Offense count: 2
|
130
|
+
# Cop supports --auto-correct.
|
131
|
+
Style/ExpandPathArguments:
|
132
|
+
Exclude:
|
133
|
+
# - 'promotexter.gemspec'
|
134
|
+
|
135
|
+
# Offense count: 1
|
136
|
+
# Cop supports --auto-correct.
|
137
|
+
# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
|
138
|
+
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
|
139
|
+
Style/HashSyntax:
|
140
|
+
Exclude:
|
141
|
+
# - 'Rakefile'
|
142
|
+
|
143
|
+
# Offense count: 3
|
144
|
+
# Cop supports --auto-correct.
|
145
|
+
Style/MutableConstant:
|
146
|
+
Exclude:
|
147
|
+
- 'lib/promotexter/client.rb'
|
148
|
+
- 'lib/promotexter/version.rb'
|
149
|
+
|
150
|
+
# Offense count: 5
|
151
|
+
# Cop supports --auto-correct.
|
152
|
+
# Configuration parameters: EnforcedStyle.
|
153
|
+
# SupportedStyles: short, verbose
|
154
|
+
Style/PreferredHashMethods:
|
155
|
+
Exclude:
|
156
|
+
# - 'lib/promotexter/client.rb'
|
157
|
+
# - 'spec/promotexter_spec.rb'
|
158
|
+
|
159
|
+
# Offense count: 1
|
160
|
+
# Cop supports --auto-correct.
|
161
|
+
# Configuration parameters: EnforcedStyle.
|
162
|
+
# SupportedStyles: compact, exploded
|
163
|
+
Style/RaiseArgs:
|
164
|
+
Exclude:
|
165
|
+
# - 'lib/promotexter/client.rb'
|
166
|
+
|
167
|
+
# Offense count: 1
|
168
|
+
# Cop supports --auto-correct.
|
169
|
+
# Configuration parameters: .
|
170
|
+
# SupportedStyles: use_perl_names, use_english_names
|
171
|
+
Style/SpecialGlobalVars:
|
172
|
+
EnforcedStyle: use_perl_names
|
173
|
+
|
174
|
+
# Offense count: 52
|
175
|
+
# Cop supports --auto-correct.
|
176
|
+
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
|
177
|
+
# SupportedStyles: single_quotes, double_quotes
|
178
|
+
Style/StringLiterals:
|
179
|
+
Exclude:
|
180
|
+
# - 'Gemfile'
|
181
|
+
# - 'Rakefile'
|
182
|
+
# - 'lib/promotexter.rb'
|
183
|
+
# - 'lib/promotexter/version.rb'
|
184
|
+
# - 'promotexter.gemspec'
|
185
|
+
# - 'spec/promotexter_spec.rb'
|
186
|
+
# - 'spec/spec_helper.rb'
|
187
|
+
|
188
|
+
# Offense count: 41
|
189
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
190
|
+
# URISchemes: http, https
|
191
|
+
Metrics/LineLength:
|
192
|
+
Max: 261
|
data/.travis.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
sudo: false
|
2
|
+
language: ruby
|
3
|
+
rvm:
|
4
|
+
- 2.4.1
|
5
|
+
before_install: gem install bundler -v 1.16.1
|
6
|
+
notifications: false
|
7
|
+
|
8
|
+
env:
|
9
|
+
global:
|
10
|
+
- CC_TEST_REPORTER_ID=ff3fec53f2aa08704cf6b6cec93a2e21db5b38b0fbd9a481468aae635b949b1f
|
11
|
+
|
12
|
+
before_script:
|
13
|
+
- bundle exec rspec && CODECLIMATE_REPO_TOKEN=ff3fec53f2aa08704cf6b6cec93a2e21db5b38b0fbd9a481468aae635b949b1f
|
14
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
15
|
+
- chmod +x ./cc-test-reporter
|
16
|
+
- ./cc-test-reporter before-build
|
17
|
+
|
18
|
+
scripts:
|
19
|
+
- bundle exec rspec spec
|
20
|
+
|
21
|
+
after_script:
|
22
|
+
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
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 cecillegsevilla01@gmail.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
@@ -0,0 +1,14 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in promotexter.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
group :test do
|
9
|
+
gem 'byebug'
|
10
|
+
gem 'generator_spec'
|
11
|
+
gem 'rubocop'
|
12
|
+
gem 'simplecov'
|
13
|
+
gem 'simplecov-console'
|
14
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016-2018 Den Mark Meralpis, Cecille Sevilla, Andrey Ramirez, Jett Robin Andres, Andrei Navarro
|
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,59 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/denmarkmeralpis/promotexter.svg?branch=master)](https://travis-ci.org/denmarkmeralpis/promotexter) [![Test Coverage](https://api.codeclimate.com/v1/badges/c20c43addcd61c8777f1/test_coverage)](https://codeclimate.com/github/denmarkmeralpis/promotexter/test_coverage) [![Maintainability](https://api.codeclimate.com/v1/badges/c20c43addcd61c8777f1/maintainability)](https://codeclimate.com/github/denmarkmeralpis/promotexter/maintainability) [![Gem Version](https://badge.fury.io/rb/promotexter.svg)](https://badge.fury.io/rb/promotexter)
|
2
|
+
|
3
|
+
Promotexter
|
4
|
+
======
|
5
|
+
|
6
|
+
A Ruby gem for consuming the [Promotexter API](http://promotexter.com/index.php/landing/developers) for sending mesages
|
7
|
+
|
8
|
+
## Requirements
|
9
|
+
|
10
|
+
Ruby 2.x.x
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
$ gem install promotexter
|
15
|
+
|
16
|
+
Or add it to your `Gemfile`:
|
17
|
+
|
18
|
+
gem promotexter
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
Construct a Promotexter::Client object and use the #send_message method to
|
23
|
+
send a message. For example:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
require 'promotexter'
|
27
|
+
|
28
|
+
client = Promotexter::Client.new(api_key:'key', api_secret:'secret', from:'xxxxxx')
|
29
|
+
client.send_message(message:'This is a test', to:'639171234567')
|
30
|
+
```
|
31
|
+
|
32
|
+
## Production environment variables
|
33
|
+
|
34
|
+
Best practice for storing credentials for external services in production is
|
35
|
+
to use environment variables, as described by [12factor.net/config](http://12factor.net/config).
|
36
|
+
Promotexter::Client defaults to extracting the client_id, secret_key and shortcode it needs from the
|
37
|
+
PROMOTEXTER_API_KEY, PROMOTEXTER_API_SECRET and PROMOTEXTER_FROM environment variables if the
|
38
|
+
options were not specified explicitly.
|
39
|
+
|
40
|
+
## Contributing
|
41
|
+
|
42
|
+
1. Fork it
|
43
|
+
2. Create your feature branch (`git checkout -b new-feature`)
|
44
|
+
3. Commit your changes (`git commit -am 'Added awesome new features'`)
|
45
|
+
4. Push to the branch (`git push origin new-feature`)
|
46
|
+
5. Create new Pull Request
|
47
|
+
|
48
|
+
## MIT Open Source License
|
49
|
+
|
50
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
51
|
+
|
52
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
53
|
+
|
54
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
55
|
+
|
56
|
+
## Acknowledgement
|
57
|
+
Originally created by Nujian Den Mark Meralpis, Updated by Scrambled Eggs Software Inc.
|
58
|
+
|
59
|
+
2016-2018
|
data/Rakefile
CHANGED
@@ -1,42 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
3
|
|
4
|
-
RSpec::Core::RakeTask.new
|
4
|
+
RSpec::Core::RakeTask.new(:spec)
|
5
5
|
|
6
|
-
task :
|
7
|
-
task :test => :spec
|
8
|
-
|
9
|
-
# begin
|
10
|
-
# require 'bundler/setup'
|
11
|
-
# rescue LoadError
|
12
|
-
# puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
13
|
-
# end
|
14
|
-
#
|
15
|
-
# require 'rdoc/task'
|
16
|
-
#
|
17
|
-
# RDoc::Task.new(:rdoc) do |rdoc|
|
18
|
-
# rdoc.rdoc_dir = 'rdoc'
|
19
|
-
# rdoc.title = 'Promotexter'
|
20
|
-
# rdoc.options << '--line-numbers'
|
21
|
-
# rdoc.rdoc_files.include('README.rdoc')
|
22
|
-
# rdoc.rdoc_files.include('lib/**/*.rb')
|
23
|
-
# end
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
# Bundler::GemHelper.install_tasks
|
31
|
-
#
|
32
|
-
# require 'rake/testtask'
|
33
|
-
#
|
34
|
-
# Rake::TestTask.new(:test) do |t|
|
35
|
-
# t.libs << 'lib'
|
36
|
-
# t.libs << 'test'
|
37
|
-
# t.pattern = 'test/**/*_test.rb'
|
38
|
-
# t.verbose = false
|
39
|
-
# end
|
40
|
-
#
|
41
|
-
#
|
42
|
-
# task default: :test
|
6
|
+
task default: :spec
|
data/lib/promotexter.rb
CHANGED
@@ -1,28 +1,2 @@
|
|
1
1
|
require 'promotexter/version'
|
2
|
-
require 'promotexter/
|
3
|
-
require 'promotexter/messenger'
|
4
|
-
require 'promotexter/base'
|
5
|
-
|
6
|
-
module Promotexter
|
7
|
-
|
8
|
-
attr_accessor :configuration
|
9
|
-
|
10
|
-
class << self
|
11
|
-
attr_accessor :configuration
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.configure
|
15
|
-
self.configuration ||= Configuration.new
|
16
|
-
# yield(configuration)
|
17
|
-
end
|
18
|
-
|
19
|
-
class Configuration
|
20
|
-
|
21
|
-
attr_accessor :api_key
|
22
|
-
|
23
|
-
def initialize
|
24
|
-
@api_key = ''
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
2
|
+
require 'promotexter/client'
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Promotexter
|
5
|
+
class Error < StandardError
|
6
|
+
def initialize(message)
|
7
|
+
super(message)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class BadRequestError < Error; end
|
12
|
+
|
13
|
+
class AuthenticationError < Error; end
|
14
|
+
|
15
|
+
class Client
|
16
|
+
attr_accessor :api_secret, :api_key, :from, :http, :to, :text
|
17
|
+
SMSAPI_PATH = '/sms/send'
|
18
|
+
MESSAGE_PARAMS = {}
|
19
|
+
|
20
|
+
def initialize(options = {})
|
21
|
+
@api_key = options[:api_key]
|
22
|
+
@api_secret = options[:api_secret]
|
23
|
+
@from = options[:from]
|
24
|
+
|
25
|
+
@host = 'https://rest-portal.promotexter.com'
|
26
|
+
@http = Net::HTTP.new(@host, Net::HTTP.https_default_port)
|
27
|
+
|
28
|
+
MESSAGE_PARAMS['apiKey'] = @api_key
|
29
|
+
MESSAGE_PARAMS['apiSecret'] = @api_secret
|
30
|
+
MESSAGE_PARAMS['from'] = @from
|
31
|
+
end
|
32
|
+
|
33
|
+
def send_message(params = {})
|
34
|
+
uri = URI(@host + SMSAPI_PATH)
|
35
|
+
MESSAGE_PARAMS['to'] = params[:to]
|
36
|
+
MESSAGE_PARAMS['text'] = params[:text]
|
37
|
+
|
38
|
+
res = Net::HTTP.post_form(uri, MESSAGE_PARAMS)
|
39
|
+
puts res.inspect
|
40
|
+
response = JSON.parse(res.body, symbolize_names: true)
|
41
|
+
|
42
|
+
if response.key?(:statusCode)
|
43
|
+
case response[:statusCode]
|
44
|
+
when 400
|
45
|
+
raise BadRequestError.new(message: response[:message])
|
46
|
+
when 401
|
47
|
+
raise AuthenticationError.new(message: response[:message])
|
48
|
+
else
|
49
|
+
raise Error, response[:message]
|
50
|
+
end
|
51
|
+
else
|
52
|
+
response
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/promotexter/version.rb
CHANGED
data/promotexter.gemspec
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
$:.push File.expand_path('lib', __dir__)
|
2
|
+
|
3
|
+
# Maintain your gem's version:
|
4
|
+
require 'promotexter/version'
|
5
|
+
|
6
|
+
# Describe your gem and declare its dependencies:
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = 'promotexter'
|
9
|
+
s.version = Promotexter::VERSION
|
10
|
+
s.authors = ['Nujian Den Mark Meralpis', 'Cecille Sevilla', 'Andrey Ramirez', 'Jett Robin Andres', 'Andrei Navarro']
|
11
|
+
s.email = ['denmarkmeralpis@gmail.com', 'cecillegsevilla01@gmail.com', 'jettrobin.andres@gmail.com', 'ramirez.jag00@gmail.com', 'andrei@phonebooky.com']
|
12
|
+
s.homepage = 'https://github.com/denmarkmeralpis/promotexter'
|
13
|
+
s.summary = 'Simple way of sending SMS via Promotexter API'
|
14
|
+
s.description = 'The gem provides a simple way of sending SMS via Promotexter API'
|
15
|
+
s.license = 'MIT'
|
16
|
+
|
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 s.respond_to?(:metadata)
|
20
|
+
s.metadata['allowed_push_host'] = 'https://rubygems.org/gems/promotexter'
|
21
|
+
else
|
22
|
+
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
23
|
+
'public gem pushes.'
|
24
|
+
end
|
25
|
+
|
26
|
+
# Specify which files should be added to the gem when it is released.
|
27
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
28
|
+
s.files = Dir.chdir(File.expand_path(__dir__)) do
|
29
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
30
|
+
end
|
31
|
+
|
32
|
+
s.require_paths = ['lib']
|
33
|
+
|
34
|
+
s.add_development_dependency 'bundler', '~> 1.16'
|
35
|
+
s.add_development_dependency 'dotenv', '~> 2.5.0'
|
36
|
+
s.add_development_dependency 'rake', '~> 10.0'
|
37
|
+
s.add_development_dependency 'rspec', '~> 3.0'
|
38
|
+
s.add_development_dependency 'webmock', '~> 3.4.2'
|
39
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: promotexter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Nujian Den Mark Meralpis
|
8
|
+
- Cecille Sevilla
|
9
|
+
- Andrey Ramirez
|
10
|
+
- Jett Robin Andres
|
11
|
+
- Andrei Navarro
|
8
12
|
autorequire:
|
9
13
|
bindir: bin
|
10
14
|
cert_chain: []
|
11
|
-
date:
|
15
|
+
date: 2018-07-27 00:00:00.000000000 Z
|
12
16
|
dependencies:
|
13
17
|
- !ruby/object:Gem::Dependency
|
14
18
|
name: bundler
|
@@ -16,14 +20,28 @@ dependencies:
|
|
16
20
|
requirements:
|
17
21
|
- - "~>"
|
18
22
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
23
|
+
version: '1.16'
|
20
24
|
type: :development
|
21
25
|
prerelease: false
|
22
26
|
version_requirements: !ruby/object:Gem::Requirement
|
23
27
|
requirements:
|
24
28
|
- - "~>"
|
25
29
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
30
|
+
version: '1.16'
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: dotenv
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - "~>"
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 2.5.0
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - "~>"
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: 2.5.0
|
27
45
|
- !ruby/object:Gem::Dependency
|
28
46
|
name: rake
|
29
47
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,29 +56,66 @@ dependencies:
|
|
38
56
|
- - "~>"
|
39
57
|
- !ruby/object:Gem::Version
|
40
58
|
version: '10.0'
|
59
|
+
- !ruby/object:Gem::Dependency
|
60
|
+
name: rspec
|
61
|
+
requirement: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - "~>"
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '3.0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - "~>"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '3.0'
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
name: webmock
|
75
|
+
requirement: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - "~>"
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: 3.4.2
|
80
|
+
type: :development
|
81
|
+
prerelease: false
|
82
|
+
version_requirements: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - "~>"
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 3.4.2
|
41
87
|
description: The gem provides a simple way of sending SMS via Promotexter API
|
42
88
|
email:
|
43
|
-
-
|
89
|
+
- denmarkmeralpis@gmail.com
|
90
|
+
- cecillegsevilla01@gmail.com
|
91
|
+
- jettrobin.andres@gmail.com
|
92
|
+
- ramirez.jag00@gmail.com
|
93
|
+
- andrei@phonebooky.com
|
44
94
|
executables: []
|
45
95
|
extensions: []
|
46
96
|
extra_rdoc_files: []
|
47
97
|
files:
|
48
|
-
-
|
49
|
-
-
|
98
|
+
- ".env.sample"
|
99
|
+
- ".gitignore"
|
100
|
+
- ".rspec"
|
101
|
+
- ".rubocop.yml"
|
102
|
+
- ".rubocop_todo.yml"
|
103
|
+
- ".travis.yml"
|
104
|
+
- CODE_OF_CONDUCT.md
|
105
|
+
- Gemfile
|
106
|
+
- Gemfile.lock
|
107
|
+
- LICENSE.txt
|
108
|
+
- README.md
|
50
109
|
- Rakefile
|
51
110
|
- lib/promotexter.rb
|
52
|
-
- lib/promotexter/
|
53
|
-
- lib/promotexter/http_client.rb
|
54
|
-
- lib/promotexter/messenger.rb
|
111
|
+
- lib/promotexter/client.rb
|
55
112
|
- lib/promotexter/version.rb
|
56
|
-
-
|
57
|
-
|
58
|
-
- test/sms_test.rb
|
59
|
-
- test/test_helper.rb
|
60
|
-
homepage: http://nueca.net
|
113
|
+
- promotexter.gemspec
|
114
|
+
homepage: https://github.com/denmarkmeralpis/promotexter
|
61
115
|
licenses:
|
62
116
|
- MIT
|
63
|
-
metadata:
|
117
|
+
metadata:
|
118
|
+
allowed_push_host: https://rubygems.org/gems/promotexter
|
64
119
|
post_install_message:
|
65
120
|
rdoc_options: []
|
66
121
|
require_paths:
|
@@ -77,11 +132,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
132
|
version: '0'
|
78
133
|
requirements: []
|
79
134
|
rubyforge_project:
|
80
|
-
rubygems_version: 2.
|
135
|
+
rubygems_version: 2.7.6
|
81
136
|
signing_key:
|
82
137
|
specification_version: 4
|
83
138
|
summary: Simple way of sending SMS via Promotexter API
|
84
|
-
test_files:
|
85
|
-
- test/promotexter_test.rb
|
86
|
-
- test/sms_test.rb
|
87
|
-
- test/test_helper.rb
|
139
|
+
test_files: []
|
data/MIT-LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright 2016 Den Mark Meralpis
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
= Promotexter
|
2
|
-
|
3
|
-
This project rocks and uses MIT-LICENSE.
|
4
|
-
|
5
|
-
<b>initialize</b>
|
6
|
-
|
7
|
-
clientid = ''
|
8
|
-
senderid = ''
|
9
|
-
passkey = ''
|
10
|
-
|
11
|
-
restprovider = Promotexter::Base.new(clientid, senderid, passkey)
|
12
|
-
|
13
|
-
<b>Sending SMS</b>
|
14
|
-
response = restprovider.send_sms(message, recipient)
|
15
|
-
|
16
|
-
<b>Get Available Balance</b>
|
17
|
-
response = restprovider.get_balance
|
data/lib/promotexter/base.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
module Promotexter
|
2
|
-
class Base
|
3
|
-
|
4
|
-
attr_accessor :configuration
|
5
|
-
|
6
|
-
def initialize clientid, senderid
|
7
|
-
@domain = "http://promotexter.com"
|
8
|
-
@clientid = clientid
|
9
|
-
@senderid = senderid
|
10
|
-
@api_key = Promotexter.configure.api_key
|
11
|
-
end
|
12
|
-
|
13
|
-
def send_sms(message, recipient)
|
14
|
-
messenger = Messenger.new @domain, @clientid, @senderid, @api_key
|
15
|
-
messenger.send_sms(message, recipient)
|
16
|
-
end
|
17
|
-
|
18
|
-
def get_balance
|
19
|
-
messenger = Messenger.new @domain, @clientid, @senderid, @api_key
|
20
|
-
messenger.get_balance
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'net/http'
|
2
|
-
|
3
|
-
module Promotexter
|
4
|
-
module HttpClient
|
5
|
-
def get(url)
|
6
|
-
uri = URI(url)
|
7
|
-
|
8
|
-
req = Net::HTTP::Get.new(uri)
|
9
|
-
|
10
|
-
Net::HTTP.start(uri.host, uri.port,
|
11
|
-
:use_ssl => uri.scheme == 'https') do |http|
|
12
|
-
response = http.request req # Net::HTTPResponse object
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'http_client.rb')
|
2
|
-
|
3
|
-
module Promotexter
|
4
|
-
class Messenger
|
5
|
-
|
6
|
-
include HttpClient
|
7
|
-
|
8
|
-
def initialize domain, clientid, senderid, passkey
|
9
|
-
@domain = domain
|
10
|
-
@clientid = clientid
|
11
|
-
@senderid = senderid
|
12
|
-
@passkey = passkey
|
13
|
-
end
|
14
|
-
|
15
|
-
def send_sms message, recipient
|
16
|
-
message = URI.encode(message)
|
17
|
-
url = "#{@domain}/sendsms.php?clientid=#{@clientid}&passkey=#{@passkey}&msisdn=#{recipient}&message=#{message}&senderid=#{@senderid}&encoding=url"
|
18
|
-
get(url)
|
19
|
-
end
|
20
|
-
|
21
|
-
def get_balance
|
22
|
-
url = "#{@domain}/getbalance.php?clientid=#{@clientid}&passkey=#{@passkey}"
|
23
|
-
get(url)
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
end
|
data/test/promotexter_test.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class PromotexterTest < ActiveSupport::TestCase
|
4
|
-
# test "truth" do
|
5
|
-
# assert_kind_of Module, Promotexter
|
6
|
-
# end
|
7
|
-
|
8
|
-
test "Send SMS" do
|
9
|
-
clientid = '20000739'
|
10
|
-
passkey = 'E5CD404AB8CE31EB7E4906D3D90271D8'
|
11
|
-
msisdn = '639778198061'
|
12
|
-
senderid = 'Demo'
|
13
|
-
message = URI.escape(message)
|
14
|
-
|
15
|
-
rest_provider = Promotexter::Base.new(clientid, senderid, passkey)
|
16
|
-
response = rest_provider.send_sms('Testing Promotexter Gem 0.0.2', '639778198061')
|
17
|
-
assert_not_equal(response.body.to_s, '-1')
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
data/test/sms_test.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# require 'uri'
|
2
|
-
# require 'test_helper'
|
3
|
-
#
|
4
|
-
# class SmsTest < ActiveSupport::TestCase
|
5
|
-
#
|
6
|
-
# def test_to_send_sms
|
7
|
-
# clientid='20000739'
|
8
|
-
# passkey='E5CD404AB8CE31EB7E4906D3D90271D8'
|
9
|
-
# msisdn='639778198061'
|
10
|
-
# message='Hello World!'
|
11
|
-
# senderid='Demo'
|
12
|
-
# message = URI.escape(message)
|
13
|
-
# domain = "http://promotexter.com"
|
14
|
-
#
|
15
|
-
# restprovider = Promotexter::Base.new(clientid, senderid, passkey)
|
16
|
-
# response = restprovider.send_sms(message, msisdn)
|
17
|
-
# end
|
18
|
-
#
|
19
|
-
# end
|
data/test/test_helper.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
# Configure Rails Environment
|
2
|
-
ENV["RAILS_ENV"] = "test"
|
3
|
-
|
4
|
-
# require File.expand_path("../../test/dummy/config/environment.rb", __FILE__)
|
5
|
-
# ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)]
|
6
|
-
require "rails/test_help"
|
7
|
-
|
8
|
-
# Filter out Minitest backtrace while allowing backtrace from other libraries
|
9
|
-
# to be shown.
|
10
|
-
Minitest.backtrace_filter = Minitest::BacktraceFilter.new
|
11
|
-
|
12
|
-
# Load support files
|
13
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
14
|
-
|
15
|
-
# Load fixtures from the engine
|
16
|
-
if ActiveSupport::TestCase.respond_to?(:fixture_path=)
|
17
|
-
ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
|
18
|
-
ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path
|
19
|
-
ActiveSupport::TestCase.fixtures :all
|
20
|
-
end
|