pipedrive.rb 0.2.0 → 0.3.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 (57) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +98 -10
  3. data/.travis.yml +4 -7
  4. data/Gemfile +4 -6
  5. data/HISTORY.md +43 -0
  6. data/Rakefile +5 -2
  7. data/lib/pipedrive.rb +9 -1
  8. data/lib/pipedrive/activity.rb +2 -0
  9. data/lib/pipedrive/activity_type.rb +2 -0
  10. data/lib/pipedrive/base.rb +14 -11
  11. data/lib/pipedrive/deal.rb +2 -0
  12. data/lib/pipedrive/deal_field.rb +2 -0
  13. data/lib/pipedrive/file.rb +2 -0
  14. data/lib/pipedrive/filter.rb +2 -0
  15. data/lib/pipedrive/goal.rb +2 -0
  16. data/lib/pipedrive/note.rb +2 -0
  17. data/lib/pipedrive/operations/create.rb +2 -0
  18. data/lib/pipedrive/operations/delete.rb +2 -0
  19. data/lib/pipedrive/operations/read.rb +6 -3
  20. data/lib/pipedrive/operations/update.rb +4 -1
  21. data/lib/pipedrive/organization.rb +6 -3
  22. data/lib/pipedrive/organization_field.rb +2 -0
  23. data/lib/pipedrive/person.rb +7 -3
  24. data/lib/pipedrive/person_field.rb +2 -0
  25. data/lib/pipedrive/pipeline.rb +10 -0
  26. data/lib/pipedrive/product.rb +2 -0
  27. data/lib/pipedrive/product_field.rb +2 -0
  28. data/lib/pipedrive/railties.rb +2 -0
  29. data/lib/pipedrive/role.rb +2 -0
  30. data/lib/pipedrive/stage.rb +2 -0
  31. data/lib/pipedrive/user.rb +10 -0
  32. data/lib/pipedrive/utils.rb +6 -4
  33. data/lib/pipedrive/version.rb +3 -1
  34. data/pipedrive.gemspec +12 -8
  35. data/spec/lib/pipedrive/activity_spec.rb +6 -2
  36. data/spec/lib/pipedrive/activity_type_spec.rb +6 -2
  37. data/spec/lib/pipedrive/base_spec.rb +82 -49
  38. data/spec/lib/pipedrive/deal_field_spec.rb +6 -2
  39. data/spec/lib/pipedrive/deal_spec.rb +6 -2
  40. data/spec/lib/pipedrive/file_spec.rb +6 -2
  41. data/spec/lib/pipedrive/filter_spec.rb +6 -2
  42. data/spec/lib/pipedrive/goal_spec.rb +6 -2
  43. data/spec/lib/pipedrive/note_spec.rb +6 -2
  44. data/spec/lib/pipedrive/ogranization_spec.rb +6 -2
  45. data/spec/lib/pipedrive/operations/create_spec.rb +5 -3
  46. data/spec/lib/pipedrive/operations/delete_spec.rb +8 -5
  47. data/spec/lib/pipedrive/operations/read_spec.rb +32 -24
  48. data/spec/lib/pipedrive/operations/update_spec.rb +9 -6
  49. data/spec/lib/pipedrive/organization_field_spec.rb +6 -2
  50. data/spec/lib/pipedrive/person_field_spec.rb +6 -2
  51. data/spec/lib/pipedrive/person_spec.rb +18 -12
  52. data/spec/lib/pipedrive/product_field_spec.rb +6 -2
  53. data/spec/lib/pipedrive/product_spec.rb +6 -2
  54. data/spec/lib/pipedrive_spec.rb +28 -20
  55. data/spec/spec_helper.rb +2 -2
  56. metadata +40 -10
  57. data/Guardfile +0 -24
@@ -1,9 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe ::Pipedrive::Filter do
4
6
  subject { described_class.new('token') }
5
- context '#entity_name' do
7
+
8
+ describe '#entity_name' do
6
9
  subject { super().entity_name }
10
+
7
11
  it { is_expected.to eq('filters') }
8
12
  end
9
- end
13
+ end
@@ -1,9 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe ::Pipedrive::Goal do
4
6
  subject { described_class.new('token') }
5
- context '#entity_name' do
7
+
8
+ describe '#entity_name' do
6
9
  subject { super().entity_name }
10
+
7
11
  it { is_expected.to eq('goals') }
8
12
  end
9
- end
13
+ end
@@ -1,9 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe ::Pipedrive::Note do
4
6
  subject { described_class.new('token') }
5
- context '#entity_name' do
7
+
8
+ describe '#entity_name' do
6
9
  subject { super().entity_name }
10
+
7
11
  it { is_expected.to eq('notes') }
8
12
  end
9
- end
13
+ end
@@ -1,9 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe ::Pipedrive::Organization do
4
6
  subject { described_class.new('token') }
5
- context '#entity_name' do
7
+
8
+ describe '#entity_name' do
6
9
  subject { super().entity_name }
10
+
7
11
  it { is_expected.to eq('organizations') }
8
12
  end
9
- end
13
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe ::Pipedrive::Operations::Create do
@@ -7,9 +9,9 @@ RSpec.describe ::Pipedrive::Operations::Create do
7
9
  end.new('token')
8
10
  end
9
11
 
10
- context '#create' do
11
- it 'should call #make_api_call' do
12
- expect(subject).to receive(:make_api_call).with(:post, {foo: 'bar'})
12
+ describe '#create' do
13
+ it 'calls #make_api_call' do
14
+ expect(subject).to receive(:make_api_call).with(:post, { foo: 'bar' })
13
15
  subject.create(foo: 'bar')
14
16
  end
15
17
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe ::Pipedrive::Operations::Delete do
@@ -7,16 +9,17 @@ RSpec.describe ::Pipedrive::Operations::Delete do
7
9
  end.new('token')
8
10
  end
9
11
 
10
- context '#delete' do
11
- it 'should call #make_api_call' do
12
+ describe '#delete' do
13
+ it 'calls #make_api_call' do
12
14
  expect(subject).to receive(:make_api_call).with(:delete, 12)
13
15
  subject.delete(12)
14
16
  end
15
17
  end
16
- context '#delete_all' do
17
- it 'should call #make_api_call' do
18
+
19
+ describe '#delete_all' do
20
+ it 'calls #make_api_call' do
18
21
  expect(subject).to receive(:make_api_call).with(:delete)
19
22
  subject.delete_all
20
23
  end
21
24
  end
22
- end
25
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe ::Pipedrive::Operations::Read do
@@ -7,45 +9,51 @@ RSpec.describe ::Pipedrive::Operations::Read do
7
9
  end.new('token')
8
10
  end
9
11
 
10
- context '#find_by_id' do
11
- it 'should call #make_api_call' do
12
+ describe '#find_by_id' do
13
+ it 'calls #make_api_call' do
12
14
  expect(subject).to receive(:make_api_call).with(:get, 12)
13
15
  subject.find_by_id(12)
14
16
  end
15
17
  end
16
18
 
17
- context '#each' do
19
+ describe '#each' do
18
20
  let(:additional_data) do
19
- {pagination: { more_items_in_collection?: true, next_start: 10}}
21
+ { pagination: { more_items_in_collection?: true, next_start: 10 } }
20
22
  end
21
- it 'should return Enumerator if no block given' do
23
+
24
+ it 'returns Enumerator if no block given' do
22
25
  expect(subject.each).to be_a(::Enumerator)
23
26
  end
24
- it 'should call to_enum with params' do
25
- expect(subject).to receive(:to_enum).with(:each, {foo: 'bar'})
27
+
28
+ it 'calls to_enum with params' do
29
+ expect(subject).to receive(:to_enum).with(:each, { foo: 'bar' })
26
30
  subject.each(foo: 'bar')
27
31
  end
28
- it 'should yield data' do
29
- expect(subject).to receive(:chunk).and_return(::Hashie::Mash.new(data: [1,2], success: true))
30
- expect { |b| subject.each(&b)}.to yield_successive_args(1,2)
32
+
33
+ it 'yields data' do
34
+ expect(subject).to receive(:chunk).and_return(::Hashie::Mash.new(data: [1, 2], success: true))
35
+ expect { |b| subject.each(&b) }.to yield_successive_args(1, 2)
31
36
  end
32
- it 'should follow pagination' do
33
- expect(subject).to receive(:chunk).with(start: 0).and_return(::Hashie::Mash.new(data: [1,2], success: true, additional_data: additional_data))
34
- expect(subject).to receive(:chunk).with(start: 10).and_return(::Hashie::Mash.new(data: [3,4], success: true))
35
- expect { |b| subject.each(&b)}.to yield_successive_args(1,2,3,4)
37
+
38
+ it 'follows pagination' do
39
+ expect(subject).to receive(:chunk).with(start: 0).and_return(::Hashie::Mash.new(data: [1, 2], success: true, additional_data: additional_data))
40
+ expect(subject).to receive(:chunk).with(start: 10).and_return(::Hashie::Mash.new(data: [3, 4], success: true))
41
+ expect { |b| subject.each(&b) }.to yield_successive_args(1, 2, 3, 4)
36
42
  end
37
- it 'should not yield anything if result is empty' do
43
+
44
+ it 'does not yield anything if result is empty' do
38
45
  expect(subject).to receive(:chunk).with(start: 0).and_return(::Hashie::Mash.new(success: true))
39
- expect { |b| subject.each(&b)}.to yield_successive_args
46
+ expect { |b| subject.each(&b) }.to yield_successive_args
40
47
  end
41
- it 'should not yield anything if result is not success' do
48
+
49
+ it 'does not yield anything if result is not success' do
42
50
  expect(subject).to receive(:chunk).with(start: 0).and_return(::Hashie::Mash.new(success: false))
43
- expect { |b| subject.each(&b)}.to yield_successive_args
51
+ expect { |b| subject.each(&b) }.to yield_successive_args
44
52
  end
45
53
  end
46
54
 
47
- context '#all' do
48
- it 'should call #each' do
55
+ describe '#all' do
56
+ it 'calls #each' do
49
57
  arr = double('enumerator')
50
58
  allow(arr).to receive(:to_a)
51
59
  expect(subject).to receive(:each).and_return(arr)
@@ -53,17 +61,17 @@ RSpec.describe ::Pipedrive::Operations::Read do
53
61
  end
54
62
  end
55
63
 
56
- context '#chunk' do
57
- it 'should return []' do
64
+ describe '#chunk' do
65
+ it 'returns []' do
58
66
  res = double('res', success?: false)
59
67
  expect(subject).to receive(:make_api_call).with(:get, {}).and_return(res)
60
68
  expect(subject.chunk).to eq([])
61
69
  end
62
70
 
63
- it 'should return result' do
71
+ it 'returns result' do
64
72
  res = double('res', success?: true)
65
73
  expect(subject).to receive(:make_api_call).with(:get, {}).and_return(res)
66
74
  expect(subject.chunk).to eq(res)
67
75
  end
68
76
  end
69
- end
77
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe ::Pipedrive::Operations::Update do
@@ -7,14 +9,15 @@ RSpec.describe ::Pipedrive::Operations::Update do
7
9
  end.new('token')
8
10
  end
9
11
 
10
- context '#create' do
11
- it 'should call #make_api_call' do
12
- expect(subject).to receive(:make_api_call).with(:put, 12, {foo: 'bar'})
12
+ describe '#create' do
13
+ it 'calls #make_api_call' do
14
+ expect(subject).to receive(:make_api_call).with(:put, 12, { foo: 'bar' })
13
15
  subject.update(12, foo: 'bar')
14
16
  end
15
- it 'should call #make_api_call with id in params' do
16
- expect(subject).to receive(:make_api_call).with(:put, 14, {foo: 'bar'})
17
+
18
+ it 'calls #make_api_call with id in params' do
19
+ expect(subject).to receive(:make_api_call).with(:put, 14, { foo: 'bar' })
17
20
  subject.update(foo: 'bar', id: 14)
18
21
  end
19
22
  end
20
- end
23
+ end
@@ -1,9 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe ::Pipedrive::OrganizationField do
4
6
  subject { described_class.new('token') }
5
- context '#entity_name' do
7
+
8
+ describe '#entity_name' do
6
9
  subject { super().entity_name }
10
+
7
11
  it { is_expected.to eq('organizationFields') }
8
12
  end
9
- end
13
+ end
@@ -1,9 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe ::Pipedrive::PersonField do
4
6
  subject { described_class.new('token') }
5
- context '#entity_name' do
7
+
8
+ describe '#entity_name' do
6
9
  subject { super().entity_name }
10
+
7
11
  it { is_expected.to eq('personFields') }
8
12
  end
9
- end
13
+ end
@@ -1,24 +1,30 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe ::Pipedrive::Person do
4
6
  subject { described_class.new('token') }
5
- context '#entity_name' do
7
+
8
+ describe '#entity_name' do
6
9
  subject { super().entity_name }
10
+
7
11
  it { is_expected.to eq('persons') }
8
12
  end
9
13
 
10
- context '#find_by_name' do
11
- it 'should call #make_api_call with term' do
12
- expect(subject).to receive(:make_api_call).with(:get, 'find', {term: 'term', search_by_email: 0, start: 0})
13
- expect { |b| subject.find_by_name('term', &b)}.to yield_successive_args
14
+ describe '#find_by_name' do
15
+ it 'calls #make_api_call with term' do
16
+ expect(subject).to receive(:make_api_call).with(:get, 'find', { term: 'term', search_by_email: 0, start: 0 })
17
+ expect { |b| subject.find_by_name('term', &b) }.to yield_successive_args
14
18
  end
15
- it 'should call #make_api_call with term and search_by_email' do
16
- expect(subject).to receive(:make_api_call).with(:get, 'find', {term: 'term', search_by_email: 1, start: 0})
17
- expect { |b| subject.find_by_name('term', true, &b)}.to yield_successive_args
19
+
20
+ it 'calls #make_api_call with term and search_by_email' do
21
+ expect(subject).to receive(:make_api_call).with(:get, 'find', { term: 'term', search_by_email: 1, start: 0 })
22
+ expect { |b| subject.find_by_name('term', true, &b) }.to yield_successive_args
18
23
  end
19
- it 'should yield results' do
20
- expect(subject).to receive(:make_api_call).with(:get, 'find', {term: 'term', search_by_email: 0, start: 0}).and_return(::Hashie::Mash.new(data: [1,2], success: true))
21
- expect { |b| subject.find_by_name('term', &b)}.to yield_successive_args(1,2)
24
+
25
+ it 'yields results' do
26
+ expect(subject).to receive(:make_api_call).with(:get, 'find', { term: 'term', search_by_email: 0, start: 0 }).and_return(::Hashie::Mash.new(data: [1, 2], success: true))
27
+ expect { |b| subject.find_by_name('term', &b) }.to yield_successive_args(1, 2)
22
28
  end
23
29
  end
24
- end
30
+ end
@@ -1,9 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe ::Pipedrive::ProductField do
4
6
  subject { described_class.new('token') }
5
- context '#entity_name' do
7
+
8
+ describe '#entity_name' do
6
9
  subject { super().entity_name }
10
+
7
11
  it { is_expected.to eq('productFields') }
8
12
  end
9
- end
13
+ end
@@ -1,9 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe ::Pipedrive::Product do
4
6
  subject { described_class.new('token') }
5
- context '#entity_name' do
7
+
8
+ describe '#entity_name' do
6
9
  subject { super().entity_name }
10
+
7
11
  it { is_expected.to eq('products') }
8
12
  end
9
- end
13
+ end
@@ -1,65 +1,73 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe ::Pipedrive do
4
-
5
6
  subject { described_class }
6
7
 
7
- before :each do
8
+ before do
8
9
  described_class.reset!
9
10
  end
10
11
 
11
- context '#reset!' do
12
+ describe '#reset!' do
12
13
  describe '#user_agent' do
13
14
  subject { super().user_agent }
15
+
14
16
  it { is_expected.to eq("Pipedrive Ruby Client v#{::Pipedrive::VERSION}") }
15
17
  end
16
18
 
17
19
  describe '#api_token' do
18
20
  subject { super().api_token }
21
+
19
22
  it { is_expected.to be_nil }
20
23
  end
21
24
 
22
25
  describe '#logger' do
23
26
  subject { super().logger }
27
+
24
28
  it { is_expected.to be_kind_of(::Logger) }
25
29
  end
26
30
  end
27
31
 
28
- context '#setup' do
32
+ describe '#setup' do
29
33
  context 'single call' do
30
- it 'should set user_agent' do
31
- subject.setup do |c|
34
+ let(:client) { described_class }
35
+
36
+ it 'sets user_agent' do
37
+ client.setup do |c|
32
38
  c.user_agent = 'Test1245'
33
39
  end
34
- expect(subject.user_agent).to eq('Test1245')
40
+ expect(client.user_agent).to eq('Test1245')
35
41
  end
36
42
 
37
- it 'should set logger' do
38
- newlogger = ::Logger.new(STDERR)
39
- subject.setup do |c|
43
+ it 'sets logger' do
44
+ newlogger = ::Logger.new($stderr)
45
+ client.setup do |c|
40
46
  c.logger = newlogger
41
47
  end
42
- expect(subject.logger).to eq(newlogger)
48
+ expect(client.logger).to eq(newlogger)
43
49
  end
44
50
 
45
- it 'should set api_token' do
46
- subject.setup do |c|
51
+ it 'sets api_token' do
52
+ client.setup do |c|
47
53
  c.api_token = 'test-api-key'
48
54
  end
49
- expect(subject.api_token).to eq('test-api-key')
55
+ expect(client.api_token).to eq('test-api-key')
50
56
  end
51
57
  end
52
58
 
53
- context 'double call' do
54
- it 'should not accept running setup more then once' do
55
- subject.setup do |c|
59
+ context 'with double call' do
60
+ let(:client) { described_class }
61
+
62
+ it 'does not accept running setup more then once' do
63
+ client.setup do |c|
56
64
  c.api_token = 'test-api-key'
57
65
  end
58
- subject.setup do |c|
66
+ client.setup do |c|
59
67
  c.api_token = 'test-api-key2'
60
68
  end
61
- expect(subject.api_token).to eq('test-api-key')
69
+ expect(client.api_token).to eq('test-api-key')
62
70
  end
63
71
  end
64
72
  end
65
- end
73
+ end
@@ -1,9 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'simplecov'
2
- require 'coveralls'
3
4
 
4
5
  SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
5
6
  SimpleCov::Formatter::HTMLFormatter,
6
- Coveralls::SimpleCov::Formatter
7
7
  ]
8
8
  SimpleCov.start do
9
9
  add_filter 'spec'