bitrix24_cloud_api 0.1.0 → 0.1.2

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: 84085ace187be8919be8a75f9504323d4de260c0
4
- data.tar.gz: d122f691d8b5703228acdf08c12575b89d52f6e0
3
+ metadata.gz: 5159253f72c36ac996990d4c399611008be7fc5f
4
+ data.tar.gz: 1e0a269fa6c15b2a19fb2ed2b4f44c939235f075
5
5
  SHA512:
6
- metadata.gz: 0e04975c75b6df639cd8ac3bb685d00e19b6ee8335f181c2cdb1e92a72492c2b63c7095cb4800e9375d8fc57c69d8442c6d38af213acbe6db7b55d330dcaffad
7
- data.tar.gz: e1a79ab3a3b32bf317727afffe3e58757b0819fd008c7ae4e734992fd8ca734b584ed560b5d1c4daa259a7a49439662c27e38423083233253fd5a96d9d3e7e39
6
+ metadata.gz: be7f8a8a9a625e993fc6da21543d8987fbe2f53185d3b5cf2e794044f83664afd9039335fddd7e6c45c5046efbc5c2414c41a604a5a7cba255647c2eca8600f5
7
+ data.tar.gz: f0466a691abd36b383766c8af28fe5c39a1f71feb9ab541b39069af07a688fbc69601bd44aeac9c385d7b6acf209b2f4c2b1e21a07a735064006c47256d0e21d
data/.gitignore CHANGED
@@ -7,4 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
- /.idea/
10
+ .idea/
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
+ [![Build Status](https://travis-ci.org/nononoy/bitrix24_cloud_api.svg?branch=master)](https://travis-ci.org/nononoy/bitrix24_cloud_api)
2
+
1
3
  # Bitrix24CloudApi
2
4
 
3
- Ruby library for [Bitrix24 REST API](https://dev.1c-bitrix.ru/rest_help/index.php) **(only Cloud version)**.
5
+ Ruby library for [Bitrix24 REST API](https://dev.1c-bitrix.ru/rest_help/index.php).
4
6
 
5
7
  ## Installation
6
8
 
@@ -51,46 +53,8 @@ it's response contains a hash with refreshed *oauth2 credentials*.
51
53
  If you already **have a valid access_token** add it to the client's attributes `@client.update(access_token: access_token)` or create a new client instance `@client = Bitrix24CloudApi::Client.new(access_token: access_token)`.
52
54
 
53
55
  ### CRM
54
-
55
- Available models
56
56
 
57
- * Bitrix24CloudApi::CRM::Activity
58
- * Bitrix24CloudApi::CRM::ACTIVITY::Communication
59
-
60
- * Bitrix24CloudApi::CRM::Company
61
- * Bitrix24CloudApi::CRM::COMPANY::Userfield
62
-
63
- * Bitrix24CloudApi::CRM::Contact
64
- * Bitrix24CloudApi::CRM::CONTACT::Userfield
65
-
66
- * Bitrix24CloudApi::CRM::Currency
67
- * Bitrix24CloudApi::CRM::CURRENCY::Localizations
68
-
69
- * Bitrix24CloudApi::CRM::Deal
70
- * Bitrix24CloudApi::CRM::DEAL::Userfield
71
- * Bitrix24CloudApi::CRM::DEAL::ProductRows
72
-
73
- * Bitrix24CloudApi::CRM::Lead
74
- * Bitrix24CloudApi::CRM::LEAD::Userfield
75
- * Bitrix24CloudApi::CRM::LEAD::ProductRows
76
-
77
- * Bitrix24CloudApi::CRM::Quote
78
- * Bitrix24CloudApi::CRM::QUOTE::Userfield
79
- * Bitrix24CloudApi::CRM::QUOTE::ProductRows
80
-
81
- * Bitrix24CloudApi::CRM::Localizations
82
- * Bitrix24CloudApi::CRM::Product
83
- * Bitrix24CloudApi::CRM::ProductRows
84
- * Bitrix24CloudApi::CRM::ProductSection
85
- * Bitrix24CloudApi::CRM::Userfield
86
- * Bitrix24CloudApi::CRM::Duplicate
87
- * Bitrix24CloudApi::CRM::Enum
88
- * Bitrix24CloudApi::CRM::Invoice
89
- * Bitrix24CloudApi::CRM::InvoiceStatus
90
- * Bitrix24CloudApi::CRM::Communication
91
- * Bitrix24CloudApi::CRM::Catalog
92
-
93
- All models' metods are provided. Second attribute in method call is a hash for bitrix24 REST API query. Example:
57
+ All REST API methods are provided. Second attribute in method call is a hash for bitrix24 REST API query. Example:
94
58
 
95
59
  params = { fields: {TITLE: title, PHONE: [VALUE: phone, VALUE_TYPE: "WORK"]} }
96
60
  Bitrix24CloudApi::CRM::Lead.add(@client, params)
@@ -14,22 +14,18 @@ Gem::Specification.new do |spec|
14
14
  spec.homepage = "https://github.com/nononoy/bitrix24_cloud_api"
15
15
  spec.license = "MIT"
16
16
 
17
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
- # to allow pushing to a single host or delete this section to allow pushing to any host.
19
- # if spec.respond_to?(:metadata)
20
- # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
- # else
22
- # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
- # end
24
-
25
17
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
18
  spec.bindir = "exe"
27
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
20
  spec.require_paths = ["lib"]
29
21
 
22
+ spec.add_runtime_dependency "oauth2", "~> 1.1"
23
+ spec.add_runtime_dependency "httparty", "~> 0.13.7"
24
+
30
25
  spec.add_development_dependency "bundler", "~> 1.12"
31
26
  spec.add_development_dependency "rake", "~> 10.0"
32
27
  spec.add_development_dependency "rspec", "~> 3.0"
33
- spec.add_development_dependency "oauth2", "~> 1.1"
34
- spec.add_development_dependency "httparty", "~> 0.13.7"
28
+ spec.add_development_dependency "webmock"
29
+ spec.add_development_dependency 'pry'
30
+ spec.add_development_dependency 'shoulda-matchers', "~> 2.0"
35
31
  end
@@ -11,6 +11,11 @@ module Bitrix24CloudApi
11
11
  end
12
12
 
13
13
  class Activity < Bitrix24CloudApi::Crm
14
+ [:company, :contact].each do |action|
15
+ define_singleton_method(action) do |client, query = {}|
16
+ client.make_post_request(resource_url(client, action), query)
17
+ end
18
+ end
14
19
  end
15
20
  end
16
21
  end
@@ -10,49 +10,89 @@ module Bitrix24CloudApi
10
10
  end
11
11
  end
12
12
 
13
- class Userfield < Bitrix24CloudApi::Crm
13
+ class Localizations < Bitrix24CloudApi::Crm
14
14
  class << self
15
- undef_method :fields
15
+ def set(client, query = {})
16
+ client.make_post_request(resource_url(client, __method__), query)
17
+ end
18
+ end
19
+ end
16
20
 
17
- def types(client, query = {})
21
+ class Communication < Bitrix24CloudApi::Base
22
+ class << self
23
+ def fields(client, query = {})
18
24
  client.make_get_request(resource_url(client, __method__), query)
19
25
  end
20
26
  end
21
27
  end
22
28
 
23
- class Localizations < Bitrix24CloudApi::Crm
29
+ class Multifield < Bitrix24CloudApi::Base
24
30
  class << self
25
- undef_method :delete, :fields, :get
31
+ def fields(client, query = {})
32
+ client.make_get_request(resource_url(client, __method__), query)
33
+ end
34
+ end
35
+ end
26
36
 
27
- def set(client, query = {})
28
- client.make_post_request(resource_url(client, __method__), query)
37
+ class Duplicate < Bitrix24CloudApi::Base
38
+ [:findbycomm].each do |action|
39
+ define_singleton_method(action) do |client, query = {}|
40
+ client.make_get_request(resource_url(client, action), query)
29
41
  end
30
42
  end
31
43
  end
32
44
 
33
- class Communication < Bitrix24CloudApi::Crm
34
- class << self
35
- undef_method :add, :delete, :update, :get, :list
45
+ class Stage < Bitrix24CloudApi::Base
46
+ [:list, :fields].each do |action|
47
+ define_singleton_method(action) do |client, query = {}|
48
+ client.make_get_request(resource_url(client, action), query)
49
+ end
36
50
  end
37
51
  end
38
52
 
39
- class Duplicate < Bitrix24CloudApi::Crm
40
- class << self
41
- undef_method :add, :delete, :update, :get, :list
53
+ class Enum < Bitrix24CloudApi::Base
54
+ [:ownertype, :contenttype, :activitytype, :activitypriority, :activitydirection,
55
+ :activitynotifytype, :fields].each do |action|
56
+ define_singleton_method(action) do |client, query = {}|
57
+ client.make_get_request(resource_url(client, action), query)
58
+ end
59
+ end
60
+ end
42
61
 
43
- def findbycomm(client, query = {})
62
+ class Settings < Bitrix24CloudApi::Base
63
+ class << self
64
+ def fields(client, query = {})
44
65
  client.make_get_request(resource_url(client, __method__), query)
45
66
  end
46
67
  end
47
68
  end
48
69
 
49
- class Enum < Bitrix24CloudApi::Crm
70
+ class Enumeration < Bitrix24CloudApi::Base
50
71
  class << self
51
- undef_method :add, :delete, :update, :get, :list
72
+ def fields(client, query = {})
73
+ client.make_get_request(resource_url(client, __method__), query)
74
+ end
52
75
  end
76
+ end
53
77
 
54
- [:ownertype, :contenttype, :activitytype, :activitypriority, :activitydirection,
55
- :activitynotifytype].each do |action|
78
+ class Paysystem < Bitrix24CloudApi::Base
79
+ [:list, :fields].each do |action|
80
+ define_singleton_method(action) do |client, query = {}|
81
+ client.make_get_request(resource_url(client, action), query)
82
+ end
83
+ end
84
+ end
85
+
86
+ class PersonType < Bitrix24CloudApi::Base
87
+ [:list, :fields].each do |action|
88
+ define_singleton_method(action) do |client, query = {}|
89
+ client.make_get_request(resource_url(client, action), query)
90
+ end
91
+ end
92
+ end
93
+
94
+ class Entity < Bitrix24CloudApi::Base
95
+ [:types, :items].each do |action|
56
96
  define_singleton_method(action) do |client, query = {}|
57
97
  client.make_get_request(resource_url(client, action), query)
58
98
  end
@@ -0,0 +1,9 @@
1
+ module Bitrix24CloudApi
2
+ module CRM
3
+ class Address < Bitrix24CloudApi::Crm
4
+ class << self
5
+ undef_method :get
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,22 @@
1
+ module Bitrix24CloudApi
2
+ module CRM
3
+ module DEAL_CATEGORY
4
+ def self.const_missing(c)
5
+ if c == :Stage
6
+ target_class = Bitrix24CloudApi::CRM.const_get(c)
7
+ target_class.define_singleton_method(:resource_path) { "crm.dealcategory.#{c.downcase}" }
8
+ target_class
9
+ end
10
+ end
11
+ end
12
+
13
+ class DealCategory < Bitrix24CloudApi::Crm
14
+
15
+ [:status].each do |action|
16
+ define_singleton_method(action) do |client, query = {}|
17
+ client.make_get_request(resource_url(client, action), query)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,30 @@
1
+ module Bitrix24CloudApi
2
+ module CRM
3
+ module EXTERNALCHANNEL
4
+ def self.const_missing(c)
5
+ if c == :Activity
6
+ target_class = Bitrix24CloudApi::CRM.const_get(c)
7
+ target_class.define_singleton_method(:resource_path) { "crm.externalchannel.#{c.downcase}" }
8
+ target_class
9
+ end
10
+ end
11
+
12
+ class Connector < Bitrix24CloudApi::Base
13
+ class << self
14
+ def register(client, query = {})
15
+ client.make_post_request(resource_url(client, __method__), query)
16
+ end
17
+ end
18
+ end
19
+ end
20
+
21
+ class Externalchannel < Bitrix24CloudApi::Base
22
+
23
+ [:company, :contact].each do |action|
24
+ define_singleton_method(action) do |client, query = {}|
25
+ client.make_get_request(resource_url(client, action), query)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -1,5 +1,15 @@
1
1
  module Bitrix24CloudApi
2
2
  module CRM
3
+ module INVOICE
4
+ def self.const_missing(c)
5
+ if c == :Userfield
6
+ target_class = Bitrix24CloudApi::CRM.const_get(c)
7
+ target_class.define_singleton_method(:resource_path) { "crm.invoice.#{c.downcase}" }
8
+ target_class
9
+ end
10
+ end
11
+ end
12
+
3
13
  class Invoice < Bitrix24CloudApi::Crm
4
14
  end
5
15
  end
@@ -0,0 +1,11 @@
1
+ module Bitrix24CloudApi
2
+ module CRM
3
+ class LiveFeedMessage < Bitrix24CloudApi::Base
4
+ class << self
5
+ def add(client, query = {})
6
+ client.make_post_request(resource_url(client, __method__), query)
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,6 @@
1
+ module Bitrix24CloudApi
2
+ module CRM
3
+ class Measure < Bitrix24CloudApi::Crm
4
+ end
5
+ end
6
+ end
@@ -1,5 +1,25 @@
1
1
  module Bitrix24CloudApi
2
2
  module CRM
3
+ module PRODUCT
4
+ module PROPERTY
5
+ def self.const_missing(c)
6
+ if [:Settings, :Enumeration].any?{|x| x == c}
7
+ target_class = Bitrix24CloudApi::CRM.const_get(c)
8
+ target_class.define_singleton_method(:resource_path) { "crm.product.property.#{c.downcase}" }
9
+ target_class
10
+ end
11
+ end
12
+ end
13
+
14
+ def self.const_missing(c)
15
+ if c == :Property
16
+ target_class = Bitrix24CloudApi::CRM.const_get(c)
17
+ target_class.define_singleton_method(:resource_path) { "crm.product.#{c.downcase}" }
18
+ target_class
19
+ end
20
+ end
21
+ end
22
+
3
23
  class Product < Bitrix24CloudApi::Crm
4
24
  end
5
25
  end
@@ -0,0 +1,11 @@
1
+ module Bitrix24CloudApi
2
+ module CRM
3
+ class ProductRow < Bitrix24CloudApi::Base
4
+ [:list, :fields].each do |action|
5
+ define_singleton_method(action) do |client, query = {}|
6
+ client.make_get_request(resource_url(client, action), query)
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Bitrix24CloudApi
2
+ module CRM
3
+ class Property < Bitrix24CloudApi::Crm
4
+ class << self
5
+ def types(client, query = {})
6
+ client.make_get_request(resource_url(client, __method__), query)
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,54 @@
1
+ module Bitrix24CloudApi
2
+ module CRM
3
+ module REQUISITE
4
+ module PRESET
5
+ class Field < Bitrix24CloudApi::Crm
6
+ class << self
7
+ def availabletoadd(client, query = {})
8
+ client.make_get_request(resource_url(client, __method__), query)
9
+ end
10
+ end
11
+ end
12
+ end
13
+
14
+ def self.const_missing(c)
15
+ if [:Userfield].any?{|x| x == c}
16
+ target_class = Bitrix24CloudApi::CRM.const_get(c)
17
+ target_class.define_singleton_method(:resource_path) { "crm.requisite.#{c.downcase}" }
18
+ target_class
19
+ end
20
+ end
21
+
22
+ class Bankdetail < Bitrix24CloudApi::Crm
23
+ end
24
+
25
+ class Link < Bitrix24CloudApi::Base
26
+ [:fields, :get, :list].each do |action|
27
+ define_singleton_method(action) do |client, query = {}|
28
+ client.make_get_request(resource_url(client, action), query)
29
+ end
30
+ end
31
+
32
+ [:register, :unregister].each do |action|
33
+ define_singleton_method(action) do |client, query = {}|
34
+ client.make_post_request(resource_url(client, action), query)
35
+ end
36
+ end
37
+ end
38
+
39
+ class Preset < Bitrix24CloudApi::Crm
40
+ class << self
41
+ def countries(client, query = {})
42
+ client.make_get_request(resource_url(client, __method__), query)
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+ class Requisite < Bitrix24CloudApi::Crm
49
+ class << self
50
+ undef_method :update
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,16 @@
1
+ module Bitrix24CloudApi
2
+ module CRM
3
+ module STATUS
4
+ def self.const_missing(c)
5
+ if c == :Entity
6
+ target_class = Bitrix24CloudApi::CRM.const_get(c)
7
+ target_class.define_singleton_method(:resource_path) { "crm.status.#{c.downcase}" }
8
+ target_class
9
+ end
10
+ end
11
+ end
12
+
13
+ class Status < Bitrix24CloudApi::Crm
14
+ end
15
+ end
16
+ end