basecrm 0.1.2 → 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.
- checksums.yaml +4 -4
- data/LICENSE +2 -2
- data/README.md +273 -17
- data/lib/basecrm.rb +185 -1
- data/lib/basecrm/configuration.rb +59 -0
- data/lib/basecrm/envelope.rb +7 -0
- data/lib/basecrm/errors.rb +65 -0
- data/lib/basecrm/http_client.rb +91 -0
- data/lib/basecrm/middlewares/oauth_bearer_token.rb +18 -0
- data/lib/basecrm/middlewares/raise_error.rb +31 -0
- data/lib/basecrm/model.rb +6 -0
- data/lib/basecrm/models/account.rb +31 -0
- data/lib/basecrm/models/address.rb +22 -0
- data/lib/basecrm/models/associated_contact.rb +19 -0
- data/lib/basecrm/models/contact.rb +88 -0
- data/lib/basecrm/models/deal.rb +58 -0
- data/lib/basecrm/models/lead.rb +79 -0
- data/lib/basecrm/models/loss_reason.rb +22 -0
- data/lib/basecrm/models/note.rb +28 -0
- data/lib/basecrm/models/pipeline.rb +19 -0
- data/lib/basecrm/models/source.rb +22 -0
- data/lib/basecrm/models/stage.rb +34 -0
- data/lib/basecrm/models/tag.rb +25 -0
- data/lib/basecrm/models/task.rb +46 -0
- data/lib/basecrm/models/user.rb +31 -0
- data/lib/basecrm/paginated_resource.rb +32 -0
- data/lib/basecrm/services/accounts_service.rb +33 -0
- data/lib/basecrm/services/associated_contacts_service.rb +91 -0
- data/lib/basecrm/services/contacts_service.rb +138 -0
- data/lib/basecrm/services/deals_service.rb +137 -0
- data/lib/basecrm/services/leads_service.rb +140 -0
- data/lib/basecrm/services/loss_reasons_service.rb +133 -0
- data/lib/basecrm/services/notes_service.rb +134 -0
- data/lib/basecrm/services/pipelines_service.rb +50 -0
- data/lib/basecrm/services/sources_service.rb +133 -0
- data/lib/basecrm/services/stages_service.rb +52 -0
- data/lib/basecrm/services/tags_service.rb +132 -0
- data/lib/basecrm/services/tasks_service.rb +141 -0
- data/lib/basecrm/services/users_service.rb +83 -0
- data/lib/basecrm/version.rb +3 -0
- data/spec/factories/associated_contact.rb +14 -0
- data/spec/factories/contact.rb +27 -0
- data/spec/factories/deal.rb +17 -0
- data/spec/factories/lead.rb +26 -0
- data/spec/factories/loss_reason.rb +11 -0
- data/spec/factories/note.rb +13 -0
- data/spec/factories/source.rb +11 -0
- data/spec/factories/tag.rb +12 -0
- data/spec/factories/task.rb +15 -0
- data/spec/services/accounts_service_spec.rb +16 -0
- data/spec/services/associated_contacts_service_spec.rb +43 -0
- data/spec/services/contacts_service_spec.rb +58 -0
- data/spec/services/deals_service_spec.rb +58 -0
- data/spec/services/leads_service_spec.rb +58 -0
- data/spec/services/loss_reasons_service_spec.rb +58 -0
- data/spec/services/notes_service_spec.rb +58 -0
- data/spec/services/pipelines_service_spec.rb +23 -0
- data/spec/services/sources_service_spec.rb +58 -0
- data/spec/services/stages_service_spec.rb +23 -0
- data/spec/services/tags_service_spec.rb +58 -0
- data/spec/services/tasks_service_spec.rb +58 -0
- data/spec/services/users_service_spec.rb +39 -0
- data/spec/spec_helper.rb +24 -12
- data/spec/support/client_helpers.rb +19 -0
- metadata +160 -71
- data/.gitignore +0 -20
- data/.rspec +0 -2
- data/.travis.yml +0 -6
- data/Gemfile +0 -4
- data/Rakefile +0 -8
- data/basecrm.gemspec +0 -23
- data/lib/base_crm.rb +0 -24
- data/lib/base_crm/account.rb +0 -11
- data/lib/base_crm/api_client_ext.rb +0 -6
- data/lib/base_crm/config.rb +0 -21
- data/lib/base_crm/contact.rb +0 -44
- data/lib/base_crm/custom_fieldable.rb +0 -32
- data/lib/base_crm/deal.rb +0 -50
- data/lib/base_crm/forecasting.rb +0 -12
- data/lib/base_crm/lead.rb +0 -36
- data/lib/base_crm/note.rb +0 -15
- data/lib/base_crm/noteable.rb +0 -15
- data/lib/base_crm/related_object_scope.rb +0 -35
- data/lib/base_crm/resource.rb +0 -14
- data/lib/base_crm/session.rb +0 -48
- data/lib/base_crm/source.rb +0 -14
- data/lib/base_crm/task.rb +0 -16
- data/lib/base_crm/taskable.rb +0 -15
- data/lib/base_crm/version.rb +0 -3
- data/spec/base_crm/account_spec.rb +0 -20
- data/spec/base_crm/contact_spec.rb +0 -92
- data/spec/base_crm/deal_spec.rb +0 -138
- data/spec/base_crm/forecasting_spec.rb +0 -34
- data/spec/base_crm/lead_spec.rb +0 -63
- data/spec/base_crm/note_spec.rb +0 -20
- data/spec/base_crm/resource_mixin_spec.rb +0 -26
- data/spec/base_crm/session_spec.rb +0 -97
- data/spec/base_crm/source_spec.rb +0 -20
- data/spec/base_crm/task_spec.rb +0 -21
- data/spec/support/noteable_shared_examples.rb +0 -64
- data/spec/support/taskable_shared_examples.rb +0 -69
@@ -0,0 +1,17 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :deal, class: BaseCRM::Deal do
|
3
|
+
|
4
|
+
currency { "EUR" }
|
5
|
+
dropbox_email { "dropbox@4e627bcd.deals.futuresimple.com" }
|
6
|
+
hot { true }
|
7
|
+
name { Faker::Name.name }
|
8
|
+
tags { ["important"] }
|
9
|
+
value { 1000 }
|
10
|
+
|
11
|
+
contact_id { contact.id }
|
12
|
+
|
13
|
+
to_create do |deal|
|
14
|
+
client.deals.create(deal)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :lead, class: BaseCRM::Lead do
|
3
|
+
|
4
|
+
description { "I know him via Tom" }
|
5
|
+
email { "mark@designservices.com" }
|
6
|
+
facebook { "mjohnson" }
|
7
|
+
fax { "+44-208-1234567" }
|
8
|
+
first_name { Faker::Name.first_name }
|
9
|
+
industry { "Design Services" }
|
10
|
+
last_name { Faker::Name.last_name }
|
11
|
+
linkedin { "mjohnson" }
|
12
|
+
mobile { "508-778-6516" }
|
13
|
+
phone { "508-778-6516" }
|
14
|
+
skype { "mjohnson" }
|
15
|
+
status { "Unqualified" }
|
16
|
+
tags { ["important"] }
|
17
|
+
title { "CEO" }
|
18
|
+
twitter { "mjohnson" }
|
19
|
+
website { "www.designservices.com" }
|
20
|
+
|
21
|
+
|
22
|
+
to_create do |lead|
|
23
|
+
client.leads.create(lead)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :task, class: BaseCRM::Task do
|
3
|
+
|
4
|
+
content { "Contact Tom" }
|
5
|
+
due_date { "2014-09-27T16:32:56+00:00" }
|
6
|
+
remind_at { "2014-09-29T15:32:56+00:00" }
|
7
|
+
|
8
|
+
resource_id { contact.id }
|
9
|
+
resource_type { :contact }
|
10
|
+
|
11
|
+
to_create do |task|
|
12
|
+
client.tasks.create(task)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe BaseCRM::AccountsService do
|
4
|
+
describe 'Responds to' do
|
5
|
+
subject { client.accounts }
|
6
|
+
|
7
|
+
it { should respond_to :self }
|
8
|
+
|
9
|
+
end
|
10
|
+
|
11
|
+
describe :self do
|
12
|
+
it "returns instance of Account class" do
|
13
|
+
expect(client.accounts.self).to be_instance_of BaseCRM::Account
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe BaseCRM::AssociatedContactsService do
|
4
|
+
describe 'Responds to' do
|
5
|
+
subject { client.associated_contacts }
|
6
|
+
|
7
|
+
it { should respond_to :all }
|
8
|
+
it { should respond_to :create }
|
9
|
+
it { should respond_to :destroy }
|
10
|
+
it { should respond_to :where }
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
describe :all do
|
15
|
+
it "returns a PaginatedResource" do
|
16
|
+
deal_id = create(:deal).id
|
17
|
+
expect(client.associated_contacts.all(deal_id)).to be_instance_of BaseCRM::PaginatedResource
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe :where do
|
22
|
+
it "returns an array" do
|
23
|
+
deal_id = create(:deal).id
|
24
|
+
expect(client.associated_contacts.where(deal_id, page: 1)).to be_an Array
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe :create do
|
29
|
+
it "returns instance of AssociatedContact class" do
|
30
|
+
deal_id = create(:deal).id
|
31
|
+
@associated_contact = build(:associated_contact)
|
32
|
+
expect(client.associated_contacts.create(deal_id, @associated_contact)).to be_instance_of BaseCRM::AssociatedContact
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe :destroy do
|
37
|
+
it "returns true on success" do
|
38
|
+
deal_id = create(:deal).id
|
39
|
+
@associated_contact = create(:associated_contact, deal_id: deal_id)
|
40
|
+
expect(client.associated_contacts.destroy(deal_id, @associated_contact.contact_id)).to be_truthy
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe BaseCRM::ContactsService do
|
4
|
+
describe 'Responds to' do
|
5
|
+
subject { client.contacts }
|
6
|
+
|
7
|
+
it { should respond_to :all }
|
8
|
+
it { should respond_to :create }
|
9
|
+
it { should respond_to :destroy }
|
10
|
+
it { should respond_to :find }
|
11
|
+
it { should respond_to :update }
|
12
|
+
it { should respond_to :where }
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
describe :all do
|
17
|
+
it "returns a PaginatedResource" do
|
18
|
+
expect(client.contacts.all()).to be_instance_of BaseCRM::PaginatedResource
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe :where do
|
23
|
+
it "returns an array" do
|
24
|
+
expect(client.contacts.where(page: 1)).to be_an Array
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe :create do
|
29
|
+
it "returns instance of Contact class" do
|
30
|
+
@contact = build(:contact)
|
31
|
+
expect(client.contacts.create(@contact)).to be_instance_of BaseCRM::Contact
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe :find do
|
36
|
+
before :each do
|
37
|
+
@contact = create(:contact)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "returns an instance of Contact class" do
|
41
|
+
expect(client.contacts.find(@contact.id)).to be_instance_of BaseCRM::Contact
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe :update do
|
46
|
+
it "returns an updated instance of Contact class" do
|
47
|
+
@contact = create(:contact)
|
48
|
+
expect(client.contacts.update(@contact)).to be_instance_of BaseCRM::Contact
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe :destroy do
|
53
|
+
it "returns true on success" do
|
54
|
+
@contact = create(:contact)
|
55
|
+
expect(client.contacts.destroy(@contact.id)).to be_truthy
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe BaseCRM::DealsService do
|
4
|
+
describe 'Responds to' do
|
5
|
+
subject { client.deals }
|
6
|
+
|
7
|
+
it { should respond_to :all }
|
8
|
+
it { should respond_to :create }
|
9
|
+
it { should respond_to :destroy }
|
10
|
+
it { should respond_to :find }
|
11
|
+
it { should respond_to :update }
|
12
|
+
it { should respond_to :where }
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
describe :all do
|
17
|
+
it "returns a PaginatedResource" do
|
18
|
+
expect(client.deals.all()).to be_instance_of BaseCRM::PaginatedResource
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe :where do
|
23
|
+
it "returns an array" do
|
24
|
+
expect(client.deals.where(page: 1)).to be_an Array
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe :create do
|
29
|
+
it "returns instance of Deal class" do
|
30
|
+
@deal = build(:deal)
|
31
|
+
expect(client.deals.create(@deal)).to be_instance_of BaseCRM::Deal
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe :find do
|
36
|
+
before :each do
|
37
|
+
@deal = create(:deal)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "returns an instance of Deal class" do
|
41
|
+
expect(client.deals.find(@deal.id)).to be_instance_of BaseCRM::Deal
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe :update do
|
46
|
+
it "returns an updated instance of Deal class" do
|
47
|
+
@deal = create(:deal)
|
48
|
+
expect(client.deals.update(@deal)).to be_instance_of BaseCRM::Deal
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe :destroy do
|
53
|
+
it "returns true on success" do
|
54
|
+
@deal = create(:deal)
|
55
|
+
expect(client.deals.destroy(@deal.id)).to be_truthy
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe BaseCRM::LeadsService do
|
4
|
+
describe 'Responds to' do
|
5
|
+
subject { client.leads }
|
6
|
+
|
7
|
+
it { should respond_to :all }
|
8
|
+
it { should respond_to :create }
|
9
|
+
it { should respond_to :destroy }
|
10
|
+
it { should respond_to :find }
|
11
|
+
it { should respond_to :update }
|
12
|
+
it { should respond_to :where }
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
describe :all do
|
17
|
+
it "returns a PaginatedResource" do
|
18
|
+
expect(client.leads.all()).to be_instance_of BaseCRM::PaginatedResource
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe :where do
|
23
|
+
it "returns an array" do
|
24
|
+
expect(client.leads.where(page: 1)).to be_an Array
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe :create do
|
29
|
+
it "returns instance of Lead class" do
|
30
|
+
@lead = build(:lead)
|
31
|
+
expect(client.leads.create(@lead)).to be_instance_of BaseCRM::Lead
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe :find do
|
36
|
+
before :each do
|
37
|
+
@lead = create(:lead)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "returns an instance of Lead class" do
|
41
|
+
expect(client.leads.find(@lead.id)).to be_instance_of BaseCRM::Lead
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe :update do
|
46
|
+
it "returns an updated instance of Lead class" do
|
47
|
+
@lead = create(:lead)
|
48
|
+
expect(client.leads.update(@lead)).to be_instance_of BaseCRM::Lead
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe :destroy do
|
53
|
+
it "returns true on success" do
|
54
|
+
@lead = create(:lead)
|
55
|
+
expect(client.leads.destroy(@lead.id)).to be_truthy
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe BaseCRM::LossReasonsService do
|
4
|
+
describe 'Responds to' do
|
5
|
+
subject { client.loss_reasons }
|
6
|
+
|
7
|
+
it { should respond_to :all }
|
8
|
+
it { should respond_to :create }
|
9
|
+
it { should respond_to :destroy }
|
10
|
+
it { should respond_to :find }
|
11
|
+
it { should respond_to :update }
|
12
|
+
it { should respond_to :where }
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
describe :all do
|
17
|
+
it "returns a PaginatedResource" do
|
18
|
+
expect(client.loss_reasons.all()).to be_instance_of BaseCRM::PaginatedResource
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe :where do
|
23
|
+
it "returns an array" do
|
24
|
+
expect(client.loss_reasons.where(page: 1)).to be_an Array
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe :create do
|
29
|
+
it "returns instance of LossReason class" do
|
30
|
+
@loss_reason = build(:loss_reason)
|
31
|
+
expect(client.loss_reasons.create(@loss_reason)).to be_instance_of BaseCRM::LossReason
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe :find do
|
36
|
+
before :each do
|
37
|
+
@loss_reason = create(:loss_reason)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "returns an instance of LossReason class" do
|
41
|
+
expect(client.loss_reasons.find(@loss_reason.id)).to be_instance_of BaseCRM::LossReason
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe :update do
|
46
|
+
it "returns an updated instance of LossReason class" do
|
47
|
+
@loss_reason = create(:loss_reason)
|
48
|
+
expect(client.loss_reasons.update(@loss_reason)).to be_instance_of BaseCRM::LossReason
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe :destroy do
|
53
|
+
it "returns true on success" do
|
54
|
+
@loss_reason = create(:loss_reason)
|
55
|
+
expect(client.loss_reasons.destroy(@loss_reason.id)).to be_truthy
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe BaseCRM::NotesService do
|
4
|
+
describe 'Responds to' do
|
5
|
+
subject { client.notes }
|
6
|
+
|
7
|
+
it { should respond_to :all }
|
8
|
+
it { should respond_to :create }
|
9
|
+
it { should respond_to :destroy }
|
10
|
+
it { should respond_to :find }
|
11
|
+
it { should respond_to :update }
|
12
|
+
it { should respond_to :where }
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
describe :all do
|
17
|
+
it "returns a PaginatedResource" do
|
18
|
+
expect(client.notes.all()).to be_instance_of BaseCRM::PaginatedResource
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe :where do
|
23
|
+
it "returns an array" do
|
24
|
+
expect(client.notes.where(page: 1)).to be_an Array
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe :create do
|
29
|
+
it "returns instance of Note class" do
|
30
|
+
@note = build(:note)
|
31
|
+
expect(client.notes.create(@note)).to be_instance_of BaseCRM::Note
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe :find do
|
36
|
+
before :each do
|
37
|
+
@note = create(:note)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "returns an instance of Note class" do
|
41
|
+
expect(client.notes.find(@note.id)).to be_instance_of BaseCRM::Note
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe :update do
|
46
|
+
it "returns an updated instance of Note class" do
|
47
|
+
@note = create(:note)
|
48
|
+
expect(client.notes.update(@note)).to be_instance_of BaseCRM::Note
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe :destroy do
|
53
|
+
it "returns true on success" do
|
54
|
+
@note = create(:note)
|
55
|
+
expect(client.notes.destroy(@note.id)).to be_truthy
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|