bitrix_webhook 0.2.6 → 0.2.7

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
- SHA1:
3
- metadata.gz: 3d899609882e1ef93241c03813b0b830b2dd9e7e
4
- data.tar.gz: cee2deae8fd0a9e093de9de766f370629d6faa32
2
+ SHA256:
3
+ metadata.gz: c739cf30161c7366f1f593525a0631512ee70cfb11cb753510d1da3d7e980a94
4
+ data.tar.gz: 103b557c1d08e443cebe95e06caf6b36a41a30b69db554ed5946533b744e41ba
5
5
  SHA512:
6
- metadata.gz: 925a05c6b190ce9ae695162aacc8272b67052992e97d03857634ab392751ab89f52ba665ee095f9e7a86434f6f3269fb6fcaa552e3fd57bb8dd5d77bb5728cc8
7
- data.tar.gz: 020219144c0f04d4a5eef33cc8cf796c71dc475388e0cb9b66148e6dab5385851fcb169e8d06ffa824a0da0c9f659a9345c9d0016e6d85283b8061ae943db87e
6
+ metadata.gz: 005ea236e9a8d33355d06bca443818a11f34164145fe1dae31738600edcbf0f71a59c008a40c89056409626d3639604c36b9aa22f2e19f65f278682bc523d6b9
7
+ data.tar.gz: 9d2490d6cb91e713172cb0027f012ad488b00e67c34d582490982693953580db207647e2461c7be95d3bcda1c7add96bdeb9f682d89af938982873e98f022206
data/.gitignore CHANGED
@@ -3,6 +3,7 @@
3
3
  /_yardoc/
4
4
  /coverage/
5
5
  /doc/
6
+ /ruby
6
7
  /pkg/
7
8
  /spec/reports/
8
9
  /tmp/
data/README.md CHANGED
@@ -53,13 +53,53 @@ end
53
53
 
54
54
  ## Usage
55
55
 
56
- Now available only **crm.lead.add**
56
+ ###Available methods:
57
57
 
58
- *I'm sorry i didn't have time to write all methods.*
58
+ ####CRM Lead
59
+ 1. **add**
59
60
 
60
- ```ruby
61
- BitrixWebhook::CRM::LEAD.add(fname:'Serhii',lname:'Danovskyi',phone:'+380675807873',email:'serhii.danovskyi@gamil.com')
62
- ```
61
+ ```ruby
62
+ BitrixWebhook::CRM::LEAD.add(fname:'Serhii',lname:'Danovskyi',phone:'+380675807873',email:'serhii.danovskyi@gamil.com')
63
+ ```
64
+
65
+ 2. **get**
66
+
67
+ ```ruby
68
+ BitrixWebhook::CRM::LEAD.get(1)
69
+ ```
70
+
71
+ 2. **update one field**
72
+
73
+ ```ruby
74
+ BitrixWebhook::CRM::LEAD.update_one_field(1, :fname, 'Victor')
75
+ ```
76
+
77
+ ####CRM Deal
78
+ 1. **get**
79
+
80
+ ```ruby
81
+ BitrixWebhook::CRM::DEAL.get(1)
82
+ ```
83
+
84
+ ####CRM Status
85
+ 1. **list**
86
+
87
+ ```ruby
88
+ BitrixWebhook::CRM::STATUS.list
89
+ ```
90
+
91
+ ####Task Item
92
+ 1. **add**
93
+
94
+ ```ruby
95
+ BitrixWebhook::TASK::ITEM.add(title: 'Just a task title', responsible_id: 2, crm_user_id:11)
96
+ ```
97
+
98
+ 2. **getdata** by task_id
99
+
100
+ ```ruby
101
+ BitrixWebhook::CRM::DEAL.get(1)
102
+ ```
63
103
 
64
104
  ## Development
65
105
 
@@ -0,0 +1,23 @@
1
+ module BitrixWebhook
2
+ module CRM
3
+ module DEAL
4
+
5
+ def self.base_url(method)
6
+ "https://#{BitrixWebhook.bitrix24_url}/rest/#{BitrixWebhook.webhook_user}/#{ BitrixWebhook.hook}/crm.deal.#{method}?"
7
+ end
8
+
9
+ def self.get(id)
10
+ query_params = {
11
+ id: id
12
+ }.to_query
13
+ get_url = base_url('get').to_s + query_params
14
+ begin
15
+ JSON.parse(HTTP.get(get_url).body)
16
+ rescue => e
17
+ {error:e}.to_json
18
+ end
19
+ end
20
+
21
+ end
22
+ end
23
+ end
@@ -19,15 +19,21 @@ module BitrixWebhook
19
19
 
20
20
  def self.add(options = {})
21
21
  options = config.merge(options )
22
- post_url = base_url("add").to_s + "fields%5BTITLE%5D=#{options[:fname].to_s + '+' + options[:lname].to_s}&" +
23
- "fields%5BNAME%5D=#{options[:fname]}&" +
24
- "fields%5BLAST_NAME%5D=#{options[:lname]}&" +
25
- "fields%5BSTATUS_ID%5D=#{options[:status_id]}&" +
26
- "fields%5BOPENED%5D=#{options[:opened]}&" +
27
- "fields%5BASSIGNED_BY_ID%5D=#{options[:assigned_by_id]}&" +
28
- "fields%5BPHONE%5D%5B0%5D%5BVALUE%5D=#{options[:phone]}&" +
29
- "fields%5BEMAIL%5D%5B0%5D%5BVALUE%5D=#{options[:email]}&" +
30
- "params%5BREGISTER_SONET_EVENT%5D=#{options[:register_sonet_event]}"
22
+ query_params = {
23
+ fields:
24
+ { TITLE: "#{options[:fname]} #{options[:lname]}",
25
+ NAME: options[:fname],
26
+ LAST_NAME: options[:lname],
27
+ STATUS_ID: options[:status_id],
28
+ OPENED: options[:opened],
29
+ ASSIGNED_BY_ID: options[:assigned_by_id],
30
+ PHONE: { '0': { VALUE: options[:phone] } },
31
+ EMAIL: { '0': { VALUE: options[:email] } } },
32
+ params: {
33
+ REGISTER_SONET_EVENT: options[:register_sonet_event]
34
+ }
35
+ }.to_query
36
+ post_url = base_url('add').to_s + query_params
31
37
 
32
38
  begin
33
39
  JSON.parse(HTTP.post(post_url).body)
@@ -36,9 +42,28 @@ module BitrixWebhook
36
42
  end
37
43
  end
38
44
 
45
+ def self.get(id)
46
+ query_params = {
47
+ id: id
48
+ }.to_query
49
+ get_url = base_url('get').to_s + query_params
50
+ begin
51
+ JSON.parse(HTTP.get(get_url).body)
52
+ rescue => e
53
+ {error:e}.to_json
54
+ end
55
+ end
39
56
 
40
57
  def self.update_one_filed(id,filed,value)
41
- post_url = base_url("update").to_s + "id=#{id}&fields%5B#{filed}%5D=#{value}"
58
+ query_params = {
59
+ id: id,
60
+ fields: {
61
+ filed => value
62
+ }
63
+ }.to_query
64
+ post_url = base_url('update').to_s + query_params
65
+
66
+
42
67
  begin
43
68
  JSON.parse(HTTP.post(post_url).body)
44
69
  rescue => e
@@ -47,5 +72,7 @@ module BitrixWebhook
47
72
  end
48
73
 
49
74
  end
75
+
76
+ LEAD.singleton_class.send(:alias_method, :update_one_field, :update_one_filed)
50
77
  end
51
78
  end
@@ -0,0 +1,20 @@
1
+ module BitrixWebhook
2
+ module CRM
3
+ module STATUS
4
+
5
+ def self.base_url(method)
6
+ "https://#{BitrixWebhook.bitrix24_url}/rest/#{BitrixWebhook.webhook_user}/#{ BitrixWebhook.hook}/crm.status.#{method}?"
7
+ end
8
+
9
+ def self.list
10
+ get_url = base_url('list').to_s
11
+ begin
12
+ JSON.parse(HTTP.get(get_url).body)
13
+ rescue => e
14
+ {error:e}.to_json
15
+ end
16
+ end
17
+
18
+ end
19
+ end
20
+ end
@@ -1,6 +1,14 @@
1
1
  module BitrixWebhook
2
2
  class Crm
3
3
  end
4
+
5
+ class Deal
6
+ end
7
+
8
+ class Status
9
+ end
4
10
  end
5
11
 
6
- require 'bitrix_webhook/CRM/lead'
12
+ require 'bitrix_webhook/CRM/lead'
13
+ require 'bitrix_webhook/CRM/deal'
14
+ require 'bitrix_webhook/CRM/status'
@@ -0,0 +1,50 @@
1
+ module BitrixWebhook
2
+ module TASK
3
+ module ITEM
4
+
5
+ def self.config
6
+ {
7
+ responsible_id: BitrixWebhook.webhook_user
8
+ }
9
+ end
10
+
11
+ def self.base_url(method)
12
+ "https://#{BitrixWebhook.bitrix24_url}/rest/#{BitrixWebhook.webhook_user}/#{ BitrixWebhook.hook}/task.item.#{method}?"
13
+ end
14
+
15
+ def self.add(options = {})
16
+ options = config.merge(options)
17
+ query_params = {
18
+ fields: {
19
+ TITLE: options[:title],
20
+ RESPONSIBLE_ID: options[:responsible_id],
21
+ DEADLINE: (DateTime.now + 1.day).strftime("%FT%T%:z"),
22
+ UF_CRM_TASK: ["D_#{options[:crm_user_id]}"]
23
+ },
24
+ }.to_query
25
+ post_url = base_url('add').to_s + query_params
26
+
27
+ begin
28
+ JSON.parse(HTTP.post(post_url).body)
29
+ rescue => e
30
+ {error:e}.to_json
31
+ end
32
+ end
33
+
34
+
35
+ def self.getdata(task_id)
36
+ query_params = {
37
+ TASKID: task_id
38
+ }.to_query
39
+ post_url = base_url('getdata').to_s + query_params
40
+
41
+ begin
42
+ JSON.parse(HTTP.post(post_url).body)
43
+ rescue => e
44
+ {error:e}.to_json
45
+ end
46
+ end
47
+
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,6 @@
1
+ module BitrixWebhook
2
+ class Task
3
+ end
4
+ end
5
+
6
+ require 'bitrix_webhook/task/item'
@@ -1,3 +1,3 @@
1
1
  module BitrixWebhook
2
- VERSION = "0.2.6"
2
+ VERSION = "0.2.7"
3
3
  end
@@ -1,6 +1,7 @@
1
1
  require 'bitrix_webhook/version'
2
2
  require 'bitrix_webhook/config'
3
3
  require 'bitrix_webhook/crm'
4
+ require 'bitrix_webhook/task'
4
5
  require 'net/http'
5
6
  require 'uri'
6
7
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitrix_webhook
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Serhii Danovskyi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-06-22 00:00:00.000000000 Z
11
+ date: 2018-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -54,9 +54,13 @@ files:
54
54
  - bin/setup
55
55
  - bitrix_webhook.gemspec
56
56
  - lib/bitrix_webhook.rb
57
+ - lib/bitrix_webhook/CRM/deal.rb
57
58
  - lib/bitrix_webhook/CRM/lead.rb
59
+ - lib/bitrix_webhook/CRM/status.rb
58
60
  - lib/bitrix_webhook/config.rb
59
61
  - lib/bitrix_webhook/crm.rb
62
+ - lib/bitrix_webhook/task.rb
63
+ - lib/bitrix_webhook/task/item.rb
60
64
  - lib/bitrix_webhook/version.rb
61
65
  - lib/helpers/configuration.rb
62
66
  - lib/rails/generators/bitrix_webhook/config/config_generator.rb
@@ -82,9 +86,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
86
  version: '0'
83
87
  requirements: []
84
88
  rubyforge_project:
85
- rubygems_version: 2.5.1
89
+ rubygems_version: 2.7.7
86
90
  signing_key:
87
91
  specification_version: 4
88
92
  summary: bitrix24 webhook rails
89
93
  test_files: []
90
- has_rdoc: