smsapi-client 0.3.1 → 1.0.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 +4 -4
- data/CHANGELOG.md +17 -0
- data/README.md +5 -5
- data/lib/{smsapi/smsapi.rb → smsapi.rb} +1 -1
- data/lib/smsapi/client.rb +2 -2
- data/lib/smsapi/client/version.rb +3 -0
- data/lib/smsapi/server.rb +5 -11
- data/lib/smsapi/server/connection.rb +4 -1
- data/smsapi-client.gemspec +7 -4
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41a0a8f58f3c352ae1e984482d77f060b7c1bb09
|
4
|
+
data.tar.gz: 8b72242c91bccad928fc231d121ac0169a997f62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0955a4561baec7b30673927e05f2e17cc88b69fd2b6a87a61fec6d7aa7d27b8cbd764736454e0674eefbb64922e107cd617fc8a434ad32ea12347f338a0429ea'
|
7
|
+
data.tar.gz: ba4b125e3893c224839a7564bb18891a184d11596395aa6d3f5bc9b53b633f3b28cbdea9d51d2879022cb82489202d6d447997f467fc92748d6bb74324cd74d3
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
|
+
|
7
|
+
## [Unreleased]
|
8
|
+
|
9
|
+
## [1.0.0] - 2019-08-13
|
10
|
+
### Added
|
11
|
+
- Changelog.
|
12
|
+
- Version tag.
|
13
|
+
|
14
|
+
### Changed
|
15
|
+
- Removed username/password auth in favor of OAuth2 token.
|
16
|
+
- Moved version number to a separate file.
|
17
|
+
- Moved main module outside of `smsapi` namespace.
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@ Smsapi::Client is a Ruby implementation for SMSAPI.pl gateway created by [Ruby L
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
9
|
```ruby
|
10
|
-
gem 'smsapi-client', '~> 0
|
10
|
+
gem 'smsapi-client', '~> 1.0'
|
11
11
|
```
|
12
12
|
|
13
13
|
And then execute:
|
@@ -16,19 +16,19 @@ And then execute:
|
|
16
16
|
|
17
17
|
Or install it yourself as:
|
18
18
|
|
19
|
-
$ gem install smsapi-client -v '~> 0
|
19
|
+
$ gem install smsapi-client -v '~> 1.0'
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
Be sure you have a
|
23
|
+
Be sure you have a token. You can obtain it on [SMSAPI.pl](http://smsapi.pl)
|
24
24
|
|
25
25
|
```ruby
|
26
26
|
# Include the library
|
27
|
-
require 'smsapi
|
27
|
+
require 'smsapi'
|
28
28
|
|
29
29
|
# Create the client
|
30
30
|
|
31
|
-
client = Smsapi::Client.new('
|
31
|
+
client = Smsapi::Client.new('your_secret_token')
|
32
32
|
|
33
33
|
# Get credits (account details)
|
34
34
|
credits = client.credits
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require_relative 'smsapi/client/version'
|
1
2
|
require 'smsapi/server'
|
2
3
|
require 'smsapi/server/connection'
|
3
4
|
require 'smsapi/client'
|
@@ -11,7 +12,6 @@ module Smsapi
|
|
11
12
|
class Error < StandardError; end
|
12
13
|
class ServerError < Error; end
|
13
14
|
|
14
|
-
VERSION = '0.3.1'
|
15
15
|
API = {
|
16
16
|
uri: 'ssl.smsapi.pl',
|
17
17
|
port: 443,
|
data/lib/smsapi/client.rb
CHANGED
data/lib/smsapi/server.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
module Smsapi
|
2
2
|
class Server
|
3
|
-
def initialize(
|
4
|
-
@
|
5
|
-
@password = password
|
3
|
+
def initialize(token)
|
4
|
+
@token = token
|
6
5
|
@connection = setup_connection
|
7
6
|
end
|
8
7
|
|
@@ -21,18 +20,13 @@ module Smsapi
|
|
21
20
|
def setup_connection
|
22
21
|
Smsapi::Server::Connection.new(
|
23
22
|
Smsapi::API[:uri],
|
24
|
-
Smsapi::API[:port]
|
23
|
+
Smsapi::API[:port],
|
24
|
+
@token
|
25
25
|
)
|
26
26
|
end
|
27
27
|
|
28
28
|
def make_request(path, params)
|
29
|
-
|
30
|
-
response = @connection.post(path, params)
|
31
|
-
response.body
|
32
|
-
end
|
33
|
-
|
34
|
-
def authorize_params(params)
|
35
|
-
params.merge(username: @username, password: @password)
|
29
|
+
@connection.post(path, params).body
|
36
30
|
end
|
37
31
|
end
|
38
32
|
end
|
@@ -1,12 +1,14 @@
|
|
1
1
|
require 'net/http'
|
2
|
+
require 'openssl'
|
2
3
|
|
3
4
|
module Smsapi
|
4
5
|
class Server
|
5
6
|
class Connection
|
6
|
-
def initialize(uri, port)
|
7
|
+
def initialize(uri, port, token)
|
7
8
|
@http = Net::HTTP.new(uri, port)
|
8
9
|
@http.use_ssl = true
|
9
10
|
@http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
11
|
+
@token = token
|
10
12
|
end
|
11
13
|
|
12
14
|
def post(path, params)
|
@@ -18,6 +20,7 @@ module Smsapi
|
|
18
20
|
def post_request(path, params)
|
19
21
|
request = Net::HTTP::Post.new(path)
|
20
22
|
request.set_form_data(params)
|
23
|
+
request['Authorization'] = "Bearer #{@token}"
|
21
24
|
request
|
22
25
|
end
|
23
26
|
end
|
data/smsapi-client.gemspec
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'smsapi
|
4
|
+
require 'smsapi'
|
5
|
+
require 'smsapi/client/version'
|
5
6
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
8
|
spec.name = "smsapi-client"
|
@@ -17,8 +18,10 @@ Gem::Specification.new do |spec|
|
|
17
18
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
19
|
spec.bindir = "exe"
|
19
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
-
spec.require_paths = [
|
21
|
+
spec.require_paths = ['lib']
|
21
22
|
|
22
|
-
spec.
|
23
|
-
|
23
|
+
spec.required_ruby_version = '>= 2.3'
|
24
|
+
|
25
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
26
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
24
27
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smsapi-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alek Niemczyk
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2019-
|
13
|
+
date: 2019-08-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -18,14 +18,14 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - "~>"
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
21
|
+
version: '2.0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - "~>"
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: '
|
28
|
+
version: '2.0'
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: rake
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,21 +50,23 @@ files:
|
|
50
50
|
- ".gitignore"
|
51
51
|
- ".rspec"
|
52
52
|
- ".travis.yml"
|
53
|
+
- CHANGELOG.md
|
53
54
|
- Gemfile
|
54
55
|
- LICENSE.txt
|
55
56
|
- README.md
|
56
57
|
- Rakefile
|
57
58
|
- bin/console
|
58
59
|
- bin/setup
|
60
|
+
- lib/smsapi.rb
|
59
61
|
- lib/smsapi/bulk_sms.rb
|
60
62
|
- lib/smsapi/client.rb
|
63
|
+
- lib/smsapi/client/version.rb
|
61
64
|
- lib/smsapi/credits.rb
|
62
65
|
- lib/smsapi/defaults.rb
|
63
66
|
- lib/smsapi/group_sms.rb
|
64
67
|
- lib/smsapi/server.rb
|
65
68
|
- lib/smsapi/server/connection.rb
|
66
69
|
- lib/smsapi/sms.rb
|
67
|
-
- lib/smsapi/smsapi.rb
|
68
70
|
- smsapi-client.gemspec
|
69
71
|
homepage: https://github.com/ruby-logic/smsapi-client
|
70
72
|
licenses:
|
@@ -78,7 +80,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
78
80
|
requirements:
|
79
81
|
- - ">="
|
80
82
|
- !ruby/object:Gem::Version
|
81
|
-
version: '
|
83
|
+
version: '2.3'
|
82
84
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
85
|
requirements:
|
84
86
|
- - ">="
|
@@ -86,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
88
|
version: '0'
|
87
89
|
requirements: []
|
88
90
|
rubyforge_project:
|
89
|
-
rubygems_version: 2.
|
91
|
+
rubygems_version: 2.6.14.4
|
90
92
|
signing_key:
|
91
93
|
specification_version: 4
|
92
94
|
summary: SMSAPI.pl Ruby client
|