greensms 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ .gem/
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.0
6
+ before_install: gem install bundler -v 2.1.2
@@ -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
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in greensms.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "minitest", "~> 5.0"
@@ -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
@@ -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.
@@ -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/
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
@@ -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__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,12 @@
1
+ require_relative "init"
2
+
3
+ @client = Example::CLIENT
4
+
5
+ puts "Account Balance"
6
+ puts @client.account.balance
7
+
8
+ puts "Access Token"
9
+ puts @client.account.token(token: 100)
10
+
11
+ puts "Tariff"
12
+ puts @client.account.tariff
@@ -0,0 +1,11 @@
1
+ require_relative "init"
2
+
3
+ @client = Example::CLIENT
4
+
5
+ puts "Call Send"
6
+ resp = @client.call.send(to: "79260000112")
7
+ puts resp
8
+
9
+ sleep(3)
10
+ puts "Call Status"
11
+ puts @client.call.status(id: resp["request_id"])
@@ -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")
@@ -0,0 +1,6 @@
1
+ require_relative "init"
2
+
3
+ @client = Example::CLIENT
4
+
5
+ puts "Server Status"
6
+ puts @client.status
@@ -0,0 +1,11 @@
1
+ require_relative "init"
2
+
3
+ @client = Example::CLIENT
4
+
5
+ puts "HLR Send"
6
+ resp = @client.hlr.send(to: "79260000121", txt: "1221")
7
+ puts resp
8
+
9
+ sleep(3)
10
+ puts "HLR Status"
11
+ puts @client.hlr.status(id: resp["request_id"], to: "79260000121")
@@ -0,0 +1,6 @@
1
+ $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
2
+ require "greensms"
3
+
4
+ module Example
5
+ CLIENT = GreenSMS::GreenSMSClient.new(user: "test", pass: "test")
6
+ end
@@ -0,0 +1,11 @@
1
+ require_relative "init"
2
+
3
+ @client = Example::CLIENT
4
+
5
+ puts "Pay Send"
6
+ resp = @client.pay.send(to: "79260000121", amount: 10)
7
+ puts resp
8
+
9
+ sleep(3)
10
+ puts "Pay Status"
11
+ puts @client.pay.status(id: resp["request_id"])
@@ -0,0 +1,11 @@
1
+ require_relative "init"
2
+
3
+ @client = Example::CLIENT
4
+
5
+ puts "SMS Send"
6
+ resp = @client.sms.send(to: "79260000121", txt: "Hello Message Content")
7
+ puts resp
8
+
9
+ sleep(3)
10
+ puts "SMS Status"
11
+ puts @client.sms.status(id: resp["request_id"])
@@ -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"])