bitrix24_cloud_api 0.1.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.
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.12.4
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at lucky-@mail.ru. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in bitrix24_cloud_api.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 nononoy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,115 @@
1
+ # Bitrix24CloudApi
2
+
3
+ Ruby library for [Bitrix24 REST API](https://dev.1c-bitrix.ru/rest_help/index.php) **(only Cloud version)**.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'bitrix24_cloud_api'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install bitrix24_cloud_api
20
+
21
+ ## Usage
22
+
23
+ ### Oauth2
24
+ Bitrix24's oauth2 implementation not compatible with *oauth2 gem*, so there is some changes in realization. Firstly, you have to create client entity. CLIENT_ID and CLIENT_SECRET you can find in your Bitrix24 Marketplace app.
25
+
26
+ params = { endpoint: api_endpoint,
27
+ client_id: CLIENT_ID,
28
+ client_secret: CLIENT_SECRET,
29
+ scope: "crm", [optional]
30
+ extension: "json", [optional]
31
+ redirect_uri: redirect_uri
32
+ }
33
+ @client = Bitrix24CloudApi::Client.new(params)
34
+
35
+ To get oauth2 authorize_url for **code** simple use:
36
+
37
+ authorize_url = @client.authorize_url
38
+
39
+ To get oauth2 **access_token** use:
40
+
41
+ access_token = @client.get_access_token(code)
42
+
43
+ it's response contains a hash with *oauth2 credentials* and some other usefull data.
44
+
45
+ To **refresh** oauth2 **access_token** use:
46
+
47
+ access_token = @client.refresh_token(refresh_token)
48
+
49
+ it's response contains a hash with refreshed *oauth2 credentials*.
50
+
51
+ 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
+
53
+ ### CRM
54
+
55
+ Available models
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:
94
+
95
+ params = { fields: {TITLE: title, PHONE: [VALUE: phone, VALUE_TYPE: "WORK"]} }
96
+ Bitrix24CloudApi::CRM::Lead.add(@client, params)
97
+ Bitrix24CloudApi::CRM::Lead.list(@client)
98
+ Bitrix24CloudApi::CRM::Lead.get(@client, ID: 1)
99
+
100
+
101
+ ## Development
102
+
103
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
104
+
105
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
106
+
107
+ ## Contributing
108
+
109
+ Bug reports and pull requests are welcome on GitHub at https://github.com/nononoy/bitrix24_cloud_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
110
+
111
+
112
+ ## License
113
+
114
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
115
+
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
8
+ task :console do
9
+ require 'irb'
10
+ require 'irb/completion'
11
+ require 'bitrix24_cloud_api'
12
+ ARGV.clear
13
+ IRB.start
14
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "bitrix24_cloud_api"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,35 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'bitrix24_cloud_api/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "bitrix24_cloud_api"
8
+ spec.version = Bitrix24CloudApi::VERSION
9
+ spec.authors = ["Viacheslav Gruzdov"]
10
+ spec.email = ["lucky-@mail.ru"]
11
+
12
+ spec.summary = "Bitrix24 REST API on Ruby"
13
+ spec.description = "Bitrix24 REST API wrapper (for only cloud version)"
14
+ spec.homepage = "https://github.com/nononoy/bitrix24_cloud_api"
15
+ spec.license = "MIT"
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
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.12"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "rspec", "~> 3.0"
33
+ spec.add_development_dependency "oauth2", "~> 1.1"
34
+ spec.add_development_dependency "httparty", "~> 0.13.7"
35
+ end
@@ -0,0 +1,16 @@
1
+ module Bitrix24CloudApi
2
+ module CRM
3
+ module ACTIVITY
4
+ def self.const_missing(c)
5
+ if :Communication == c
6
+ target_class = Bitrix24CloudApi::CRM.const_get(c)
7
+ target_class.define_singleton_method(:resource_path) { "crm.activity.#{c.downcase}" }
8
+ target_class
9
+ end
10
+ end
11
+ end
12
+
13
+ class Activity < Bitrix24CloudApi::Crm
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,63 @@
1
+ module Bitrix24CloudApi
2
+ module CRM
3
+ class ProductRows < Bitrix24CloudApi::Crm
4
+ class << self
5
+ undef_method :add, :delete, :update
6
+
7
+ def set(client, query = {})
8
+ client.make_post_request(resource_url(client, __method__), query)
9
+ end
10
+ end
11
+ end
12
+
13
+ class Userfield < Bitrix24CloudApi::Crm
14
+ class << self
15
+ undef_method :fields
16
+
17
+ def types(client, query = {})
18
+ client.make_get_request(resource_url(client, __method__), query)
19
+ end
20
+ end
21
+ end
22
+
23
+ class Localizations < Bitrix24CloudApi::Crm
24
+ class << self
25
+ undef_method :delete, :fields, :get
26
+
27
+ def set(client, query = {})
28
+ client.make_post_request(resource_url(client, __method__), query)
29
+ end
30
+ end
31
+ end
32
+
33
+ class Communication < Bitrix24CloudApi::Crm
34
+ class << self
35
+ undef_method :add, :delete, :update, :get, :list
36
+ end
37
+ end
38
+
39
+ class Duplicate < Bitrix24CloudApi::Crm
40
+ class << self
41
+ undef_method :add, :delete, :update, :get, :list
42
+
43
+ def findbycomm(client, query = {})
44
+ client.make_get_request(resource_url(client, __method__), query)
45
+ end
46
+ end
47
+ end
48
+
49
+ class Enum < Bitrix24CloudApi::Crm
50
+ class << self
51
+ undef_method :add, :delete, :update, :get, :list
52
+ end
53
+
54
+ [:ownertype, :contenttype, :activitytype, :activitypriority, :activitydirection,
55
+ :activitynotifytype].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
61
+ end
62
+ end
63
+
@@ -0,0 +1,9 @@
1
+ module Bitrix24CloudApi
2
+ module CRM
3
+ class Catalog < Bitrix24CloudApi::Crm
4
+ class << self
5
+ undef_method :add, :delete, :update
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,16 @@
1
+ module Bitrix24CloudApi
2
+ module CRM
3
+ module COMPANY
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.company.#{c.downcase}" }
8
+ target_class
9
+ end
10
+ end
11
+ end
12
+
13
+ class Company < Bitrix24CloudApi::Crm
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ module Bitrix24CloudApi
2
+ module CRM
3
+ module CONTACT
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.contact.#{c.downcase}" }
8
+ target_class
9
+ end
10
+ end
11
+ end
12
+
13
+ class Contact < Bitrix24CloudApi::Crm
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ module Bitrix24CloudApi
2
+ module CRM
3
+ module CURRENCY
4
+ def self.const_missing(c)
5
+ if c == :Localizations
6
+ target_class = Bitrix24CloudApi::CRM.const_get(c)
7
+ target_class.define_singleton_method(:resource_path) { "crm.currency.#{c.downcase}" }
8
+ target_class
9
+ end
10
+ end
11
+ end
12
+
13
+ class Currency < Bitrix24CloudApi::Crm
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,22 @@
1
+ module Bitrix24CloudApi
2
+ module CRM
3
+ module DEAL
4
+ def self.const_missing(c)
5
+ if [:Userfield, :ProductRows].any?{|x| x == c}
6
+ target_class = Bitrix24CloudApi::CRM.const_get(c)
7
+ target_class.define_singleton_method(:resource_path) { "crm.deal.#{c.downcase}" }
8
+ target_class
9
+ end
10
+ end
11
+ end
12
+
13
+ class Deal < Bitrix24CloudApi::Crm
14
+
15
+ [:types, :set].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,6 @@
1
+ module Bitrix24CloudApi
2
+ module CRM
3
+ class Invoice < Bitrix24CloudApi::Crm
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Bitrix24CloudApi
2
+ module CRM
3
+ class InvoiceStatus < Bitrix24CloudApi::Crm
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,16 @@
1
+ module Bitrix24CloudApi
2
+ module CRM
3
+ module LEAD
4
+ def self.const_missing(c)
5
+ if [:Userfield, :ProductRows].any?{|x| x == c}
6
+ target_class = Bitrix24CloudApi::CRM.const_get(c)
7
+ target_class.define_singleton_method(:resource_path) { "crm.lead.#{c.downcase}" }
8
+ target_class
9
+ end
10
+ end
11
+ end
12
+
13
+ class Lead < Bitrix24CloudApi::Crm
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,6 @@
1
+ module Bitrix24CloudApi
2
+ module CRM
3
+ class Product < Bitrix24CloudApi::Crm
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Bitrix24CloudApi
2
+ module CRM
3
+ class ProductSection < Bitrix24CloudApi::Crm
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,16 @@
1
+ module Bitrix24CloudApi
2
+ module CRM
3
+ module QUOTE
4
+ def self.const_missing(c)
5
+ if [:Userfield, :ProductRows].any?{|x| x == c}
6
+ target_class = Bitrix24CloudApi::CRM.const_get(c)
7
+ target_class.define_singleton_method(:resource_path) { "crm.quote.#{c.downcase}" }
8
+ target_class
9
+ end
10
+ end
11
+ end
12
+
13
+ class Quote < Bitrix24CloudApi::Crm
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,20 @@
1
+ module Bitrix24CloudApi
2
+ require 'forwardable'
3
+
4
+ class Base
5
+ require "httparty"
6
+ extend Forwardable
7
+ def_delegators 'self.class', :resource_url
8
+
9
+ class << self
10
+
11
+ def resource_url(client, action)
12
+ "#{client.api_endpoint + resource_path}.#{action}.#{client.extension}"
13
+ end
14
+
15
+ def resource_path
16
+ name.gsub("Bitrix24CloudApi::", "").gsub("::", ".").downcase
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,111 @@
1
+ module Bitrix24CloudApi
2
+
3
+ class Client < Base
4
+ require 'oauth2'
5
+
6
+ attr_reader :endpoint, :access_token, :redirect_uri, :client_id, :client_secret, :scope, :oauth2client, :extension
7
+ attr_writer :access_token
8
+
9
+ def initialize(attrs = {})
10
+ puts attrs[:extension]
11
+ @extension = attrs[:extension] || "json"
12
+ @endpoint = attrs[:endpoint]
13
+ @access_token = attrs[:access_token]
14
+ @client_id = attrs[:client_id]
15
+ @client_secret = attrs[:client_secret]
16
+ @redirect_uri = attrs[:redirect_uri]
17
+ @scope = attrs[:scope]
18
+ if @client_id && @client_secret
19
+ @oauth2client = OAuth2::Client.new(@client_id, @client_secret, :site => api_endpoint)
20
+ end
21
+ end
22
+
23
+ def api_endpoint
24
+ "https://#{endpoint}/rest/"
25
+ end
26
+
27
+ def authorize_url
28
+ return nil unless oauth2client
29
+
30
+ oauth2client.auth_code.authorize_url(:redirect_uri => redirect_uri)
31
+ end
32
+
33
+ def get_access_token(code)
34
+ return nil unless oauth2client
35
+
36
+ auth_token_query = {}
37
+ auth_token_query[:client_id] = client_id
38
+ auth_token_query[:client_secret] = client_secret
39
+ auth_token_query[:grant_type] = "authorization_code"
40
+ auth_token_query[:scope] = scope
41
+ auth_token_query[:redirect_uri] = redirect_uri
42
+ auth_token_path = oauth2client.options[:token_url] + "?#{to_query(auth_token_query)}"
43
+ oauth2client.options[:token_url] = auth_token_path
44
+
45
+ begin
46
+ token = oauth2client.auth_code.get_token(code, :redirect_uri => redirect_uri)
47
+ token.params.merge({:access_token => token.token,
48
+ :refresh_token => token.refresh_token,
49
+ :expires_at => token.expires_at})
50
+ rescue OAuth2::Error
51
+ return nil
52
+ end
53
+ end
54
+
55
+ def refresh_token(refresh_token_hash)
56
+ return nil unless oauth2client
57
+
58
+ auth_token_query = {}
59
+ auth_token_query[:client_id] = client_id
60
+ auth_token_query[:client_secret] = client_secret
61
+ auth_token_query[:grant_type] = 'refresh_token'
62
+ auth_token_query[:refresh_token] = refresh_token_hash
63
+ auth_token_path = "/oauth/token?#{to_query(auth_token_query)}"
64
+ oauth2client.options[:token_url] = auth_token_path
65
+
66
+ begin
67
+ token = oauth2client.get_token(auth_token_query)
68
+ token.params.merge({:access_token => token.token,
69
+ :refresh_token => token.refresh_token,
70
+ :expires_at => token.expires_at})
71
+ rescue OAuth2::Error
72
+ return false
73
+ end
74
+ end
75
+
76
+ def make_get_request(path, params = {})
77
+ params.merge!(auth: access_token)
78
+ response = HTTParty.get(path, query: params)
79
+ check_response(response)
80
+ end
81
+
82
+ def make_post_request(path, params = {})
83
+ params.merge!(auth: access_token)
84
+ response = HTTParty.post(path, query: params)
85
+ check_response(response)
86
+ end
87
+
88
+ def check_response(response)
89
+ if response.success?
90
+ response.parsed_response
91
+ else
92
+ response.parsed_response.merge(code: response.code)
93
+ end
94
+ end
95
+
96
+ def deals
97
+ Bitrix24CloudApi::CRM::Deal.list(self)
98
+ end
99
+
100
+ def leads
101
+ Bitrix24CloudApi::CRM::Lead.list(self)
102
+ end
103
+
104
+ def contacts
105
+ Bitrix24CloudApi::CRM::Contact.list(self)
106
+ end
107
+
108
+ class << self
109
+ end
110
+ end
111
+ end
@@ -0,0 +1,32 @@
1
+ module Bitrix24CloudApi
2
+
3
+ class Crm < Base
4
+
5
+ [:add, :delete, :update].each do |action|
6
+ define_singleton_method(action) do |client, query = {}|
7
+ client.make_post_request(resource_url(client, action), query)
8
+ end
9
+ end
10
+
11
+
12
+ [:get, :list, :fields].each do |action|
13
+ define_singleton_method(action) do |client, query = {}|
14
+ client.make_get_request(resource_url(client, action), query)
15
+ end
16
+ end
17
+ end
18
+ end
19
+
20
+ require "bitrix24_cloud_api/CRM/additional_entities"
21
+ require "bitrix24_cloud_api/CRM/activity"
22
+ require "bitrix24_cloud_api/CRM/catalog"
23
+ require "bitrix24_cloud_api/CRM/company"
24
+ require "bitrix24_cloud_api/CRM/contact"
25
+ require "bitrix24_cloud_api/CRM/currency"
26
+ require "bitrix24_cloud_api/CRM/deal"
27
+ require "bitrix24_cloud_api/CRM/invoice"
28
+ require "bitrix24_cloud_api/CRM/invoice_status"
29
+ require "bitrix24_cloud_api/CRM/lead"
30
+ require "bitrix24_cloud_api/CRM/product"
31
+ require "bitrix24_cloud_api/CRM/product_section"
32
+ require "bitrix24_cloud_api/CRM/quote"