basecrm 0.1.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +2 -2
  3. data/README.md +273 -17
  4. data/lib/basecrm.rb +185 -1
  5. data/lib/basecrm/configuration.rb +59 -0
  6. data/lib/basecrm/envelope.rb +7 -0
  7. data/lib/basecrm/errors.rb +65 -0
  8. data/lib/basecrm/http_client.rb +91 -0
  9. data/lib/basecrm/middlewares/oauth_bearer_token.rb +18 -0
  10. data/lib/basecrm/middlewares/raise_error.rb +31 -0
  11. data/lib/basecrm/model.rb +6 -0
  12. data/lib/basecrm/models/account.rb +31 -0
  13. data/lib/basecrm/models/address.rb +22 -0
  14. data/lib/basecrm/models/associated_contact.rb +19 -0
  15. data/lib/basecrm/models/contact.rb +88 -0
  16. data/lib/basecrm/models/deal.rb +58 -0
  17. data/lib/basecrm/models/lead.rb +79 -0
  18. data/lib/basecrm/models/loss_reason.rb +22 -0
  19. data/lib/basecrm/models/note.rb +28 -0
  20. data/lib/basecrm/models/pipeline.rb +19 -0
  21. data/lib/basecrm/models/source.rb +22 -0
  22. data/lib/basecrm/models/stage.rb +34 -0
  23. data/lib/basecrm/models/tag.rb +25 -0
  24. data/lib/basecrm/models/task.rb +46 -0
  25. data/lib/basecrm/models/user.rb +31 -0
  26. data/lib/basecrm/paginated_resource.rb +32 -0
  27. data/lib/basecrm/services/accounts_service.rb +33 -0
  28. data/lib/basecrm/services/associated_contacts_service.rb +91 -0
  29. data/lib/basecrm/services/contacts_service.rb +138 -0
  30. data/lib/basecrm/services/deals_service.rb +137 -0
  31. data/lib/basecrm/services/leads_service.rb +140 -0
  32. data/lib/basecrm/services/loss_reasons_service.rb +133 -0
  33. data/lib/basecrm/services/notes_service.rb +134 -0
  34. data/lib/basecrm/services/pipelines_service.rb +50 -0
  35. data/lib/basecrm/services/sources_service.rb +133 -0
  36. data/lib/basecrm/services/stages_service.rb +52 -0
  37. data/lib/basecrm/services/tags_service.rb +132 -0
  38. data/lib/basecrm/services/tasks_service.rb +141 -0
  39. data/lib/basecrm/services/users_service.rb +83 -0
  40. data/lib/basecrm/version.rb +3 -0
  41. data/spec/factories/associated_contact.rb +14 -0
  42. data/spec/factories/contact.rb +27 -0
  43. data/spec/factories/deal.rb +17 -0
  44. data/spec/factories/lead.rb +26 -0
  45. data/spec/factories/loss_reason.rb +11 -0
  46. data/spec/factories/note.rb +13 -0
  47. data/spec/factories/source.rb +11 -0
  48. data/spec/factories/tag.rb +12 -0
  49. data/spec/factories/task.rb +15 -0
  50. data/spec/services/accounts_service_spec.rb +16 -0
  51. data/spec/services/associated_contacts_service_spec.rb +43 -0
  52. data/spec/services/contacts_service_spec.rb +58 -0
  53. data/spec/services/deals_service_spec.rb +58 -0
  54. data/spec/services/leads_service_spec.rb +58 -0
  55. data/spec/services/loss_reasons_service_spec.rb +58 -0
  56. data/spec/services/notes_service_spec.rb +58 -0
  57. data/spec/services/pipelines_service_spec.rb +23 -0
  58. data/spec/services/sources_service_spec.rb +58 -0
  59. data/spec/services/stages_service_spec.rb +23 -0
  60. data/spec/services/tags_service_spec.rb +58 -0
  61. data/spec/services/tasks_service_spec.rb +58 -0
  62. data/spec/services/users_service_spec.rb +39 -0
  63. data/spec/spec_helper.rb +24 -12
  64. data/spec/support/client_helpers.rb +19 -0
  65. metadata +160 -71
  66. data/.gitignore +0 -20
  67. data/.rspec +0 -2
  68. data/.travis.yml +0 -6
  69. data/Gemfile +0 -4
  70. data/Rakefile +0 -8
  71. data/basecrm.gemspec +0 -23
  72. data/lib/base_crm.rb +0 -24
  73. data/lib/base_crm/account.rb +0 -11
  74. data/lib/base_crm/api_client_ext.rb +0 -6
  75. data/lib/base_crm/config.rb +0 -21
  76. data/lib/base_crm/contact.rb +0 -44
  77. data/lib/base_crm/custom_fieldable.rb +0 -32
  78. data/lib/base_crm/deal.rb +0 -50
  79. data/lib/base_crm/forecasting.rb +0 -12
  80. data/lib/base_crm/lead.rb +0 -36
  81. data/lib/base_crm/note.rb +0 -15
  82. data/lib/base_crm/noteable.rb +0 -15
  83. data/lib/base_crm/related_object_scope.rb +0 -35
  84. data/lib/base_crm/resource.rb +0 -14
  85. data/lib/base_crm/session.rb +0 -48
  86. data/lib/base_crm/source.rb +0 -14
  87. data/lib/base_crm/task.rb +0 -16
  88. data/lib/base_crm/taskable.rb +0 -15
  89. data/lib/base_crm/version.rb +0 -3
  90. data/spec/base_crm/account_spec.rb +0 -20
  91. data/spec/base_crm/contact_spec.rb +0 -92
  92. data/spec/base_crm/deal_spec.rb +0 -138
  93. data/spec/base_crm/forecasting_spec.rb +0 -34
  94. data/spec/base_crm/lead_spec.rb +0 -63
  95. data/spec/base_crm/note_spec.rb +0 -20
  96. data/spec/base_crm/resource_mixin_spec.rb +0 -26
  97. data/spec/base_crm/session_spec.rb +0 -97
  98. data/spec/base_crm/source_spec.rb +0 -20
  99. data/spec/base_crm/task_spec.rb +0 -21
  100. data/spec/support/noteable_shared_examples.rb +0 -64
  101. data/spec/support/taskable_shared_examples.rb +0 -69
@@ -1,97 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe BaseCrm::Session do
4
-
5
- let(:token) { "OMGTOKEN" }
6
-
7
- subject do
8
- BaseCrm::Session.new(token)
9
- end
10
-
11
- describe "passing of headers" do
12
- let(:scope) { double }
13
- let(:scope_class) { double }
14
-
15
- before do
16
- scope_class.should_receive(:headers).with({
17
- "X-Pipejump-Auth" => token
18
- }).and_return(scope)
19
- scope.should_receive(:headers).with({
20
- "X-Futuresimple-Token" => token
21
- })
22
- end
23
-
24
- describe "#contacts" do
25
- let(:scope_class) { BaseCrm::Contact }
26
-
27
- it "queries the contacts with the right header" do
28
- subject.contacts
29
- end
30
-
31
- end
32
-
33
- describe "#deals" do
34
- let(:scope_class) { BaseCrm::Deal }
35
-
36
- it "queries the deals with the right header" do
37
- subject.deals
38
- end
39
-
40
- end
41
-
42
- describe "#sources" do
43
- let(:scope_class) { BaseCrm::Source }
44
-
45
- it "queries the sources with the right header" do
46
- subject.sources
47
- end
48
-
49
- end
50
-
51
- describe "#notes" do
52
- let(:scope_class) { BaseCrm::Note }
53
-
54
- it "queries the notes with the right header" do
55
- subject.notes
56
- end
57
-
58
- end
59
-
60
- describe "#tasks" do
61
- let(:scope_class) { BaseCrm::Task }
62
-
63
- it "queries the tasks with the right header" do
64
- subject.tasks
65
- end
66
-
67
- end
68
-
69
- describe "#leads" do
70
- let(:scope_class) { BaseCrm::Lead }
71
-
72
- it "queries the leads with the right header" do
73
- subject.leads
74
- end
75
-
76
- end
77
-
78
-
79
- end
80
-
81
- describe "#account" do
82
-
83
- it "gets the account" do
84
- BaseCrm::Account.should_receive(:headers).with({
85
- "X-Pipejump-Auth" => token
86
- }).and_return(BaseCrm::Account)
87
- BaseCrm::Account.should_receive(:headers).with({
88
- "X-Futuresimple-Token" => token
89
- }).and_return(BaseCrm::Account)
90
- BaseCrm::Account.should_receive(:fetch).with('/api/v1/account.json')
91
- subject.account
92
- end
93
-
94
- end
95
-
96
- end
97
-
@@ -1,20 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe BaseCrm::Source do
4
-
5
- subject do
6
- BaseCrm::Source.new({})
7
- end
8
-
9
- describe "endpoint" do
10
-
11
- it "uses the production endpoint" do
12
- BaseCrm::Source.scope.instance_eval do
13
- @endpoint.should == "https://sales.futuresimple.com"
14
- end
15
- end
16
-
17
- end
18
-
19
- end
20
-
@@ -1,21 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe BaseCrm::Task do
4
-
5
- subject do
6
- BaseCrm::Task.new({})
7
- end
8
-
9
- describe "endpoint" do
10
-
11
- it "uses the production endpoint" do
12
- BaseCrm::Task.scope.instance_eval do
13
- @endpoint.should == "https://common.futuresimple.com"
14
- end
15
- end
16
-
17
- end
18
-
19
- end
20
-
21
-
@@ -1,64 +0,0 @@
1
- shared_examples "noteable" do |noteable_type|
2
-
3
- let(:scope) { double }
4
-
5
- describe "#notes" do
6
- let(:fetch_scope) { double }
7
-
8
- it "passes the token and applies the params" do
9
- subject.
10
- should_receive(:pass_headers).
11
- with(BaseCrm::Note).
12
- and_return(scope)
13
- scope.should_receive(:params).
14
- with({
15
- :noteable_type => noteable_type,
16
- :noteable_id => subject.id
17
- }).and_return(fetch_scope)
18
- subject.notes.should == fetch_scope
19
- end
20
-
21
- end
22
-
23
- describe "#notes.create" do
24
- let(:message) { double }
25
- let(:note) { double }
26
- let(:fetch_scope) { double }
27
-
28
- it "passes the token and applies the params" do
29
- subject.
30
- should_receive(:pass_headers).
31
- with(BaseCrm::Note).
32
- and_return(scope)
33
- scope.should_receive(:params).
34
- with({
35
- :noteable_type => noteable_type,
36
- :noteable_id => subject.id
37
- }).and_return(scope)
38
- scope.should_receive(:create).with({
39
- :content => message,
40
- :noteable_type => noteable_type,
41
- :noteable_id => subject.id
42
- }).and_return(note)
43
- subject.notes.create(:content => message).should == note
44
- end
45
-
46
- end
47
-
48
- describe "#create_note" do
49
- let(:message) { double }
50
- let(:notes) { double }
51
- let(:note) { double }
52
-
53
- it "creates a new note" do
54
- subject.should_receive(:notes).and_return(notes)
55
- notes.should_receive(:create).with({
56
- :content => message
57
- }).and_return(note)
58
- subject.create_note(message).should == note
59
- end
60
-
61
- end
62
-
63
- end
64
-
@@ -1,69 +0,0 @@
1
- shared_examples "taskable" do |taskable_type|
2
-
3
- let(:scope) { double }
4
-
5
- describe "#tasks" do
6
- let(:fetch_scope) { double }
7
-
8
- it "passes the token and applies the params" do
9
- subject.
10
- should_receive(:pass_headers).
11
- with(BaseCrm::Task).
12
- and_return(scope)
13
- scope.should_receive(:params).
14
- with({
15
- :taskable_type => taskable_type,
16
- :taskable_id => subject.id
17
- }).and_return(fetch_scope)
18
- subject.tasks.should == fetch_scope
19
- end
20
-
21
- end
22
-
23
- describe "#tasks.create" do
24
- let(:params) do
25
- { :content => task_content }
26
- end
27
- let(:task_content) { double }
28
- let(:task) { double }
29
-
30
- it "creates a new task" do
31
- subject.
32
- should_receive(:pass_headers).
33
- with(BaseCrm::Task).
34
- and_return(scope)
35
- scope.should_receive(:params).
36
- with({
37
- :taskable_type => taskable_type,
38
- :taskable_id => subject.id
39
- }).and_return(scope)
40
- scope.should_receive(:create).with({
41
- :content => task_content,
42
- :taskable_type => taskable_type,
43
- :taskable_id => subject.id
44
- }).and_return(task)
45
- subject.create_task(params).should == task
46
- end
47
- end
48
-
49
- describe "#create_task" do
50
- let(:params) do
51
- { :content => task_content }
52
- end
53
- let(:task_content) { double }
54
- let(:tasks) { double }
55
- let(:task) { double }
56
-
57
- it "creates a new task" do
58
- subject.should_receive(:tasks).and_return(tasks)
59
- tasks.should_receive(:create).with({
60
- :content => task_content
61
- }).and_return(task)
62
- subject.create_task(params).should == task
63
- end
64
-
65
- end
66
-
67
- end
68
-
69
-