Skip to content

say8425/sens_sms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

56 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Ncloud Sens SMS Gem

gem version GitHub Actions Test GitHub Actions Release GitHub license

Ncloud Sens SMS๋ฅผ Ruby์—์„œ ๋ณด๋‚ด์„ธ์š”.

If you want to read English document, then click here.

Installation

Rails

Application's Gemfile์— ์•„๋ž˜ ์ค„์„ ์ถ”๊ฐ€ํ•˜์„ธ์š”:

gem 'sens_sms'

๊ทธ ๋‹ค์Œ ์•„๋ž˜ ๋ช…๋ น์„ ์‹คํ–‰ํ•˜์„ธ์š”:

$ bundle

๋งˆ์ง€๋ง‰์œผ๋กœ generator์„ ์‹คํ–‰ํ•˜์„ธ์š”:

$ rails generate sens_sms:install

์—ฌ๊ธฐ๊นŒ์ง€ ํ•˜์…จ์œผ๋ฉด, sens_sms configuration ํŒŒ์ผ์„ YOUR_PROJECT/config/initializers/sens_sms.rb์—์„œ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

require 'sens_sms'

SensSms::Client.configure do |config|
  config.access_key = ENV['NCLOUD_ACCESS_KEY']
  config.secret_key = ENV['NCLOUD_SECRET_KEY']
  config.service_id = ENV['NCLOUD_SERVICE_ID']
end

Ncloud access key๋ฅผ ์—ฌ๊ธฐ์— ์ง์ ‘ ์„ธํŒ…ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ํ™˜๊ฒฝ๋ณ€์ˆ˜ ์‚ฌ์šฉ์„ ๊ถŒ์žฅํ• ๊ฒŒ์š”. access key ๋ฐœ๊ธ‰ํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ์—ฌ๊ธฐ์—์„œ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Sinatra or Plain ol' Ruby

gem์„ ์„ค์น˜ํ•˜์„ธ์š”:

$ gem install sens_sms

plain Ruby ํ”„๋กœ์ ํŠธ์—์„œ sens_sms gem์„ ์“ฐ์‹ค๊ฑฐ๋ผ๋ฉด, rails generator ๊ฐ€ ํ•ด์ค€ ๊ฒƒ์ฒ˜๋Ÿผ require 'sens_sms' ๊ณผ SensSms::Client.configure block ์„ ํ˜ธ์ถœํ•ด์„œ access keys๋ฅผ ๊ผญ ์„ธํŒ…ํ•˜๊ณ , deliverํ•จ์ˆ˜๋ฅผ ์“ฐ์„ธ์š”.

Usage

# SMS
SensSms::Client.new
               .deliver(type: :sms,
                        from_number: '01012345678',
                        to_numbers: '01098765432',
                        message: '์ „ ์„ธ๊ณ„์— ์•Œ๋ ค์ง„ ํŽญ๊ท„์˜ ์ข…๋ฅ˜๋Š” 17์ข… ํ˜น์€ 18์ข…์ด๋‹ค.')
# LMS
SensSms::Client.new
               .deliver(type: :lms,
                        from_number: '01012345678',
                        to_numbers: '01098765432',
                        title: 'ํŽญ๊ท„',
                        message: '์ „ ์„ธ๊ณ„์— ์•Œ๋ ค์ง„ ํŽญ๊ท„์˜ ์ข…๋ฅ˜๋Š” 17์ข… ํ˜น์€ 18์ข…์ด๋‹ค. (์‡ ํ‘ธ๋ฅธํŽญ๊ท„๊ณผ ํฐ๋‚ ๊ฐœํŽญ๊ท„์ด
                                  ์‹๋ณ„๋˜๋Š”์ง€ ์•„๋‹Œ์ง€์— ๋”ฐ๋ผ ๋‹ฌ๋ผ์ง„๋‹ค.) ๋ชจ๋“  ํŽญ๊ท„ ์ข…์˜ ๊ณ ํ–ฅ์ด ๋‚จ๋ฐ˜๊ตฌ์ด๊ธฐ๋Š” ํ•˜์ง€๋งŒ,
                                  ํ†ต๋…๊ณผ ๋‹ฌ๋ฆฌ, ๋‚จ๊ทน๊ณผ ๊ฐ™์ด ์ถ”์šด ๊ธฐํ›„์—์„œ๋งŒ ์„œ์‹ํ•˜์ง€๋Š” ์•Š๋Š”๋‹ค. ์‹ค์ œ๋กœ๋Š” ๋ช‡๋ช‡ ์ข…๋งŒ์ด
                                  ๊ทน์ง€๋ฐฉ์— ์‚ฐ๋‹ค. 3์ข…์€ ์—ด๋Œ€ ์ง€๋ฐฉ์— ์‚ด๋ฉฐ, ๊ทธ ๊ฐ€์šด๋ฐ ๊ฐˆ๋ผํŒŒ๊ณ ์Šค ์ œ๋„์— ์‚ฌ๋Š” ํ•œ ์ข…์€ ๋จน์ด๋ฅผ
                                  ์ฐพ๋‹ค๊ฐ€ ์ ๋„๋ฅผ ๊ฑด๋„ˆ๊ธฐ๋„ ํ•œ๋‹ค. ๊ฐ€์žฅ ํฐ ์ข…์€ ํ™ฉ์ œํŽญ๊ท„์œผ๋กœ, ๋‹ค ์ž๋ผ๋ฉด ํ‚ค๊ฐ€ ์•ฝ 1.1๋ฏธํ„ฐ,
                                  ๋ฌด๊ฒŒ๊ฐ€ ์•ฝ 35ํ‚ฌ๋กœ๊ทธ๋žจ ์ด์ƒ์ด๋‹ค. ๊ฐ€์žฅ ์ž‘์€ ์ข…์€ ์‡ ํ‘ธ๋ฅธํŽญ๊ท„์œผ๋กœ, ํ‚ค๋Š” ์•ฝ 40์„ผํ‹ฐ๋ฏธํ„ฐ์—
                                  ๋ชธ๋ฌด๊ฒŒ๊ฐ€ 1ํ‚ฌ๋กœ๊ทธ๋žจ์— ๋ถˆ๊ณผํ•˜๋‹ค. ์ผ๋ฐ˜์ ์œผ๋กœ ํŽญ๊ท„์€ ๋ฉ์น˜๊ฐ€ ํด์ˆ˜๋ก ์—ด์„ ์ž˜ ๋ณด๊ด€ํ•ด์„œ
                                  ์ถ”์šด ์ง€๋ฐฉ์— ์‚ด๊ณ , ์ž‘์€ ํŽญ๊ท„๋“ค์€ ์˜จ๋Œ€๋‚˜ ์‹ฌ์ง€์–ด ์—ด๋Œ€์—์„œ ๋ฐœ๊ฒฌ๋œ๋‹ค.')

SensSms::Client.new.deliver ํ•จ์ˆ˜๋ฅผ ์•„๋ž˜ argument ๋“ค๊ณผ ํ•จ๊ป˜ ํ˜ธ์ถœํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.

From Number

from_number key๋กœ Ncloud SENS ์ฝ˜์†”์— ๋“ฑ๋ก๋œ ๋ฐœ์‹ ์ž ๋ฒˆํ˜ธ๋ฅผ ์„ค์ • ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

To Number

to_numbers key๋กœ ์ˆ˜์‹ ์ž ๋ฒˆํ˜ธ๋ฅผ ์„ค์ • ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

to_numbers: ['01012345678', '01009876543']

๋˜ํ•œ to_numbers key๋Š” Array type ์œผ๋กœ ์—ฌ๋Ÿฌ ๋ฒˆํ˜ธ๋ฅผ ์ง€์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. (์˜ˆ. numbers: ['01012345678', '01009876543'] )

Type

type key๋กœ ๋ฉ”์‹œ์ง€ ํƒ€์ž…์„ ์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

SMS๋Š” ์ œ๋ชฉ์„ ์“ธ ์ˆ˜ ์—†๊ณ , 80๋ฐ”์ดํŠธ๋กœ ์ œํ•œ๋˜๋Š” ์งง์€ ๋ฉ”์‹œ์ง€๋ฅผ ๋ณด๋‚ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

LMS๋Š” ์ œ๋ชฉ์„ ์“ธ ์ˆ˜ ์žˆ๊ณ , 2,000๋ฐ”์ดํŠธ๋กœ ์ œํ•œ๋˜๋Š” ๊ธด ๋ฉ”์‹œ์ง€๋ฅผ ๋ณด๋‚ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Title

๊ธฐ๋ณธ์ ์œผ๋กœ ์ด key๋Š” optional์ด๋ฉฐ, LMS ๋ฉ”์‹œ์ง€์—์„œ ์ œ๋ชฉ์šฉ๋„๋กœ ์“ฐ์ž…๋‹ˆ๋‹ค. ๋ฌผ๋ก  SMS ํƒ€์ž…์—์„œ ์“ธ ์ˆ˜ ์žˆ์ง€๋งŒ, ์•„๋ฌด์ผ๋„ ์ƒ๊ธฐ์ง€ ์•Š์„ ๊ฒƒ์ž…๋‹ˆ๋‹ค.

Message

ํ…์ŠคํŠธ ๋ฉ”์‹œ์ง€์ž…๋‹ˆ๋‹ค.

Contributing

๋ฒ„๊ทธ ๋ฆฌํฌํŠธ์™€ ํ’€๋ฆฌํ€˜์Šค๋Š” ํ™˜์˜์ž…๋‹ˆ๋‹ค.

License

The gem is available as open source under the terms of the MIT License.