atompark-sms-api 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/.gitignore +16 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +5 -0
- data/Rakefile +1 -0
- data/atompark-sms-api.gemspec +25 -0
- data/lib/atompark-sms-api.rb +5 -0
- data/lib/atompark-sms-api/configuration.rb +20 -0
- data/lib/atompark-sms-api/gateway.rb +33 -0
- data/lib/atompark-sms-api/response.rb +21 -0
- data/lib/atompark-sms-api/send.rb +5 -0
- data/lib/atompark-sms-api/version.rb +4 -0
- data/spec/spec_helper.rb +2 -0
- metadata +114 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 74d7bbb7fdbbc9c57af816e4fe3148caa52a5a15
|
4
|
+
data.tar.gz: 2cf1c24001c9175021b3b5433e9e36d1e87b68d9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e4538d4846c9ba66034f637d77dd19c4856022af33435288e48bdd2aa8e7a19938680e09b49801d3b2f259a3901655205f66922d9b36648f94d8d8aad864ba99
|
7
|
+
data.tar.gz: b2d06f8e31c92307ae46acb96b250504da71cb322bd10287dbbfc49cf16830654654f3ed812418ec0e9bcc1b53cdb9c4101de59454297ae95702ec4db93d1a1a
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 TODO: Write your name
|
2
|
+
|
3
|
+
MIT License
|
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
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,25 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'atompark-sms-api/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'atompark-sms-api'
|
7
|
+
spec.version = AtomparkSmsApi::VERSION
|
8
|
+
spec.authors = ['uno4ki']
|
9
|
+
spec.email = ['i.have@no.mail']
|
10
|
+
spec.description = 'Atompark SMS API'
|
11
|
+
spec.summary = 'Atompark SMS API wrapper. Works only with v3 api'
|
12
|
+
spec.homepage = 'https://github.com/the-furnish/atompark-sms-api'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(/^spec\//)
|
18
|
+
spec.require_paths = ['lib']
|
19
|
+
|
20
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
21
|
+
spec.add_development_dependency 'rake', '~> 10.3'
|
22
|
+
spec.add_development_dependency 'rspec', '~> 3.1'
|
23
|
+
|
24
|
+
spec.add_dependency 'faraday', '~>0.9'
|
25
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module AtomparkSmsApi
|
2
|
+
def self.config
|
3
|
+
@configuration ||= AtomparkSmsApi::Configuration.new
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.configure
|
7
|
+
yield config if block_given?
|
8
|
+
end
|
9
|
+
|
10
|
+
class Configuration
|
11
|
+
attr_accessor :pubkey, :pvtkey, :base_url, :sender
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
@pubkey = ''
|
15
|
+
@pvtkey = ''
|
16
|
+
@sender = ''
|
17
|
+
@base_url = 'http://api.atompark.com/sms/3.0/'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class AtomparkSmsApi::Gateway
|
2
|
+
def self.perform(*args)
|
3
|
+
fail "Don't call me that way"
|
4
|
+
end
|
5
|
+
|
6
|
+
def initialize(method, params)
|
7
|
+
@method = method
|
8
|
+
@params = params.merge(action: method, key: AtomparkSmsApi.config.pubkey, version: '3.0')
|
9
|
+
@conn = Faraday.new(url: AtomparkSmsApi.config.base_url)
|
10
|
+
# do |faraday|
|
11
|
+
# faraday.response(:logger)
|
12
|
+
# end
|
13
|
+
end
|
14
|
+
|
15
|
+
def perform
|
16
|
+
AtomparkSmsApi::Response.new(perform!)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
attr_reader :method, :conn, :params
|
22
|
+
|
23
|
+
def perform!
|
24
|
+
conn.post do |req|
|
25
|
+
req.url(method.to_s)
|
26
|
+
req.params = params.merge(sum: checksum)
|
27
|
+
end.body
|
28
|
+
end
|
29
|
+
|
30
|
+
def checksum
|
31
|
+
@_checksum ||= Digest::MD5.hexdigest(params.sort.map{ |v| v[1] }.join('') + AtomparkSmsApi.config.pvtkey)
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class AtomparkSmsApi::Response
|
2
|
+
def initialize(data)
|
3
|
+
@response = JSON.parse(data)
|
4
|
+
end
|
5
|
+
|
6
|
+
def success?
|
7
|
+
!error?
|
8
|
+
end
|
9
|
+
|
10
|
+
def error?
|
11
|
+
response.has_key?('error')
|
12
|
+
end
|
13
|
+
|
14
|
+
def message
|
15
|
+
"<#{response['code']}> #{response['error']}"
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
attr_reader :response
|
21
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: atompark-sms-api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- uno4ki
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-02-12 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.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.1'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.1'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: faraday
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.9'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.9'
|
69
|
+
description: Atompark SMS API
|
70
|
+
email:
|
71
|
+
- i.have@no.mail
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE.txt
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- atompark-sms-api.gemspec
|
82
|
+
- lib/atompark-sms-api.rb
|
83
|
+
- lib/atompark-sms-api/configuration.rb
|
84
|
+
- lib/atompark-sms-api/gateway.rb
|
85
|
+
- lib/atompark-sms-api/response.rb
|
86
|
+
- lib/atompark-sms-api/send.rb
|
87
|
+
- lib/atompark-sms-api/version.rb
|
88
|
+
- spec/spec_helper.rb
|
89
|
+
homepage: https://github.com/the-furnish/atompark-sms-api
|
90
|
+
licenses:
|
91
|
+
- MIT
|
92
|
+
metadata: {}
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubyforge_project:
|
109
|
+
rubygems_version: 2.5.1
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: Atompark SMS API wrapper. Works only with v3 api
|
113
|
+
test_files:
|
114
|
+
- spec/spec_helper.rb
|