qiksms 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.env_sample +4 -0
- data/.gitignore +14 -0
- data/.rspec +3 -0
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +251 -0
- data/.travis.yml +22 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +14 -0
- data/README.md +53 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/generators/qiksms/install_generator.rb +18 -0
- data/lib/generators/qiksms/templates/qiksms_initializer.rb +16 -0
- data/lib/qiksms.rb +24 -0
- data/lib/qiksms/client.rb +63 -0
- data/lib/qiksms/configuration.rb +34 -0
- data/lib/qiksms/errors/configuration.rb +7 -0
- data/lib/qiksms/version.rb +3 -0
- data/qiksms.gemspec +37 -0
- metadata +151 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 40dde3b915b00ce11500f256afb318ff7a270c508f6e64d530b196e95d705f56
|
4
|
+
data.tar.gz: 85b96c7152e1889f2923580152366a205f2d338de7b06c5a512a01cfce4a6316
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fa18dee8c4868377156b1f93e43b05fd001baecc285bca8203ab5783a9302ecd036ddeb2d3a664eb29aff474da46c440d578b2e1f6b664e0d79cf295e5ef9203
|
7
|
+
data.tar.gz: 9f91394ba9eecb054ae75b7ceaa976c84e61310f044497b52f321d069c9ed7e5a7c48c1922b9a9e773cf3576936f975a1209c2a5d2c717331fd9ec5a6808eeeb
|
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,251 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2018-07-23 11:57:43 +0800 using RuboCop version 0.58.1.
|
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: 2
|
10
|
+
# Cop supports --auto-correct.
|
11
|
+
# Configuration parameters: Include, TreatCommentsAsGroupSeparators.
|
12
|
+
# Include: **/*.gemspec
|
13
|
+
Gemspec/OrderedDependencies:
|
14
|
+
Exclude:
|
15
|
+
# - 'qiksms.gemspec'
|
16
|
+
|
17
|
+
# Offense count: 1
|
18
|
+
# Cop supports --auto-correct.
|
19
|
+
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
20
|
+
# SupportedStyles: outdent, indent
|
21
|
+
Layout/AccessModifierIndentation:
|
22
|
+
Exclude:
|
23
|
+
# - 'lib/qiksms/client.rb'
|
24
|
+
|
25
|
+
# Offense count: 2
|
26
|
+
# Cop supports --auto-correct.
|
27
|
+
# Configuration parameters: EnforcedStyleAlignWith.
|
28
|
+
# SupportedStylesAlignWith: either, start_of_block, start_of_line
|
29
|
+
Layout/BlockAlignment:
|
30
|
+
Exclude:
|
31
|
+
# - 'spec/qiksms/client_spec.rb'
|
32
|
+
# - 'spec/qiksms/configuration_spec.rb'
|
33
|
+
|
34
|
+
# Offense count: 1
|
35
|
+
# Cop supports --auto-correct.
|
36
|
+
# Configuration parameters: EnforcedStyle.
|
37
|
+
# SupportedStyles: empty_lines, no_empty_lines
|
38
|
+
Layout/EmptyLinesAroundBlockBody:
|
39
|
+
Exclude:
|
40
|
+
# - 'spec/qiksms/client_spec.rb'
|
41
|
+
|
42
|
+
# Offense count: 1
|
43
|
+
# Cop supports --auto-correct.
|
44
|
+
# Configuration parameters: EnforcedStyleAlignWith, AutoCorrect, Severity.
|
45
|
+
# SupportedStylesAlignWith: keyword, variable, start_of_line
|
46
|
+
Layout/EndAlignment:
|
47
|
+
Exclude:
|
48
|
+
# - 'lib/qiksms/configuration.rb'
|
49
|
+
|
50
|
+
# Offense count: 1
|
51
|
+
# Cop supports --auto-correct.
|
52
|
+
# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment.
|
53
|
+
Layout/ExtraSpacing:
|
54
|
+
Exclude:
|
55
|
+
# - 'qiksms.gemspec'
|
56
|
+
|
57
|
+
# Offense count: 4
|
58
|
+
# Cop supports --auto-correct.
|
59
|
+
# Configuration parameters: EnforcedStyle.
|
60
|
+
# SupportedStyles: normal, rails
|
61
|
+
Layout/IndentationConsistency:
|
62
|
+
Exclude:
|
63
|
+
# - 'spec/qiksms/client_spec.rb'
|
64
|
+
|
65
|
+
# Offense count: 75
|
66
|
+
# Cop supports --auto-correct.
|
67
|
+
# Configuration parameters: Width, IgnoredPatterns.
|
68
|
+
Layout/IndentationWidth:
|
69
|
+
Exclude:
|
70
|
+
# - 'Gemfile'
|
71
|
+
# - 'lib/generators/qiksms/install_generator.rb'
|
72
|
+
# - 'lib/qiksms.rb'
|
73
|
+
# - 'lib/qiksms/client.rb'
|
74
|
+
# - 'lib/qiksms/configuration.rb'
|
75
|
+
# - 'lib/qiksms/errors/configuration.rb'
|
76
|
+
# - 'spec/qiksms/client_spec.rb'
|
77
|
+
# - 'spec/qiksms/configuration_spec.rb'
|
78
|
+
# - 'spec/qiksms/install_generator_spec.rb'
|
79
|
+
|
80
|
+
# Offense count: 1
|
81
|
+
# Cop supports --auto-correct.
|
82
|
+
Layout/LeadingBlankLines:
|
83
|
+
Exclude:
|
84
|
+
# - 'qiksms.gemspec'
|
85
|
+
|
86
|
+
# Offense count: 2
|
87
|
+
# Cop supports --auto-correct.
|
88
|
+
# Configuration parameters: .
|
89
|
+
# SupportedStyles: space, no_space
|
90
|
+
Layout/SpaceAroundEqualsInParameterDefault:
|
91
|
+
EnforcedStyle: no_space
|
92
|
+
|
93
|
+
# Offense count: 2
|
94
|
+
# Cop supports --auto-correct.
|
95
|
+
# Configuration parameters: AllowForAlignment.
|
96
|
+
Layout/SpaceAroundOperators:
|
97
|
+
Exclude:
|
98
|
+
# - 'lib/qiksms/client.rb'
|
99
|
+
# - 'qiksms.gemspec'
|
100
|
+
|
101
|
+
# Offense count: 1
|
102
|
+
# Cop supports --auto-correct.
|
103
|
+
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
|
104
|
+
# SupportedStyles: space, no_space
|
105
|
+
# SupportedStylesForEmptyBraces: space, no_space
|
106
|
+
Layout/SpaceInsideBlockBraces:
|
107
|
+
Exclude:
|
108
|
+
# - 'Gemfile'
|
109
|
+
|
110
|
+
# Offense count: 117
|
111
|
+
# Cop supports --auto-correct.
|
112
|
+
# Configuration parameters: IndentationWidth.
|
113
|
+
Layout/Tab:
|
114
|
+
Exclude:
|
115
|
+
# - 'lib/qiksms.rb'
|
116
|
+
# - 'spec/qiksms/client_spec.rb'
|
117
|
+
# - 'spec/qiksms/configuration_spec.rb'
|
118
|
+
|
119
|
+
# Offense count: 9
|
120
|
+
# Cop supports --auto-correct.
|
121
|
+
# Configuration parameters: EnforcedStyle.
|
122
|
+
# SupportedStyles: final_newline, final_blank_line
|
123
|
+
Layout/TrailingBlankLines:
|
124
|
+
Exclude:
|
125
|
+
# - 'Gemfile'
|
126
|
+
# - 'lib/generators/qiksms/install_generator.rb'
|
127
|
+
# - 'lib/qiksms.rb'
|
128
|
+
# - 'lib/qiksms/client.rb'
|
129
|
+
# - 'lib/qiksms/configuration.rb'
|
130
|
+
# - 'lib/qiksms/errors/configuration.rb'
|
131
|
+
# - 'spec/qiksms/client_spec.rb'
|
132
|
+
# - 'spec/qiksms/configuration_spec.rb'
|
133
|
+
# - 'spec/qiksms/install_generator_spec.rb'
|
134
|
+
|
135
|
+
# Offense count: 20
|
136
|
+
# Cop supports --auto-correct.
|
137
|
+
# Configuration parameters: AllowInHeredoc.
|
138
|
+
Layout/TrailingWhitespace:
|
139
|
+
Exclude:
|
140
|
+
# - 'lib/qiksms.rb'
|
141
|
+
# - 'lib/qiksms/client.rb'
|
142
|
+
# - 'lib/qiksms/configuration.rb'
|
143
|
+
# - 'spec/qiksms/client_spec.rb'
|
144
|
+
# - 'spec/qiksms/configuration_spec.rb'
|
145
|
+
# - 'spec/qiksms/install_generator_spec.rb'
|
146
|
+
|
147
|
+
# Offense count: 1
|
148
|
+
Lint/DuplicateMethods:
|
149
|
+
Exclude:
|
150
|
+
- 'lib/qiksms.rb'
|
151
|
+
|
152
|
+
# Offense count: 1
|
153
|
+
Lint/ShadowingOuterLocalVariable:
|
154
|
+
Exclude:
|
155
|
+
# - 'spec/spec_helper.rb'
|
156
|
+
|
157
|
+
# Offense count: 3
|
158
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
159
|
+
# ExcludedMethods: refine
|
160
|
+
Metrics/BlockLength:
|
161
|
+
Max: 52
|
162
|
+
|
163
|
+
# Offense count: 4
|
164
|
+
Style/Documentation:
|
165
|
+
Exclude:
|
166
|
+
# - 'spec/**/*'
|
167
|
+
# - 'test/**/*'
|
168
|
+
# - 'lib/generators/qiksms/install_generator.rb'
|
169
|
+
# - 'lib/qiksms.rb'
|
170
|
+
# - 'lib/qiksms/client.rb'
|
171
|
+
# - 'lib/qiksms/configuration.rb'
|
172
|
+
|
173
|
+
# Offense count: 3
|
174
|
+
# Cop supports --auto-correct.
|
175
|
+
Style/ExpandPathArguments:
|
176
|
+
Exclude:
|
177
|
+
# - 'lib/generators/qiksms/install_generator.rb'
|
178
|
+
# - 'qiksms.gemspec'
|
179
|
+
# - 'spec/qiksms/install_generator_spec.rb'
|
180
|
+
|
181
|
+
# Offense count: 1
|
182
|
+
# Cop supports --auto-correct.
|
183
|
+
# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
|
184
|
+
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
|
185
|
+
Style/HashSyntax:
|
186
|
+
Exclude:
|
187
|
+
# - 'Rakefile'
|
188
|
+
|
189
|
+
# Offense count: 3
|
190
|
+
# Cop supports --auto-correct.
|
191
|
+
Style/MutableConstant:
|
192
|
+
Exclude:
|
193
|
+
- 'lib/qiksms/client.rb'
|
194
|
+
# - 'lib/qiksms/version.rb'
|
195
|
+
|
196
|
+
# Offense count: 3
|
197
|
+
# Cop supports --auto-correct.
|
198
|
+
# Configuration parameters: PreferredDelimiters.
|
199
|
+
Style/PercentLiteralDelimiters:
|
200
|
+
Exclude:
|
201
|
+
# - 'qiksms.gemspec'
|
202
|
+
# - 'spec/qiksms/install_generator_spec.rb'
|
203
|
+
|
204
|
+
# Offense count: 1
|
205
|
+
# Cop supports --auto-correct.
|
206
|
+
# Configuration parameters: EnforcedStyle.
|
207
|
+
# SupportedStyles: short, verbose
|
208
|
+
Style/PreferredHashMethods:
|
209
|
+
Exclude:
|
210
|
+
# - 'lib/qiksms/client.rb'
|
211
|
+
|
212
|
+
# Offense count: 1
|
213
|
+
# Cop supports --auto-correct.
|
214
|
+
# Configuration parameters: AllowMultipleReturnValues.
|
215
|
+
Style/RedundantReturn:
|
216
|
+
Exclude:
|
217
|
+
# - 'lib/qiksms/client.rb'
|
218
|
+
|
219
|
+
# Offense count: 1
|
220
|
+
# Cop supports --auto-correct.
|
221
|
+
Style/RedundantSelf:
|
222
|
+
Exclude:
|
223
|
+
# - 'lib/qiksms/client.rb'
|
224
|
+
|
225
|
+
# Offense count: 37
|
226
|
+
# Cop supports --auto-correct.
|
227
|
+
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
|
228
|
+
# SupportedStyles: single_quotes, double_quotes
|
229
|
+
Style/StringLiterals:
|
230
|
+
Exclude:
|
231
|
+
# - 'Gemfile'
|
232
|
+
# - 'Rakefile'
|
233
|
+
# - 'bin/console'
|
234
|
+
# - 'lib/generators/qiksms/install_generator.rb'
|
235
|
+
# - 'lib/qiksms/configuration.rb'
|
236
|
+
# - 'lib/qiksms/version.rb'
|
237
|
+
# - 'qiksms.gemspec'
|
238
|
+
# - 'spec/qiksms_spec.rb'
|
239
|
+
# - 'spec/spec_helper.rb'
|
240
|
+
|
241
|
+
# Offense count: 2
|
242
|
+
# Cop supports --auto-correct.
|
243
|
+
Style/UnneededPercentQ:
|
244
|
+
Exclude:
|
245
|
+
# - 'qiksms.gemspec'
|
246
|
+
|
247
|
+
# Offense count: 24
|
248
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
249
|
+
# URISchemes: http, https
|
250
|
+
Metrics/LineLength:
|
251
|
+
Max: 162
|
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=a3b7526acf2673cd554941961e6a84ee041978350b16f49ac2d4cc6eb2149427
|
11
|
+
|
12
|
+
before_script:
|
13
|
+
- bundle exec rspec && CODECLIMATE_REPO_TOKEN=a3b7526acf2673cd554941961e6a84ee041978350b16f49ac2d4cc6eb2149427
|
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 meralpisdenmark@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 qiksms.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/README.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/denmarkmeralpis/qiksms.svg?branch=master)](https://travis-ci.org/denmarkmeralpis/qiksms) [![Test Coverage](https://api.codeclimate.com/v1/badges/ea4b451049d8a6ac530b/test_coverage)](https://codeclimate.com/github/denmarkmeralpis/qiksms/test_coverage) [![Maintainability](https://api.codeclimate.com/v1/badges/ea4b451049d8a6ac530b/maintainability)](https://codeclimate.com/github/denmarkmeralpis/qiksms/maintainability) [![Gem Version](https://badge.fury.io/rb/qiksms.svg)](https://badge.fury.io/rb/qiksms)
|
2
|
+
# Qiksms
|
3
|
+
|
4
|
+
This ruby plugin will easily help you send SMS using qiksms API. You can contact qiksms to enable your Developers API console.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'qiksms'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install qiksms
|
21
|
+
|
22
|
+
Then generate initializer:
|
23
|
+
|
24
|
+
$ rails g qiksms:install
|
25
|
+
|
26
|
+
then edit the file in `config/initializer/qiksms.rb` and supply the necessary details.
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
|
30
|
+
Send SMS:
|
31
|
+
```ruby
|
32
|
+
client = Qiksms::Client.new(recipient: '917XXXXXXX', message: 'Your awesome message!')
|
33
|
+
client.send
|
34
|
+
```
|
35
|
+
or simply:
|
36
|
+
```ruby
|
37
|
+
Qiksms::Client.send(recipient: '917XXXXXXX', message: 'Your awesome message!')
|
38
|
+
```
|
39
|
+
|
40
|
+
You can also change the `sender_id` and `char_type` on the fly:
|
41
|
+
```ruby
|
42
|
+
Qiksms::Client.send(recipient: '917XXXXXXX', message: 'Your awesome message!', char_type: '8', sender_id: 'custom')
|
43
|
+
```
|
44
|
+
|
45
|
+
NOTE: Changing of `sender_id` requires approval/subscription from https://wwww.qiksms.com
|
46
|
+
|
47
|
+
## Contributing
|
48
|
+
|
49
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/denmarkmeralpis/qiksms. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
50
|
+
|
51
|
+
## Code of Conduct
|
52
|
+
|
53
|
+
Everyone interacting in the Qiksms project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/denmarkmeralpis/qiksms/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'qiksms'
|
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
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
# name
|
4
|
+
module Qiksms
|
5
|
+
# Generator
|
6
|
+
module Generators
|
7
|
+
# Class generatpr
|
8
|
+
class InstallGenerator < Rails::Generators::NamedBase
|
9
|
+
source_root File.expand_path('templates', __dir__)
|
10
|
+
desc 'Creates qiksms.rb initializer for your application'
|
11
|
+
|
12
|
+
def copy_initializer
|
13
|
+
template 'qiksms_initializer.rb', 'config/initializers/qiksms.rb'
|
14
|
+
puts 'Done install! Configure the file in config/initializers/qiksms.rb'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Qiksms.configure do |config|
|
2
|
+
# Get it from qiksms.com
|
3
|
+
config.api_key = ENV['QIKSMS_API_KEY']
|
4
|
+
|
5
|
+
# Get it from qiksms.com
|
6
|
+
config.api_secret = ENV['QIKSMS_API_SECRET']
|
7
|
+
|
8
|
+
# This will be the name of the sender
|
9
|
+
# If you want to change this, contact Qiksms
|
10
|
+
config.sender_id = 'websms'
|
11
|
+
|
12
|
+
# When using the Unicode message, the message length becomes 70 chars max per message.
|
13
|
+
# char_type 0 is not unicode
|
14
|
+
# char_type 8 is unicode message
|
15
|
+
config.char_type = '0'
|
16
|
+
end
|
data/lib/qiksms.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'qiksms/version'
|
2
|
+
require 'qiksms/configuration'
|
3
|
+
require 'qiksms/client'
|
4
|
+
require 'qiksms/errors/configuration'
|
5
|
+
require 'generators/qiksms/install_generator'
|
6
|
+
|
7
|
+
# Qiksms configuration block
|
8
|
+
module Qiksms
|
9
|
+
class << self
|
10
|
+
attr_accessor :configuration
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.configuration
|
14
|
+
@configuration ||= Configuration.new
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.reset
|
18
|
+
@configuration = Configuration.new
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.configure
|
22
|
+
yield(configuration)
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
# namespace
|
5
|
+
module Qiksms
|
6
|
+
# class
|
7
|
+
class Client
|
8
|
+
attr_accessor :api_key, :api_secret, :recipient, :message
|
9
|
+
|
10
|
+
MSG_PARAMS = {}
|
11
|
+
HOST = 'https://app.qiksms.com/api/send'.freeze
|
12
|
+
|
13
|
+
def initialize(options={})
|
14
|
+
@api_key = Qiksms.configuration.api_key
|
15
|
+
@api_secret = Qiksms.configuration.api_secret
|
16
|
+
@sender_id = options[:sender_id]
|
17
|
+
@char_type = options[:char_type]
|
18
|
+
@recipient = options[:recipient]
|
19
|
+
@message = options[:message]
|
20
|
+
end
|
21
|
+
|
22
|
+
def sender_id
|
23
|
+
@sender_id ||= Qiksms.configuration.sender_id
|
24
|
+
end
|
25
|
+
|
26
|
+
def char_type
|
27
|
+
@char_type ||= Qiksms.configuration.char_type
|
28
|
+
end
|
29
|
+
|
30
|
+
def send
|
31
|
+
uri = URI(HOST)
|
32
|
+
|
33
|
+
request = Net::HTTP.post_form(uri, message_params)
|
34
|
+
response = JSON.parse(request.body, symbolize_names: true)
|
35
|
+
|
36
|
+
return raise Errors::Authentication, response[:error] if response.key?(:error)
|
37
|
+
|
38
|
+
case response[:code]
|
39
|
+
when 200
|
40
|
+
response
|
41
|
+
when 422
|
42
|
+
raise Errors::BadRequest, response[:message]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.send(options={})
|
47
|
+
obj = new(options)
|
48
|
+
obj.send
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def message_params
|
54
|
+
MSG_PARAMS['api_secret'] = api_secret
|
55
|
+
MSG_PARAMS['api_key'] = api_key
|
56
|
+
MSG_PARAMS['recipient'] = recipient
|
57
|
+
MSG_PARAMS['message'] = message
|
58
|
+
MSG_PARAMS['char_type'] = char_type
|
59
|
+
MSG_PARAMS['from'] = sender_id
|
60
|
+
MSG_PARAMS
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# namespacing
|
2
|
+
module Qiksms
|
3
|
+
# class cofiguration
|
4
|
+
class Configuration
|
5
|
+
attr_writer :api_key, :api_secret, :char_type, :sender_id
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@api_key = nil
|
9
|
+
@api_secret = nil
|
10
|
+
@char_type = nil
|
11
|
+
@sender_id = nil
|
12
|
+
end
|
13
|
+
|
14
|
+
def api_key
|
15
|
+
raise Errors::Configuration, 'Qiksms api_key is missing! See documentation for configuration settings.' unless @api_key
|
16
|
+
@api_key
|
17
|
+
end
|
18
|
+
|
19
|
+
def api_secret
|
20
|
+
raise Errors::Configuration, 'Qiksms api_secret is missing! See documentation for configuration settings.' unless @api_secret
|
21
|
+
@api_secret
|
22
|
+
end
|
23
|
+
|
24
|
+
def char_type
|
25
|
+
raise Errors::Configuration, 'Qiksms char_type is missing! See documentation for configuration settings.' unless @char_type
|
26
|
+
@char_type
|
27
|
+
end
|
28
|
+
|
29
|
+
def sender_id
|
30
|
+
raise Errors::Configuration, 'Qiksms sender_id is missing! See documentation for configuration settings.' unless @sender_id
|
31
|
+
@sender_id
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/qiksms.gemspec
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'qiksms/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'qiksms'
|
7
|
+
spec.version = Qiksms::VERSION
|
8
|
+
spec.authors = ['Nujian Den Mark Meralpis']
|
9
|
+
spec.email = ['denmarkmeralpis@gmail.com', 'meralpisdenmark@gmail.com']
|
10
|
+
|
11
|
+
spec.summary = 'A simple way of sending SMS using qiksms'
|
12
|
+
spec.description = 'This gem is intended for developers that requires SMS integration to their ruby application.'
|
13
|
+
spec.homepage = 'https://github.com/denmarkmeralpis/qiksms'
|
14
|
+
|
15
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
16
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
17
|
+
if spec.respond_to?(:metadata)
|
18
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org/gems/qiksms'
|
19
|
+
else
|
20
|
+
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
21
|
+
'public gem pushes.'
|
22
|
+
end
|
23
|
+
|
24
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
25
|
+
f.match(%r{^(test|spec|features)/})
|
26
|
+
end
|
27
|
+
spec.bindir = 'exe'
|
28
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ['lib']
|
30
|
+
|
31
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
32
|
+
spec.add_development_dependency 'dotenv', '~> 2.5'
|
33
|
+
spec.add_development_dependency 'rails', '~> 5.2'
|
34
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
35
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
36
|
+
spec.add_development_dependency 'webmock', '~> 3.4'
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: qiksms
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nujian Den Mark Meralpis
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-07-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: dotenv
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.5'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.2'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.2'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: webmock
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.4'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.4'
|
97
|
+
description: This gem is intended for developers that requires SMS integration to
|
98
|
+
their ruby application.
|
99
|
+
email:
|
100
|
+
- denmarkmeralpis@gmail.com
|
101
|
+
- meralpisdenmark@gmail.com
|
102
|
+
executables: []
|
103
|
+
extensions: []
|
104
|
+
extra_rdoc_files: []
|
105
|
+
files:
|
106
|
+
- ".env_sample"
|
107
|
+
- ".gitignore"
|
108
|
+
- ".rspec"
|
109
|
+
- ".rubocop.yml"
|
110
|
+
- ".rubocop_todo.yml"
|
111
|
+
- ".travis.yml"
|
112
|
+
- CODE_OF_CONDUCT.md
|
113
|
+
- Gemfile
|
114
|
+
- Gemfile.lock
|
115
|
+
- README.md
|
116
|
+
- Rakefile
|
117
|
+
- bin/console
|
118
|
+
- bin/setup
|
119
|
+
- lib/generators/qiksms/install_generator.rb
|
120
|
+
- lib/generators/qiksms/templates/qiksms_initializer.rb
|
121
|
+
- lib/qiksms.rb
|
122
|
+
- lib/qiksms/client.rb
|
123
|
+
- lib/qiksms/configuration.rb
|
124
|
+
- lib/qiksms/errors/configuration.rb
|
125
|
+
- lib/qiksms/version.rb
|
126
|
+
- qiksms.gemspec
|
127
|
+
homepage: https://github.com/denmarkmeralpis/qiksms
|
128
|
+
licenses: []
|
129
|
+
metadata:
|
130
|
+
allowed_push_host: https://rubygems.org/gems/qiksms
|
131
|
+
post_install_message:
|
132
|
+
rdoc_options: []
|
133
|
+
require_paths:
|
134
|
+
- lib
|
135
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
requirements: []
|
146
|
+
rubyforge_project:
|
147
|
+
rubygems_version: 2.7.6
|
148
|
+
signing_key:
|
149
|
+
specification_version: 4
|
150
|
+
summary: A simple way of sending SMS using qiksms
|
151
|
+
test_files: []
|