bitrix_webhook 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1ac8d3f392dc7e2e4a1a56d43e777efb75c63457
4
- data.tar.gz: 044c680f808943aa6bea1ad4f004266795737071
3
+ metadata.gz: 1dc4edf803972ca7e9faefbde10cfc5bfc7d8c84
4
+ data.tar.gz: eae0616ffb77999497bb57a794edafc38580dc2f
5
5
  SHA512:
6
- metadata.gz: 7db0feca2ccba1f901d1627c90033d536f4a223f7c4a142b401af3fabd92d5fdef59c6eb4564a493e5162ed0fb4c1942e6d69be8d628a3306d5009571e036531
7
- data.tar.gz: 973f73fa20837c24635de76482bef8a8f8d449aacb61f5654ed88255bb167fa866ec9bbd89341c06e07556014e8a687f9564586a4972860e1d5feccbd797d51d
6
+ metadata.gz: cc3c5a47f4cad97245b47efba5a5642696d3a71b2c094ac8cedec40a2e31ab049e3571bd97f3e4ad0fa165a249bfdc3adbb77ad39b3db06f07273254b24b6485
7
+ data.tar.gz: dfef522d39e68b786caa61e5b2d58a59c6daa6838571fe174513ed4ec9a1daa7e93312692320320141a444fdc0b51028d5b94a19881bc11a4474b1b0b6d653d5
data/.gitignore CHANGED
@@ -6,3 +6,5 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ # RubyMine project files
10
+ .idea
@@ -0,0 +1,39 @@
1
+ module BitrixWebhook
2
+ module CRM
3
+ module LEAD
4
+
5
+ DEFAULT = {
6
+ fname: '',
7
+ lname: '',
8
+ status_id: 'NEW',
9
+ opened: 'Y',
10
+ assigned_by_id: 1,
11
+ register_sonet_event: 'Y',
12
+ }
13
+
14
+ def self.base_url(method)
15
+ "https://#{BitrixWebhook.bitrix24_url}/rest/1/#{ BitrixWebhook.hook}/crm.lead.#{method}.json?"
16
+ end
17
+
18
+ def self.add(options = {})
19
+ options = DEFAULT.merge(options )
20
+ post_url = base_url("add").to_s + "fields%5BTITLE%5D=#{options[:fname].to_s + '+' + options[:lname].to_s}&" +
21
+ "fields%5BNAME%5D=#{options[:fname]}&" +
22
+ "fields%5BLAST_NAME%5D=#{options[:lname]}&" +
23
+ "fields%5BSTATUS_ID%5D=#{options[:status_id]}&" +
24
+ "fields%5BOPENED%5D=#{options[:opened]}&" +
25
+ "fields%5BASSIGNED_BY_ID%5D=#{options[:assigned_by_id]}&" +
26
+ "fields%5BPHONE%5D%5B0%5D%5BVALUE%5D=#{options[:phone]}&" +
27
+ "fields%5BEMAIL%5D%5B0%5D%5BVALUE%5D=#{options[:email]}&" +
28
+ "params%5BREGISTER_SONET_EVENT%5D=#{options[:register_sonet_event]}"
29
+
30
+ begin
31
+ JSON.parse(HTTP.post(post_url).body)
32
+ rescue => e
33
+ {error:e}.to_json
34
+ end
35
+ end
36
+
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,6 @@
1
+ module BitrixWebhook
2
+ class Crm
3
+ end
4
+ end
5
+
6
+ require 'bitrix_webhook/CRM/lead'
@@ -1,3 +1,3 @@
1
1
  module BitrixWebhook
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -1,5 +1,6 @@
1
1
  require 'bitrix_webhook/version'
2
2
  require 'bitrix_webhook/config'
3
+ require 'bitrix_webhook/crm'
3
4
  require 'net/http'
4
5
  require 'uri'
5
6
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitrix_webhook
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Serhii Danovskyi
@@ -54,7 +54,9 @@ files:
54
54
  - bin/setup
55
55
  - bitrix_webhook.gemspec
56
56
  - lib/bitrix_webhook.rb
57
+ - lib/bitrix_webhook/CRM/lead.rb
57
58
  - lib/bitrix_webhook/config.rb
59
+ - lib/bitrix_webhook/crm.rb
58
60
  - lib/bitrix_webhook/version.rb
59
61
  - lib/helpers/configuration.rb
60
62
  - lib/rails/generators/bitrix_webhook/config/config_generator.rb