coolsms 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -1
- data/lib/coolsms/.auth.rb.swp +0 -0
- data/lib/coolsms/applications.rb +19 -0
- data/lib/coolsms/balance.rb +1 -0
- data/lib/coolsms/send.rb +2 -22
- data/lib/coolsms/status.rb +29 -0
- data/lib/coolsms/version.rb +1 -1
- data/lib/coolsms.rb +3 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5194fa82585592bc14688c5af4d68cd506812cd3
|
4
|
+
data.tar.gz: 8cbcbae9ecf92896d61933f4de5fbddf052cd300
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47f0d2cfe4cec22dfd3534d4c512515c955de4169af877e6596538d36c36edcb8e2914208b459fc695e8918d79ddf86cc07dc34a67604185775e6d12ec610bbf
|
7
|
+
data.tar.gz: c8ebd5449ca534b3bdc8e7a48f9209c7b5aab580d5cadaaf19604a46b3397cd408701c53c9880ae4131c51c6eed84bc8334efdb888305f5e16fb4a88b26a1cbb
|
data/README.md
CHANGED
@@ -53,7 +53,20 @@ Or install it yourself as:
|
|
53
53
|
|
54
54
|
Methods
|
55
55
|
- balance
|
56
|
-
|
56
|
+
|
57
|
+
- ####Status
|
58
|
+
|
59
|
+
COOLSMS_STATUS = Coolsms::SMS::Balance.new( options )
|
60
|
+
COOLSMS_STATUS.status
|
61
|
+
Options
|
62
|
+
- count
|
63
|
+
- unit
|
64
|
+
- date
|
65
|
+
- channel
|
66
|
+
|
67
|
+
Methods
|
68
|
+
- status
|
69
|
+
|
57
70
|
## Coolsms Rest API Document
|
58
71
|
|
59
72
|
http://www.coolsms.co.kr/REST_API_Global
|
Binary file
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Applications
|
2
|
+
|
3
|
+
def set_fields(options)
|
4
|
+
options.each do |key, value|
|
5
|
+
self.public_send( "#{key}=", value ) if self.class.instance_methods.include? key
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def fields(*keys)
|
10
|
+
field = Auth.new.auth
|
11
|
+
keys.each do |key|
|
12
|
+
if self.class.instance_methods.include? key
|
13
|
+
field[key] = self.public_send(key)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
return field
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
data/lib/coolsms/balance.rb
CHANGED
data/lib/coolsms/send.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
class Send
|
1
|
+
class Send < Applications
|
2
2
|
|
3
3
|
#SMS Type default : SMS
|
4
4
|
attr_accessor :type
|
@@ -33,29 +33,15 @@ class Send
|
|
33
33
|
#Force_sms
|
34
34
|
attr_accessor :force_sms
|
35
35
|
|
36
|
-
protected
|
37
|
-
|
38
36
|
def initialize(options = {})
|
39
37
|
self.set_fields(options)
|
40
38
|
end
|
41
39
|
|
42
|
-
def fields(*keys)
|
43
|
-
field = Auth.new.auth
|
44
|
-
keys.each do |key|
|
45
|
-
if self.class.instance_methods.include? key
|
46
|
-
field[key] = self.public_send(key)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
return field
|
50
|
-
end
|
51
|
-
|
52
|
-
public
|
53
|
-
|
54
40
|
def send(from, to, text)
|
55
41
|
fields = self.fields( :type, :charset, :datetime, :delay, :refname, :country, :subject, :srk, :mode, :extension, :force_sms )
|
56
42
|
fields = fields.merge(from: from, to: to, text: text, type: self.type )
|
57
|
-
|
58
43
|
res = Request.new.post( "send", fields )
|
44
|
+
|
59
45
|
if res.code == "200"
|
60
46
|
body = JSON.parse(res.body)
|
61
47
|
{ ret: body['result_code'] == "00", message: body['result_message'], code: res.code }
|
@@ -64,10 +50,4 @@ class Send
|
|
64
50
|
end
|
65
51
|
end
|
66
52
|
|
67
|
-
def set_fields(options)
|
68
|
-
options.each do |key, value|
|
69
|
-
self.public_send( "#{key}=", value ) if self.class.instance_methods.include? key
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
53
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class Status < Applications
|
2
|
+
|
3
|
+
attr_accessor :count
|
4
|
+
|
5
|
+
#minute(default), hour, day
|
6
|
+
attr_accessor :unit
|
7
|
+
|
8
|
+
#Datetime Format YYYYMMDDHHMISS
|
9
|
+
attr_accessor :date
|
10
|
+
|
11
|
+
attr_accessor :channel
|
12
|
+
|
13
|
+
def initialize(options = {})
|
14
|
+
self.set_fields(options)
|
15
|
+
end
|
16
|
+
|
17
|
+
def status
|
18
|
+
fields = self.fields( :count, :unit, :date, :channel )
|
19
|
+
res = Request.new.get( "status", fields )
|
20
|
+
|
21
|
+
if res.code == "200"
|
22
|
+
body = JSON.parse( res.body )
|
23
|
+
{ ret: true, message: body, code: res.code }
|
24
|
+
else
|
25
|
+
{ ret: false, code: res.code }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
data/lib/coolsms/version.rb
CHANGED
data/lib/coolsms.rb
CHANGED
@@ -2,16 +2,19 @@ require "coolsms/version"
|
|
2
2
|
require 'securerandom'
|
3
3
|
require 'net/http'
|
4
4
|
require 'json'
|
5
|
+
require_relative 'coolsms/applications'
|
5
6
|
require_relative "coolsms/auth"
|
6
7
|
require_relative "coolsms/request"
|
7
8
|
require_relative 'coolsms/send'
|
8
9
|
require_relative 'coolsms/balance'
|
10
|
+
require_relative 'coolsms/status'
|
9
11
|
|
10
12
|
module Coolsms
|
11
13
|
class SMS
|
12
14
|
|
13
15
|
Send = Class.new(Send)
|
14
16
|
Balance = Class.new(Balance)
|
17
|
+
Status = Class.new(Status)
|
15
18
|
|
16
19
|
end
|
17
20
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coolsms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JunSangPil
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,10 +52,13 @@ files:
|
|
52
52
|
- Rakefile
|
53
53
|
- coolsms.gemspec
|
54
54
|
- lib/coolsms.rb
|
55
|
+
- lib/coolsms/.auth.rb.swp
|
56
|
+
- lib/coolsms/applications.rb
|
55
57
|
- lib/coolsms/auth.rb
|
56
58
|
- lib/coolsms/balance.rb
|
57
59
|
- lib/coolsms/request.rb
|
58
60
|
- lib/coolsms/send.rb
|
61
|
+
- lib/coolsms/status.rb
|
59
62
|
- lib/coolsms/version.rb
|
60
63
|
homepage: http://github.com/jun85664396
|
61
64
|
licenses:
|