From 94480744c10bbafeccff3e51abb38e5d0df43aa2 Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Sat, 3 Sep 2022 22:48:12 +0300 Subject: [PATCH] add config --- .gitignore | 2 ++ config.example.yml | 3 +++ src/modules/sms_ru.cr | 6 +++++- 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 config.example.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0abbe52 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +lib/ +config.yml diff --git a/config.example.yml b/config.example.yml new file mode 100644 index 0000000..1ca073f --- /dev/null +++ b/config.example.yml @@ -0,0 +1,3 @@ +--- +sms.ru: + api_id: F1FC9A76-1408-E4CF-1F89-E7CC756762B6 diff --git a/src/modules/sms_ru.cr b/src/modules/sms_ru.cr index abe52dd..a5709ab 100644 --- a/src/modules/sms_ru.cr +++ b/src/modules/sms_ru.cr @@ -1,6 +1,10 @@ +require "yaml" require "http/client" +CONFIG = File.open("./config.yml") { |file| YAML.parse(file) } +CONFIG.class + get "/api/v1.0/smsru_status" do - response = HTTP::Client.get "https://sms.ru/my/free?api_id=F1FC9A76-1408-E4CF-1F89-E7CC756762B6&json=1" + response = HTTP::Client.get "https://sms.ru/my/free?api_id=#{CONFIG["sms.ru"]["api_id"]}&json=1" response.body end