pipedrive_api_rb 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.
Files changed (66) hide show
  1. checksums.yaml +7 -0
  2. data/.cane +5 -0
  3. data/.gitignore +23 -0
  4. data/.rspec +2 -0
  5. data/.rubocop.yml +105 -0
  6. data/.travis.yml +14 -0
  7. data/Gemfile +6 -0
  8. data/HISTORY.md +43 -0
  9. data/LICENSE.txt +22 -0
  10. data/README.md +98 -0
  11. data/Rakefile +12 -0
  12. data/defaults.reek +11 -0
  13. data/lib/pipedrive/activity.rb +10 -0
  14. data/lib/pipedrive/activity_type.rb +14 -0
  15. data/lib/pipedrive/base.rb +93 -0
  16. data/lib/pipedrive/deal.rb +10 -0
  17. data/lib/pipedrive/deal_field.rb +13 -0
  18. data/lib/pipedrive/file.rb +10 -0
  19. data/lib/pipedrive/filter.rb +8 -0
  20. data/lib/pipedrive/goal.rb +10 -0
  21. data/lib/pipedrive/lead.rb +8 -0
  22. data/lib/pipedrive/lead_label.rb +12 -0
  23. data/lib/pipedrive/note.rb +10 -0
  24. data/lib/pipedrive/operations/create.rb +13 -0
  25. data/lib/pipedrive/operations/delete.rb +17 -0
  26. data/lib/pipedrive/operations/read.rb +32 -0
  27. data/lib/pipedrive/operations/update.rb +18 -0
  28. data/lib/pipedrive/organization.rb +20 -0
  29. data/lib/pipedrive/organization_field.rb +13 -0
  30. data/lib/pipedrive/person.rb +22 -0
  31. data/lib/pipedrive/person_field.rb +14 -0
  32. data/lib/pipedrive/pipeline.rb +10 -0
  33. data/lib/pipedrive/product.rb +10 -0
  34. data/lib/pipedrive/product_field.rb +13 -0
  35. data/lib/pipedrive/railties.rb +9 -0
  36. data/lib/pipedrive/role.rb +10 -0
  37. data/lib/pipedrive/stage.rb +10 -0
  38. data/lib/pipedrive/user.rb +10 -0
  39. data/lib/pipedrive/utils.rb +20 -0
  40. data/lib/pipedrive/version.rb +5 -0
  41. data/lib/pipedrive.rb +100 -0
  42. data/pipedrive.gemspec +34 -0
  43. data/spec/lib/pipedrive/activity_spec.rb +13 -0
  44. data/spec/lib/pipedrive/activity_type_spec.rb +13 -0
  45. data/spec/lib/pipedrive/base_spec.rb +155 -0
  46. data/spec/lib/pipedrive/deal_field_spec.rb +13 -0
  47. data/spec/lib/pipedrive/deal_spec.rb +13 -0
  48. data/spec/lib/pipedrive/file_spec.rb +13 -0
  49. data/spec/lib/pipedrive/filter_spec.rb +13 -0
  50. data/spec/lib/pipedrive/goal_spec.rb +13 -0
  51. data/spec/lib/pipedrive/lead_label_spec.rb +9 -0
  52. data/spec/lib/pipedrive/lead_spec.rb +9 -0
  53. data/spec/lib/pipedrive/note_spec.rb +13 -0
  54. data/spec/lib/pipedrive/ogranization_spec.rb +13 -0
  55. data/spec/lib/pipedrive/operations/create_spec.rb +18 -0
  56. data/spec/lib/pipedrive/operations/delete_spec.rb +25 -0
  57. data/spec/lib/pipedrive/operations/read_spec.rb +77 -0
  58. data/spec/lib/pipedrive/operations/update_spec.rb +23 -0
  59. data/spec/lib/pipedrive/organization_field_spec.rb +13 -0
  60. data/spec/lib/pipedrive/person_field_spec.rb +13 -0
  61. data/spec/lib/pipedrive/person_spec.rb +30 -0
  62. data/spec/lib/pipedrive/product_field_spec.rb +13 -0
  63. data/spec/lib/pipedrive/product_spec.rb +13 -0
  64. data/spec/lib/pipedrive_spec.rb +73 -0
  65. data/spec/spec_helper.rb +5 -0
  66. metadata +285 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1736d092cf795cb084b83ba4bcf44308ad29dfa9d6ce87deb7f38236e5e565e5
4
+ data.tar.gz: 607e8e21ec8b1a674d4e0cdd3598099931535ce3a98b393f19302a0a166d71a3
5
+ SHA512:
6
+ metadata.gz: cf8a9b1993e39a89716262aa3830f6ab73cf0b8cdf85199689e8309174c1c7735c0bd49c959112910967648a93c4683560a07927b8009784e8f5ec3449ac8945
7
+ data.tar.gz: 0ac483c074c8c6d483c678f910435492ddaf7b46bb37b12acd9877daa3305a1634a6be2a7388a784ad63427265cae4e574777656bd204de52f31f6af909f8759
data/.cane ADDED
@@ -0,0 +1,5 @@
1
+ --no-doc
2
+ --no-style
3
+ --style-measure 99
4
+ --abc-max 18
5
+ --style-exclude spec/**/*
data/.gitignore ADDED
@@ -0,0 +1,23 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+ .idea
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,105 @@
1
+ require:
2
+ - rubocop/cop/internal_affairs
3
+ - rubocop-performance
4
+ - rubocop-rspec
5
+ AllCops:
6
+ NewCops: enable
7
+ Exclude:
8
+ - "bin/*"
9
+ - "vendor/**/*"
10
+ - "Rakefile"
11
+ - "tmp/**/*"
12
+ - ".git/**/*"
13
+ TargetRubyVersion: 2.5
14
+ Style/Documentation:
15
+ Enabled: false
16
+ Layout/LineLength:
17
+ Max: 1000
18
+ Metrics/MethodLength:
19
+ Max: 250
20
+ Metrics/ClassLength:
21
+ Max: 1000
22
+ Metrics/AbcSize:
23
+ Max: 250
24
+ Metrics/BlockLength:
25
+ Max: 1500
26
+ Metrics/CyclomaticComplexity:
27
+ Max: 50
28
+ Metrics/PerceivedComplexity:
29
+ Max: 50
30
+ Style/ClassAndModuleChildren:
31
+ Enabled: false
32
+ Style/ModuleFunction:
33
+ Enabled: false
34
+ Style/ParallelAssignment:
35
+ Enabled: false
36
+ Style/SymbolProc:
37
+ Enabled: false
38
+ Layout/HashAlignment:
39
+ Enabled: false
40
+ Metrics/BlockNesting:
41
+ Enabled: false
42
+ Lint/NonLocalExitFromIterator:
43
+ Enabled: false
44
+ Style/HashEachMethods:
45
+ Enabled: true
46
+ Style/HashTransformKeys:
47
+ Enabled: true
48
+ Style/HashTransformValues:
49
+ Enabled: true
50
+ Style/AndOr:
51
+ Enabled: false
52
+ RSpec/ExampleLength:
53
+ Enabled: false
54
+ RSpec/MultipleExpectations:
55
+ Enabled: false
56
+ RSpec/DescribeClass:
57
+ Enabled: false
58
+ Style/IfInsideElse:
59
+ Enabled: false
60
+ Layout/EmptyLinesAroundAttributeAccessor:
61
+ Enabled: true
62
+ Layout/SpaceAroundMethodCallOperator:
63
+ Enabled: true
64
+ Lint/DeprecatedOpenSSLConstant:
65
+ Enabled: true
66
+ Lint/MixedRegexpCaptureTypes:
67
+ Enabled: true
68
+ Lint/RaiseException:
69
+ Enabled: true
70
+ Lint/StructNewOverride:
71
+ Enabled: true
72
+ Style/ExponentialNotation:
73
+ Enabled: false
74
+ Style/RedundantFetchBlock:
75
+ Enabled: true
76
+ Style/RedundantRegexpCharacterClass:
77
+ Enabled: true
78
+ Style/RedundantRegexpEscape:
79
+ Enabled: true
80
+ Style/SlicingWithRange:
81
+ Enabled: true
82
+ Style/AccessorGrouping:
83
+ Enabled: true
84
+ Style/BisectedAttrAccessor:
85
+ Enabled: true
86
+ Style/RedundantAssignment:
87
+ Enabled: true
88
+ Performance/AncestorsInclude:
89
+ Enabled: true
90
+ Performance/BigDecimalWithNumericArgument:
91
+ Enabled: true
92
+ Performance/RedundantSortBlock:
93
+ Enabled: true
94
+ Performance/RedundantStringChars:
95
+ Enabled: true
96
+ Performance/ReverseFirst:
97
+ Enabled: true
98
+ Performance/SortReverse:
99
+ Enabled: true
100
+ Performance/Squeeze:
101
+ Enabled: true
102
+ Performance/StringInclude:
103
+ Enabled: true
104
+ RSpec/ContextWording:
105
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,14 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.7.2
4
+ - 3.1.2
5
+ - 3.2.0
6
+ - ruby-head
7
+
8
+ matrix:
9
+ allow_failures:
10
+ - rvm: ruby-head
11
+
12
+ bundler_args: --without local_development
13
+
14
+ before_install: gem install bundler
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in pipedrive.gemspec
6
+ gemspec
data/HISTORY.md ADDED
@@ -0,0 +1,43 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [v0.3.0](https://github.com/amoniacou/pipedrive.rb/compare/v0.2.0...v0.3.0) - 2020-10-10
9
+
10
+ ### Merged
11
+
12
+ - add User endpoints [`#15`](https://github.com/amoniacou/pipedrive.rb/pull/15)
13
+ - add pipeline endpoints [`#17`](https://github.com/amoniacou/pipedrive.rb/pull/17)
14
+ - add pipeline endpoints [`#2`](https://github.com/amoniacou/pipedrive.rb/pull/2)
15
+
16
+ ### Commits
17
+
18
+ - Small code improvements [`fb28bb4`](https://github.com/amoniacou/pipedrive.rb/commit/fb28bb4ed3d86c15a4f2a95247e13393d598aad1)
19
+ - Fix specs [`e772b83`](https://github.com/amoniacou/pipedrive.rb/commit/e772b837c61150b574ef3f6c95b495e1f2dfda9a)
20
+ - Update .travis.yml [`873cea4`](https://github.com/amoniacou/pipedrive.rb/commit/873cea4cfd82806ef71f62a3db823322b168f964)
21
+
22
+ ## [v0.2.0](https://github.com/amoniacou/pipedrive.rb/compare/v0.1.0...v0.2.0) - 2020-01-14
23
+
24
+ ### Merged
25
+
26
+ - Inflection fix for persons [`#9`](https://github.com/amoniacou/pipedrive.rb/pull/9)
27
+ - Move adapter setup to the last line in defining connection [`#7`](https://github.com/amoniacou/pipedrive.rb/pull/7)
28
+ - Replace find by find_by_id in the docs [`#5`](https://github.com/amoniacou/pipedrive.rb/pull/5)
29
+ - Find by name organisation && update personfields [`#3`](https://github.com/amoniacou/pipedrive.rb/pull/3)
30
+
31
+ ### Commits
32
+
33
+ - Remove problematic reek and cane [`bf8535c`](https://github.com/amoniacou/pipedrive.rb/commit/bf8535c10d0894fb508828a43aefb036b000c263)
34
+ - Fix tests [`bca6171`](https://github.com/amoniacou/pipedrive.rb/commit/bca6171ae43068bd671bf6b8ecf924a7e2ad1af3)
35
+ - Fix outdated rubocop, contrain on rake to pass reek [`e799cbc`](https://github.com/amoniacou/pipedrive.rb/commit/e799cbca4eada29582e6c5a1e20e8f97ed709713)
36
+
37
+ ## v0.1.0 - 2014-10-16
38
+
39
+ ### Commits
40
+
41
+ - Initial commit [`cbd2138`](https://github.com/amoniacou/pipedrive.rb/commit/cbd2138ae11a19f4a398af3c25fac8ed2e6a0e1b)
42
+ - Test coverage and small refactoring [`ca0577f`](https://github.com/amoniacou/pipedrive.rb/commit/ca0577fef23f59515cb58ea152e10d3130f26730)
43
+ - Add more entities basic support. Add support for field selector [`73b47a4`](https://github.com/amoniacou/pipedrive.rb/commit/73b47a4455b1c50906bbc811bddac7d979fae966)
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Alexander Simonov
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,98 @@
1
+ # Pipedrive Ruby API
2
+
3
+ [![Build Status](https://app.travis-ci.com/honzasterba/pipedrive_rb.svg?branch=master)](https://app.travis-ci.com/honzasterba/pipedrive_rb)
4
+
5
+ Pipedrive.com API wrapper
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'pipedrive_api_rb'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install pipedrive_api_rb
20
+
21
+ ## Usage
22
+
23
+ ### Person
24
+
25
+ You need initialize Person client:
26
+
27
+ ```ruby
28
+ client = ::Pipedrive::Person.new('api_token')
29
+ ```
30
+
31
+ You can get person's JSON data:
32
+
33
+ ```ruby
34
+ person = client.find_by_id(12345)
35
+ person.success? # check what request was successful
36
+ person.data # JSON data of person entity
37
+ ```
38
+
39
+ You can update person:
40
+
41
+ ```ruby
42
+ res = client.update(12345, name: 'New Name', 'custom_field_key' => 'value')
43
+ res.success? # check what request was successful
44
+ res.data # updated JSON data of person
45
+ ```
46
+
47
+ Or you can update person with only hash what include id:
48
+
49
+ ```ruby
50
+ res = client.update(id: 12345, name: 'New Name', 'custom_field_key' => 'value')
51
+ ```
52
+
53
+ You can get the list of all persons:
54
+
55
+ ```ruby
56
+ all_persons = client.all # all persons - can be a time consume operation
57
+ all_persons = client.all(start: 200) # Skipping first 200 persons
58
+ ```
59
+
60
+ Or you can get first page of persons:
61
+
62
+ ```ruby
63
+ first_page = client.chunk(start: 200, limit: 10) # get 10 records after skipping 200
64
+ ```
65
+
66
+ Or you can iterate by all persons:
67
+
68
+ ```ruby
69
+ client.each(start: 200) do |json_item|
70
+ # some logic
71
+ end
72
+ ```
73
+
74
+ Or you can work with enumerate:
75
+
76
+ ```ruby
77
+ client.each(start: 100).select {|x| x['company_id'] == 12345}
78
+ ```
79
+
80
+ ### Rails integration
81
+
82
+ If you need use only one pipedrive account for whole application, then you can create `config/initializer/pipedrive.rb` file with next content:
83
+
84
+ ```ruby
85
+ Pipedrive.setup do |pd|
86
+ pd.api_token = ENV['PIPEDRIVE_API_TOKEN']
87
+ end
88
+ ```
89
+
90
+ And you can skip providing `api_token` to the entities classes.
91
+
92
+ ## Contributing
93
+
94
+ 1. Fork it ( https://github.com/honzasterba/pipedrive_api_rb/fork )
95
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
96
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
97
+ 4. Push to the branch (`git push origin my-new-feature`)
98
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ require 'rspec/core/rake_task'
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ # rubocop
7
+ require 'rubocop/rake_task'
8
+ RuboCop::RakeTask.new(:rubocop)
9
+
10
+ default_tasks = %i[spec rubocop]
11
+
12
+ task default: default_tasks
data/defaults.reek ADDED
@@ -0,0 +1,11 @@
1
+ ---
2
+ NestedIterators:
3
+ max_allowed_nesting: 2
4
+ UtilityFunction:
5
+ enabled: false
6
+ IrresponsibleModule:
7
+ enabled: false
8
+ DuplicateMethodCall:
9
+ max_calls: 5
10
+ FeatureEnvy:
11
+ enabled: false
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pipedrive
4
+ class Activity < Base
5
+ include ::Pipedrive::Operations::Create
6
+ include ::Pipedrive::Operations::Read
7
+ include ::Pipedrive::Operations::Update
8
+ include ::Pipedrive::Operations::Delete
9
+ end
10
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pipedrive
4
+ class ActivityType < Base
5
+ include ::Pipedrive::Operations::Create
6
+ include ::Pipedrive::Operations::Read
7
+ include ::Pipedrive::Operations::Update
8
+ include ::Pipedrive::Operations::Delete
9
+
10
+ def entity_name
11
+ 'activityTypes'
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,93 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pipedrive
4
+ class Base
5
+ def initialize(api_token = ::Pipedrive.api_token)
6
+ raise 'api_token should be set' unless api_token.present?
7
+
8
+ @api_token = api_token
9
+ end
10
+
11
+ def connection
12
+ self.class.connection.dup
13
+ end
14
+
15
+ def make_api_call(*args)
16
+ params = args.extract_options!
17
+ method = args[0]
18
+ raise 'method param missing' unless method.present?
19
+
20
+ url = build_url(args, params.delete(:fields_to_select))
21
+ params = params.to_json unless method.to_sym == :get
22
+ begin
23
+ res = connection.__send__(method.to_sym, url, params)
24
+ rescue Errno::ETIMEDOUT
25
+ retry
26
+ rescue Faraday::ParsingError
27
+ sleep 5
28
+ retry
29
+ end
30
+ process_response(res)
31
+ end
32
+
33
+ def build_url(args, fields_to_select = nil)
34
+ url = +"/v1/#{entity_name}"
35
+ url << "/#{args[1]}" if args[1]
36
+ url << ":(#{fields_to_select.join(',')})" if fields_to_select.is_a?(::Array) && fields_to_select.size.positive?
37
+ url << "?api_token=#{@api_token}"
38
+ url
39
+ end
40
+
41
+ def process_response(res)
42
+ if res.success?
43
+ data = if res.body.is_a?(::Hashie::Mash)
44
+ res.body.merge(success: true)
45
+ else
46
+ ::Hashie::Mash.new(success: true)
47
+ end
48
+ return data
49
+ end
50
+ failed_response(res)
51
+ end
52
+
53
+ def failed_response(res)
54
+ failed_res = res.body.merge(success: false, not_authorized: false,
55
+ failed: false)
56
+ case res.status
57
+ when 401
58
+ failed_res[:not_authorized] = true
59
+ when 420
60
+ failed_res[:failed] = true
61
+ end
62
+ failed_res
63
+ end
64
+
65
+ def entity_name
66
+ class_name = self.class.name.split('::')[-1].downcase.pluralize
67
+ class_names = { 'people' => 'persons' }
68
+ class_names[class_name] || class_name
69
+ end
70
+
71
+ class << self
72
+ def faraday_options
73
+ { url: 'https://api.pipedrive.com',
74
+ headers: {
75
+ accept: 'application/json',
76
+ content_type: 'application/json',
77
+ user_agent: ::Pipedrive.user_agent
78
+ } }
79
+ end
80
+
81
+ # This method smells of :reek:TooManyStatements
82
+ # :nodoc
83
+ def connection
84
+ @connection ||= Faraday.new(faraday_options) do |conn|
85
+ conn.request :url_encoded
86
+ conn.response :mashify
87
+ conn.response :json, content_type: /\bjson$/
88
+ conn.response :logger, ::Pipedrive.logger if ::Pipedrive.debug
89
+ end
90
+ end
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pipedrive
4
+ class Deal < Base
5
+ include ::Pipedrive::Operations::Create
6
+ include ::Pipedrive::Operations::Read
7
+ include ::Pipedrive::Operations::Update
8
+ include ::Pipedrive::Operations::Delete
9
+ end
10
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pipedrive
4
+ class DealField < Base
5
+ include ::Pipedrive::Operations::Create
6
+ include ::Pipedrive::Operations::Read
7
+ include ::Pipedrive::Operations::Delete
8
+
9
+ def entity_name
10
+ 'dealFields'
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pipedrive
4
+ class File < Base
5
+ include ::Pipedrive::Operations::Create
6
+ include ::Pipedrive::Operations::Read
7
+ include ::Pipedrive::Operations::Update
8
+ include ::Pipedrive::Operations::Delete
9
+ end
10
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pipedrive
4
+ class Filter < Base
5
+ include ::Pipedrive::Operations::Read
6
+ include ::Pipedrive::Operations::Delete
7
+ end
8
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pipedrive
4
+ class Goal < Base
5
+ include ::Pipedrive::Operations::Create
6
+ include ::Pipedrive::Operations::Read
7
+ include ::Pipedrive::Operations::Update
8
+ include ::Pipedrive::Operations::Delete
9
+ end
10
+ end
@@ -0,0 +1,8 @@
1
+ module Pipedrive
2
+ class Lead < Base
3
+ include ::Pipedrive::Operations::Create
4
+ include ::Pipedrive::Operations::Read
5
+ include ::Pipedrive::Operations::Update
6
+ include ::Pipedrive::Operations::Delete
7
+ end
8
+ end
@@ -0,0 +1,12 @@
1
+ module Pipedrive
2
+ class LeadLabel < Base
3
+ include ::Pipedrive::Operations::Create
4
+ include ::Pipedrive::Operations::Read
5
+ include ::Pipedrive::Operations::Update
6
+ include ::Pipedrive::Operations::Delete
7
+
8
+ def entity_name
9
+ 'leadLabels'
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pipedrive
4
+ class Note < Base
5
+ include ::Pipedrive::Operations::Create
6
+ include ::Pipedrive::Operations::Read
7
+ include ::Pipedrive::Operations::Update
8
+ include ::Pipedrive::Operations::Delete
9
+ end
10
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pipedrive
4
+ module Operations
5
+ module Create
6
+ extend ActiveSupport::Concern
7
+
8
+ def create(params)
9
+ make_api_call(:post, params)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pipedrive
4
+ module Operations
5
+ module Delete
6
+ extend ActiveSupport::Concern
7
+
8
+ def delete(id)
9
+ make_api_call(:delete, id)
10
+ end
11
+
12
+ def delete_all
13
+ make_api_call(:delete)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pipedrive
4
+ module Operations
5
+ module Read
6
+ extend ActiveSupport::Concern
7
+ include ::Enumerable
8
+ include ::Pipedrive::Utils
9
+
10
+ def each(params = {}, &block)
11
+ return to_enum(:each, params) unless block_given?
12
+
13
+ follow_pagination(:chunk, [], params, &block)
14
+ end
15
+
16
+ def all(params = {})
17
+ each(params).to_a
18
+ end
19
+
20
+ def chunk(params = {})
21
+ res = make_api_call(:get, params)
22
+ return [] unless res.success?
23
+
24
+ res
25
+ end
26
+
27
+ def find_by_id(id)
28
+ make_api_call(:get, id)
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pipedrive
4
+ module Operations
5
+ module Update
6
+ extend ActiveSupport::Concern
7
+
8
+ def update(*args)
9
+ params = args.extract_options!
10
+ params.symbolize_keys!
11
+ id = params.delete(:id) || args[0]
12
+ raise 'id must be provided' unless id
13
+
14
+ make_api_call(:put, id, params)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pipedrive
4
+ class Organization < Base
5
+ include ::Pipedrive::Operations::Read
6
+ include ::Pipedrive::Operations::Create
7
+ include ::Pipedrive::Operations::Update
8
+ include ::Pipedrive::Operations::Delete
9
+ include ::Pipedrive::Utils
10
+
11
+ def find_by_name(*args, &block)
12
+ params = args.extract_options!
13
+ params[:term] ||= args[0]
14
+ raise 'term is missing' unless params[:term]
15
+ return to_enum(:find_by_name, params) unless block_given?
16
+
17
+ follow_pagination(:make_api_call, [:get, 'find'], params, &block)
18
+ end
19
+ end
20
+ end