itexmo 0.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 +7 -0
- data/.env.sample +1 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +224 -0
- data/.travis.yml +22 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +195 -0
- data/LICENSE-MIT.md +22 -0
- data/README.md +88 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/itexmo.gemspec +38 -0
- data/lib/generators/itexmo/install_generator.rb +18 -0
- data/lib/generators/itexmo/templates/itexmo_initializer.rb +7 -0
- data/lib/itexmo.rb +30 -0
- data/lib/itexmo/configuration.rb +19 -0
- data/lib/itexmo/errors/authentication.rb +5 -0
- data/lib/itexmo/errors/bad_request.rb +5 -0
- data/lib/itexmo/errors/configuration.rb +5 -0
- data/lib/itexmo/message.rb +78 -0
- data/lib/itexmo/response_helper.rb +37 -0
- data/lib/itexmo/service.rb +45 -0
- data/lib/itexmo/sms.rb +109 -0
- data/lib/itexmo/version.rb +3 -0
- metadata +156 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 95534a9da39e1612c1ad3a29791495b4a7a61fb649a176a1b3eb80d43791ff1d
|
|
4
|
+
data.tar.gz: c10000d90f3d5d192c6277a402fd0bd083e9fa9ca381f7df7402462d2180bb72
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 50beb50e29d7380ba99f914e5e4e037d4dd603d78aa996b6f6c11cd901234d49e34f17a2313085acf5f3011300d1720716ee8507f4e106d43e85402738e92b4a
|
|
7
|
+
data.tar.gz: 9e3dee6604a2de80f81c377fc26e6fb30eeeed46427fc44119522fe85cad003873e8c1010fe36a60d708ff4656d882180a661eed2dd91e339eb6049329a49d4b
|
data/.env.sample
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ITEXMO_API_CODE=you-api-code-here
|
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,224 @@
|
|
|
1
|
+
# This configuration was generated by
|
|
2
|
+
# `rubocop --auto-gen-config`
|
|
3
|
+
# on 2018-07-29 15:51:51 +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: 4
|
|
10
|
+
# Cop supports --auto-correct.
|
|
11
|
+
# Configuration parameters: EnforcedStyle.
|
|
12
|
+
# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only
|
|
13
|
+
Layout/EmptyLinesAroundClassBody:
|
|
14
|
+
Exclude:
|
|
15
|
+
# - 'lib/itexmo/message.rb'
|
|
16
|
+
# - 'lib/itexmo/response_helper.rb'
|
|
17
|
+
# - 'lib/itexmo/service.rb'
|
|
18
|
+
|
|
19
|
+
# Offense count: 1
|
|
20
|
+
# Cop supports --auto-correct.
|
|
21
|
+
# Configuration parameters: EnforcedStyleAlignWith, AutoCorrect, Severity.
|
|
22
|
+
# SupportedStylesAlignWith: keyword, variable, start_of_line
|
|
23
|
+
Layout/EndAlignment:
|
|
24
|
+
Exclude:
|
|
25
|
+
# - 'lib/itexmo/configuration.rb'
|
|
26
|
+
|
|
27
|
+
# Offense count: 1
|
|
28
|
+
# Cop supports --auto-correct.
|
|
29
|
+
# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment.
|
|
30
|
+
Layout/ExtraSpacing:
|
|
31
|
+
Exclude:
|
|
32
|
+
# - 'itexmo.gemspec'
|
|
33
|
+
|
|
34
|
+
# Offense count: 158
|
|
35
|
+
# Cop supports --auto-correct.
|
|
36
|
+
# Configuration parameters: Width, IgnoredPatterns.
|
|
37
|
+
Layout/IndentationWidth:
|
|
38
|
+
Exclude:
|
|
39
|
+
# - 'lib/itexmo/configuration.rb'
|
|
40
|
+
# - 'lib/itexmo/errors/authentication.rb'
|
|
41
|
+
# - 'lib/itexmo/errors/bad_request.rb'
|
|
42
|
+
# - 'lib/itexmo/errors/configuration.rb'
|
|
43
|
+
# - 'lib/itexmo/message.rb'
|
|
44
|
+
# - 'lib/itexmo/response_helper.rb'
|
|
45
|
+
# - 'lib/itexmo/service.rb'
|
|
46
|
+
# - 'lib/itexmo/sms.rb'
|
|
47
|
+
# - 'spec/itextmo/message_spec.rb'
|
|
48
|
+
# - 'spec/itextmo/response_helper_spec.rb'
|
|
49
|
+
# - 'spec/itextmo/service_spec.rb'
|
|
50
|
+
# - 'spec/itextmo/sms_spec.rb'
|
|
51
|
+
|
|
52
|
+
# Offense count: 1
|
|
53
|
+
# Cop supports --auto-correct.
|
|
54
|
+
Layout/LeadingBlankLines:
|
|
55
|
+
Exclude:
|
|
56
|
+
# - 'itexmo.gemspec'
|
|
57
|
+
|
|
58
|
+
# Offense count: 2
|
|
59
|
+
# Cop supports --auto-correct.
|
|
60
|
+
# Configuration parameters: EnforcedStyle.
|
|
61
|
+
# SupportedStyles: space, no_space
|
|
62
|
+
Layout/SpaceAroundEqualsInParameterDefault:
|
|
63
|
+
Exclude:
|
|
64
|
+
# - 'lib/itexmo/message.rb'
|
|
65
|
+
|
|
66
|
+
# Offense count: 1
|
|
67
|
+
# Cop supports --auto-correct.
|
|
68
|
+
# Configuration parameters: AllowForAlignment.
|
|
69
|
+
Layout/SpaceAroundOperators:
|
|
70
|
+
Exclude:
|
|
71
|
+
# - 'itexmo.gemspec'
|
|
72
|
+
|
|
73
|
+
# Offense count: 2
|
|
74
|
+
# Cop supports --auto-correct.
|
|
75
|
+
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
|
|
76
|
+
# SupportedStyles: space, no_space
|
|
77
|
+
# SupportedStylesForEmptyBraces: space, no_space
|
|
78
|
+
Layout/SpaceInsideBlockBraces:
|
|
79
|
+
Exclude:
|
|
80
|
+
# - 'Gemfile'
|
|
81
|
+
# - 'spec/itextmo/message_spec.rb'
|
|
82
|
+
|
|
83
|
+
# Offense count: 9
|
|
84
|
+
# Cop supports --auto-correct.
|
|
85
|
+
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
|
|
86
|
+
# SupportedStyles: space, no_space, compact
|
|
87
|
+
# SupportedStylesForEmptyBraces: space, no_space
|
|
88
|
+
Layout/SpaceInsideHashLiteralBraces:
|
|
89
|
+
Exclude:
|
|
90
|
+
# - 'lib/itexmo/message.rb'
|
|
91
|
+
# - 'spec/itextmo/service_spec.rb'
|
|
92
|
+
|
|
93
|
+
# Offense count: 11
|
|
94
|
+
# Cop supports --auto-correct.
|
|
95
|
+
# Configuration parameters: EnforcedStyle.
|
|
96
|
+
# SupportedStyles: final_newline, final_blank_line
|
|
97
|
+
Layout/TrailingBlankLines:
|
|
98
|
+
Exclude:
|
|
99
|
+
# - 'Gemfile'
|
|
100
|
+
# - 'lib/itexmo/errors/authentication.rb'
|
|
101
|
+
# - 'lib/itexmo/errors/bad_request.rb'
|
|
102
|
+
# - 'lib/itexmo/errors/configuration.rb'
|
|
103
|
+
# - 'lib/itexmo/message.rb'
|
|
104
|
+
# - 'lib/itexmo/response_helper.rb'
|
|
105
|
+
# - 'lib/itexmo/service.rb'
|
|
106
|
+
# - 'spec/itextmo/message_spec.rb'
|
|
107
|
+
# - 'spec/itextmo/response_helper_spec.rb'
|
|
108
|
+
# - 'spec/itextmo/service_spec.rb'
|
|
109
|
+
# - 'spec/itextmo/sms_spec.rb'
|
|
110
|
+
|
|
111
|
+
# Offense count: 21
|
|
112
|
+
# Cop supports --auto-correct.
|
|
113
|
+
# Configuration parameters: AllowInHeredoc.
|
|
114
|
+
Layout/TrailingWhitespace:
|
|
115
|
+
Exclude:
|
|
116
|
+
# - 'lib/generators/itexmo/templates/itexmo_initializer.rb'
|
|
117
|
+
# - 'lib/itexmo/configuration.rb'
|
|
118
|
+
# - 'lib/itexmo/message.rb'
|
|
119
|
+
# - 'lib/itexmo/response_helper.rb'
|
|
120
|
+
# - 'lib/itexmo/service.rb'
|
|
121
|
+
# - 'lib/itexmo/sms.rb'
|
|
122
|
+
# - 'spec/itextmo/message_spec.rb'
|
|
123
|
+
# - 'spec/itextmo/response_helper_spec.rb'
|
|
124
|
+
# - 'spec/itextmo/service_spec.rb'
|
|
125
|
+
# - 'spec/itextmo/sms_spec.rb'
|
|
126
|
+
|
|
127
|
+
# Offense count: 1
|
|
128
|
+
Lint/DuplicateMethods:
|
|
129
|
+
Exclude:
|
|
130
|
+
- 'lib/itexmo.rb'
|
|
131
|
+
|
|
132
|
+
# Offense count: 1
|
|
133
|
+
Metrics/AbcSize:
|
|
134
|
+
Max: 20
|
|
135
|
+
|
|
136
|
+
# Offense count: 4
|
|
137
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
|
138
|
+
# ExcludedMethods: refine
|
|
139
|
+
Metrics/BlockLength:
|
|
140
|
+
Max: 91
|
|
141
|
+
|
|
142
|
+
# Offense count: 2
|
|
143
|
+
Metrics/CyclomaticComplexity:
|
|
144
|
+
Max: 15
|
|
145
|
+
|
|
146
|
+
# Offense count: 2
|
|
147
|
+
# Configuration parameters: CountComments.
|
|
148
|
+
Metrics/MethodLength:
|
|
149
|
+
Max: 33
|
|
150
|
+
|
|
151
|
+
# Offense count: 4
|
|
152
|
+
Style/Documentation:
|
|
153
|
+
Exclude:
|
|
154
|
+
# - 'spec/**/*'
|
|
155
|
+
# - 'test/**/*'
|
|
156
|
+
# - 'lib/itexmo/message.rb'
|
|
157
|
+
# - 'lib/itexmo/response_helper.rb'
|
|
158
|
+
# - 'lib/itexmo/service.rb'
|
|
159
|
+
# - 'lib/itexmo/sms.rb'
|
|
160
|
+
|
|
161
|
+
# Offense count: 1
|
|
162
|
+
# Cop supports --auto-correct.
|
|
163
|
+
Style/ExpandPathArguments:
|
|
164
|
+
Exclude:
|
|
165
|
+
# - 'itexmo.gemspec'
|
|
166
|
+
|
|
167
|
+
# Offense count: 1
|
|
168
|
+
# Cop supports --auto-correct.
|
|
169
|
+
# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
|
|
170
|
+
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
|
|
171
|
+
Style/HashSyntax:
|
|
172
|
+
Exclude:
|
|
173
|
+
# - 'Rakefile'
|
|
174
|
+
|
|
175
|
+
# Offense count: 6
|
|
176
|
+
# Cop supports --auto-correct.
|
|
177
|
+
Style/MutableConstant:
|
|
178
|
+
Exclude:
|
|
179
|
+
- 'lib/itexmo/message.rb'
|
|
180
|
+
# - 'lib/itexmo/service.rb'
|
|
181
|
+
- 'lib/itexmo/sms.rb'
|
|
182
|
+
# - 'lib/itexmo/version.rb'
|
|
183
|
+
|
|
184
|
+
# Offense count: 2
|
|
185
|
+
# Cop supports --auto-correct.
|
|
186
|
+
# Configuration parameters: PreferredDelimiters.
|
|
187
|
+
Style/PercentLiteralDelimiters:
|
|
188
|
+
Exclude:
|
|
189
|
+
# - 'itexmo.gemspec'
|
|
190
|
+
|
|
191
|
+
# Offense count: 26
|
|
192
|
+
# Cop supports --auto-correct.
|
|
193
|
+
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
|
|
194
|
+
# SupportedStyles: single_quotes, double_quotes
|
|
195
|
+
Style/StringLiterals:
|
|
196
|
+
Exclude:
|
|
197
|
+
# - 'Gemfile'
|
|
198
|
+
# - 'Rakefile'
|
|
199
|
+
# - 'bin/console'
|
|
200
|
+
# - 'itexmo.gemspec'
|
|
201
|
+
# - 'lib/itexmo/message.rb'
|
|
202
|
+
# - 'spec/itexmo_spec.rb'
|
|
203
|
+
# - 'spec/itextmo/sms_spec.rb'
|
|
204
|
+
# - 'spec/spec_helper.rb'
|
|
205
|
+
|
|
206
|
+
# Offense count: 1
|
|
207
|
+
# Cop supports --auto-correct.
|
|
208
|
+
# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, Whitelist.
|
|
209
|
+
# Whitelist: to_ary, to_a, to_c, to_enum, to_h, to_hash, to_i, to_int, to_io, to_open, to_path, to_proc, to_r, to_regexp, to_str, to_s, to_sym
|
|
210
|
+
Style/TrivialAccessors:
|
|
211
|
+
Exclude:
|
|
212
|
+
# - 'lib/itexmo/configuration.rb'
|
|
213
|
+
|
|
214
|
+
# Offense count: 2
|
|
215
|
+
# Cop supports --auto-correct.
|
|
216
|
+
Style/UnneededPercentQ:
|
|
217
|
+
Exclude:
|
|
218
|
+
# - 'itexmo.gemspec'
|
|
219
|
+
|
|
220
|
+
# Offense count: 46
|
|
221
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
|
222
|
+
# URISchemes: http, https
|
|
223
|
+
Metrics/LineLength:
|
|
224
|
+
Max: 226
|
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=92300106cf271985d719c3538c2910fbb7e707656a50bc7b3d8e43d8f1762801
|
|
11
|
+
|
|
12
|
+
before_script:
|
|
13
|
+
- bundle exec rspec && CODECLIMATE_REPO_TOKEN=92300106cf271985d719c3538c2910fbb7e707656a50bc7b3d8e43d8f1762801
|
|
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 denmarkmeralpis@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 itexmo.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/Gemfile.lock
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
itexmo (0.0.1)
|
|
5
|
+
|
|
6
|
+
GEM
|
|
7
|
+
remote: https://rubygems.org/
|
|
8
|
+
specs:
|
|
9
|
+
actioncable (5.2.0)
|
|
10
|
+
actionpack (= 5.2.0)
|
|
11
|
+
nio4r (~> 2.0)
|
|
12
|
+
websocket-driver (>= 0.6.1)
|
|
13
|
+
actionmailer (5.2.0)
|
|
14
|
+
actionpack (= 5.2.0)
|
|
15
|
+
actionview (= 5.2.0)
|
|
16
|
+
activejob (= 5.2.0)
|
|
17
|
+
mail (~> 2.5, >= 2.5.4)
|
|
18
|
+
rails-dom-testing (~> 2.0)
|
|
19
|
+
actionpack (5.2.0)
|
|
20
|
+
actionview (= 5.2.0)
|
|
21
|
+
activesupport (= 5.2.0)
|
|
22
|
+
rack (~> 2.0)
|
|
23
|
+
rack-test (>= 0.6.3)
|
|
24
|
+
rails-dom-testing (~> 2.0)
|
|
25
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
|
26
|
+
actionview (5.2.0)
|
|
27
|
+
activesupport (= 5.2.0)
|
|
28
|
+
builder (~> 3.1)
|
|
29
|
+
erubi (~> 1.4)
|
|
30
|
+
rails-dom-testing (~> 2.0)
|
|
31
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
|
32
|
+
activejob (5.2.0)
|
|
33
|
+
activesupport (= 5.2.0)
|
|
34
|
+
globalid (>= 0.3.6)
|
|
35
|
+
activemodel (5.2.0)
|
|
36
|
+
activesupport (= 5.2.0)
|
|
37
|
+
activerecord (5.2.0)
|
|
38
|
+
activemodel (= 5.2.0)
|
|
39
|
+
activesupport (= 5.2.0)
|
|
40
|
+
arel (>= 9.0)
|
|
41
|
+
activestorage (5.2.0)
|
|
42
|
+
actionpack (= 5.2.0)
|
|
43
|
+
activerecord (= 5.2.0)
|
|
44
|
+
marcel (~> 0.3.1)
|
|
45
|
+
activesupport (5.2.0)
|
|
46
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
47
|
+
i18n (>= 0.7, < 2)
|
|
48
|
+
minitest (~> 5.1)
|
|
49
|
+
tzinfo (~> 1.1)
|
|
50
|
+
addressable (2.5.2)
|
|
51
|
+
public_suffix (>= 2.0.2, < 4.0)
|
|
52
|
+
ansi (1.5.0)
|
|
53
|
+
arel (9.0.0)
|
|
54
|
+
ast (2.4.0)
|
|
55
|
+
builder (3.2.3)
|
|
56
|
+
byebug (10.0.2)
|
|
57
|
+
concurrent-ruby (1.0.5)
|
|
58
|
+
crack (0.4.3)
|
|
59
|
+
safe_yaml (~> 1.0.0)
|
|
60
|
+
crass (1.0.4)
|
|
61
|
+
diff-lcs (1.3)
|
|
62
|
+
docile (1.3.1)
|
|
63
|
+
dotenv (2.5.0)
|
|
64
|
+
erubi (1.7.1)
|
|
65
|
+
generator_spec (0.9.4)
|
|
66
|
+
activesupport (>= 3.0.0)
|
|
67
|
+
railties (>= 3.0.0)
|
|
68
|
+
globalid (0.4.1)
|
|
69
|
+
activesupport (>= 4.2.0)
|
|
70
|
+
hashdiff (0.3.7)
|
|
71
|
+
hirb (0.7.3)
|
|
72
|
+
i18n (1.0.1)
|
|
73
|
+
concurrent-ruby (~> 1.0)
|
|
74
|
+
jaro_winkler (1.5.1)
|
|
75
|
+
json (2.1.0)
|
|
76
|
+
loofah (2.2.2)
|
|
77
|
+
crass (~> 1.0.2)
|
|
78
|
+
nokogiri (>= 1.5.9)
|
|
79
|
+
mail (2.7.0)
|
|
80
|
+
mini_mime (>= 0.1.1)
|
|
81
|
+
marcel (0.3.2)
|
|
82
|
+
mimemagic (~> 0.3.2)
|
|
83
|
+
method_source (0.9.0)
|
|
84
|
+
mimemagic (0.3.2)
|
|
85
|
+
mini_mime (1.0.0)
|
|
86
|
+
mini_portile2 (2.3.0)
|
|
87
|
+
minitest (5.11.3)
|
|
88
|
+
nio4r (2.3.1)
|
|
89
|
+
nokogiri (1.8.4)
|
|
90
|
+
mini_portile2 (~> 2.3.0)
|
|
91
|
+
parallel (1.12.1)
|
|
92
|
+
parser (2.5.1.2)
|
|
93
|
+
ast (~> 2.4.0)
|
|
94
|
+
powerpack (0.1.2)
|
|
95
|
+
public_suffix (3.0.2)
|
|
96
|
+
rack (2.0.5)
|
|
97
|
+
rack-test (1.1.0)
|
|
98
|
+
rack (>= 1.0, < 3)
|
|
99
|
+
rails (5.2.0)
|
|
100
|
+
actioncable (= 5.2.0)
|
|
101
|
+
actionmailer (= 5.2.0)
|
|
102
|
+
actionpack (= 5.2.0)
|
|
103
|
+
actionview (= 5.2.0)
|
|
104
|
+
activejob (= 5.2.0)
|
|
105
|
+
activemodel (= 5.2.0)
|
|
106
|
+
activerecord (= 5.2.0)
|
|
107
|
+
activestorage (= 5.2.0)
|
|
108
|
+
activesupport (= 5.2.0)
|
|
109
|
+
bundler (>= 1.3.0)
|
|
110
|
+
railties (= 5.2.0)
|
|
111
|
+
sprockets-rails (>= 2.0.0)
|
|
112
|
+
rails-dom-testing (2.0.3)
|
|
113
|
+
activesupport (>= 4.2.0)
|
|
114
|
+
nokogiri (>= 1.6)
|
|
115
|
+
rails-html-sanitizer (1.0.4)
|
|
116
|
+
loofah (~> 2.2, >= 2.2.2)
|
|
117
|
+
railties (5.2.0)
|
|
118
|
+
actionpack (= 5.2.0)
|
|
119
|
+
activesupport (= 5.2.0)
|
|
120
|
+
method_source
|
|
121
|
+
rake (>= 0.8.7)
|
|
122
|
+
thor (>= 0.18.1, < 2.0)
|
|
123
|
+
rainbow (3.0.0)
|
|
124
|
+
rake (10.5.0)
|
|
125
|
+
rspec (3.7.0)
|
|
126
|
+
rspec-core (~> 3.7.0)
|
|
127
|
+
rspec-expectations (~> 3.7.0)
|
|
128
|
+
rspec-mocks (~> 3.7.0)
|
|
129
|
+
rspec-core (3.7.1)
|
|
130
|
+
rspec-support (~> 3.7.0)
|
|
131
|
+
rspec-expectations (3.7.0)
|
|
132
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
133
|
+
rspec-support (~> 3.7.0)
|
|
134
|
+
rspec-mocks (3.7.0)
|
|
135
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
136
|
+
rspec-support (~> 3.7.0)
|
|
137
|
+
rspec-support (3.7.1)
|
|
138
|
+
rubocop (0.58.2)
|
|
139
|
+
jaro_winkler (~> 1.5.1)
|
|
140
|
+
parallel (~> 1.10)
|
|
141
|
+
parser (>= 2.5, != 2.5.1.1)
|
|
142
|
+
powerpack (~> 0.1)
|
|
143
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
144
|
+
ruby-progressbar (~> 1.7)
|
|
145
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
|
146
|
+
ruby-progressbar (1.9.0)
|
|
147
|
+
safe_yaml (1.0.4)
|
|
148
|
+
simplecov (0.16.1)
|
|
149
|
+
docile (~> 1.1)
|
|
150
|
+
json (>= 1.8, < 3)
|
|
151
|
+
simplecov-html (~> 0.10.0)
|
|
152
|
+
simplecov-console (0.4.2)
|
|
153
|
+
ansi
|
|
154
|
+
hirb
|
|
155
|
+
simplecov
|
|
156
|
+
simplecov-html (0.10.2)
|
|
157
|
+
sprockets (3.7.2)
|
|
158
|
+
concurrent-ruby (~> 1.0)
|
|
159
|
+
rack (> 1, < 3)
|
|
160
|
+
sprockets-rails (3.2.1)
|
|
161
|
+
actionpack (>= 4.0)
|
|
162
|
+
activesupport (>= 4.0)
|
|
163
|
+
sprockets (>= 3.0.0)
|
|
164
|
+
thor (0.20.0)
|
|
165
|
+
thread_safe (0.3.6)
|
|
166
|
+
tzinfo (1.2.5)
|
|
167
|
+
thread_safe (~> 0.1)
|
|
168
|
+
unicode-display_width (1.4.0)
|
|
169
|
+
webmock (3.4.2)
|
|
170
|
+
addressable (>= 2.3.6)
|
|
171
|
+
crack (>= 0.3.2)
|
|
172
|
+
hashdiff
|
|
173
|
+
websocket-driver (0.7.0)
|
|
174
|
+
websocket-extensions (>= 0.1.0)
|
|
175
|
+
websocket-extensions (0.1.3)
|
|
176
|
+
|
|
177
|
+
PLATFORMS
|
|
178
|
+
ruby
|
|
179
|
+
|
|
180
|
+
DEPENDENCIES
|
|
181
|
+
bundler (~> 1.16)
|
|
182
|
+
byebug
|
|
183
|
+
dotenv (~> 2.5)
|
|
184
|
+
generator_spec
|
|
185
|
+
itexmo!
|
|
186
|
+
rails (~> 5.2)
|
|
187
|
+
rake (~> 10.0)
|
|
188
|
+
rspec (~> 3.0)
|
|
189
|
+
rubocop
|
|
190
|
+
simplecov
|
|
191
|
+
simplecov-console
|
|
192
|
+
webmock (~> 3.4)
|
|
193
|
+
|
|
194
|
+
BUNDLED WITH
|
|
195
|
+
1.16.1
|
data/LICENSE-MIT.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 Nujian Den Mark Meralpis
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
[](https://travis-ci.org/denmarkmeralpis/itexmo) [](https://codeclimate.com/github/denmarkmeralpis/itexmo/maintainability) [](https://codeclimate.com/github/denmarkmeralpis/itexmo/test_coverage) [](https://badge.fury.io/rb/itexmo)
|
|
2
|
+
|
|
3
|
+
# iTexMo Ruby Plugin
|
|
4
|
+
A ruby plugin that uses the iTexMo REST API. You can send SMS using itextmo gem without hassle.
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
Add this line to your application's Gemfile:
|
|
9
|
+
|
|
10
|
+
```ruby
|
|
11
|
+
gem 'itexmo'
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
And then execute:
|
|
15
|
+
|
|
16
|
+
$ bundle
|
|
17
|
+
|
|
18
|
+
Or install it yourself as:
|
|
19
|
+
|
|
20
|
+
$ gem install itexmo
|
|
21
|
+
|
|
22
|
+
Finally, generate initializer
|
|
23
|
+
|
|
24
|
+
$ rails g initializer:itexmo
|
|
25
|
+
|
|
26
|
+
this will create a file under `config/initializer/itexmo.rb` Note: `api_code` should be supplied inside the itextmo.rb.
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
### I. Sending an SMS
|
|
30
|
+
Two ways of sending SMS
|
|
31
|
+
```ruby
|
|
32
|
+
message = Itexmo::Message.new(message: 'Your awesome message!', to: '0917XXXXXXX')
|
|
33
|
+
message.send
|
|
34
|
+
```
|
|
35
|
+
or simply:
|
|
36
|
+
|
|
37
|
+
```ruby
|
|
38
|
+
Itexmo::Message.send(message: 'Your awesome message!', to: '0917XXXXXXXX')
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### II. Checking of Service
|
|
42
|
+
```ruby
|
|
43
|
+
#Check API Service Status and your SMS Server Status
|
|
44
|
+
Itexmo::Service.status
|
|
45
|
+
|
|
46
|
+
# Check `api_code` Info and Status
|
|
47
|
+
Itexmo::Service.apicode_info
|
|
48
|
+
```
|
|
49
|
+
### III. SMS Reports/Actions
|
|
50
|
+
```ruby
|
|
51
|
+
# Show Pending or Outgoing SMS:
|
|
52
|
+
Itexmo::Sms.display_outgoing('desc') # default order is 'asc'
|
|
53
|
+
|
|
54
|
+
# Delete All Pending or Outgoing SMS:
|
|
55
|
+
Itexmo::Sms.delete_all_outgoing
|
|
56
|
+
|
|
57
|
+
# Return All SMS Received (Corporate Premium Apicodes)
|
|
58
|
+
Itexmo::Sms.display_messages
|
|
59
|
+
|
|
60
|
+
# Return All SMS Received using Originator as Filter (Corporate Premium Apicodes)
|
|
61
|
+
Itexmo::Sms.display_messages_via_originator('0917XXXXXXX')
|
|
62
|
+
|
|
63
|
+
# Delete All SMS Received using Originator as Filter (Corporate Premium Apicodes)
|
|
64
|
+
Itexmo::Sms.delete_message_via_originator('0917XXXXXXX')
|
|
65
|
+
|
|
66
|
+
# Delete an SMS Received using SMS ID as filter (Corporate Premium Apicodes)
|
|
67
|
+
Itexmo::Sms.delete_message_via_id('105')
|
|
68
|
+
|
|
69
|
+
# Delete All SMS Received (Corporate Premium Apicodes)
|
|
70
|
+
Itexmo::Sms.delete_messages_all
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Contributing
|
|
74
|
+
|
|
75
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/denmarkmeralpis/itexmo. 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.
|
|
76
|
+
|
|
77
|
+
## Code of Conduct
|
|
78
|
+
|
|
79
|
+
Everyone interacting in the Itexmo project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[denmarkmeralpis]/itexmo/blob/master/CODE_OF_CONDUCT.md).
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
## License
|
|
83
|
+
|
|
84
|
+
The gem is available as open source under the terms of the [MIT License](https://github.com/denmarkmeralpis/itexmo/blob/master/LICENSE.txt).
|
|
85
|
+
|
|
86
|
+
## Donate
|
|
87
|
+
|
|
88
|
+
[](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=nujiandenmarkmeralpis@gmail.com&lc=US&item_name=For+Living&no_note=0&cn=&curency_code=USD&bn=PP-DonationsBF:btn_donateCC_LG.gif:NonHosted)
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'bundler/setup'
|
|
4
|
+
require 'itexmo'
|
|
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
data/itexmo.gemspec
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
|
+
require 'itexmo/version'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = 'itexmo'
|
|
7
|
+
spec.version = Itexmo::VERSION
|
|
8
|
+
spec.authors = ['Nujian Den Mark Meralpis']
|
|
9
|
+
spec.email = ['denmarkmeralpis@gmail.com']
|
|
10
|
+
|
|
11
|
+
spec.summary = 'A ruby plugin for sending SMS using itexmo API.'
|
|
12
|
+
spec.description = 'A very simple way of sending SMS through itexmo.com REST API'
|
|
13
|
+
spec.homepage = 'https://github.com/denmarkmeralpis/itexmo'
|
|
14
|
+
spec.license = 'MIT'
|
|
15
|
+
|
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
|
18
|
+
if spec.respond_to?(:metadata)
|
|
19
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
|
20
|
+
else
|
|
21
|
+
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
|
22
|
+
'public gem pushes.'
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
26
|
+
f.match(%r{^(test|spec|features)/})
|
|
27
|
+
end
|
|
28
|
+
spec.bindir = 'exe'
|
|
29
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
30
|
+
spec.require_paths = ['lib']
|
|
31
|
+
|
|
32
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
|
33
|
+
spec.add_development_dependency 'dotenv', '~> 2.5'
|
|
34
|
+
spec.add_development_dependency 'rails', '~> 5.2'
|
|
35
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
|
36
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
|
37
|
+
spec.add_development_dependency 'webmock', '~> 3.4'
|
|
38
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'rails/generators'
|
|
2
|
+
|
|
3
|
+
# name
|
|
4
|
+
module Itexmo
|
|
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 itexmo.rb initializer for your application'
|
|
11
|
+
|
|
12
|
+
def copy_initializer
|
|
13
|
+
template 'itexmo_initializer.rb', 'config/initializers/itexmo.rb'
|
|
14
|
+
puts 'Done install! Configure the file in config/initializers/itexmo.rb'
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
data/lib/itexmo.rb
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require 'itexmo/version'
|
|
2
|
+
require 'itexmo/response_helper'
|
|
3
|
+
require 'itexmo/configuration'
|
|
4
|
+
require 'itexmo/message'
|
|
5
|
+
require 'itexmo/service'
|
|
6
|
+
require 'itexmo/sms'
|
|
7
|
+
require 'itexmo/errors/authentication'
|
|
8
|
+
require 'itexmo/errors/configuration'
|
|
9
|
+
require 'itexmo/errors/bad_request'
|
|
10
|
+
require 'generators/itexmo/install_generator'
|
|
11
|
+
|
|
12
|
+
# itexmo configuration block
|
|
13
|
+
module Itexmo
|
|
14
|
+
# class
|
|
15
|
+
class << self
|
|
16
|
+
attr_accessor :configuration
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.configuration
|
|
20
|
+
@configuration ||= Configuration.new
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def self.reset
|
|
24
|
+
@configuration = Configuration.new
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def self.configure
|
|
28
|
+
yield(configuration)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# itexmo module
|
|
2
|
+
module Itexmo
|
|
3
|
+
# cofiguration class
|
|
4
|
+
class Configuration
|
|
5
|
+
attr_writer :api_code, :priority
|
|
6
|
+
|
|
7
|
+
def initialize
|
|
8
|
+
@api_code = nil
|
|
9
|
+
@priority = 'NORMAL'
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def api_code
|
|
13
|
+
raise Errors::Configuration, 'Itexmo api_code is missing! See documentation for configuration settings.' unless @api_code
|
|
14
|
+
@api_code
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
attr_reader :priority
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
require 'net/http'
|
|
2
|
+
require 'json'
|
|
3
|
+
|
|
4
|
+
# module
|
|
5
|
+
module Itexmo
|
|
6
|
+
# message class
|
|
7
|
+
class Message
|
|
8
|
+
attr_accessor :api_code, :message, :to
|
|
9
|
+
|
|
10
|
+
PARAMS = {}
|
|
11
|
+
API_ENDPOINT = 'https://www.itexmo.com/php_api'.freeze
|
|
12
|
+
|
|
13
|
+
def initialize(options = {})
|
|
14
|
+
@api_code = Itexmo.configuration.api_code
|
|
15
|
+
@message = options[:message]
|
|
16
|
+
@priority = options[:priority]
|
|
17
|
+
@to = options[:to]
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# default is NORMAL
|
|
21
|
+
def priority
|
|
22
|
+
@priority ||= Itexmo.configuration.priority
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def send
|
|
26
|
+
uri = URI(API_ENDPOINT + '/api.php')
|
|
27
|
+
|
|
28
|
+
request = Net::HTTP.post_form(uri, parameters)
|
|
29
|
+
response = request.body
|
|
30
|
+
|
|
31
|
+
case response
|
|
32
|
+
when '0'
|
|
33
|
+
{ code: 200, message: 'Success! Message is now on queue and will be sent soon.' }
|
|
34
|
+
when '1'
|
|
35
|
+
raise Errors::BadRequest, 'Invalid value for parameter to'
|
|
36
|
+
when '2'
|
|
37
|
+
raise Errors::BadRequest, 'Number prefix not supported. Please contact itexmo'
|
|
38
|
+
when '3'
|
|
39
|
+
raise Errors::Authentication, 'Invalid api_code'
|
|
40
|
+
when '4'
|
|
41
|
+
{ code: 400, message: 'Maximum Message per day reached. This will be reset every 12MN' }
|
|
42
|
+
when '5'
|
|
43
|
+
raise Errors::BadRequest, 'Maximum allowed characters for message reached'
|
|
44
|
+
when '6'
|
|
45
|
+
{ code: 422, message: 'System OFFLINE' }
|
|
46
|
+
when '7'
|
|
47
|
+
raise Errors::Authentication, 'Expired ApiCode'
|
|
48
|
+
when '8'
|
|
49
|
+
{ code: 500, message: 'iTexMo Error. Please try again later.' }
|
|
50
|
+
when '9'
|
|
51
|
+
raise Errors::BadRequest, 'Invalid Function Parameters'
|
|
52
|
+
when '10'
|
|
53
|
+
{ code: 422, message: "Recipient's number is blocked due to FLOODING, message was ignored" }
|
|
54
|
+
when '11'
|
|
55
|
+
{ code: 422, message: "Recipient's number is blocked temporarily due to HARD sending (after 3 retries of sending and message still failed to send) and the message was ignored. Try again after an hour. " }
|
|
56
|
+
when '12'
|
|
57
|
+
raise Errors::BadRequest, "Invalid request. You can't set message priorities on non corporate apicodes"
|
|
58
|
+
when '13'
|
|
59
|
+
raise Errors::BadRequest, 'Invalid or Not Registered Custom Sender ID.'
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def self.send(options = {})
|
|
64
|
+
instance = new(options)
|
|
65
|
+
instance.send
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
private
|
|
69
|
+
|
|
70
|
+
def parameters
|
|
71
|
+
PARAMS['1'] = to
|
|
72
|
+
PARAMS['2'] = message
|
|
73
|
+
PARAMS['3'] = api_code
|
|
74
|
+
PARAMS['5'] = priority
|
|
75
|
+
PARAMS
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require 'net/http'
|
|
2
|
+
require 'json'
|
|
3
|
+
# helper
|
|
4
|
+
module Itexmo
|
|
5
|
+
# helper
|
|
6
|
+
class ResponseHelper
|
|
7
|
+
attr_accessor :body
|
|
8
|
+
|
|
9
|
+
def initialize(body)
|
|
10
|
+
@body = body
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def parse
|
|
14
|
+
case body
|
|
15
|
+
when 'INVALID', 'INVALID_APICODE'
|
|
16
|
+
raise Errors::Authentication, 'invalid api_code'
|
|
17
|
+
when 'INVALID PARAMETERS'
|
|
18
|
+
raise Errors::BadRequest, 'invalid parameters'
|
|
19
|
+
when 'EMPTY'
|
|
20
|
+
[]
|
|
21
|
+
when 'ERROR'
|
|
22
|
+
{ code: 422, message: 'unable to do action' }
|
|
23
|
+
when 'SUCCESS'
|
|
24
|
+
{ code: 200, message: 'action succeeded' }
|
|
25
|
+
when 'NOT_SUPPORTED'
|
|
26
|
+
raise Errors::Authentication, 'api_code is not a corporate one'
|
|
27
|
+
else
|
|
28
|
+
JSON.parse(body, symbolize_names: true)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def self.parse(body)
|
|
33
|
+
instance = new(body)
|
|
34
|
+
instance.parse
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require 'net/http'
|
|
2
|
+
require 'json'
|
|
3
|
+
# module
|
|
4
|
+
module Itexmo
|
|
5
|
+
# service
|
|
6
|
+
class Service
|
|
7
|
+
attr_accessor :api_code
|
|
8
|
+
|
|
9
|
+
API_ENDPOINT = 'https://www.itexmo.com/php_api'.freeze
|
|
10
|
+
|
|
11
|
+
def initialize
|
|
12
|
+
@api_code = Itexmo.configuration.api_code
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def status
|
|
16
|
+
uri = URI(API_ENDPOINT + '/serverstatus.php')
|
|
17
|
+
uri.query = URI.encode_www_form(parameters)
|
|
18
|
+
request = Net::HTTP.get_response(uri)
|
|
19
|
+
ResponseHelper.parse(request.body)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.status
|
|
23
|
+
instance = new
|
|
24
|
+
instance.status
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def apicode_info
|
|
28
|
+
uri = URI(API_ENDPOINT + '/apicode_info.php')
|
|
29
|
+
uri.query = URI.encode_www_form(parameters)
|
|
30
|
+
request = Net::HTTP.get_response(uri)
|
|
31
|
+
ResponseHelper.parse(request.body)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def self.apicode_info
|
|
35
|
+
instance = new
|
|
36
|
+
instance.apicode_info
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
private
|
|
40
|
+
|
|
41
|
+
def parameters
|
|
42
|
+
{ 'apicode' => api_code }
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
data/lib/itexmo/sms.rb
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
require 'net/http'
|
|
2
|
+
require 'json'
|
|
3
|
+
# module
|
|
4
|
+
module Itexmo
|
|
5
|
+
# sms
|
|
6
|
+
class Sms
|
|
7
|
+
attr_accessor :api_code
|
|
8
|
+
|
|
9
|
+
API_ENDPOINT = 'https://www.itexmo.com/php_api'.freeze
|
|
10
|
+
PARAMETERS = {}
|
|
11
|
+
|
|
12
|
+
def initialize
|
|
13
|
+
@api_code = Itexmo.configuration.api_code
|
|
14
|
+
PARAMETERS['apicode'] = api_code
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def display_outgoing(sortby = 'asc')
|
|
18
|
+
PARAMETERS[:sortby] = sortby
|
|
19
|
+
uri = URI(API_ENDPOINT + '/display_outgoing.php')
|
|
20
|
+
uri.query = URI.encode_www_form(PARAMETERS)
|
|
21
|
+
request = Net::HTTP.get_response(uri)
|
|
22
|
+
PARAMETERS.except!(:sortby)
|
|
23
|
+
ResponseHelper.parse(request.body)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.display_outgoing(sortby = 'asc')
|
|
27
|
+
instance = new
|
|
28
|
+
instance.display_outgoing(sortby)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def delete_all_outgoing
|
|
32
|
+
uri = URI(API_ENDPOINT + '/delete_outgoing_all.php')
|
|
33
|
+
uri.query = URI.encode_www_form(PARAMETERS)
|
|
34
|
+
request = Net::HTTP.get_response(uri)
|
|
35
|
+
ResponseHelper.parse(request.body)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def self.delete_all_outgoing
|
|
39
|
+
instance = new
|
|
40
|
+
instance.delete_all_outgoing
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def display_messages
|
|
44
|
+
uri = URI(API_ENDPOINT + '/display_messages.php')
|
|
45
|
+
uri.query = URI.encode_www_form(PARAMETERS)
|
|
46
|
+
request = Net::HTTP.get_response(uri)
|
|
47
|
+
ResponseHelper.parse(request.body)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def self.display_messages
|
|
51
|
+
instance = new
|
|
52
|
+
instance.display_messages
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def display_messages_via_originator(originator)
|
|
56
|
+
PARAMETERS[:originator] = originator
|
|
57
|
+
uri = URI(API_ENDPOINT + '/display_messages_via_originator.php')
|
|
58
|
+
uri.query = URI.encode_www_form(PARAMETERS)
|
|
59
|
+
request = Net::HTTP.get_response(uri)
|
|
60
|
+
PARAMETERS.except!(:originator)
|
|
61
|
+
ResponseHelper.parse(request.body)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def self.display_messages_via_originator(originator)
|
|
65
|
+
instance = new
|
|
66
|
+
instance.display_messages_via_originator(originator)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def delete_message_via_originator(originator)
|
|
70
|
+
PARAMETERS[:originator] = originator
|
|
71
|
+
uri = URI(API_ENDPOINT + '/delete_message_via_originator.php')
|
|
72
|
+
uri.query = URI.encode_www_form(PARAMETERS)
|
|
73
|
+
request = Net::HTTP.get_response(uri)
|
|
74
|
+
PARAMETERS.except!(:originator)
|
|
75
|
+
ResponseHelper.parse(request.body)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def self.delete_message_via_originator(originator)
|
|
79
|
+
instance = new
|
|
80
|
+
instance.delete_message_via_originator(originator)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def delete_message_via_id(id)
|
|
84
|
+
PARAMETERS[:id] = id
|
|
85
|
+
uri = URI(API_ENDPOINT + '/delete_message_via_id.php')
|
|
86
|
+
uri.query = URI.encode_www_form(PARAMETERS)
|
|
87
|
+
request = Net::HTTP.get_response(uri)
|
|
88
|
+
PARAMETERS.except!(:id)
|
|
89
|
+
ResponseHelper.parse(request.body)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def self.delete_message_via_id(originator)
|
|
93
|
+
instance = new
|
|
94
|
+
instance.delete_message_via_id(originator)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def delete_messages_all
|
|
98
|
+
uri = URI(API_ENDPOINT + '/delete_messages_all.php')
|
|
99
|
+
uri.query = URI.encode_www_form(PARAMETERS)
|
|
100
|
+
request = Net::HTTP.get_response(uri)
|
|
101
|
+
ResponseHelper.parse(request.body)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def self.delete_messages_all
|
|
105
|
+
instance = new
|
|
106
|
+
instance.delete_messages_all
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: itexmo
|
|
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-29 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: A very simple way of sending SMS through itexmo.com REST API
|
|
98
|
+
email:
|
|
99
|
+
- denmarkmeralpis@gmail.com
|
|
100
|
+
executables: []
|
|
101
|
+
extensions: []
|
|
102
|
+
extra_rdoc_files: []
|
|
103
|
+
files:
|
|
104
|
+
- ".env.sample"
|
|
105
|
+
- ".gitignore"
|
|
106
|
+
- ".rspec"
|
|
107
|
+
- ".rubocop.yml"
|
|
108
|
+
- ".rubocop_todo.yml"
|
|
109
|
+
- ".travis.yml"
|
|
110
|
+
- CODE_OF_CONDUCT.md
|
|
111
|
+
- Gemfile
|
|
112
|
+
- Gemfile.lock
|
|
113
|
+
- LICENSE-MIT.md
|
|
114
|
+
- README.md
|
|
115
|
+
- Rakefile
|
|
116
|
+
- bin/console
|
|
117
|
+
- bin/setup
|
|
118
|
+
- itexmo.gemspec
|
|
119
|
+
- lib/generators/itexmo/install_generator.rb
|
|
120
|
+
- lib/generators/itexmo/templates/itexmo_initializer.rb
|
|
121
|
+
- lib/itexmo.rb
|
|
122
|
+
- lib/itexmo/configuration.rb
|
|
123
|
+
- lib/itexmo/errors/authentication.rb
|
|
124
|
+
- lib/itexmo/errors/bad_request.rb
|
|
125
|
+
- lib/itexmo/errors/configuration.rb
|
|
126
|
+
- lib/itexmo/message.rb
|
|
127
|
+
- lib/itexmo/response_helper.rb
|
|
128
|
+
- lib/itexmo/service.rb
|
|
129
|
+
- lib/itexmo/sms.rb
|
|
130
|
+
- lib/itexmo/version.rb
|
|
131
|
+
homepage: https://github.com/denmarkmeralpis/itexmo
|
|
132
|
+
licenses:
|
|
133
|
+
- MIT
|
|
134
|
+
metadata:
|
|
135
|
+
allowed_push_host: https://rubygems.org
|
|
136
|
+
post_install_message:
|
|
137
|
+
rdoc_options: []
|
|
138
|
+
require_paths:
|
|
139
|
+
- lib
|
|
140
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
141
|
+
requirements:
|
|
142
|
+
- - ">="
|
|
143
|
+
- !ruby/object:Gem::Version
|
|
144
|
+
version: '0'
|
|
145
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
|
+
requirements:
|
|
147
|
+
- - ">="
|
|
148
|
+
- !ruby/object:Gem::Version
|
|
149
|
+
version: '0'
|
|
150
|
+
requirements: []
|
|
151
|
+
rubyforge_project:
|
|
152
|
+
rubygems_version: 2.7.6
|
|
153
|
+
signing_key:
|
|
154
|
+
specification_version: 4
|
|
155
|
+
summary: A ruby plugin for sending SMS using itexmo API.
|
|
156
|
+
test_files: []
|