cafe24_sms 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ .bundle
2
+ *.gem
3
+ pkg/*
4
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format=nested
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in cafe24_sms.gemspec
4
+ gemspec
data/README.mkd ADDED
@@ -0,0 +1,36 @@
1
+ Cafe24 SMS 발송 Ruby wrapper
2
+ ==========================
3
+ cafe24 sms 발송 서비스(유료) ruby wrapper. 필수 parameter를 넘겨서 sms 발송하는 기능만 있음(v. 0.0.1)
4
+
5
+ Installation
6
+ ------------
7
+ 아직 안 올림
8
+
9
+ ``` sh
10
+ gem install cafe24_sms
11
+ ```
12
+
13
+ Usage
14
+ -----
15
+ ``` ruby
16
+ require 'cafe24_sms'
17
+
18
+ # sms 발송
19
+ Cafe24.send_sms(:user_id => "user_id", :secure => "secure", :sphone1 => "011", :sphone2 => "9999", :sphone3 => "0000", :rphone => "011-9090-9090", :msg => "hello world!")
20
+
21
+
22
+ # 기본값 설정 가능
23
+ Cafe24Sms.configure do |config|
24
+ config.user_id = "user_id"
25
+ config.secure = "secure"
26
+ config.sphone1 = "011"
27
+ config.sphone2 = "9999"
28
+ config.sphone3 = "0000"
29
+ end
30
+
31
+ Cafe24.send_sms(:rphone => "011-9090-9090", :msg => "hello world!")
32
+
33
+
34
+ # 예약 발송
35
+ Cafe24.send_sms(:rphone => "011-9090-9090", :msg => "hello world!", :rdate => "20110501", :rtime => "173000")
36
+ ```
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "cafe24_sms/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.add_development_dependency('rspec')
7
+ s.add_development_dependency('autotest')
8
+ s.add_development_dependency('webmock')
9
+
10
+ s.name = "cafe24_sms"
11
+ s.version = Cafe24Sms::VERSION
12
+ s.platform = Gem::Platform::RUBY
13
+ s.authors = ["bayja"]
14
+ s.email = ["potato9@gmail.com"]
15
+ s.homepage = ""
16
+ s.summary = %q{카페24 sms 사용을 위한 gem}
17
+ s.description = %q{카페24 sms 사용을 위한 gem}
18
+
19
+ s.rubyforge_project = "cafe24_sms"
20
+
21
+ s.files = `git ls-files`.split("\n")
22
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
23
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
24
+ s.require_paths = ["lib"]
25
+ end
@@ -0,0 +1,11 @@
1
+ module Cafe24Sms
2
+ module Configuration
3
+ SMS_URL = "https://sslsms.cafe24.com/sms_sender.php"
4
+ attr_accessor :user_id, :secure, :sphone1, :sphone2, :sphone3
5
+
6
+ # Convenience method to allow configuration options to be set in a block
7
+ def configure
8
+ yield self
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,28 @@
1
+ require 'net/https'
2
+ require 'uri'
3
+
4
+ module Cafe24Sms
5
+ module SendSms
6
+ def send_sms(options)
7
+ url = URI.parse(Configuration::SMS_URL)
8
+ req = Net::HTTP::Post.new(url.path)
9
+ req.set_form_data(_form_data(options), '&')
10
+
11
+ http_session = Net::HTTP.new(url.host, url.port)
12
+ http_session.use_ssl = true
13
+ http_session.start {|http| http.request(req)}
14
+
15
+ # Net::HTTP.post_form(URI.parse(Configuration::SMS_URL), _form_data(options))
16
+ end
17
+
18
+ def _form_data(options)
19
+ { :sms_url => Configuration::SMS_URL,
20
+ :user_id => self.user_id,
21
+ :secure => self.secure,
22
+ :sphone1 => self.sphone1,
23
+ :sphone2 => self.sphone2,
24
+ :sphone3 => self.sphone3
25
+ }.merge(options)
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,3 @@
1
+ module Cafe24Sms
2
+ VERSION = "0.0.2"
3
+ end
data/lib/cafe24_sms.rb ADDED
@@ -0,0 +1,7 @@
1
+ require 'cafe24_sms/configuration'
2
+ require 'cafe24_sms/send_sms'
3
+
4
+ module Cafe24Sms
5
+ extend Configuration
6
+ extend SendSms
7
+ end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+ require 'net/https'
3
+
4
+ describe Cafe24Sms, ".configuration" do
5
+ it 'should mass assign config value via a block' do
6
+ Cafe24Sms.configure do |config|
7
+ config.user_id = "boribook"
8
+ config.secure = "__my_secure__"
9
+ config.sphone1 = "011"
10
+ config.sphone2 = "0000"
11
+ config.sphone3 = "0001"
12
+ end
13
+
14
+ Cafe24Sms.user_id.should == "boribook"
15
+ Cafe24Sms.secure.should == "__my_secure__"
16
+ Cafe24Sms.sphone1.should == "011"
17
+ Cafe24Sms.sphone2.should == "0000"
18
+ Cafe24Sms.sphone3.should == "0001"
19
+ end
20
+ end
21
+
22
+ describe Cafe24Sms, ".send" do
23
+ before :each do
24
+ stub_request(:post, Cafe24Sms::Configuration::SMS_URL)
25
+ end
26
+
27
+ it 'should generate form_data with essential data' do
28
+ data = Cafe24Sms._form_data(:rphone => "011-9988-4928", :msg => "hello world")
29
+
30
+ [:sms_url, :user_id, :secure, :sphone1, :sphone2, :sphone3, :rphone, :msg].each do |key|
31
+ data.keys.include?(key).should be_true
32
+ end
33
+
34
+ data[:sms_url].should == Cafe24Sms::Configuration::SMS_URL
35
+ data[:user_id].should == 'boribook'
36
+ data[:secure].should == '__my_secure__'
37
+ data[:sphone1].should == '011'
38
+ data[:sphone2].should == '0000'
39
+ data[:sphone3].should == '0001'
40
+ end
41
+
42
+ it "should send_sms" do
43
+ Cafe24Sms.send_sms(:rphone => "011-9988-9988", :msg => "hello world")
44
+ WebMock.should have_requested(:post, Cafe24Sms::Configuration::SMS_URL)
45
+ .with(:body => "sms_url=https%3a%2f%2fsslsms.cafe24.com%2fsms_sender.php&user_id=boribook&secure=__my_secure__&sphone1=011&sphone2=0000&sphone3=0001&rphone=011-9988-9988&msg=hello%20world")
46
+ end
47
+ end
@@ -0,0 +1,3 @@
1
+ require 'cafe24_sms'
2
+ require 'webmock/rspec'
3
+
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cafe24_sms
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.2
6
+ platform: ruby
7
+ authors:
8
+ - bayja
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-05-01 00:00:00 +09:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: rspec
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: "0"
25
+ type: :development
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: autotest
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: "0"
36
+ type: :development
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: webmock
40
+ prerelease: false
41
+ requirement: &id003 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: "0"
47
+ type: :development
48
+ version_requirements: *id003
49
+ description: "\xEC\xB9\xB4\xED\x8E\x9824 sms \xEC\x82\xAC\xEC\x9A\xA9\xEC\x9D\x84 \xEC\x9C\x84\xED\x95\x9C gem"
50
+ email:
51
+ - potato9@gmail.com
52
+ executables: []
53
+
54
+ extensions: []
55
+
56
+ extra_rdoc_files: []
57
+
58
+ files:
59
+ - .gitignore
60
+ - .rspec
61
+ - Gemfile
62
+ - README.mkd
63
+ - Rakefile
64
+ - cafe24_sms.gemspec
65
+ - lib/cafe24_sms.rb
66
+ - lib/cafe24_sms/configuration.rb
67
+ - lib/cafe24_sms/send_sms.rb
68
+ - lib/cafe24_sms/version.rb
69
+ - spec/cafe24_sms_spec.rb
70
+ - spec/spec_helper.rb
71
+ has_rdoc: true
72
+ homepage: ""
73
+ licenses: []
74
+
75
+ post_install_message:
76
+ rdoc_options: []
77
+
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: "0"
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: "0"
92
+ requirements: []
93
+
94
+ rubyforge_project: cafe24_sms
95
+ rubygems_version: 1.5.0
96
+ signing_key:
97
+ specification_version: 3
98
+ summary: "\xEC\xB9\xB4\xED\x8E\x9824 sms \xEC\x82\xAC\xEC\x9A\xA9\xEC\x9D\x84 \xEC\x9C\x84\xED\x95\x9C gem"
99
+ test_files:
100
+ - spec/cafe24_sms_spec.rb
101
+ - spec/spec_helper.rb