greensms 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.github/workflows/ruby.yml +35 -0
- data/.gitignore +9 -0
- data/.travis.yml +6 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +35 -0
- data/LICENSE.txt +21 -0
- data/README.md +102 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/examples/account.rb +12 -0
- data/examples/call.rb +11 -0
- data/examples/env.rb +13 -0
- data/examples/general.rb +6 -0
- data/examples/hlr.rb +11 -0
- data/examples/init.rb +6 -0
- data/examples/pay.rb +11 -0
- data/examples/sms.rb +11 -0
- data/examples/social.rb +11 -0
- data/examples/token.rb +11 -0
- data/examples/viber.rb +11 -0
- data/examples/voice.rb +11 -0
- data/examples/whois.rb +6 -0
- data/greensms.gemspec +33 -0
- data/lib/greensms.rb +6 -0
- data/lib/greensms/api/module.rb +37 -0
- data/lib/greensms/api/module_loader.rb +89 -0
- data/lib/greensms/api/modules.rb +153 -0
- data/lib/greensms/api/schema.rb +186 -0
- data/lib/greensms/client.rb +100 -0
- data/lib/greensms/constants.rb +10 -0
- data/lib/greensms/http/error.rb +32 -0
- data/lib/greensms/http/rest.rb +86 -0
- data/lib/greensms/utils/str.rb +24 -0
- data/lib/greensms/utils/url.rb +17 -0
- data/lib/greensms/utils/validator.rb +12 -0
- data/lib/greensms/utils/version.rb +18 -0
- data/lib/greensms/version.rb +3 -0
- metadata +141 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c9f0683de25ff0c40f5ed19b27a8e7d0997a7218e1151a39002f688e8b508827
|
4
|
+
data.tar.gz: c04d47dc7606f116bf7007697bed9e26b76d3c01822a0ad19188a322de58b177
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7b98db04817d0e0d7f59466179dd1cf72ff77a4c8003d0246cb42607ee622d37490d1b28b51e2aabf7f3a2a6018b64670c2ac2a71e21896643d45fc8e7f03d42
|
7
|
+
data.tar.gz: 6276b86e31157afa79854d98d0707f1e0b87b3f0edaacbc841051124d338897dad262b769b3a518fe4e4e5cd392cd5410684990662413b12734f4884c9e8ae78
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Ruby
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: [main]
|
13
|
+
pull_request:
|
14
|
+
branches: [main]
|
15
|
+
|
16
|
+
jobs:
|
17
|
+
test:
|
18
|
+
runs-on: ubuntu-latest
|
19
|
+
strategy:
|
20
|
+
matrix:
|
21
|
+
ruby: [ '2.6' ]
|
22
|
+
|
23
|
+
steps:
|
24
|
+
- uses: actions/checkout@v2
|
25
|
+
- name: Set up Ruby
|
26
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
27
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
28
|
+
uses: ruby/setup-ruby@v1
|
29
|
+
#uses: ruby/setup-ruby@ec106b438a1ff6ff109590de34ddc62c540232e0
|
30
|
+
with:
|
31
|
+
ruby-version: ${{ matrix.ruby }}
|
32
|
+
- name: Install dependencies
|
33
|
+
run: bundle install
|
34
|
+
- name: Run tests
|
35
|
+
run: bundle exec rake
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
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 [support@greensms.ru](mailto:support@greensms.ru). 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 [https://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: https://contributor-covenant.org
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
greensms (0.1.0)
|
5
|
+
faraday
|
6
|
+
json-schema
|
7
|
+
rake
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
addressable (2.7.0)
|
13
|
+
public_suffix (>= 2.0.2, < 5.0)
|
14
|
+
faraday (1.1.0)
|
15
|
+
multipart-post (>= 1.2, < 3)
|
16
|
+
ruby2_keywords
|
17
|
+
json-schema (2.8.1)
|
18
|
+
addressable (>= 2.4)
|
19
|
+
minitest (5.14.2)
|
20
|
+
multipart-post (2.1.1)
|
21
|
+
public_suffix (4.0.6)
|
22
|
+
rake (12.3.3)
|
23
|
+
ruby2_keywords (0.0.2)
|
24
|
+
|
25
|
+
PLATFORMS
|
26
|
+
ruby
|
27
|
+
|
28
|
+
DEPENDENCIES
|
29
|
+
bundler (>= 1.0.0)
|
30
|
+
greensms!
|
31
|
+
minitest (~> 5.0)
|
32
|
+
rake (~> 12.0)
|
33
|
+
|
34
|
+
BUNDLED WITH
|
35
|
+
2.1.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Manan Jadhav
|
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,102 @@
|
|
1
|
+
# greensms-ruby
|
2
|
+
|
3
|
+
## Documentation
|
4
|
+
|
5
|
+
The documentation for the GREENSMS API can be found [here][apidocs].
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'greensms'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
```bash
|
18
|
+
$ bundle install
|
19
|
+
```
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
```
|
24
|
+
$ gem install greensms
|
25
|
+
```
|
26
|
+
|
27
|
+
## Sample Usage
|
28
|
+
|
29
|
+
Check out these [code examples](examples) to get up and running quickly.
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
|
33
|
+
require "greensms"
|
34
|
+
|
35
|
+
# Register at my.greeensms.ru first
|
36
|
+
@client = GreenSMS::GreenSMSClient.new(user: "test", pass: "test")
|
37
|
+
|
38
|
+
response = @client.sms.send(to: '71231234567', txt: 'Message to deliver')
|
39
|
+
puts response["request_id"]
|
40
|
+
|
41
|
+
|
42
|
+
```
|
43
|
+
|
44
|
+
### Environment Variables
|
45
|
+
|
46
|
+
`greensms-ruby` supports credential storage in environment variables. If no credentials are provided following env vars will be used: `GREENSMS_USER`/`GREENSMS_PASS` OR `GREENSMS_TOKEN`
|
47
|
+
|
48
|
+
### Token Auth
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
|
52
|
+
require "greensms"
|
53
|
+
|
54
|
+
# Register at my.greeensms.ru first
|
55
|
+
@client = GreenSMS::GreenSMSClient.new(token: "Your Auth Token comes here")
|
56
|
+
|
57
|
+
response = @client.account.balance
|
58
|
+
puts response["balance"]
|
59
|
+
|
60
|
+
|
61
|
+
```
|
62
|
+
|
63
|
+
## Compatibility
|
64
|
+
|
65
|
+
`greensms-ruby` is compatible with Ruby 2.4+ onwards until the latest version
|
66
|
+
|
67
|
+
## Methods
|
68
|
+
|
69
|
+
- You can either use username/password combination or auth token to create an object with constructor
|
70
|
+
- All methods support named keyword arguments `(to: "", extended: true)`
|
71
|
+
- Each API Function is available as `MODULE.FUNCTION()`
|
72
|
+
- Parameters for each API can be referred from [here][apidocs]
|
73
|
+
- Response keys can be used as hash keys `response['key']`
|
74
|
+
- Response keys by default are available in `snake_case`. If you want to use `camelCase`, then pass `camel_case_response: true`, in the constructor
|
75
|
+
|
76
|
+
## Handling Exceptions
|
77
|
+
|
78
|
+
- Exceptions for all APIs are thrown with `RestError` class. It extends the default Ruby StandardError class.
|
79
|
+
- Each error, will have `error`, `code`, `message`, `errorType` fields.
|
80
|
+
- In case of _Validation Error_, additional params are available to show field-wise rule failures. Can be accessed by `e.params` property on the error object
|
81
|
+
|
82
|
+
## Getting help
|
83
|
+
|
84
|
+
If you need help installing or using the library, please contact us: [support@greensms.ru](mailto:support@greensms.ru).
|
85
|
+
|
86
|
+
If you've instead found a bug in the library or would like new features added, go ahead and open issues or pull requests against this repo!
|
87
|
+
|
88
|
+
## Development
|
89
|
+
|
90
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
91
|
+
|
92
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
93
|
+
|
94
|
+
## Contributing
|
95
|
+
|
96
|
+
Bug reports and pull requests are welcome on GitHub [here](https://github.com/greensms-ru/greensms-ruby). If you're not familiar with the GitHub pull request/contribution process, [this is a nice tutorial](https://gun.io/blog/how-to-github-fork-branch-and-pull-request/).
|
97
|
+
|
98
|
+
## License
|
99
|
+
|
100
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
101
|
+
|
102
|
+
[apidocs]: https://api.greensms.ru/
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "greensms"
|
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/examples/account.rb
ADDED
data/examples/call.rb
ADDED
data/examples/env.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require_relative "init"
|
2
|
+
|
3
|
+
puts "Set Env Variables"
|
4
|
+
ENV["GREENSMS_USER"] = "test"
|
5
|
+
ENV["GREENSMS_PASS"] = "test"
|
6
|
+
|
7
|
+
puts "\nExecute Client Example"
|
8
|
+
@env_client = GreenSMS::GreenSMSClient.new
|
9
|
+
puts @env_client.account.balance
|
10
|
+
|
11
|
+
puts "\nDelete Env Variables"
|
12
|
+
ENV.delete("GREENSMS_USER")
|
13
|
+
ENV.delete("GREENSMS_PASS")
|
data/examples/general.rb
ADDED
data/examples/hlr.rb
ADDED
data/examples/init.rb
ADDED
data/examples/pay.rb
ADDED
data/examples/sms.rb
ADDED
data/examples/social.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require_relative "init"
|
2
|
+
|
3
|
+
@client = Example::CLIENT
|
4
|
+
|
5
|
+
puts "Social Send"
|
6
|
+
resp = @client.social.send(to: "79260000121", txt: "Hello Message Content", from: "GreenSMS")
|
7
|
+
puts resp
|
8
|
+
|
9
|
+
sleep(3)
|
10
|
+
puts "Social Status"
|
11
|
+
puts @client.social.status(id: resp["request_id"])
|