lenza-notifier 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +3 -0
- data/README.md +46 -0
- data/lib/lenza/config.rb +18 -0
- data/lib/lenza/notifier.rb +33 -0
- data/lib/lenza/version.rb +3 -0
- data/lib/lenza-notifier.rb +2 -0
- data/lib/lenza_notifier.rb +1 -0
- metadata +53 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: bb3b7fdd207dee4924e62f6d8944add97b0d4d49f4b006c17112cf1fc0d00566
|
|
4
|
+
data.tar.gz: b17b9ea778ef4e215e267737637c6f0b79d4232e089099c8c298cfd2b7128457
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: bdf748596641c3a0f08e28873fde40c4e52a82a02a3ccb0467aa632432da6a48d2eb9e49209e69b179285e10a9f5b9e37987fb2f29d15e5249362bf355e9d5b0
|
|
7
|
+
data.tar.gz: fbb138cff94aa75ed4c73642b1557804722ef0dffc9c68e7b76eda24df839472c53d410d57bd37c6b46d06a04e434580e7ad3e2d79be067912a0afdba29129c2
|
data/CHANGELOG.md
ADDED
data/README.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Lenza Notifier
|
|
2
|
+
[](https://badge.fury.io/rb/lenza-notifier)
|
|
3
|
+
|
|
4
|
+
Ruby-гем для работы с API мессенджера Lenza.
|
|
5
|
+
|
|
6
|
+

|
|
7
|
+
|
|
8
|
+
## Установка
|
|
9
|
+
|
|
10
|
+
Добавить в Gemfile
|
|
11
|
+
|
|
12
|
+
```ruby
|
|
13
|
+
gem 'lenza-notifier'
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
И выполнить:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
bundle
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Использование
|
|
23
|
+
|
|
24
|
+
Создайте вебхук в пространстве Lenza и отправьте сообщение, передав его URL:
|
|
25
|
+
|
|
26
|
+
```ruby
|
|
27
|
+
Lenza::Notifier.new('https://api.lenzaos.com/integration/webhook/Jsp_K2g6D6nPckttVvQxCG71SQ0Z6f8C74Xd7S9').ping('Привет!')
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Конфигурация
|
|
31
|
+
|
|
32
|
+
Добавьте файл конфигурации `config/initializers/lenza.rb` и задайте URL вебхука (настройка необязательна):
|
|
33
|
+
|
|
34
|
+
```ruby
|
|
35
|
+
Lenza.configure do |config|
|
|
36
|
+
|
|
37
|
+
config.webhook_url = ENV['LENZA_WEBHOOK_URL']
|
|
38
|
+
|
|
39
|
+
end
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
После этого передавать URL вебхука при отправке сообщения не обязательно:
|
|
43
|
+
|
|
44
|
+
```ruby
|
|
45
|
+
Lenza::Notifier.new.ping('Привет!')
|
|
46
|
+
```
|
data/lib/lenza/config.rb
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module Lenza
|
|
2
|
+
class Notifier
|
|
3
|
+
|
|
4
|
+
def initialize(webhook_url = nil)
|
|
5
|
+
url = Lenza::Config.webhook_url || webhook_url
|
|
6
|
+
|
|
7
|
+
if url.blank?
|
|
8
|
+
raise StandardError.new('URL вебхука отсутствует')
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
@uri = URI.parse(url)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def ping(message)
|
|
15
|
+
# формирование запроса
|
|
16
|
+
request = Net::HTTP::Post.new(@uri)
|
|
17
|
+
request.content_type = 'application/json'
|
|
18
|
+
request.body = JSON.dump(message:)
|
|
19
|
+
|
|
20
|
+
# отправка запроса
|
|
21
|
+
response = Net::HTTP.start(@uri.hostname, @uri.port, use_ssl: true) do |http|
|
|
22
|
+
http.request(request)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# ответ
|
|
26
|
+
{
|
|
27
|
+
code: response.code,
|
|
28
|
+
body: JSON.parse(response.body)
|
|
29
|
+
}
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'lenza-notifier'
|
metadata
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: lenza-notifier
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Павел Бабин
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2025-01-20 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: Ruby-wrapper для отправки сообщений в мессенджере Lenza с помощью вебхуков
|
|
14
|
+
email: babin359@icloud.com
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- CHANGELOG.md
|
|
20
|
+
- README.md
|
|
21
|
+
- lib/lenza-notifier.rb
|
|
22
|
+
- lib/lenza/config.rb
|
|
23
|
+
- lib/lenza/notifier.rb
|
|
24
|
+
- lib/lenza/version.rb
|
|
25
|
+
- lib/lenza_notifier.rb
|
|
26
|
+
homepage: https://gitverse.ru/babin/lenza-notifier
|
|
27
|
+
licenses:
|
|
28
|
+
- MIT
|
|
29
|
+
metadata:
|
|
30
|
+
rubygems_mfa_required: 'true'
|
|
31
|
+
changelog_uri: https://gitverse.ru/babin/lenza-notifier/content/master/CHANGELOG.md
|
|
32
|
+
source_code_uri: https://gitverse.ru/babin/lenza-notifier
|
|
33
|
+
bug_tracker_uri: https://gitverse.ru/babin/lenza-notifier/tasktracker
|
|
34
|
+
post_install_message:
|
|
35
|
+
rdoc_options: []
|
|
36
|
+
require_paths:
|
|
37
|
+
- lib
|
|
38
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
39
|
+
requirements:
|
|
40
|
+
- - ">="
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
version: 3.1.0
|
|
43
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
requirements: []
|
|
49
|
+
rubygems_version: 3.0.6
|
|
50
|
+
signing_key:
|
|
51
|
+
specification_version: 4
|
|
52
|
+
summary: Ruby-wrapper для отправки сообщений в мессенджере Lenza с помощью вебхуков
|
|
53
|
+
test_files: []
|