coolsms 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +111 -79
- data/lib/coolsms.rb +4 -6
- data/lib/coolsms/applications.rb +0 -1
- data/lib/coolsms/auth.rb +4 -5
- data/lib/coolsms/balance.rb +0 -1
- data/lib/coolsms/cancel.rb +0 -1
- data/lib/coolsms/request.rb +5 -6
- data/lib/coolsms/send.rb +73 -21
- data/lib/coolsms/sent.rb +11 -2
- data/lib/coolsms/status.rb +0 -1
- data/lib/coolsms/version.rb +1 -1
- data/test/coolsms_test.rb +9 -2
- data/test/test_helper.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4cab4ba648eedb4fe24d415f8c57af8ab6e934a8
|
4
|
+
data.tar.gz: 2bb0e491b9d014f713e005ba0e2f21178782a30e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 160fd4c42243b57250e047d62c91b23918ed8344104e30a8b5a3ea91f10f47020d44f9d1d1536165050aaa8ea3323526ab8da00690a94567ffd1b213a2932131
|
7
|
+
data.tar.gz: 355d180a5701ab164066fe67bccb609c11b61dc2c3e12bda401f60a6a8db376fa51030415a5d5fdad1532b9cc3fa6910e7691745bd0a16490e5d0cceee27c8b6
|
data/README.md
CHANGED
@@ -12,11 +12,21 @@ gem 'coolsms'
|
|
12
12
|
|
13
13
|
And then execute:
|
14
14
|
|
15
|
-
|
15
|
+
```
|
16
|
+
$ bundle
|
17
|
+
```
|
16
18
|
|
17
19
|
Or install it yourself as:
|
18
20
|
|
19
|
-
|
21
|
+
```
|
22
|
+
$ gem install coolsms
|
23
|
+
```
|
24
|
+
|
25
|
+
Test
|
26
|
+
|
27
|
+
```
|
28
|
+
$ ruby test/coolsms_test.rb -v
|
29
|
+
```
|
20
30
|
|
21
31
|
## Configuration
|
22
32
|
|
@@ -24,97 +34,119 @@ Or install it yourself as:
|
|
24
34
|
|
25
35
|
## Usage
|
26
36
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
- charset
|
35
|
-
- datetime
|
36
|
-
- delay
|
37
|
-
- refname
|
38
|
-
- country
|
39
|
-
- subject
|
40
|
-
- srk
|
41
|
-
- mode
|
42
|
-
- extension
|
43
|
-
- force_sms
|
44
|
-
|
45
|
-
Methods
|
46
|
-
- send
|
47
|
-
- set_field
|
48
|
-
|
49
|
-
- ####Balance
|
37
|
+
####Send < Applications
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
COOLSMS_SEND = Coolsms::SMS::Send.new( { options } )
|
41
|
+
COOLSMS_SEND.send( from, to, text)
|
42
|
+
COOLSMS_SEND.set_field( { options} )
|
43
|
+
```
|
50
44
|
|
51
|
-
|
52
|
-
|
45
|
+
* Options
|
46
|
+
- type
|
47
|
+
- image
|
48
|
+
- image_encoding
|
49
|
+
- refname
|
50
|
+
- country
|
51
|
+
- datetime
|
52
|
+
- subject
|
53
|
+
- charset
|
54
|
+
- srk
|
55
|
+
- mode
|
56
|
+
- extension
|
57
|
+
- delay
|
58
|
+
- force_sms
|
59
|
+
- os_platform
|
60
|
+
- dev_lang
|
61
|
+
- sdk_version
|
62
|
+
- app_version
|
63
|
+
- sender_key
|
64
|
+
- template_code
|
65
|
+
|
66
|
+
* Methods
|
67
|
+
- send
|
68
|
+
- set_field
|
53
69
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
70
|
+
####Balance
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
COOLSMS_BALANCE = Coolsms::SMS::Balance.new
|
74
|
+
COOLSMS_BALANCE.balance
|
75
|
+
```
|
76
|
+
|
77
|
+
* Methods
|
78
|
+
- balance
|
79
|
+
|
80
|
+
####Status < Applications
|
81
|
+
|
82
|
+
```ruby
|
83
|
+
COOLSMS_STATUS = Coolsms::SMS::Status.new( options )
|
84
|
+
COOLSMS_STATUS.status
|
85
|
+
```
|
86
|
+
|
87
|
+
* Options
|
88
|
+
- count
|
89
|
+
- unit
|
90
|
+
- date
|
91
|
+
- channel
|
66
92
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
93
|
+
* Methods
|
94
|
+
- status
|
95
|
+
|
96
|
+
####Sent < Applications
|
97
|
+
|
98
|
+
```ruby
|
99
|
+
COOLSMS_SENT = Coolsms::SMS::Sent.new( options )
|
100
|
+
COOLSMS_SENT.sent
|
101
|
+
```
|
102
|
+
|
103
|
+
* Options
|
104
|
+
- count
|
105
|
+
- page
|
106
|
+
- rcpt
|
107
|
+
- start
|
108
|
+
- end
|
109
|
+
- status
|
110
|
+
- resultcode
|
111
|
+
- notin_resultcode
|
112
|
+
- mid
|
113
|
+
- gid
|
85
114
|
|
86
|
-
|
87
|
-
|
115
|
+
* Methods
|
116
|
+
- sent
|
88
117
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
118
|
+
####Cancel < Applications
|
119
|
+
|
120
|
+
```ruby
|
121
|
+
COOLSMS_CANCEL = Coolsms::SMS::Cancel.new( options )
|
122
|
+
COOLSMS_CANCEL.cancel
|
123
|
+
```
|
93
124
|
|
94
|
-
|
95
|
-
|
96
|
-
|
125
|
+
* Options
|
126
|
+
- mid
|
127
|
+
- gid
|
97
128
|
|
98
|
-
|
99
|
-
|
129
|
+
* Methods
|
130
|
+
- cancel
|
100
131
|
|
101
|
-
|
132
|
+
#### Applications
|
102
133
|
|
103
|
-
|
104
|
-
|
105
|
-
|
134
|
+
* Methods
|
135
|
+
- set_fields
|
136
|
+
- fields
|
106
137
|
|
107
|
-
|
138
|
+
#### TODO
|
108
139
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
140
|
+
- [x] Send
|
141
|
+
- [x] Sent
|
142
|
+
- [x] Cancel
|
143
|
+
- [x] Balance
|
144
|
+
- [x] Status
|
114
145
|
|
115
146
|
## Coolsms Rest API Document
|
116
147
|
|
117
|
-
http://www.coolsms.co.kr/
|
148
|
+
* [Coolsms REST API](http://www.coolsms.co.kr/REST_API)
|
149
|
+
* Support API version : 1.5
|
118
150
|
|
119
151
|
## Contributing
|
120
152
|
|
data/lib/coolsms.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
# @name Coolsms Rest API Helper
|
2
2
|
# @author JunSangPil
|
3
|
-
# @version 0.1.
|
3
|
+
# @version 0.1.2
|
4
4
|
# @url http://github.com/jun85664396/coolsms
|
5
5
|
# @license MIT License
|
6
6
|
|
7
|
-
require "coolsms/version"
|
8
7
|
require 'securerandom'
|
9
8
|
require 'net/http'
|
10
9
|
require 'json'
|
10
|
+
require_relative 'coolsms/version'
|
11
11
|
require_relative 'coolsms/applications'
|
12
|
-
require_relative
|
13
|
-
require_relative
|
12
|
+
require_relative 'coolsms/auth'
|
13
|
+
require_relative 'coolsms/request'
|
14
14
|
require_relative 'coolsms/send'
|
15
15
|
require_relative 'coolsms/balance'
|
16
16
|
require_relative 'coolsms/status'
|
@@ -19,12 +19,10 @@ require_relative 'coolsms/cancel'
|
|
19
19
|
|
20
20
|
module Coolsms
|
21
21
|
class SMS
|
22
|
-
|
23
22
|
Send = Class.new(Send)
|
24
23
|
Balance = Class.new(Balance)
|
25
24
|
Status = Class.new(Status)
|
26
25
|
Sent = Class.new(Sent)
|
27
26
|
Cancel = Class.new(Cancel)
|
28
|
-
|
29
27
|
end
|
30
28
|
end
|
data/lib/coolsms/applications.rb
CHANGED
data/lib/coolsms/auth.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
class Auth
|
2
2
|
|
3
|
-
#Time Default : now
|
3
|
+
# Time Default : now
|
4
4
|
attr_accessor :timestamp
|
5
5
|
|
6
|
-
#Salt
|
6
|
+
# Salt
|
7
7
|
attr_accessor :salt
|
8
8
|
|
9
|
-
#API KEY
|
9
|
+
# API KEY
|
10
10
|
attr_accessor :api_key
|
11
11
|
|
12
|
-
#API SECRET KEY
|
12
|
+
# API SECRET KEY
|
13
13
|
attr_accessor :api_secret
|
14
14
|
|
15
15
|
def initialize
|
@@ -27,5 +27,4 @@ class Auth
|
|
27
27
|
def auth
|
28
28
|
{ api_key: self.api_key, signature: self.signature, timestamp: self.timestamp, salt: self.salt }
|
29
29
|
end
|
30
|
-
|
31
30
|
end
|
data/lib/coolsms/balance.rb
CHANGED
data/lib/coolsms/cancel.rb
CHANGED
data/lib/coolsms/request.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class Request
|
2
2
|
|
3
|
-
#URI
|
3
|
+
# URI
|
4
4
|
attr_accessor :uri
|
5
5
|
|
6
6
|
def initialize
|
@@ -8,13 +8,12 @@ class Request
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def post(key, fields = {})
|
11
|
-
res = Net::HTTP.post_form(
|
11
|
+
res = Net::HTTP.post_form(self.uri+"/sms/1.5/#{key}", fields)
|
12
12
|
end
|
13
13
|
|
14
14
|
def get(key, fields = {})
|
15
|
-
uri = URI(
|
16
|
-
uri.query = URI.encode_www_form(
|
17
|
-
res = Net::HTTP.get_response(
|
15
|
+
uri = URI(self.uri+"/sms/1.5/#{key}")
|
16
|
+
uri.query = URI.encode_www_form(fields)
|
17
|
+
res = Net::HTTP.get_response(uri)
|
18
18
|
end
|
19
|
-
|
20
19
|
end
|
data/lib/coolsms/send.rb
CHANGED
@@ -1,53 +1,105 @@
|
|
1
1
|
class Send < Applications
|
2
2
|
|
3
|
-
#
|
3
|
+
# Message Type : SMS(default), LMS, MMS, ATA
|
4
|
+
# If not +82, force SMS
|
4
5
|
attr_accessor :type
|
5
6
|
|
6
|
-
#
|
7
|
-
|
7
|
+
# Image
|
8
|
+
# JPEG, PNG, GIF < 300KB, 2048x2048 px
|
9
|
+
attr_accessor :image
|
8
10
|
|
9
|
-
#
|
10
|
-
|
11
|
+
# Image encoding
|
12
|
+
# binary(default), base64
|
13
|
+
attr_accessor :image_encoding
|
11
14
|
|
12
|
-
#
|
13
|
-
attr_accessor :delay
|
14
|
-
|
15
|
-
#Refname
|
15
|
+
# Reference name
|
16
16
|
attr_accessor :refname
|
17
17
|
|
18
|
-
#Country
|
18
|
+
# Country
|
19
|
+
# Korea : +82 (default)
|
19
20
|
attr_accessor :country
|
20
21
|
|
21
|
-
#
|
22
|
+
# Schedule datetime.
|
23
|
+
# Format: YYYYMMDDHHMISS
|
24
|
+
attr_accessor :datetime
|
25
|
+
|
26
|
+
# MMS, LMS subject
|
22
27
|
attr_accessor :subject
|
23
28
|
|
24
|
-
#
|
29
|
+
# Charset encoding
|
30
|
+
# default: utf8
|
31
|
+
attr_accessor :charset
|
32
|
+
|
33
|
+
# Srk
|
25
34
|
attr_accessor :srk
|
26
35
|
|
27
|
-
#Mode
|
36
|
+
# Mode
|
37
|
+
# if 'test'
|
38
|
+
# from_num : '010000000'
|
39
|
+
# datetime is ignore
|
40
|
+
# return_value : 60
|
41
|
+
# recharge
|
28
42
|
attr_accessor :mode
|
29
43
|
|
30
|
-
#Extension
|
44
|
+
# Extension
|
45
|
+
# JSON data
|
31
46
|
attr_accessor :extension
|
32
47
|
|
33
|
-
#
|
48
|
+
# Delay
|
49
|
+
# value : 0 ~ 20
|
50
|
+
attr_accessor :delay
|
51
|
+
|
52
|
+
# Force SMS
|
53
|
+
# true or false
|
34
54
|
attr_accessor :force_sms
|
35
55
|
|
56
|
+
# Client OS and platform
|
57
|
+
attr_accessor :os_platform
|
58
|
+
|
59
|
+
# Development language
|
60
|
+
attr_accessor :dev_lang
|
61
|
+
|
62
|
+
# SDK version
|
63
|
+
attr_accessor :sdk_version
|
64
|
+
|
65
|
+
# Application version
|
66
|
+
attr_accessor :app_version
|
67
|
+
|
68
|
+
# AlarmTalk sender Key
|
69
|
+
attr_accessor :sender_key
|
70
|
+
|
71
|
+
# AlarmTalk template code
|
72
|
+
attr_accessor :template_code
|
73
|
+
|
36
74
|
def initialize(options = {})
|
37
75
|
self.set_fields(options)
|
38
76
|
end
|
39
77
|
|
40
78
|
def send(from, to, text)
|
41
|
-
fields = self.fields(
|
42
|
-
|
79
|
+
fields = self.fields(
|
80
|
+
:type, :image, :image_encoding, :refname, :country,
|
81
|
+
:datetime, :subject, :charset, :srk, :mode,
|
82
|
+
:extension, :delay, :force_sms, :os_platform, :dev_lang,
|
83
|
+
:sdk_version, :app_version, :sender_key, :template_code
|
84
|
+
)
|
85
|
+
|
86
|
+
fields = fields.merge( from: from, to: to, text: text, type: self.type )
|
87
|
+
|
43
88
|
res = Request.new.post( "send", fields )
|
44
89
|
|
45
90
|
if res.code == "200"
|
46
91
|
body = JSON.parse(res.body)
|
47
|
-
{
|
92
|
+
{
|
93
|
+
ret: body['result_code'] == "00",
|
94
|
+
message: body['result_message'],
|
95
|
+
code: res.code,
|
96
|
+
gid: body['group_id']
|
97
|
+
}
|
48
98
|
else
|
49
|
-
{
|
99
|
+
{
|
100
|
+
ret: false,
|
101
|
+
code: res.code
|
102
|
+
}
|
50
103
|
end
|
51
|
-
end
|
52
|
-
|
104
|
+
end
|
53
105
|
end
|
data/lib/coolsms/sent.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
class Sent < Applications
|
2
2
|
|
3
|
+
# Message count
|
4
|
+
# defualt: 20
|
3
5
|
attr_accessor :count
|
4
6
|
|
5
7
|
attr_accessor :page
|
6
8
|
|
9
|
+
# Search for to number
|
7
10
|
attr_accessor :rcpt
|
8
11
|
|
9
12
|
# Date Format YYYY-MM-DD HH:MI:SS
|
@@ -12,14 +15,18 @@ class Sent < Applications
|
|
12
15
|
# DateFormat YYYY-MM-DD HH:MI:SS
|
13
16
|
attr_accessor :end
|
14
17
|
|
18
|
+
# Message status
|
15
19
|
attr_accessor :status
|
16
20
|
|
21
|
+
# Sending result code
|
17
22
|
attr_accessor :resultcode
|
18
23
|
|
19
24
|
attr_accessor :notin_resultcode
|
20
25
|
|
26
|
+
# Message ID
|
21
27
|
attr_accessor :mid
|
22
28
|
|
29
|
+
# Group ID
|
23
30
|
attr_accessor :gid
|
24
31
|
|
25
32
|
def initialize(options={})
|
@@ -27,7 +34,10 @@ class Sent < Applications
|
|
27
34
|
end
|
28
35
|
|
29
36
|
def sent
|
30
|
-
fields = self.fields(
|
37
|
+
fields = self.fields(
|
38
|
+
:count, :page, :rcpt, :start, :end,
|
39
|
+
:status, :resultcode, :notin_resultcode, :mid, :gid
|
40
|
+
)
|
31
41
|
res = Request.new.get( "sent", fields )
|
32
42
|
|
33
43
|
if res.code == "200"
|
@@ -37,5 +47,4 @@ class Sent < Applications
|
|
37
47
|
{ ret: false, code: res.code }
|
38
48
|
end
|
39
49
|
end
|
40
|
-
|
41
50
|
end
|
data/lib/coolsms/status.rb
CHANGED
data/lib/coolsms/version.rb
CHANGED
data/test/coolsms_test.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require_relative 'test_helper'
|
2
|
-
require 'coolsms'
|
3
2
|
|
4
3
|
describe "Coolsms" do
|
5
4
|
before do
|
@@ -9,25 +8,33 @@ describe "Coolsms" do
|
|
9
8
|
|
10
9
|
it "Send" do
|
11
10
|
send = Coolsms::SMS::Send.new(mode: "test")
|
12
|
-
res = send.send("
|
11
|
+
res = send.send("01012345678", "01000000000", "Test Message")
|
12
|
+
p res
|
13
|
+
|
13
14
|
assert_equal res[:code], "200"
|
14
15
|
end
|
15
16
|
|
16
17
|
it "Balance" do
|
17
18
|
balance = Coolsms::SMS::Balance.new
|
18
19
|
res = balance.balance
|
20
|
+
p res
|
21
|
+
|
19
22
|
assert_equal res[:code], "200"
|
20
23
|
end
|
21
24
|
|
22
25
|
it "Status" do
|
23
26
|
status = Coolsms::SMS::Status.new
|
24
27
|
res = status.status
|
28
|
+
p res
|
29
|
+
|
25
30
|
assert_equal res[:code], "200"
|
26
31
|
end
|
27
32
|
|
28
33
|
it "Sent" do
|
29
34
|
sent = Coolsms::SMS::Sent.new
|
30
35
|
res = sent.sent
|
36
|
+
p res
|
37
|
+
|
31
38
|
assert_equal res[:code], "200"
|
32
39
|
end
|
33
40
|
|
data/test/test_helper.rb
CHANGED
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.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JunSangPil
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|