Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/say8425/sens_sms
๐ฉ Send SMS with Ncloud Sens
https://github.com/say8425/sens_sms
Last synced: 3 months ago
JSON representation
๐ฉ Send SMS with Ncloud Sens
- Host: GitHub
- URL: https://github.com/say8425/sens_sms
- Owner: say8425
- License: mit
- Created: 2019-11-05T06:16:41.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-05-19T14:35:59.000Z (over 4 years ago)
- Last Synced: 2024-05-02T05:51:10.341Z (8 months ago)
- Language: Ruby
- Homepage:
- Size: 53.7 KB
- Stars: 7
- Watchers: 3
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.en.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Ncloud Sens SMS Gem
[![gem version](https://img.shields.io/gem/v/sens_sms?color=cc342d&logo=ruby&logoColor=cc342d)](https://rubygems.org/gems/sens_sms)
[![GitHub Actions Test](https://github.com/say8425/sens_sms/workflows/Test/badge.svg)](https://github.com/say8425/sens_sms/actions?query=workflow%3ATest)
[![GitHub Actions Release](https://github.com/say8425/sens_sms/workflows/Release/badge.svg)](https://github.com/say8425/sens_sms/actions?query=workflow%3ARelease)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/say8425/sens_sms/blob/master/LICENSE)Send your SMS with [Ncloud Sens](https://www.ncloud.com/product/applicationService/sens) in Ruby.
ํ๊ตญ์ด ๋ฌธ์๋ฅผ ์ฝ๊ณ ์ถ๋ค๋ฉด, [์ฌ๊ธฐ](https://github.com/say8425/sens_sms/blob/master/README.ko.md)๋ฅผ ํด๋ฆญํ์ธ์
## Installation
### Rails
Add this line to your application's Gemfile:
```ruby
gem 'sens_sms'
```Then execute:
```shell script
$ bundle
```Finally, run the generator:
```shell script
$ rails generate sens_sms:install
```At this point, you can find a sens_sms configuration file located at `YOUR_PROJECT/config/initializers/sens_sms.rb`.
```ruby
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
```You can set your Ncloud access keys here, but we recommend to use Environment Values.
Generating access keys guide is [here](https://docs.ncloud.com/en/sens/sens-1-2.html).### Sinatra or Plain ol' Ruby
Install the gem:
```shell script
$ gem install sens_sms
```If you plan to use sens_sms gem in plain Ruby project,
then you should call `require 'sens_sms'` and `SensSms::Client.configure` block
to set access keys before calling `deliver` method like rails generator do it.## Usage
```ruby
# SMS
SensSms::Client.new
.deliver(type: :sms,
from_number: '01012345678',
to_numbers: '01098765432',
message: '์ ์ธ๊ณ์ ์๋ ค์ง ํญ๊ท์ ์ข ๋ฅ๋ 17์ข ํน์ 18์ข ์ด๋ค.')
``````ruby
# LMS
SensSms::Client.new
.deliver(type: :lms,
from_number: '01012345678',
to_numbers: '01098765432',
title: 'ํญ๊ท',
message: '์ ์ธ๊ณ์ ์๋ ค์ง ํญ๊ท์ ์ข ๋ฅ๋ 17์ข ํน์ 18์ข ์ด๋ค. (์ ํธ๋ฅธํญ๊ท๊ณผ ํฐ๋ ๊ฐํญ๊ท์ด
์๋ณ๋๋์ง ์๋์ง์ ๋ฐ๋ผ ๋ฌ๋ผ์ง๋ค.) ๋ชจ๋ ํญ๊ท ์ข ์ ๊ณ ํฅ์ด ๋จ๋ฐ๊ตฌ์ด๊ธฐ๋ ํ์ง๋ง,
ํต๋ ๊ณผ ๋ฌ๋ฆฌ, ๋จ๊ทน๊ณผ ๊ฐ์ด ์ถ์ด ๊ธฐํ์์๋ง ์์ํ์ง๋ ์๋๋ค. ์ค์ ๋ก๋ ๋ช๋ช ์ข ๋ง์ด
๊ทน์ง๋ฐฉ์ ์ฐ๋ค. 3์ข ์ ์ด๋ ์ง๋ฐฉ์ ์ด๋ฉฐ, ๊ทธ ๊ฐ์ด๋ฐ ๊ฐ๋ผํ๊ณ ์ค ์ ๋์ ์ฌ๋ ํ ์ข ์ ๋จน์ด๋ฅผ
์ฐพ๋ค๊ฐ ์ ๋๋ฅผ ๊ฑด๋๊ธฐ๋ ํ๋ค. ๊ฐ์ฅ ํฐ ์ข ์ ํฉ์ ํญ๊ท์ผ๋ก, ๋ค ์๋ผ๋ฉด ํค๊ฐ ์ฝ 1.1๋ฏธํฐ,
๋ฌด๊ฒ๊ฐ ์ฝ 35ํฌ๋ก๊ทธ๋จ ์ด์์ด๋ค. ๊ฐ์ฅ ์์ ์ข ์ ์ ํธ๋ฅธํญ๊ท์ผ๋ก, ํค๋ ์ฝ 40์ผํฐ๋ฏธํฐ์
๋ชธ๋ฌด๊ฒ๊ฐ 1ํฌ๋ก๊ทธ๋จ์ ๋ถ๊ณผํ๋ค. ์ผ๋ฐ์ ์ผ๋ก ํญ๊ท์ ๋ฉ์น๊ฐ ํด์๋ก ์ด์ ์ ๋ณด๊ดํด์
์ถ์ด ์ง๋ฐฉ์ ์ด๊ณ , ์์ ํญ๊ท๋ค์ ์จ๋๋ ์ฌ์ง์ด ์ด๋์์ ๋ฐ๊ฒฌ๋๋ค.')
```After calling configure method, use `SensSms::Client.new.deliver` with below arguments.
### From Number
You can use `from_number` key to set sender number [registered at Ncloud SENS console](https://docs.ncloud.com/en/sens/sens-1-3.html#register-view-caller-id).
### To Number
You can use `to_numbers` key to set receiver number.
Also `to_numbers` can be set multiple numbers with Array type. (eg. `['01012345678', '01009876543']` )### Type
You can use `type` key to choose message type.
#### [SMS Type](https://docs.ncloud.com/en/sens/sens-1-3.html#send-sms-messages)
SMS can send short message with up to 80 bytes and this type cannot use title.
However, sending title key will do not raise any error, it'll be just ignored.#### [LMS Type](https://docs.ncloud.com/en/sens/sens-1-3.html#send-lms-messages)
LMS type can send title and super long text message with up to 2,000 bytes.
### Title
Basically, This key is optional used by LMS message type for title.
Of course, this key can be used in SMS message type, but nothing will be happened.### Message
Text message.
## Contributing
Bug reports and pull requests are welcome.
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).