insightly2 0.1.4

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 (240) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +5 -0
  5. data/Gemfile +4 -0
  6. data/README.md +113 -0
  7. data/Rakefile +6 -0
  8. data/config/gem_secret.yml.example +1 -0
  9. data/insightly2.gemspec +29 -0
  10. data/lib/insightly2/client.rb +54 -0
  11. data/lib/insightly2/dsl/comments.rb +47 -0
  12. data/lib/insightly2/dsl/contacts.rb +130 -0
  13. data/lib/insightly2/dsl/countries.rb +12 -0
  14. data/lib/insightly2/dsl/currencies.rb +12 -0
  15. data/lib/insightly2/dsl/custom_fields.rb +22 -0
  16. data/lib/insightly2/dsl/emails.rb +57 -0
  17. data/lib/insightly2/dsl/events.rb +52 -0
  18. data/lib/insightly2/dsl/file_attachments.rb +14 -0
  19. data/lib/insightly2/dsl/file_categories.rb +52 -0
  20. data/lib/insightly2/dsl/notes.rb +85 -0
  21. data/lib/insightly2/dsl/opportunities.rb +134 -0
  22. data/lib/insightly2/dsl/opportunity_categories.rb +52 -0
  23. data/lib/insightly2/dsl/opportunity_state_reasons.rb +12 -0
  24. data/lib/insightly2/dsl/organisations.rb +128 -0
  25. data/lib/insightly2/dsl/pipeline_stages.rb +22 -0
  26. data/lib/insightly2/dsl/pipelines.rb +22 -0
  27. data/lib/insightly2/dsl/project_categories.rb +52 -0
  28. data/lib/insightly2/dsl/projects.rb +129 -0
  29. data/lib/insightly2/dsl/relationships.rb +12 -0
  30. data/lib/insightly2/dsl/tags.rb +15 -0
  31. data/lib/insightly2/dsl/task_categories.rb +52 -0
  32. data/lib/insightly2/dsl/tasks.rb +76 -0
  33. data/lib/insightly2/dsl/team_members.rb +53 -0
  34. data/lib/insightly2/dsl/teams.rb +53 -0
  35. data/lib/insightly2/dsl/users.rb +22 -0
  36. data/lib/insightly2/dsl.rb +65 -0
  37. data/lib/insightly2/errors/client_error.rb +10 -0
  38. data/lib/insightly2/errors/resource_not_found_error.rb +8 -0
  39. data/lib/insightly2/errors.rb +10 -0
  40. data/lib/insightly2/resources/comment.rb +10 -0
  41. data/lib/insightly2/resources/contact.rb +8 -0
  42. data/lib/insightly2/resources/country.rb +8 -0
  43. data/lib/insightly2/resources/currency.rb +8 -0
  44. data/lib/insightly2/resources/custom_field.rb +8 -0
  45. data/lib/insightly2/resources/email.rb +8 -0
  46. data/lib/insightly2/resources/event.rb +8 -0
  47. data/lib/insightly2/resources/file_attachment.rb +8 -0
  48. data/lib/insightly2/resources/file_category.rb +8 -0
  49. data/lib/insightly2/resources/note.rb +8 -0
  50. data/lib/insightly2/resources/object/attributes.rb +71 -0
  51. data/lib/insightly2/resources/object/serializers.rb +102 -0
  52. data/lib/insightly2/resources/object.rb +29 -0
  53. data/lib/insightly2/resources/opportunity.rb +8 -0
  54. data/lib/insightly2/resources/opportunity_category.rb +8 -0
  55. data/lib/insightly2/resources/opportunity_state_reason.rb +8 -0
  56. data/lib/insightly2/resources/organisation.rb +8 -0
  57. data/lib/insightly2/resources/pipeline.rb +8 -0
  58. data/lib/insightly2/resources/pipeline_stage.rb +8 -0
  59. data/lib/insightly2/resources/project.rb +8 -0
  60. data/lib/insightly2/resources/project_category.rb +8 -0
  61. data/lib/insightly2/resources/relationship.rb +8 -0
  62. data/lib/insightly2/resources/tag.rb +8 -0
  63. data/lib/insightly2/resources/task.rb +8 -0
  64. data/lib/insightly2/resources/task_category.rb +8 -0
  65. data/lib/insightly2/resources/team.rb +8 -0
  66. data/lib/insightly2/resources/team_member.rb +8 -0
  67. data/lib/insightly2/resources/user.rb +8 -0
  68. data/lib/insightly2/resources.rb +33 -0
  69. data/lib/insightly2/utils/url_helper.rb +17 -0
  70. data/lib/insightly2/utils.rb +8 -0
  71. data/lib/insightly2/version.rb +3 -0
  72. data/lib/insightly2.rb +22 -0
  73. data/spec/fixtures/vcr_cassettes/create_comment_attachment.yml +42 -0
  74. data/spec/fixtures/vcr_cassettes/create_contact.yml +47 -0
  75. data/spec/fixtures/vcr_cassettes/create_contact_image.yml +42 -0
  76. data/spec/fixtures/vcr_cassettes/create_email_comment.yml +47 -0
  77. data/spec/fixtures/vcr_cassettes/create_event.yml +95 -0
  78. data/spec/fixtures/vcr_cassettes/create_file_category.yml +89 -0
  79. data/spec/fixtures/vcr_cassettes/create_note.yml +95 -0
  80. data/spec/fixtures/vcr_cassettes/create_note_comment.yml +47 -0
  81. data/spec/fixtures/vcr_cassettes/create_note_file.yml +42 -0
  82. data/spec/fixtures/vcr_cassettes/create_opportunity.yml +98 -0
  83. data/spec/fixtures/vcr_cassettes/create_opportunity_category.yml +89 -0
  84. data/spec/fixtures/vcr_cassettes/create_opportunity_image.yml +42 -0
  85. data/spec/fixtures/vcr_cassettes/create_organisation.yml +116 -0
  86. data/spec/fixtures/vcr_cassettes/create_organisation_image.yml +42 -0
  87. data/spec/fixtures/vcr_cassettes/create_project.yml +106 -0
  88. data/spec/fixtures/vcr_cassettes/create_project_category.yml +89 -0
  89. data/spec/fixtures/vcr_cassettes/create_project_image.yml +42 -0
  90. data/spec/fixtures/vcr_cassettes/create_task.yml +98 -0
  91. data/spec/fixtures/vcr_cassettes/create_task_category.yml +89 -0
  92. data/spec/fixtures/vcr_cassettes/create_task_comment.yml +47 -0
  93. data/spec/fixtures/vcr_cassettes/create_team.yml +92 -0
  94. data/spec/fixtures/vcr_cassettes/create_team_member.yml +89 -0
  95. data/spec/fixtures/vcr_cassettes/delete_comment.yml +42 -0
  96. data/spec/fixtures/vcr_cassettes/delete_contact.yml +42 -0
  97. data/spec/fixtures/vcr_cassettes/delete_contact_image.yml +42 -0
  98. data/spec/fixtures/vcr_cassettes/delete_email.yml +42 -0
  99. data/spec/fixtures/vcr_cassettes/delete_event.yml +42 -0
  100. data/spec/fixtures/vcr_cassettes/delete_file_category.yml +42 -0
  101. data/spec/fixtures/vcr_cassettes/delete_note.yml +42 -0
  102. data/spec/fixtures/vcr_cassettes/delete_opportunity.yml +42 -0
  103. data/spec/fixtures/vcr_cassettes/delete_opportunity_category.yml +42 -0
  104. data/spec/fixtures/vcr_cassettes/delete_opportunity_image.yml +42 -0
  105. data/spec/fixtures/vcr_cassettes/delete_organisation.yml +42 -0
  106. data/spec/fixtures/vcr_cassettes/delete_organisation_image.yml +42 -0
  107. data/spec/fixtures/vcr_cassettes/delete_project.yml +42 -0
  108. data/spec/fixtures/vcr_cassettes/delete_project_category.yml +42 -0
  109. data/spec/fixtures/vcr_cassettes/delete_project_image.yml +42 -0
  110. data/spec/fixtures/vcr_cassettes/delete_task.yml +42 -0
  111. data/spec/fixtures/vcr_cassettes/delete_task_category.yml +42 -0
  112. data/spec/fixtures/vcr_cassettes/delete_team.yml +42 -0
  113. data/spec/fixtures/vcr_cassettes/delete_team_member.yml +42 -0
  114. data/spec/fixtures/vcr_cassettes/get_comment.yml +47 -0
  115. data/spec/fixtures/vcr_cassettes/get_contact.yml +47 -0
  116. data/spec/fixtures/vcr_cassettes/get_contact_emails.yml +47 -0
  117. data/spec/fixtures/vcr_cassettes/get_contact_image.yml +44 -0
  118. data/spec/fixtures/vcr_cassettes/get_contact_notes.yml +48 -0
  119. data/spec/fixtures/vcr_cassettes/get_contact_tasks.yml +48 -0
  120. data/spec/fixtures/vcr_cassettes/get_contacts.yml +184 -0
  121. data/spec/fixtures/vcr_cassettes/get_countries.yml +85 -0
  122. data/spec/fixtures/vcr_cassettes/get_currencies.yml +124 -0
  123. data/spec/fixtures/vcr_cassettes/get_custom_field.yml +46 -0
  124. data/spec/fixtures/vcr_cassettes/get_custom_fields.yml +46 -0
  125. data/spec/fixtures/vcr_cassettes/get_email.yml +48 -0
  126. data/spec/fixtures/vcr_cassettes/get_email_comments.yml +49 -0
  127. data/spec/fixtures/vcr_cassettes/get_emails.yml +47 -0
  128. data/spec/fixtures/vcr_cassettes/get_event.yml +48 -0
  129. data/spec/fixtures/vcr_cassettes/get_events.yml +48 -0
  130. data/spec/fixtures/vcr_cassettes/get_file_attachment.yml +4057 -0
  131. data/spec/fixtures/vcr_cassettes/get_file_categories.yml +46 -0
  132. data/spec/fixtures/vcr_cassettes/get_file_category.yml +46 -0
  133. data/spec/fixtures/vcr_cassettes/get_note.yml +48 -0
  134. data/spec/fixtures/vcr_cassettes/get_note_comments.yml +48 -0
  135. data/spec/fixtures/vcr_cassettes/get_notes.yml +52 -0
  136. data/spec/fixtures/vcr_cassettes/get_opportunities.yml +81 -0
  137. data/spec/fixtures/vcr_cassettes/get_opportunity.yml +49 -0
  138. data/spec/fixtures/vcr_cassettes/get_opportunity_categories.yml +46 -0
  139. data/spec/fixtures/vcr_cassettes/get_opportunity_category.yml +46 -0
  140. data/spec/fixtures/vcr_cassettes/get_opportunity_emails.yml +48 -0
  141. data/spec/fixtures/vcr_cassettes/get_opportunity_image.yml +44 -0
  142. data/spec/fixtures/vcr_cassettes/get_opportunity_notes.yml +48 -0
  143. data/spec/fixtures/vcr_cassettes/get_opportunity_state_history.yml +83 -0
  144. data/spec/fixtures/vcr_cassettes/get_opportunity_state_reasons.yml +47 -0
  145. data/spec/fixtures/vcr_cassettes/get_opportunity_tasks.yml +49 -0
  146. data/spec/fixtures/vcr_cassettes/get_organisation.yml +55 -0
  147. data/spec/fixtures/vcr_cassettes/get_organisation_emails.yml +48 -0
  148. data/spec/fixtures/vcr_cassettes/get_organisation_image.yml +42 -0
  149. data/spec/fixtures/vcr_cassettes/get_organisation_notes.yml +47 -0
  150. data/spec/fixtures/vcr_cassettes/get_organisation_tasks.yml +48 -0
  151. data/spec/fixtures/vcr_cassettes/get_organisations.yml +2092 -0
  152. data/spec/fixtures/vcr_cassettes/get_pipeline.yml +46 -0
  153. data/spec/fixtures/vcr_cassettes/get_pipeline_stage.yml +46 -0
  154. data/spec/fixtures/vcr_cassettes/get_pipeline_stages.yml +49 -0
  155. data/spec/fixtures/vcr_cassettes/get_pipelines.yml +46 -0
  156. data/spec/fixtures/vcr_cassettes/get_project.yml +52 -0
  157. data/spec/fixtures/vcr_cassettes/get_project_categories.yml +46 -0
  158. data/spec/fixtures/vcr_cassettes/get_project_category.yml +46 -0
  159. data/spec/fixtures/vcr_cassettes/get_project_emails.yml +48 -0
  160. data/spec/fixtures/vcr_cassettes/get_project_image.yml +44 -0
  161. data/spec/fixtures/vcr_cassettes/get_project_notes.yml +47 -0
  162. data/spec/fixtures/vcr_cassettes/get_project_tasks.yml +48 -0
  163. data/spec/fixtures/vcr_cassettes/get_projects.yml +52 -0
  164. data/spec/fixtures/vcr_cassettes/get_task.yml +49 -0
  165. data/spec/fixtures/vcr_cassettes/get_task_categories.yml +47 -0
  166. data/spec/fixtures/vcr_cassettes/get_task_category.yml +46 -0
  167. data/spec/fixtures/vcr_cassettes/get_task_comments.yml +47 -0
  168. data/spec/fixtures/vcr_cassettes/get_tasks.yml +148 -0
  169. data/spec/fixtures/vcr_cassettes/get_team.yml +47 -0
  170. data/spec/fixtures/vcr_cassettes/get_team_member.yml +46 -0
  171. data/spec/fixtures/vcr_cassettes/get_team_members.yml +46 -0
  172. data/spec/fixtures/vcr_cassettes/get_teams.yml +47 -0
  173. data/spec/fixtures/vcr_cassettes/get_user.yml +48 -0
  174. data/spec/fixtures/vcr_cassettes/get_users.yml +48 -0
  175. data/spec/fixtures/vcr_cassettes/update_comment.yml +97 -0
  176. data/spec/fixtures/vcr_cassettes/update_contact.yml +94 -0
  177. data/spec/fixtures/vcr_cassettes/update_contact_image.yml +42 -0
  178. data/spec/fixtures/vcr_cassettes/update_event.yml +97 -0
  179. data/spec/fixtures/vcr_cassettes/update_file_category.yml +91 -0
  180. data/spec/fixtures/vcr_cassettes/update_note.yml +100 -0
  181. data/spec/fixtures/vcr_cassettes/update_opportunity.yml +100 -0
  182. data/spec/fixtures/vcr_cassettes/update_opportunity_category.yml +91 -0
  183. data/spec/fixtures/vcr_cassettes/update_opportunity_image.yml +42 -0
  184. data/spec/fixtures/vcr_cassettes/update_organisation.yml +118 -0
  185. data/spec/fixtures/vcr_cassettes/update_organisation_image.yml +42 -0
  186. data/spec/fixtures/vcr_cassettes/update_project.yml +109 -0
  187. data/spec/fixtures/vcr_cassettes/update_project_category.yml +91 -0
  188. data/spec/fixtures/vcr_cassettes/update_project_image.yml +42 -0
  189. data/spec/fixtures/vcr_cassettes/update_task.yml +100 -0
  190. data/spec/fixtures/vcr_cassettes/update_task_category.yml +91 -0
  191. data/spec/fixtures/vcr_cassettes/update_team.yml +94 -0
  192. data/spec/fixtures/vcr_cassettes/update_team_member.yml +91 -0
  193. data/spec/fixtures/vcr_cassettes/z_insightly_client_status_check.yml +48 -0
  194. data/spec/insightly2/client_spec.rb +12 -0
  195. data/spec/insightly2/dsl/comments_spec.rb +45 -0
  196. data/spec/insightly2/dsl/contacts_spec.rb +130 -0
  197. data/spec/insightly2/dsl/countries_spec.rb +14 -0
  198. data/spec/insightly2/dsl/currencies_spec.rb +14 -0
  199. data/spec/insightly2/dsl/custom_fields_spec.rb +25 -0
  200. data/spec/insightly2/dsl/emails_spec.rb +56 -0
  201. data/spec/insightly2/dsl/events_spec.rb +55 -0
  202. data/spec/insightly2/dsl/file_attachments_spec.rb +15 -0
  203. data/spec/insightly2/dsl/file_categories_spec.rb +55 -0
  204. data/spec/insightly2/dsl/notes_spec.rb +86 -0
  205. data/spec/insightly2/dsl/opportunities_spec.rb +143 -0
  206. data/spec/insightly2/dsl/opportunity_categories_spec.rb +55 -0
  207. data/spec/insightly2/dsl/opportunity_state_reasons_spec.rb +14 -0
  208. data/spec/insightly2/dsl/organisations_spec.rb +131 -0
  209. data/spec/insightly2/dsl/pipeline_stages_spec.rb +25 -0
  210. data/spec/insightly2/dsl/pipelines_spec.rb +25 -0
  211. data/spec/insightly2/dsl/project_categories_spec.rb +55 -0
  212. data/spec/insightly2/dsl/projects_spec.rb +131 -0
  213. data/spec/insightly2/dsl/task_categories_spec.rb +55 -0
  214. data/spec/insightly2/dsl/tasks_spec.rb +75 -0
  215. data/spec/insightly2/dsl/team_members_spec.rb +56 -0
  216. data/spec/insightly2/dsl/teams_spec.rb +55 -0
  217. data/spec/insightly2/dsl/users_spec.rb +25 -0
  218. data/spec/insightly2/resources/comment_spec.rb +27 -0
  219. data/spec/insightly2/resources/contact_spec.rb +28 -0
  220. data/spec/insightly2/resources/custom_field_spec.rb +22 -0
  221. data/spec/insightly2/resources/email_spec.rb +29 -0
  222. data/spec/insightly2/resources/event_spec.rb +29 -0
  223. data/spec/insightly2/resources/file_attachment_spec.rb +31 -0
  224. data/spec/insightly2/resources/file_category_spec.rb +21 -0
  225. data/spec/insightly2/resources/note_spec.rb +29 -0
  226. data/spec/insightly2/resources/opportunity_category_spec.rb +21 -0
  227. data/spec/insightly2/resources/opportunity_spec.rb +30 -0
  228. data/spec/insightly2/resources/organisation_spec.rb +29 -0
  229. data/spec/insightly2/resources/pipeline_spec.rb +21 -0
  230. data/spec/insightly2/resources/pipeline_stage_spec.rb +21 -0
  231. data/spec/insightly2/resources/project_category_spec.rb +21 -0
  232. data/spec/insightly2/resources/project_spec.rb +30 -0
  233. data/spec/insightly2/resources/task_category_spec.rb +21 -0
  234. data/spec/insightly2/resources/task_spec.rb +32 -0
  235. data/spec/insightly2/resources/team_member_spec.rb +21 -0
  236. data/spec/insightly2/resources/team_spec.rb +27 -0
  237. data/spec/insightly2/resources/user_spec.rb +29 -0
  238. data/spec/insightly2_spec.rb +15 -0
  239. data/spec/spec_helper.rb +20 -0
  240. metadata +551 -0
@@ -0,0 +1,86 @@
1
+ require 'spec_helper'
2
+
3
+ describe Insightly2::DSL::Notes do
4
+ let(:note_id) { 15377334 }
5
+
6
+ # GET /v2.1/Notes/{id}
7
+ describe '#get_note' do
8
+ it 'returns a note' do
9
+ VCR.use_cassette('get_note') do
10
+ expect(Insightly2.client.get_note(id: note_id)).to be_a(Note)
11
+ end
12
+ end
13
+ end
14
+
15
+ # GET /v2.1/Notes
16
+ describe '#get_notes' do
17
+ it 'returns an array of notes' do
18
+ VCR.use_cassette('get_notes') do
19
+ notes = Insightly2.client.get_notes
20
+ expect(notes).to be_a(Array)
21
+ expect(notes.first).to be_a(Note)
22
+ end
23
+ end
24
+ end
25
+
26
+ # GET /v2.1/Notes/{c_id}/Comments
27
+ describe '#get_note_comments' do
28
+ it 'returns a notes comments' do
29
+ VCR.use_cassette('get_note_comments') do
30
+ notes = Insightly2.client.get_note_comments(id: note_id)
31
+ expect(notes).to be_a(Array)
32
+ expect(notes.first).to be_a(Comment)
33
+ end
34
+ end
35
+ end
36
+
37
+ # POST /v2.1/Notes
38
+ describe '#create_note' do
39
+ it 'creates and returns a note' do
40
+ VCR.use_cassette('create_note') do
41
+ note = Insightly2.client.get_note(id: note_id)
42
+ expect(Insightly2.client.create_note(note: note)).to be_a(Note)
43
+ end
44
+ end
45
+ end
46
+
47
+ # POST /v2.1/Notes/{c_id}/Comments
48
+ describe '#create_note_comment' do
49
+ it 'creates a comment for a note' do
50
+ VCR.use_cassette('create_note_comment') do
51
+ response = Insightly2.client.create_note_comment(id: note_id, comment: {title: 'Look out!'})
52
+ expect(response.status).to eq(201)
53
+ end
54
+ end
55
+ end
56
+
57
+ # POST /v2.1/Notes?c_id={c_id}&filename={filename}
58
+ describe '#create_note_file' do
59
+ it 'creates an attachment for a note' do
60
+ VCR.use_cassette('create_note_file') do
61
+ response = Insightly2.client.create_note_file(id: note_id, filename: '1.jpg')
62
+ expect(response.status).to eq(201)
63
+ end
64
+ end
65
+ end
66
+
67
+ # PUT /v2.1/Notes
68
+ describe '#update_note' do
69
+ it 'updates and returns a note' do
70
+ VCR.use_cassette('update_note') do
71
+ note = Insightly2.client.get_note(id: note_id)
72
+ expect(Insightly2.client.update_note(note: note)).to be_a(Note)
73
+ end
74
+ end
75
+ end
76
+
77
+ # DELETE /v2.1/Notes/{id}
78
+ describe '#delete_note' do
79
+ it 'returns a response with code 202' do
80
+ VCR.use_cassette('delete_note') do
81
+ response = Insightly2.client.delete_note(id: note_id)
82
+ expect(response.status).to eq(202)
83
+ end
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,143 @@
1
+ require 'spec_helper'
2
+
3
+ describe Insightly2::DSL::Opportunities do
4
+ let(:opportunity_id) { 4070112 }
5
+
6
+ # GET /v2.1/Opportunities/{id}
7
+ describe '#get_opportunity' do
8
+ it 'returns an opportunity' do
9
+ VCR.use_cassette('get_opportunity') do
10
+ expect(Insightly2.client.get_opportunity(id: opportunity_id)).to be_a(Opportunity)
11
+ end
12
+ end
13
+ end
14
+
15
+ # GET /v2.1/Opportunities/{c_id}/Emails
16
+ describe '#get_opportunity_emails' do
17
+ it 'returns an opportunity emails' do
18
+ VCR.use_cassette('get_opportunity_emails') do
19
+ emails = Insightly2.client.get_opportunity_emails(id: opportunity_id)
20
+ expect(emails).to be_a(Array)
21
+ expect(emails.first).to be_a(Email)
22
+ end
23
+ end
24
+ end
25
+
26
+ # GET /v2.1/Opportunities/{c_id}/Image
27
+ # describe '#get_opportunity_image' do
28
+ # it 'returns an opportunity image' do
29
+ # VCR.use_cassette('get_opportunity_image') do
30
+ # response = Insightly2.client.get_opportunity_image(id: opportunity_id)
31
+ # #expect(response.status).to eq(200)
32
+ # # TODO - Insightly2 server error with default opportunity image they should fix this.
33
+ # end
34
+ # end
35
+ # end
36
+
37
+ # GET /v2.1/Opportunities/{c_id}/Notes
38
+ describe '#get_opportunity_notes' do
39
+ it 'returns an opportunity notes' do
40
+ VCR.use_cassette('get_opportunity_notes') do
41
+ notes = Insightly2.client.get_opportunity_notes(id: opportunity_id)
42
+ expect(notes).to be_a(Array)
43
+ expect(notes.first).to be_a(Note)
44
+ end
45
+ end
46
+ end
47
+
48
+ # GET /v2.1/Opportunities/{c_id}/StateHistory
49
+ # describe '#get_opportunity_state_history' do
50
+ # it 'returns an opportunity state history' do
51
+ # VCR.use_cassette('get_opportunity_state_history') do
52
+ # state_history = Insightly2.client.get_opportunity_state_history(id: opportunity_id)
53
+ # #expect(state_history).to be_a(Array)
54
+ # #expect(state_history.first).to be_a(OpportunityStateReason)
55
+ # # TODO - Insightly2 server error with state history?
56
+ # end
57
+ # end
58
+ # end
59
+
60
+ # GET /v2.1/Opportunities/{c_id}/Tasks
61
+ describe '#get_opportunity_tasks' do
62
+ it 'returns an opportunity tasks' do
63
+ VCR.use_cassette('get_opportunity_tasks') do
64
+ tasks = Insightly2.client.get_opportunity_tasks(id: opportunity_id)
65
+ expect(tasks).to be_a(Array)
66
+ expect(tasks.first).to be_a(Task)
67
+ end
68
+ end
69
+ end
70
+
71
+ # GET /v2.1/Opportunities?ids={ids}&tag={tag}
72
+ describe '#get_opportunities' do
73
+ it 'returns an array of opportunities' do
74
+ VCR.use_cassette('get_opportunities') do
75
+ opportunities = Insightly2.client.get_opportunities
76
+ expect(opportunities).to be_a(Array)
77
+ expect(opportunities.first).to be_a(Opportunity)
78
+ end
79
+ end
80
+ end
81
+
82
+ # POST /v2.1/Opportunities
83
+ describe '#create_opportunity' do
84
+ it 'creates and returns an opportunity' do
85
+ VCR.use_cassette('create_opportunity') do
86
+ opportunity = Insightly2.client.get_opportunity(id: opportunity_id)
87
+ expect(Insightly2.client.create_opportunity(opportunity: opportunity)).to be_a(Opportunity)
88
+ end
89
+ end
90
+ end
91
+
92
+ # POST /v2.1/Opportunities/{c_id}/Image/{filename}
93
+ # describe '#create_opportunity_image' do
94
+ # it 'returns a response with code 201' do
95
+ # VCR.use_cassette('create_opportunity_image') do
96
+ # response = Insightly2.client.create_opportunity_image(id: opportunity_id, filename: '1.jpg')
97
+ # #expect(response.status).to eq(201)
98
+ # # TODO - Can't add image. Not sure why.
99
+ # end
100
+ # end
101
+ # end
102
+
103
+ # PUT /v2.1/Opportunities
104
+ describe '#update_opportunities' do
105
+ it 'updates and returns an opportunity' do
106
+ VCR.use_cassette('update_opportunity') do
107
+ opportunity = Insightly2.client.get_opportunity(id: opportunity_id)
108
+ expect(Insightly2.client.update_opportunity(opportunity: opportunity)).to be_a(Opportunity)
109
+ end
110
+ end
111
+ end
112
+
113
+ # PUT /v2.1/Opportunities/{c_id}/Image/{filename}
114
+ # describe '#update_opportunity_image' do
115
+ # it 'returns a response with code 201' do
116
+ # VCR.use_cassette('update_opportunity_image') do
117
+ # response = Insightly2.client.update_opportunity_image(id: opportunity_id, filename: '1.jpg')
118
+ # # TODO - Can't add image. Not sure why.
119
+ # # expect(response.status).to eq(201)
120
+ # end
121
+ # end
122
+ # end
123
+
124
+ # DELETE /v2.1/Opportunities/{id}
125
+ describe '#delete_opportunity' do
126
+ it 'returns a response with code 202' do
127
+ VCR.use_cassette('delete_opportunity') do
128
+ response = Insightly2.client.delete_opportunity(id: opportunity_id)
129
+ expect(response.status).to eq(202)
130
+ end
131
+ end
132
+ end
133
+
134
+ # DELETE /v2.1/Opportunities/{c_id}/Image
135
+ describe '#delete_opportunity_image' do
136
+ it 'returns a response with code 202' do
137
+ VCR.use_cassette('delete_opportunity_image') do
138
+ response = Insightly2.client.delete_opportunity_image(id: opportunity_id)
139
+ expect(response.status).to eq(202)
140
+ end
141
+ end
142
+ end
143
+ end
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+
3
+ describe Insightly2::DSL::OpportunityCategories do
4
+ let(:opportunity_category_id) { 2175382 }
5
+
6
+ # GET /v2.1/OpportunityCategories/{id}
7
+ describe '#get_opportunity_category' do
8
+ it 'returns an opportunity category' do
9
+ VCR.use_cassette('get_opportunity_category') do
10
+ expect(Insightly2.client.get_opportunity_category(id: opportunity_category_id)).to be_a(OpportunityCategory)
11
+ end
12
+ end
13
+ end
14
+
15
+ # GET /v2.1/OpportunityCategories
16
+ describe '#get_opportunity_categories' do
17
+ it 'returns an array of opportunity_categories' do
18
+ VCR.use_cassette('get_opportunity_categories') do
19
+ opportunity_categories = Insightly2.client.get_opportunity_categories
20
+ expect(opportunity_categories).to be_a(Array)
21
+ expect(opportunity_categories.first).to be_a(OpportunityCategory)
22
+ end
23
+ end
24
+ end
25
+
26
+ # POST /v2.1/OpportunityCategories
27
+ describe '#create_opportunity_category' do
28
+ it 'creates and returns an opportunity category' do
29
+ VCR.use_cassette('create_opportunity_category') do
30
+ opportunity_category = Insightly2.client.get_opportunity_category(id: opportunity_category_id)
31
+ expect(Insightly2.client.create_opportunity_category(category: opportunity_category)).to be_a(OpportunityCategory)
32
+ end
33
+ end
34
+ end
35
+
36
+ # PUT /v2.1/OpportunityCategories
37
+ describe '#update_opportunity_category' do
38
+ it 'updates and returns an opportunity category' do
39
+ VCR.use_cassette('update_opportunity_category') do
40
+ opportunity_category = Insightly2.client.get_opportunity_category(id: opportunity_category_id)
41
+ expect(Insightly2.client.update_opportunity_category(category: opportunity_category)).to be_a(OpportunityCategory)
42
+ end
43
+ end
44
+ end
45
+
46
+ # DELETE /v2.1/OpportunityCategories/{id}
47
+ describe '#delete_opportunity_category' do
48
+ it 'returns a response with code 202' do
49
+ VCR.use_cassette('delete_opportunity_category') do
50
+ response = Insightly2.client.delete_opportunity_category(id: opportunity_category_id)
51
+ expect(response.status).to eq(202)
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe Insightly2::DSL::Opportunities do
4
+ # GET /v2.1/OpportunityStateReasons
5
+ describe '#get_opportunity_state_reasons' do
6
+ it 'returns an array of opportunity_state_reasons' do
7
+ VCR.use_cassette('get_opportunity_state_reasons') do
8
+ opportunity_state_reasons = Insightly2.client.get_opportunity_state_reasons
9
+ expect(opportunity_state_reasons).to be_a(Array)
10
+ expect(opportunity_state_reasons.first).to be_a(OpportunityStateReason)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,131 @@
1
+ require 'spec_helper'
2
+
3
+ describe Insightly2::DSL::Organisations do
4
+ let(:organisation_id) { 39831139 }
5
+
6
+ # GET /v2.1/Organisations/{id}
7
+ describe '#get_organisation' do
8
+ it 'returns an organisation' do
9
+ VCR.use_cassette('get_organisation') do
10
+ expect(Insightly2.client.get_organisation(id: organisation_id)).to be_a(Organisation)
11
+ end
12
+ end
13
+ end
14
+
15
+ # GET /v2.1/Organisations/{c_id}/Emails
16
+ describe '#get_organisation_emails' do
17
+ it 'returns organisation emails' do
18
+ VCR.use_cassette('get_organisation_emails') do
19
+ response = Insightly2.client.get_organisation_emails(id: organisation_id)
20
+ expect(response).to be_a(Array)
21
+ expect(response.first).to be_a(Email)
22
+ end
23
+ end
24
+ end
25
+
26
+ # GET /v2.1/Organisations/{c_id}/Image
27
+ # describe '#get_organisation_image' do
28
+ # it 'returns organisation image' do
29
+ # VCR.use_cassette('get_organisation_image') do
30
+ # response = Insightly2.client.get_organisation_image(id: organisation_id)
31
+ # #expect(response.status).to eq(200)
32
+ # # TODO - Insightly2 server error with default organisation image they should fix this.
33
+ # end
34
+ # end
35
+ # end
36
+
37
+ # GET /v2.1/Organisations/{c_id}/Notes
38
+ describe '#get_organisation_notes' do
39
+ it 'returns organisation notes' do
40
+ VCR.use_cassette('get_organisation_notes') do
41
+ response = Insightly2.client.get_organisation_notes(id: organisation_id)
42
+ expect(response).to be_a(Array)
43
+ expect(response.first).to be_a(Note)
44
+ end
45
+ end
46
+ end
47
+
48
+ # GET /v2.1/Organisations/{c_id}/Tasks
49
+ describe '#get_organisation_tasks' do
50
+ it 'returns organisation tasks' do
51
+ VCR.use_cassette('get_organisation_tasks') do
52
+ response = Insightly2.client.get_organisation_tasks(id: organisation_id)
53
+ expect(response).to be_a(Array)
54
+ expect(response.first).to be_a(Task)
55
+ end
56
+ end
57
+ end
58
+
59
+ # GET /v2.1/Organisations?ids={ids}&domain={domain}&tag={tag}
60
+ describe '#get_organisations' do
61
+ it 'returns an array of organisations' do
62
+ VCR.use_cassette('get_organisations') do
63
+ organisations = Insightly2.client.get_organisations
64
+ expect(organisations).to be_a(Array)
65
+ expect(organisations.first).to be_a(Organisation)
66
+ end
67
+ end
68
+ end
69
+
70
+ # POST /v2.1/Organisations
71
+ describe '#create_organisation' do
72
+ it 'creates and returns organisation' do
73
+ VCR.use_cassette('create_organisation') do
74
+ organisation = Insightly2.client.get_organisation(id: organisation_id)
75
+ expect(Insightly2.client.create_organisation(organisation: organisation)).to be_a(Organisation)
76
+ end
77
+ end
78
+ end
79
+
80
+ # POST /v2.1/Organisations/{c_id}/Image/{filename}
81
+ # describe '#create_organisation_image' do
82
+ # it 'returns a response with code 201' do
83
+ # VCR.use_cassette('create_organisation_image') do
84
+ # response = Insightly2.client.create_organisation_image(id: organisation_id, filename: '1.jpg')
85
+ # #expect(response.status).to eq(201)
86
+ # # TODO - Can't add image. Not sure why.
87
+ # end
88
+ # end
89
+ # end
90
+
91
+ # PUT /v2.1/Organisations
92
+ describe '#update_organisation' do
93
+ it 'updates and returns organisation' do
94
+ VCR.use_cassette('update_organisation') do
95
+ organisation = Insightly2.client.get_organisation(id: organisation_id)
96
+ expect(Insightly2.client.update_organisation(organisation: organisation)).to be_a(Organisation)
97
+ end
98
+ end
99
+ end
100
+
101
+ # PUT /v2.1/Organisations/{c_id}/Image/{filename}
102
+ # describe '#update_organisation_image' do
103
+ # it 'returns a response with code 201' do
104
+ # VCR.use_cassette('update_organisation_image') do
105
+ # response = Insightly2.client.update_organisation_image(id: organisation_id, filename: '1.jpg')
106
+ # #expect(response.status).to eq(201)
107
+ # # TODO - Can't update image. Not sure why.
108
+ # end
109
+ # end
110
+ # end
111
+
112
+ # DELETE /v2.1/Organisations/{id}
113
+ describe '#delete_organisation' do
114
+ it 'returns a response with code 202' do
115
+ VCR.use_cassette('delete_organisation') do
116
+ response = Insightly2.client.delete_organisation(id: organisation_id)
117
+ expect(response.status).to eq(202)
118
+ end
119
+ end
120
+ end
121
+
122
+ # DELETE /v2.1/Organisations/{c_id}/Image
123
+ describe '#delete_organisation_image' do
124
+ it 'returns a response with code 202' do
125
+ VCR.use_cassette('delete_organisation_image') do
126
+ response = Insightly2.client.delete_organisation_image(id: organisation_id)
127
+ expect(response.status).to eq(202)
128
+ end
129
+ end
130
+ end
131
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe Insightly2::DSL::PipelineStages do
4
+ let(:pipeline_stage_id) { 377384 }
5
+
6
+ # GET /v2.1/PipelineStages/{id}
7
+ describe '#get_pipeline_stage' do
8
+ it 'returns a pipeline stage' do
9
+ VCR.use_cassette('get_pipeline_stage') do
10
+ expect(Insightly2.client.get_pipeline_stage(id: pipeline_stage_id)).to be_a(PipelineStage)
11
+ end
12
+ end
13
+ end
14
+
15
+ # GET /v2.1/PipelineStages
16
+ describe '#get_pipeline_stages' do
17
+ it 'returns an array of pipeline_stages' do
18
+ VCR.use_cassette('get_pipeline_stages') do
19
+ pipeline_stages = Insightly2.client.get_pipeline_stages
20
+ expect(pipeline_stages).to be_a(Array)
21
+ expect(pipeline_stages.first).to be_a(PipelineStage)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe Insightly2::DSL::Pipelines do
4
+ let(:pipeline_id) { 124170 }
5
+
6
+ # GET /v2.1/Pipelines/{id}
7
+ describe '#get_pipeline' do
8
+ it 'returns a pipeline' do
9
+ VCR.use_cassette('get_pipeline') do
10
+ expect(Insightly2.client.get_pipeline(id: pipeline_id)).to be_a(Pipeline)
11
+ end
12
+ end
13
+ end
14
+
15
+ # GET /v2.1/Pipelines
16
+ describe '#get_pipelines' do
17
+ it 'returns an array of pipelines' do
18
+ VCR.use_cassette('get_pipelines') do
19
+ pipelines = Insightly2.client.get_pipelines
20
+ expect(pipelines).to be_a(Array)
21
+ expect(pipelines.first).to be_a(Pipeline)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+
3
+ describe Insightly2::DSL::ProjectCategories do
4
+ let(:project_category_id) { 1947441 }
5
+
6
+ # GET /v2.1/ProjectCategories/{id}
7
+ describe '#get_project_category' do
8
+ it 'returns an project_category' do
9
+ VCR.use_cassette('get_project_category') do
10
+ expect(Insightly2.client.get_project_category(id: project_category_id)).to be_a(ProjectCategory)
11
+ end
12
+ end
13
+ end
14
+
15
+ # GET /v2.1/ProjectCategories
16
+ describe '#get_project_categories' do
17
+ it 'returns an array of project_categories' do
18
+ VCR.use_cassette('get_project_categories') do
19
+ project_categories = Insightly2.client.get_project_categories
20
+ expect(project_categories).to be_a(Array)
21
+ expect(project_categories.first).to be_a(ProjectCategory)
22
+ end
23
+ end
24
+ end
25
+
26
+ # POST /v2.1/ProjectCategories
27
+ describe '#create_project_category' do
28
+ it 'creates and returns a project_category' do
29
+ VCR.use_cassette('create_project_category') do
30
+ project_category = Insightly2.client.get_project_category(id: project_category_id)
31
+ expect(Insightly2.client.create_project_category(category: project_category)).to be_a(ProjectCategory)
32
+ end
33
+ end
34
+ end
35
+
36
+ # PUT /v2.1/ProjectCategories
37
+ describe '#update_project_category' do
38
+ it 'updates and returns a project_category' do
39
+ VCR.use_cassette('update_project_category') do
40
+ project_category = Insightly2.client.get_project_category(id: project_category_id)
41
+ expect(Insightly2.client.update_project_category(category: project_category)).to be_a(ProjectCategory)
42
+ end
43
+ end
44
+ end
45
+
46
+ # DELETE /v2.1/ProjectCategories/{id}
47
+ describe '#delete_project_category' do
48
+ it 'returns a response with code 202' do
49
+ VCR.use_cassette('delete_project_category') do
50
+ response = Insightly2.client.delete_project_category(id: project_category_id)
51
+ expect(response.status).to eq(202)
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,131 @@
1
+ require 'spec_helper'
2
+
3
+ describe Insightly2::DSL::Projects do
4
+ let(:project_id) { 1657941 }
5
+
6
+ # GET /v2.1/Projects/{id}
7
+ describe '#get_project' do
8
+ it 'returns a project' do
9
+ VCR.use_cassette('get_project') do
10
+ expect(Insightly2.client.get_project(id: project_id)).to be_a(Project)
11
+ end
12
+ end
13
+ end
14
+
15
+ # GET /v2.1/Projects/{c_id}/Emails
16
+ describe '#get_project_emails' do
17
+ it 'returns project emails' do
18
+ VCR.use_cassette('get_project_emails') do
19
+ response = Insightly2.client.get_project_emails(id: project_id)
20
+ expect(response).to be_a(Array)
21
+ expect(response.first).to be_a(Email)
22
+ end
23
+ end
24
+ end
25
+
26
+ # GET /v2.1/Projects/{c_id}/Image
27
+ # describe '#get_project_image' do
28
+ # it 'returns project image' do
29
+ # VCR.use_cassette('get_project_image') do
30
+ # response = Insightly2.client.get_project_image(id: project_id)
31
+ # # expect(response.status).to eq(200)
32
+ # # TODO - Insightly2 server error with default project image they should fix this.
33
+ # end
34
+ # end
35
+ # end
36
+
37
+ # GET /v2.1/Projects/{c_id}/Notes
38
+ describe '#get_project_notes' do
39
+ it 'returns project notes' do
40
+ VCR.use_cassette('get_project_notes') do
41
+ response = Insightly2.client.get_project_notes(id: project_id)
42
+ expect(response).to be_a(Array)
43
+ expect(response.first).to be_a(Note)
44
+ end
45
+ end
46
+ end
47
+
48
+ # GET /v2.1/Projects/{c_id}/Tasks
49
+ describe '#get_project_tasks' do
50
+ it 'returns project tasks' do
51
+ VCR.use_cassette('get_project_tasks') do
52
+ response = Insightly2.client.get_project_tasks(id: project_id)
53
+ expect(response).to be_a(Array)
54
+ expect(response.first).to be_a(Task)
55
+ end
56
+ end
57
+ end
58
+
59
+ # GET /v2.1/Projects?ids={ids}&tag={tag}
60
+ describe '#get_projects' do
61
+ it 'returns an array of projects' do
62
+ VCR.use_cassette('get_projects') do
63
+ projects = Insightly2.client.get_projects
64
+ expect(projects).to be_a(Array)
65
+ expect(projects.first).to be_a(Project)
66
+ end
67
+ end
68
+ end
69
+
70
+ # POST /v2.1/Projects
71
+ describe '#create_project' do
72
+ it 'creates and returns a project' do
73
+ VCR.use_cassette('create_project') do
74
+ project = Insightly2.client.get_project(id: project_id)
75
+ expect(Insightly2.client.create_project(project: project)).to be_a(Project)
76
+ end
77
+ end
78
+ end
79
+
80
+ # POST /v2.1/Projects/{c_id}/Image/{filename}
81
+ # describe '#create_project_image' do
82
+ # it 'returns a response with code 201' do
83
+ # VCR.use_cassette('create_project_image') do
84
+ # response = Insightly2.client.create_project_image(id: project_id, filename: '1.jpg')
85
+ # # expect(response.status).to eq(201)
86
+ # # TODO - Can't add image. Not sure why.
87
+ # end
88
+ # end
89
+ # end
90
+
91
+ # PUT /v2.1/Projects
92
+ describe '#update_project' do
93
+ it 'updates and returns a project' do
94
+ VCR.use_cassette('update_project') do
95
+ project = Insightly2.client.get_project(id: project_id)
96
+ expect(Insightly2.client.update_project(project: project)).to be_a(Project)
97
+ end
98
+ end
99
+ end
100
+
101
+ # PUT /v2.1/Projects/{c_id}/Image/{filename}
102
+ # describe '#update_project_image' do
103
+ # it 'returns a response with code 201' do
104
+ # VCR.use_cassette('update_project_image') do
105
+ # response = Insightly2.client.update_project_image(id: project_id, filename: '1.jpg')
106
+ # # expect(response.status).to eq(201)
107
+ # # TODO - Can't update image. Not sure why.
108
+ # end
109
+ # end
110
+ # end
111
+
112
+ # DELETE /v2.1/Projects/{id}
113
+ describe '#delete_project' do
114
+ it 'returns a response with code 202' do
115
+ VCR.use_cassette('delete_project') do
116
+ response = Insightly2.client.delete_project(id: project_id)
117
+ expect(response.status).to eq(202)
118
+ end
119
+ end
120
+ end
121
+
122
+ # DELETE /v2.1/Projects/{c_id}/Image
123
+ describe '#delete_project_image' do
124
+ it 'returns a response with code 202' do
125
+ VCR.use_cassette('delete_project_image') do
126
+ response = Insightly2.client.delete_project_image(id: project_id)
127
+ expect(response.status).to eq(202)
128
+ end
129
+ end
130
+ end
131
+ end