File tree 3 files changed +33
-2
lines changed
lib/generators/sms_ru/install
3 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -21,16 +21,33 @@ And then execute:
21
21
22
22
## Usage
23
23
24
- Firstly, add ` sms_ru.rb ` to initializers. Here you can set api_id.
24
+ After you add 'sms_ru' to your Gemfile, you need to run the
25
+ generator:
26
+
27
+ ``` console
28
+ rails generate sms_ru:install
29
+ ```
30
+
31
+ The generator will install an initializer to
32
+ ` config/initializers/sms_ru.rb ` . Here you can set app_id
25
33
26
34
``` ruby
27
35
SmsRu .setup do |config |
28
36
config.api_id = Rails .application.secrets.sms_ru_key
29
- # ## you can setup default settings for every sms.ru API query you want
37
+ end
38
+ ```
39
+
40
+ Also you can setup default settings for every sms.ru API query
41
+
42
+ ``` ruby
43
+ SmsRu .setup do |config |
44
+ ...
30
45
config.queries.sms.send.from = ' fasteria.ru'
31
46
end
32
47
```
33
48
49
+ Example:
50
+
34
51
``` ruby
35
52
SmsRu .sms.send(api_id: ' abcdef' , to: ' 79112223344' , text: ' Sample message' ) # => '100\n000-00000'
36
53
SmsRu .my.balance # => '100\n87.79'
Original file line number Diff line number Diff line change
1
+ module SmsRu
2
+ module Generators
3
+ class InstallGenerator < Rails ::Generators ::Base
4
+ source_root File . expand_path ( "../templates" , __FILE__ )
5
+
6
+ def copy_initializer
7
+ template 'sms_ru.rb' , 'config/initializers/sms_ru.rb'
8
+ end
9
+ end
10
+ end
11
+ end
Original file line number Diff line number Diff line change
1
+ SmsRu . setup do |config |
2
+ config . api_id = Rails . application . secrets . sms_ru_key
3
+ end
You can’t perform that action at this time.
0 commit comments