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.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/README.md +113 -0
- data/Rakefile +6 -0
- data/config/gem_secret.yml.example +1 -0
- data/insightly2.gemspec +29 -0
- data/lib/insightly2/client.rb +54 -0
- data/lib/insightly2/dsl/comments.rb +47 -0
- data/lib/insightly2/dsl/contacts.rb +130 -0
- data/lib/insightly2/dsl/countries.rb +12 -0
- data/lib/insightly2/dsl/currencies.rb +12 -0
- data/lib/insightly2/dsl/custom_fields.rb +22 -0
- data/lib/insightly2/dsl/emails.rb +57 -0
- data/lib/insightly2/dsl/events.rb +52 -0
- data/lib/insightly2/dsl/file_attachments.rb +14 -0
- data/lib/insightly2/dsl/file_categories.rb +52 -0
- data/lib/insightly2/dsl/notes.rb +85 -0
- data/lib/insightly2/dsl/opportunities.rb +134 -0
- data/lib/insightly2/dsl/opportunity_categories.rb +52 -0
- data/lib/insightly2/dsl/opportunity_state_reasons.rb +12 -0
- data/lib/insightly2/dsl/organisations.rb +128 -0
- data/lib/insightly2/dsl/pipeline_stages.rb +22 -0
- data/lib/insightly2/dsl/pipelines.rb +22 -0
- data/lib/insightly2/dsl/project_categories.rb +52 -0
- data/lib/insightly2/dsl/projects.rb +129 -0
- data/lib/insightly2/dsl/relationships.rb +12 -0
- data/lib/insightly2/dsl/tags.rb +15 -0
- data/lib/insightly2/dsl/task_categories.rb +52 -0
- data/lib/insightly2/dsl/tasks.rb +76 -0
- data/lib/insightly2/dsl/team_members.rb +53 -0
- data/lib/insightly2/dsl/teams.rb +53 -0
- data/lib/insightly2/dsl/users.rb +22 -0
- data/lib/insightly2/dsl.rb +65 -0
- data/lib/insightly2/errors/client_error.rb +10 -0
- data/lib/insightly2/errors/resource_not_found_error.rb +8 -0
- data/lib/insightly2/errors.rb +10 -0
- data/lib/insightly2/resources/comment.rb +10 -0
- data/lib/insightly2/resources/contact.rb +8 -0
- data/lib/insightly2/resources/country.rb +8 -0
- data/lib/insightly2/resources/currency.rb +8 -0
- data/lib/insightly2/resources/custom_field.rb +8 -0
- data/lib/insightly2/resources/email.rb +8 -0
- data/lib/insightly2/resources/event.rb +8 -0
- data/lib/insightly2/resources/file_attachment.rb +8 -0
- data/lib/insightly2/resources/file_category.rb +8 -0
- data/lib/insightly2/resources/note.rb +8 -0
- data/lib/insightly2/resources/object/attributes.rb +71 -0
- data/lib/insightly2/resources/object/serializers.rb +102 -0
- data/lib/insightly2/resources/object.rb +29 -0
- data/lib/insightly2/resources/opportunity.rb +8 -0
- data/lib/insightly2/resources/opportunity_category.rb +8 -0
- data/lib/insightly2/resources/opportunity_state_reason.rb +8 -0
- data/lib/insightly2/resources/organisation.rb +8 -0
- data/lib/insightly2/resources/pipeline.rb +8 -0
- data/lib/insightly2/resources/pipeline_stage.rb +8 -0
- data/lib/insightly2/resources/project.rb +8 -0
- data/lib/insightly2/resources/project_category.rb +8 -0
- data/lib/insightly2/resources/relationship.rb +8 -0
- data/lib/insightly2/resources/tag.rb +8 -0
- data/lib/insightly2/resources/task.rb +8 -0
- data/lib/insightly2/resources/task_category.rb +8 -0
- data/lib/insightly2/resources/team.rb +8 -0
- data/lib/insightly2/resources/team_member.rb +8 -0
- data/lib/insightly2/resources/user.rb +8 -0
- data/lib/insightly2/resources.rb +33 -0
- data/lib/insightly2/utils/url_helper.rb +17 -0
- data/lib/insightly2/utils.rb +8 -0
- data/lib/insightly2/version.rb +3 -0
- data/lib/insightly2.rb +22 -0
- data/spec/fixtures/vcr_cassettes/create_comment_attachment.yml +42 -0
- data/spec/fixtures/vcr_cassettes/create_contact.yml +47 -0
- data/spec/fixtures/vcr_cassettes/create_contact_image.yml +42 -0
- data/spec/fixtures/vcr_cassettes/create_email_comment.yml +47 -0
- data/spec/fixtures/vcr_cassettes/create_event.yml +95 -0
- data/spec/fixtures/vcr_cassettes/create_file_category.yml +89 -0
- data/spec/fixtures/vcr_cassettes/create_note.yml +95 -0
- data/spec/fixtures/vcr_cassettes/create_note_comment.yml +47 -0
- data/spec/fixtures/vcr_cassettes/create_note_file.yml +42 -0
- data/spec/fixtures/vcr_cassettes/create_opportunity.yml +98 -0
- data/spec/fixtures/vcr_cassettes/create_opportunity_category.yml +89 -0
- data/spec/fixtures/vcr_cassettes/create_opportunity_image.yml +42 -0
- data/spec/fixtures/vcr_cassettes/create_organisation.yml +116 -0
- data/spec/fixtures/vcr_cassettes/create_organisation_image.yml +42 -0
- data/spec/fixtures/vcr_cassettes/create_project.yml +106 -0
- data/spec/fixtures/vcr_cassettes/create_project_category.yml +89 -0
- data/spec/fixtures/vcr_cassettes/create_project_image.yml +42 -0
- data/spec/fixtures/vcr_cassettes/create_task.yml +98 -0
- data/spec/fixtures/vcr_cassettes/create_task_category.yml +89 -0
- data/spec/fixtures/vcr_cassettes/create_task_comment.yml +47 -0
- data/spec/fixtures/vcr_cassettes/create_team.yml +92 -0
- data/spec/fixtures/vcr_cassettes/create_team_member.yml +89 -0
- data/spec/fixtures/vcr_cassettes/delete_comment.yml +42 -0
- data/spec/fixtures/vcr_cassettes/delete_contact.yml +42 -0
- data/spec/fixtures/vcr_cassettes/delete_contact_image.yml +42 -0
- data/spec/fixtures/vcr_cassettes/delete_email.yml +42 -0
- data/spec/fixtures/vcr_cassettes/delete_event.yml +42 -0
- data/spec/fixtures/vcr_cassettes/delete_file_category.yml +42 -0
- data/spec/fixtures/vcr_cassettes/delete_note.yml +42 -0
- data/spec/fixtures/vcr_cassettes/delete_opportunity.yml +42 -0
- data/spec/fixtures/vcr_cassettes/delete_opportunity_category.yml +42 -0
- data/spec/fixtures/vcr_cassettes/delete_opportunity_image.yml +42 -0
- data/spec/fixtures/vcr_cassettes/delete_organisation.yml +42 -0
- data/spec/fixtures/vcr_cassettes/delete_organisation_image.yml +42 -0
- data/spec/fixtures/vcr_cassettes/delete_project.yml +42 -0
- data/spec/fixtures/vcr_cassettes/delete_project_category.yml +42 -0
- data/spec/fixtures/vcr_cassettes/delete_project_image.yml +42 -0
- data/spec/fixtures/vcr_cassettes/delete_task.yml +42 -0
- data/spec/fixtures/vcr_cassettes/delete_task_category.yml +42 -0
- data/spec/fixtures/vcr_cassettes/delete_team.yml +42 -0
- data/spec/fixtures/vcr_cassettes/delete_team_member.yml +42 -0
- data/spec/fixtures/vcr_cassettes/get_comment.yml +47 -0
- data/spec/fixtures/vcr_cassettes/get_contact.yml +47 -0
- data/spec/fixtures/vcr_cassettes/get_contact_emails.yml +47 -0
- data/spec/fixtures/vcr_cassettes/get_contact_image.yml +44 -0
- data/spec/fixtures/vcr_cassettes/get_contact_notes.yml +48 -0
- data/spec/fixtures/vcr_cassettes/get_contact_tasks.yml +48 -0
- data/spec/fixtures/vcr_cassettes/get_contacts.yml +184 -0
- data/spec/fixtures/vcr_cassettes/get_countries.yml +85 -0
- data/spec/fixtures/vcr_cassettes/get_currencies.yml +124 -0
- data/spec/fixtures/vcr_cassettes/get_custom_field.yml +46 -0
- data/spec/fixtures/vcr_cassettes/get_custom_fields.yml +46 -0
- data/spec/fixtures/vcr_cassettes/get_email.yml +48 -0
- data/spec/fixtures/vcr_cassettes/get_email_comments.yml +49 -0
- data/spec/fixtures/vcr_cassettes/get_emails.yml +47 -0
- data/spec/fixtures/vcr_cassettes/get_event.yml +48 -0
- data/spec/fixtures/vcr_cassettes/get_events.yml +48 -0
- data/spec/fixtures/vcr_cassettes/get_file_attachment.yml +4057 -0
- data/spec/fixtures/vcr_cassettes/get_file_categories.yml +46 -0
- data/spec/fixtures/vcr_cassettes/get_file_category.yml +46 -0
- data/spec/fixtures/vcr_cassettes/get_note.yml +48 -0
- data/spec/fixtures/vcr_cassettes/get_note_comments.yml +48 -0
- data/spec/fixtures/vcr_cassettes/get_notes.yml +52 -0
- data/spec/fixtures/vcr_cassettes/get_opportunities.yml +81 -0
- data/spec/fixtures/vcr_cassettes/get_opportunity.yml +49 -0
- data/spec/fixtures/vcr_cassettes/get_opportunity_categories.yml +46 -0
- data/spec/fixtures/vcr_cassettes/get_opportunity_category.yml +46 -0
- data/spec/fixtures/vcr_cassettes/get_opportunity_emails.yml +48 -0
- data/spec/fixtures/vcr_cassettes/get_opportunity_image.yml +44 -0
- data/spec/fixtures/vcr_cassettes/get_opportunity_notes.yml +48 -0
- data/spec/fixtures/vcr_cassettes/get_opportunity_state_history.yml +83 -0
- data/spec/fixtures/vcr_cassettes/get_opportunity_state_reasons.yml +47 -0
- data/spec/fixtures/vcr_cassettes/get_opportunity_tasks.yml +49 -0
- data/spec/fixtures/vcr_cassettes/get_organisation.yml +55 -0
- data/spec/fixtures/vcr_cassettes/get_organisation_emails.yml +48 -0
- data/spec/fixtures/vcr_cassettes/get_organisation_image.yml +42 -0
- data/spec/fixtures/vcr_cassettes/get_organisation_notes.yml +47 -0
- data/spec/fixtures/vcr_cassettes/get_organisation_tasks.yml +48 -0
- data/spec/fixtures/vcr_cassettes/get_organisations.yml +2092 -0
- data/spec/fixtures/vcr_cassettes/get_pipeline.yml +46 -0
- data/spec/fixtures/vcr_cassettes/get_pipeline_stage.yml +46 -0
- data/spec/fixtures/vcr_cassettes/get_pipeline_stages.yml +49 -0
- data/spec/fixtures/vcr_cassettes/get_pipelines.yml +46 -0
- data/spec/fixtures/vcr_cassettes/get_project.yml +52 -0
- data/spec/fixtures/vcr_cassettes/get_project_categories.yml +46 -0
- data/spec/fixtures/vcr_cassettes/get_project_category.yml +46 -0
- data/spec/fixtures/vcr_cassettes/get_project_emails.yml +48 -0
- data/spec/fixtures/vcr_cassettes/get_project_image.yml +44 -0
- data/spec/fixtures/vcr_cassettes/get_project_notes.yml +47 -0
- data/spec/fixtures/vcr_cassettes/get_project_tasks.yml +48 -0
- data/spec/fixtures/vcr_cassettes/get_projects.yml +52 -0
- data/spec/fixtures/vcr_cassettes/get_task.yml +49 -0
- data/spec/fixtures/vcr_cassettes/get_task_categories.yml +47 -0
- data/spec/fixtures/vcr_cassettes/get_task_category.yml +46 -0
- data/spec/fixtures/vcr_cassettes/get_task_comments.yml +47 -0
- data/spec/fixtures/vcr_cassettes/get_tasks.yml +148 -0
- data/spec/fixtures/vcr_cassettes/get_team.yml +47 -0
- data/spec/fixtures/vcr_cassettes/get_team_member.yml +46 -0
- data/spec/fixtures/vcr_cassettes/get_team_members.yml +46 -0
- data/spec/fixtures/vcr_cassettes/get_teams.yml +47 -0
- data/spec/fixtures/vcr_cassettes/get_user.yml +48 -0
- data/spec/fixtures/vcr_cassettes/get_users.yml +48 -0
- data/spec/fixtures/vcr_cassettes/update_comment.yml +97 -0
- data/spec/fixtures/vcr_cassettes/update_contact.yml +94 -0
- data/spec/fixtures/vcr_cassettes/update_contact_image.yml +42 -0
- data/spec/fixtures/vcr_cassettes/update_event.yml +97 -0
- data/spec/fixtures/vcr_cassettes/update_file_category.yml +91 -0
- data/spec/fixtures/vcr_cassettes/update_note.yml +100 -0
- data/spec/fixtures/vcr_cassettes/update_opportunity.yml +100 -0
- data/spec/fixtures/vcr_cassettes/update_opportunity_category.yml +91 -0
- data/spec/fixtures/vcr_cassettes/update_opportunity_image.yml +42 -0
- data/spec/fixtures/vcr_cassettes/update_organisation.yml +118 -0
- data/spec/fixtures/vcr_cassettes/update_organisation_image.yml +42 -0
- data/spec/fixtures/vcr_cassettes/update_project.yml +109 -0
- data/spec/fixtures/vcr_cassettes/update_project_category.yml +91 -0
- data/spec/fixtures/vcr_cassettes/update_project_image.yml +42 -0
- data/spec/fixtures/vcr_cassettes/update_task.yml +100 -0
- data/spec/fixtures/vcr_cassettes/update_task_category.yml +91 -0
- data/spec/fixtures/vcr_cassettes/update_team.yml +94 -0
- data/spec/fixtures/vcr_cassettes/update_team_member.yml +91 -0
- data/spec/fixtures/vcr_cassettes/z_insightly_client_status_check.yml +48 -0
- data/spec/insightly2/client_spec.rb +12 -0
- data/spec/insightly2/dsl/comments_spec.rb +45 -0
- data/spec/insightly2/dsl/contacts_spec.rb +130 -0
- data/spec/insightly2/dsl/countries_spec.rb +14 -0
- data/spec/insightly2/dsl/currencies_spec.rb +14 -0
- data/spec/insightly2/dsl/custom_fields_spec.rb +25 -0
- data/spec/insightly2/dsl/emails_spec.rb +56 -0
- data/spec/insightly2/dsl/events_spec.rb +55 -0
- data/spec/insightly2/dsl/file_attachments_spec.rb +15 -0
- data/spec/insightly2/dsl/file_categories_spec.rb +55 -0
- data/spec/insightly2/dsl/notes_spec.rb +86 -0
- data/spec/insightly2/dsl/opportunities_spec.rb +143 -0
- data/spec/insightly2/dsl/opportunity_categories_spec.rb +55 -0
- data/spec/insightly2/dsl/opportunity_state_reasons_spec.rb +14 -0
- data/spec/insightly2/dsl/organisations_spec.rb +131 -0
- data/spec/insightly2/dsl/pipeline_stages_spec.rb +25 -0
- data/spec/insightly2/dsl/pipelines_spec.rb +25 -0
- data/spec/insightly2/dsl/project_categories_spec.rb +55 -0
- data/spec/insightly2/dsl/projects_spec.rb +131 -0
- data/spec/insightly2/dsl/task_categories_spec.rb +55 -0
- data/spec/insightly2/dsl/tasks_spec.rb +75 -0
- data/spec/insightly2/dsl/team_members_spec.rb +56 -0
- data/spec/insightly2/dsl/teams_spec.rb +55 -0
- data/spec/insightly2/dsl/users_spec.rb +25 -0
- data/spec/insightly2/resources/comment_spec.rb +27 -0
- data/spec/insightly2/resources/contact_spec.rb +28 -0
- data/spec/insightly2/resources/custom_field_spec.rb +22 -0
- data/spec/insightly2/resources/email_spec.rb +29 -0
- data/spec/insightly2/resources/event_spec.rb +29 -0
- data/spec/insightly2/resources/file_attachment_spec.rb +31 -0
- data/spec/insightly2/resources/file_category_spec.rb +21 -0
- data/spec/insightly2/resources/note_spec.rb +29 -0
- data/spec/insightly2/resources/opportunity_category_spec.rb +21 -0
- data/spec/insightly2/resources/opportunity_spec.rb +30 -0
- data/spec/insightly2/resources/organisation_spec.rb +29 -0
- data/spec/insightly2/resources/pipeline_spec.rb +21 -0
- data/spec/insightly2/resources/pipeline_stage_spec.rb +21 -0
- data/spec/insightly2/resources/project_category_spec.rb +21 -0
- data/spec/insightly2/resources/project_spec.rb +30 -0
- data/spec/insightly2/resources/task_category_spec.rb +21 -0
- data/spec/insightly2/resources/task_spec.rb +32 -0
- data/spec/insightly2/resources/team_member_spec.rb +21 -0
- data/spec/insightly2/resources/team_spec.rb +27 -0
- data/spec/insightly2/resources/user_spec.rb +29 -0
- data/spec/insightly2_spec.rb +15 -0
- data/spec/spec_helper.rb +20 -0
- metadata +551 -0
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'insightly2/dsl'
|
2
|
+
|
3
|
+
module Insightly2
|
4
|
+
module DSL::Notes
|
5
|
+
# GET /v2.1/Notes/{id}
|
6
|
+
# Get a note.
|
7
|
+
# @param [String, Fixnum] id A note's ID.
|
8
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
9
|
+
# @return [Insightly2::Resources::Note, nil].
|
10
|
+
def get_note(id:)
|
11
|
+
raise ArgumentError, "ID cannot be blank" if id.blank?
|
12
|
+
Resources::Note.parse(request(:get, "Notes/#{id}"))
|
13
|
+
end
|
14
|
+
|
15
|
+
# GET /v2.1/Notes/{c_id}/Comments
|
16
|
+
# Gets the comments attached to a note.
|
17
|
+
# @param [String, Fixnum] id A note's ID.
|
18
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
19
|
+
# @return [Array, nil].
|
20
|
+
def get_note_comments(id:)
|
21
|
+
raise ArgumentError, "ID cannot be blank" if id.blank?
|
22
|
+
Resources::Comment.parse(request(:get, "Notes/#{id}/Comments"))
|
23
|
+
end
|
24
|
+
|
25
|
+
# GET /v2.1/Notes
|
26
|
+
# Get a list of notes.
|
27
|
+
# @return [Insightly2::Resources::Note, nil].
|
28
|
+
def get_notes
|
29
|
+
Resources::Note.parse(request(:get, "Notes"))
|
30
|
+
end
|
31
|
+
|
32
|
+
# POST /v2.1/Notes
|
33
|
+
# Creates a note.
|
34
|
+
# @param [Hash] note The note to create.
|
35
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
36
|
+
# @return [Insightly2::Resources::Note, nil].
|
37
|
+
def create_note(note:)
|
38
|
+
raise ArgumentError, "Note cannot be blank" if note.blank?
|
39
|
+
Resources::Note.parse(request(:post, "Notes", note))
|
40
|
+
end
|
41
|
+
|
42
|
+
# POST /v2.1/Notes/{c_id}/Comments
|
43
|
+
# Create a comment for a note.
|
44
|
+
# @param [String, Fixnum] id A Note's ID.
|
45
|
+
# @param [String] comment The comment to add to the note.
|
46
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
47
|
+
# @return [Faraday::Response].
|
48
|
+
def create_note_comment(id:, comment:)
|
49
|
+
raise ArgumentError, "ID cannot be blank" if id.blank?
|
50
|
+
raise ArgumentError, "Comment cannot be blank" if comment.blank?
|
51
|
+
request(:post, "Notes/#{id}/Comments", comment)
|
52
|
+
end
|
53
|
+
|
54
|
+
# POST /v2.1/Notes?c_id={c_id}&filename={filename}
|
55
|
+
# Adds a File Attachment to a Note.
|
56
|
+
# @param [String, Fixnum] id A Note's ID.
|
57
|
+
# @param [String] filename The name of the file.
|
58
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
59
|
+
# @return [Faraday::Response].
|
60
|
+
def create_note_file(id:, filename:)
|
61
|
+
raise ArgumentError, "ID cannot be blank" if id.blank?
|
62
|
+
raise ArgumentError, "Filename cannot be blank" if filename.blank?
|
63
|
+
request(:post, "Notes?c_id=#{id}&filename=#{filename}")
|
64
|
+
end
|
65
|
+
|
66
|
+
# PUT /v2.1/Notes
|
67
|
+
# Updates a note.
|
68
|
+
# @param [Hash] note The note to update.
|
69
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
70
|
+
# @return [Insightly2::Resources::Note, nil].
|
71
|
+
def update_note(note:)
|
72
|
+
raise ArgumentError, "Note cannot be blank" if note.blank?
|
73
|
+
Resources::Note.parse(request(:put, "Notes", note))
|
74
|
+
end
|
75
|
+
|
76
|
+
# DELETE /v2.1/Notes/{id}
|
77
|
+
# @param [String, Fixnum] id A note's ID.
|
78
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
79
|
+
# @return [Faraday::Response].
|
80
|
+
def delete_note(id:)
|
81
|
+
raise ArgumentError, "ID cannot be blank" if id.blank?
|
82
|
+
request(:delete, "Notes/#{id}")
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
require 'insightly2/dsl'
|
2
|
+
|
3
|
+
module Insightly2
|
4
|
+
module DSL::Opportunities
|
5
|
+
# GET /v2.1/Opportunities/{id}
|
6
|
+
# Get an opportunity.
|
7
|
+
# @param [String, Fixnum] id An opportunity's ID.
|
8
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
9
|
+
# @return [Insightly2::Resources::Opportunity, nil].
|
10
|
+
def get_opportunity(id:)
|
11
|
+
raise ArgumentError, "ID cannot be blank" if id.blank?
|
12
|
+
Resources::Opportunity.parse(request(:get, "Opportunities/#{id}"))
|
13
|
+
end
|
14
|
+
|
15
|
+
# GET /v2.1/Opportunities/{c_id}/Emails
|
16
|
+
# Get an opportunity's emails.
|
17
|
+
# @param [String, Fixnum] id An opportunity's ID.
|
18
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
19
|
+
# @return [Array, nil].
|
20
|
+
def get_opportunity_emails(id:)
|
21
|
+
raise ArgumentError, "ID cannot be blank" if id.blank?
|
22
|
+
Resources::Email.parse(request(:get, "Opportunities/#{id}/Emails"))
|
23
|
+
end
|
24
|
+
|
25
|
+
# GET /v2.1/Opportunities/{c_id}/Image
|
26
|
+
# @param [String, Fixnum] id An opportunity's ID
|
27
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
28
|
+
# @return [Faraday::Response]
|
29
|
+
def get_opportunity_image(id:)
|
30
|
+
request(:get, "Opportunities/#{id}/Image")
|
31
|
+
end
|
32
|
+
|
33
|
+
# GET /v2.1/Opportunities/{c_id}/Notes
|
34
|
+
# Get an opportunity's notes.
|
35
|
+
# @param [String, Fixnum] id An opportunity's ID.
|
36
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
37
|
+
# @return [Array, nil].
|
38
|
+
def get_opportunity_notes(id:)
|
39
|
+
raise ArgumentError, "ID cannot be blank" if id.blank?
|
40
|
+
Resources::Note.parse(request(:get, "Opportunities/#{id}/Notes"))
|
41
|
+
end
|
42
|
+
|
43
|
+
# GET /v2.1/Opportunities/{c_id}/StateHistory
|
44
|
+
# Get an opportunity's state history.
|
45
|
+
# @param [String, Fixnum] id An opportunity's ID.
|
46
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
47
|
+
# @return [Array, nil].
|
48
|
+
def get_opportunity_state_history(id:)
|
49
|
+
raise ArgumentError, "ID cannot be blank" if id.blank?
|
50
|
+
Resources::OpportunityStateReason.parse(request(:get, "Opportunities/#{id}/StateHistory"))
|
51
|
+
end
|
52
|
+
|
53
|
+
# GET /v2.1/Opportunities/{c_id}/Tasks
|
54
|
+
# Get an opportunity's tasks.
|
55
|
+
# @param [String, Fixnum] id An opportunity's ID.
|
56
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
57
|
+
# @return [Array, nil].
|
58
|
+
def get_opportunity_tasks(id:)
|
59
|
+
raise ArgumentError, "ID cannot be blank" if id.blank?
|
60
|
+
Resources::Task.parse(request(:get, "Opportunities/#{id}/Tasks"))
|
61
|
+
end
|
62
|
+
|
63
|
+
# GET /v2.1/Opportunities?ids={ids}&tag={tag}
|
64
|
+
# Get a list of opportunities.
|
65
|
+
# @param [Array] ids IDs of opportunities (optional).
|
66
|
+
# @param [String] tag The tag that has been applied to an opportunity (optional).
|
67
|
+
# @return [Array, nil].
|
68
|
+
def get_opportunities(ids: [], tag: '')
|
69
|
+
url = Utils::UrlHelper.build_url(path: "Opportunities", params: {ids: ids.join(','), tag: tag})
|
70
|
+
Resources::Opportunity.parse(request(:get, url))
|
71
|
+
end
|
72
|
+
|
73
|
+
# POST /v2.1/Opportunities
|
74
|
+
# Create an opportunity.
|
75
|
+
# @param [Hash] opportunity The opportunity to create.
|
76
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
77
|
+
# @return [Insightly2::Resources::Opportunity, nil].
|
78
|
+
def create_opportunity(opportunity:)
|
79
|
+
raise ArgumentError, "Opportunity cannot be blank" if opportunity.blank?
|
80
|
+
Resources::Opportunity.parse(request(:post, "Opportunities", opportunity))
|
81
|
+
end
|
82
|
+
|
83
|
+
# POST /v2.1/Opportunities/{c_id}/Image/{filename}
|
84
|
+
# Add an attachment to an opportunity.
|
85
|
+
# @param [String, Fixnum] id An opportunity's ID.
|
86
|
+
# @param [String] filename A name of a file.
|
87
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
88
|
+
# @return [Faraday::Response]
|
89
|
+
def create_opportunity_image(id:, filename:)
|
90
|
+
raise ArgumentError, "ID cannot be blank" if id.blank?
|
91
|
+
raise ArgumentError, "Filename cannot be blank" if filename.blank?
|
92
|
+
request(:post, "Opportunities/#{id}/Image/#{filename}")
|
93
|
+
end
|
94
|
+
|
95
|
+
# PUT /v2.1/Opportunities
|
96
|
+
# Update an opportunity.
|
97
|
+
# @param [Hash] opportunity The opportunity to update.
|
98
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
99
|
+
# @return [Insightly2::Resources::Opportunity, nil]
|
100
|
+
def update_opportunity(opportunity:)
|
101
|
+
raise ArgumentError, "Opportunity cannot be blank" if opportunity.blank?
|
102
|
+
Resources::Opportunity.parse(request(:put, "Opportunities", opportunity))
|
103
|
+
end
|
104
|
+
|
105
|
+
# PUT /v2.1/Opportunities/{c_id}/Image/{filename}
|
106
|
+
# @param [String, Fixnum] id An opportunity's ID.
|
107
|
+
# @param [String] filename A name of a file.
|
108
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
109
|
+
# @return [Faraday::Response].
|
110
|
+
def update_opportunity_image(id:, filename:)
|
111
|
+
raise ArgumentError, "ID cannot be blank" if id.blank?
|
112
|
+
raise ArgumentError, "Filename cannot be blank" if filename.blank?
|
113
|
+
request(:put, "Opportunities/#{id}/Image/#{filename}")
|
114
|
+
end
|
115
|
+
|
116
|
+
# DELETE /v2.1/Opportunities/{id}
|
117
|
+
# @param [String, Fixnum] id An opportunity's ID.
|
118
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
119
|
+
# @return [Faraday::Response].
|
120
|
+
def delete_opportunity(id:)
|
121
|
+
raise ArgumentError, "ID cannot be blank" if id.blank?
|
122
|
+
request(:delete, "Opportunities/#{id}")
|
123
|
+
end
|
124
|
+
|
125
|
+
# DELETE /v2.1/Opportunities/{c_id}/Image
|
126
|
+
# @param [String, Fixnum] id An opportunity's ID.
|
127
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
128
|
+
# @return [Faraday::Response].
|
129
|
+
def delete_opportunity_image(id:)
|
130
|
+
raise ArgumentError, "ID cannot be blank" if id.blank?
|
131
|
+
request(:delete, "Opportunities/#{id}/Image")
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'insightly2/dsl'
|
2
|
+
|
3
|
+
module Insightly2
|
4
|
+
module DSL::OpportunityCategories
|
5
|
+
# GET /v2.1/OpportunityCategories/{id}
|
6
|
+
# Get an opportunity category.
|
7
|
+
# @param [String, Fixnum] id An opportunity category's ID.
|
8
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
9
|
+
# @return [Insightly2::Resources::OpportunityCategory, nil].
|
10
|
+
def get_opportunity_category(id:)
|
11
|
+
raise ArgumentError, "ID cannot be blank" if id.blank?
|
12
|
+
Resources::OpportunityCategory.parse(request(:get, "OpportunityCategories/#{id}"))
|
13
|
+
end
|
14
|
+
|
15
|
+
# GET /v2.1/OpportunityCategories
|
16
|
+
# Get a list of opportunity categories.
|
17
|
+
# @return [Array, nil].
|
18
|
+
def get_opportunity_categories
|
19
|
+
Resources::OpportunityCategory.parse(request(:get, "OpportunityCategories"))
|
20
|
+
end
|
21
|
+
|
22
|
+
# POST /v2.1/OpportunityCategories
|
23
|
+
# Create an opportunity category.
|
24
|
+
# @param [Hash] category The opportunity category to create.
|
25
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
26
|
+
# @return [Insightly2::Resources::OpportunityCategory, nil].
|
27
|
+
def create_opportunity_category(category:)
|
28
|
+
raise ArgumentError, "Category cannot be blank" if category.blank?
|
29
|
+
Resources::OpportunityCategory.parse(request(:post, "OpportunityCategories", category))
|
30
|
+
end
|
31
|
+
|
32
|
+
# PUT /v2.1/OpportunityCategories
|
33
|
+
# Update an opportunity category.
|
34
|
+
# @param [Hash] category The opportunity category to update.
|
35
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
36
|
+
# @return [Insightly2::Resources::OpportunityCategory, nil].
|
37
|
+
def update_opportunity_category(category:)
|
38
|
+
raise ArgumentError, "Category cannot be blank" if category.blank?
|
39
|
+
Resources::OpportunityCategory.parse(request(:put, "OpportunityCategories", category))
|
40
|
+
end
|
41
|
+
|
42
|
+
# DELETE /v2.1/OpportunityCategories/{id}
|
43
|
+
# Delete an opportunity category.
|
44
|
+
# @param [String, Fixnum] id A OpportunityCategory's ID.
|
45
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
46
|
+
# @return [Faraday::Response].
|
47
|
+
def delete_opportunity_category(id:)
|
48
|
+
raise ArgumentError, "ID cannot be blank" if id.blank?
|
49
|
+
request(:delete, "OpportunityCategories/#{id}")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'insightly2/dsl'
|
2
|
+
|
3
|
+
module Insightly2
|
4
|
+
module DSL::OpportunityStateReasons
|
5
|
+
# GET /v2.1/OpportunityStateReasons
|
6
|
+
# Get a list of opportunity state reasons.
|
7
|
+
# @return [Array, nil]
|
8
|
+
def get_opportunity_state_reasons
|
9
|
+
Resources::OpportunityStateReason.parse(request(:get, 'OpportunityStateReasons'))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
require 'insightly2/dsl'
|
2
|
+
|
3
|
+
module Insightly2
|
4
|
+
module DSL::Organisations
|
5
|
+
# GET /v2.1/Organisations/{id}
|
6
|
+
# Get an organisation.
|
7
|
+
# @param [String, Fixnum] id An organisation's ID.
|
8
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
9
|
+
# @return [Insightly2::Resources::Organisation, nil].
|
10
|
+
def get_organisation(id:)
|
11
|
+
raise ArgumentError, "ID cannot be blank" if id.blank?
|
12
|
+
Resources::Organisation.parse(request(:get, "Organisations/#{id}"))
|
13
|
+
end
|
14
|
+
|
15
|
+
# GET /v2.1/Organisations/{c_id}/Emails
|
16
|
+
# Get an organisation's emails.
|
17
|
+
# @param [String, Fixnum] id An organisation's ID.
|
18
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
19
|
+
# @return [Array, nil].
|
20
|
+
def get_organisation_emails(id:)
|
21
|
+
raise ArgumentError, "ID cannot be blank" if id.blank?
|
22
|
+
Resources::Email.parse(request(:get, "Organisations/#{id}/Emails"))
|
23
|
+
end
|
24
|
+
|
25
|
+
# GET /v2.1/Organisations/{c_id}/Image
|
26
|
+
# Get an organisations image.
|
27
|
+
# @param [String, Fixnum] id An organisation's ID
|
28
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
29
|
+
# @return [Faraday::Response].
|
30
|
+
def get_organisation_image(id:)
|
31
|
+
request(:get, "Organisations/#{id}/Image")
|
32
|
+
end
|
33
|
+
|
34
|
+
# GET /v2.1/Organisations/{c_id}/Notes
|
35
|
+
# Get an organisations notes.
|
36
|
+
# @param [String, Fixnum] id An organisation's ID.
|
37
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
38
|
+
# @return [Array, nil].
|
39
|
+
def get_organisation_notes(id:)
|
40
|
+
raise ArgumentError, "ID cannot be blank" if id.blank?
|
41
|
+
Resources::Note.parse(request(:get, "Organisations/#{id}/Notes"))
|
42
|
+
end
|
43
|
+
|
44
|
+
# GET /v2.1/Organisations/{c_id}/Tasks
|
45
|
+
# Get an organisations tasks.
|
46
|
+
# @param [String, Fixnum] id An organisation's ID.
|
47
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
48
|
+
# @return [Array, nil].
|
49
|
+
def get_organisation_tasks(id:)
|
50
|
+
raise ArgumentError, "ID cannot be blank" if id.blank?
|
51
|
+
Resources::Task.parse(request(:get, "Organisations/#{id}/Tasks"))
|
52
|
+
end
|
53
|
+
|
54
|
+
# GET /v2.1/Organisations?ids={ids}&domain={domain}&tag={tag}
|
55
|
+
# @param [Array] ids The organisation's IDs (optional).
|
56
|
+
# @param [String] domain The email domain (optional).
|
57
|
+
# @param [String] tag The tag an organisation has been tagged with (optional).
|
58
|
+
# @return [Array, nil].
|
59
|
+
def get_organisations(ids: [], domain: '', tag: '')
|
60
|
+
url = Utils::UrlHelper.build_url(path: "Organisations", params: {ids: ids.join(','), domain: domain, tag: tag})
|
61
|
+
Resources::Organisation.parse(request(:get, url))
|
62
|
+
end
|
63
|
+
|
64
|
+
# POST /v2.1/Organisations
|
65
|
+
# Create an organisation.
|
66
|
+
# @param [Hash] organisation The organisation to create.
|
67
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
68
|
+
# @return [Insightly2::Resources::Organisation].
|
69
|
+
def create_organisation(organisation:)
|
70
|
+
raise ArgumentError, "Organisation cannot be blank" if organisation.blank?
|
71
|
+
Resources::Organisation.parse(request(:post, "Organisations", organisation))
|
72
|
+
end
|
73
|
+
|
74
|
+
# POST /v2.1/Organisations/{c_id}/Image/{filename}
|
75
|
+
# Create an organisation image.
|
76
|
+
# @param [String, Fixnum] id The organisation's ID.
|
77
|
+
# @param [String] filename The name of the file.
|
78
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
79
|
+
# @return [Faraday::Response].
|
80
|
+
def create_organisation_image(id:, filename:)
|
81
|
+
raise ArgumentError, "ID cannot be blank" if id.blank?
|
82
|
+
raise ArgumentError, "Filename cannot be blank" if filename.blank?
|
83
|
+
request(:post, "Organisations/#{id}/Image/#{filename}")
|
84
|
+
end
|
85
|
+
|
86
|
+
# PUT /v2.1/Organisations
|
87
|
+
# Update an organisation.
|
88
|
+
# @param [Hash] organisation The organisation to update.
|
89
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
90
|
+
# @return [Insightly2::Resources::Organisation, nil].
|
91
|
+
def update_organisation(organisation:)
|
92
|
+
raise ArgumentError, "Organisation cannot be blank" if organisation.blank?
|
93
|
+
Resources::Organisation.parse(request(:put, "Organisations", organisation))
|
94
|
+
end
|
95
|
+
|
96
|
+
# PUT /v2.1/Organisations/{c_id}/Image/{filename}
|
97
|
+
# Update an organisation's image.
|
98
|
+
# @param [String, Fixnum] id An organisation's ID.
|
99
|
+
# @param [String] filename name of the file.
|
100
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
101
|
+
# @return [Faraday::Response].
|
102
|
+
def update_organisation_image(id:, filename:)
|
103
|
+
raise ArgumentError, "ID cannot be blank" if id.blank?
|
104
|
+
raise ArgumentError, "Filename cannot be blank" if filename.blank?
|
105
|
+
request(:put, "Organisations/#{id}/Image/#{filename}")
|
106
|
+
end
|
107
|
+
|
108
|
+
# DELETE /v2.1/Organisations/{id}
|
109
|
+
# Delete an organisation.
|
110
|
+
# @param [String, Fixnum] id An organisation's ID.
|
111
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
112
|
+
# @return [Faraday::Response].
|
113
|
+
def delete_organisation(id:)
|
114
|
+
raise ArgumentError, "ID cannot be blank" if id.blank?
|
115
|
+
request(:delete, "Organisations/#{id}")
|
116
|
+
end
|
117
|
+
|
118
|
+
# DELETE /v2.1/Organisations/{c_id}/Image
|
119
|
+
# Delete an organisation image.
|
120
|
+
# @param [String, Fixnum] id An organisation's ID.
|
121
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
122
|
+
# @return [Faraday::Response].
|
123
|
+
def delete_organisation_image(id:)
|
124
|
+
raise ArgumentError, "ID cannot be blank" if id.blank?
|
125
|
+
request(:delete, "Organisations/#{id}/Image")
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'insightly2/dsl'
|
2
|
+
|
3
|
+
module Insightly2
|
4
|
+
module DSL::PipelineStages
|
5
|
+
# GET /v2.1/PipelineStages/{id}
|
6
|
+
# Get a pipeline stage.
|
7
|
+
# @param [String, Fixnum] id A pipeline stage's ID.
|
8
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
9
|
+
# @return [Insightly2::Resources::PipelineStage, nil].
|
10
|
+
def get_pipeline_stage(id:)
|
11
|
+
raise ArgumentError, "ID cannot be blank" if id.blank?
|
12
|
+
Resources::PipelineStage.parse(request(:get, "PipelineStages/#{id}"))
|
13
|
+
end
|
14
|
+
|
15
|
+
# GET /v2.1/PipelineStages
|
16
|
+
# Get a list of pipeline stages.
|
17
|
+
# @return [Array, nil]
|
18
|
+
def get_pipeline_stages
|
19
|
+
Resources::PipelineStage.parse(request(:get, "PipelineStages"))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'insightly2/dsl'
|
2
|
+
|
3
|
+
module Insightly2
|
4
|
+
module DSL::Pipelines
|
5
|
+
# GET /v2.1/Pipelines/{id}
|
6
|
+
# Get a pipeline.
|
7
|
+
# @param [String, Fixnum] id A pipeline's ID.
|
8
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
9
|
+
# @return [Insightly2::Resources::Pipeline, nil].
|
10
|
+
def get_pipeline(id:)
|
11
|
+
raise ArgumentError, "ID cannot be blank" if id.blank?
|
12
|
+
Resources::Pipeline.parse(request(:get, "Pipelines/#{id}"))
|
13
|
+
end
|
14
|
+
|
15
|
+
# GET /v2.1/Pipelines
|
16
|
+
# Get a list of pipelines.
|
17
|
+
# @return [Insightly2::Resources::Pipeline, nil].
|
18
|
+
def get_pipelines
|
19
|
+
Resources::Pipeline.parse(request(:get, "Pipelines"))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'insightly2/dsl'
|
2
|
+
|
3
|
+
module Insightly2
|
4
|
+
module DSL::ProjectCategories
|
5
|
+
# GET /v2.1/ProjectCategories/{id}
|
6
|
+
# Get a project category.
|
7
|
+
# @param [String, Fixnum] id A project category's ID.
|
8
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
9
|
+
# @return [Insightly2::Resources::ProjectCategory, nil].
|
10
|
+
def get_project_category(id:)
|
11
|
+
raise ArgumentError, "ID cannot be blank" if id.blank?
|
12
|
+
Resources::ProjectCategory.parse(request(:get, "ProjectCategories/#{id}"))
|
13
|
+
end
|
14
|
+
|
15
|
+
# GET /v2.1/ProjectCategories
|
16
|
+
# Get a list of project categories.
|
17
|
+
# @return [Array, nil].
|
18
|
+
def get_project_categories
|
19
|
+
Resources::ProjectCategory.parse(request(:get, "ProjectCategories"))
|
20
|
+
end
|
21
|
+
|
22
|
+
# POST /v2.1/ProjectCategories
|
23
|
+
# Create a project category.
|
24
|
+
# @param [Hash] category: The project category to create.
|
25
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
26
|
+
# @return [Insightly2::Resources::ProjectCategory, nil].
|
27
|
+
def create_project_category(category:)
|
28
|
+
raise ArgumentError, "Category cannot be blank" if category.blank?
|
29
|
+
Resources::ProjectCategory.parse(request(:post, "ProjectCategories", category))
|
30
|
+
end
|
31
|
+
|
32
|
+
# PUT /v2.1/ProjectCategories
|
33
|
+
# Update a project category.
|
34
|
+
# @param [Hash] category The project category to update.
|
35
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
36
|
+
# @return [Insightly2::Resources::ProjectCategory, nil]
|
37
|
+
def update_project_category(category:)
|
38
|
+
raise ArgumentError, "Category cannot be blank" if category.blank?
|
39
|
+
Resources::ProjectCategory.parse(request(:put, "ProjectCategories", category))
|
40
|
+
end
|
41
|
+
|
42
|
+
# DELETE /v2.1/ProjectCategories/{id}
|
43
|
+
# Delete a project category.
|
44
|
+
# @param [String, Fixnum] id A project category's ID.
|
45
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
46
|
+
# @return [Faraday::Response].
|
47
|
+
def delete_project_category(id:)
|
48
|
+
raise ArgumentError, "ID cannot be blank" if id.blank?
|
49
|
+
request(:delete, "ProjectCategories/#{id}")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
require 'insightly2/dsl'
|
2
|
+
|
3
|
+
module Insightly2
|
4
|
+
module DSL::Projects
|
5
|
+
# GET /v2.1/Projects/{id}
|
6
|
+
# Get a project.
|
7
|
+
# @param [String, Fixnum] id A project's ID.
|
8
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
9
|
+
# @return [Insightly2::Resources::Project, nil].
|
10
|
+
def get_project(id:)
|
11
|
+
raise ArgumentError, "ID cannot be blank" if id.blank?
|
12
|
+
Resources::Project.parse(request(:get, "Projects/#{id}"))
|
13
|
+
end
|
14
|
+
|
15
|
+
# GET /v2.1/Projects/{c_id}/Emails
|
16
|
+
# Get a list of project emails.
|
17
|
+
# @param [String, Fixnum] id A project's ID.
|
18
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
19
|
+
# @return [Array, nil].
|
20
|
+
def get_project_emails(id:)
|
21
|
+
raise ArgumentError, "ID cannot be blank" if id.blank?
|
22
|
+
Resources::Email.parse(request(:get, "Projects/#{id}/Emails"))
|
23
|
+
end
|
24
|
+
|
25
|
+
# GET /v2.1/Projects/{c_id}/Image
|
26
|
+
# Get a project image.
|
27
|
+
# @param [String, Fixnum] id A project's ID.
|
28
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
29
|
+
# @return [Faraday::Response].
|
30
|
+
def get_project_image(id:)
|
31
|
+
raise ArgumentError, "ID cannot be blank" if id.blank?
|
32
|
+
request(:get, "Projects/#{id}/Image")
|
33
|
+
end
|
34
|
+
|
35
|
+
# GET /v2.1/Projects/{c_id}/Notes
|
36
|
+
# Get a projects notes.
|
37
|
+
# @param [String, Fixnum] id A project's ID.
|
38
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
39
|
+
# @return [Array, nil].
|
40
|
+
def get_project_notes(id:)
|
41
|
+
raise ArgumentError, "ID cannot be blank" if id.blank?
|
42
|
+
Resources::Note.parse(request(:get, "Projects/#{id}/Notes"))
|
43
|
+
end
|
44
|
+
|
45
|
+
# GET /v2.1/Projects/{c_id}/Tasks
|
46
|
+
# Get a project tasks.
|
47
|
+
# @param [String, Fixnum] id A project's ID.
|
48
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
49
|
+
# @return [Array, nil].
|
50
|
+
def get_project_tasks(id:)
|
51
|
+
raise ArgumentError, "ID cannot be blank" if id.blank?
|
52
|
+
Resources::Task.parse(request(:get, "Projects/#{id}/Tasks"))
|
53
|
+
end
|
54
|
+
|
55
|
+
# GET /v2.1/Projects?ids={ids}&tag={tag}
|
56
|
+
# Get a list of projects.
|
57
|
+
# @param [Array] ids The IDs of the projects to retrieve (optional).
|
58
|
+
# @param [String] tag The tag that is applied to the projects (optional).
|
59
|
+
# @return [Array, nil].
|
60
|
+
def get_projects(ids: [], tag: '')
|
61
|
+
url = Utils::UrlHelper.build_url(path: "Projects", params: {ids: ids.join(','), tag: tag})
|
62
|
+
Resources::Project.parse(request(:get, url))
|
63
|
+
end
|
64
|
+
|
65
|
+
# POST /v2.1/Projects
|
66
|
+
# Create a project.
|
67
|
+
# @param [Hash] project The project to create.
|
68
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
69
|
+
# @return [Insightly2::Resources::Project, nil].
|
70
|
+
def create_project(project:)
|
71
|
+
raise ArgumentError, "Project cannot be blank" if project.blank?
|
72
|
+
Resources::Project.parse(request(:post, "Projects", project))
|
73
|
+
end
|
74
|
+
|
75
|
+
# POST /v2.1/Projects/{c_id}/Image/{filename}
|
76
|
+
# Create a project image.
|
77
|
+
# @param [String, Fixnum] id A project's ID.
|
78
|
+
# @param [String] filename A Project image file name.
|
79
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
80
|
+
# @return [Faraday::Response].
|
81
|
+
def create_project_image(id:, filename:)
|
82
|
+
raise ArgumentError, "ID cannot be blank" if id.blank?
|
83
|
+
raise ArgumentError, "Filename cannot be blank" if filename.blank?
|
84
|
+
request(:post, "Projects/#{id}/Image/#{filename}")
|
85
|
+
end
|
86
|
+
|
87
|
+
# PUT /v2.1/Projects
|
88
|
+
# Update a project.
|
89
|
+
# @param [Hash] project The project to update.
|
90
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
91
|
+
# @return [Insightly2::Resources::Project, nil].
|
92
|
+
def update_project(project:)
|
93
|
+
raise ArgumentError, "Project cannot be blank" if project.blank?
|
94
|
+
Resources::Project.parse(request(:put, "Projects", project))
|
95
|
+
end
|
96
|
+
|
97
|
+
# PUT /v2.1/Projects/{c_id}/Image/{filename}
|
98
|
+
# Update a project's image.
|
99
|
+
# @param [String, Fixnum] id A project's ID.
|
100
|
+
# @param [String] filename A project image file name.
|
101
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
102
|
+
# @return [Faraday::Response].
|
103
|
+
def update_project_image(id:, filename:)
|
104
|
+
raise ArgumentError, "ID cannot be blank" if id.blank?
|
105
|
+
raise ArgumentError, "Filename cannot be blank" if filename.blank?
|
106
|
+
request(:put, "Projects/#{id}/Image/#{filename}")
|
107
|
+
end
|
108
|
+
|
109
|
+
# DELETE /v2.1/Projects/{id}
|
110
|
+
# Delete a project.
|
111
|
+
# @param [String, Fixnum] id A project's ID.
|
112
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
113
|
+
# @return [Faraday::Response].
|
114
|
+
def delete_project(id:)
|
115
|
+
raise ArgumentError, "ID cannot be blank" if id.blank?
|
116
|
+
request(:delete, "Projects/#{id}")
|
117
|
+
end
|
118
|
+
|
119
|
+
# DELETE /v2.1/Projects/{c_id}/Image
|
120
|
+
# Delete a project image.
|
121
|
+
# @param [String, Fixnum] id A project's ID.
|
122
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
123
|
+
# @return [Faraday::Response].
|
124
|
+
def delete_project_image(id:)
|
125
|
+
raise ArgumentError, "ID cannot be blank" if id.blank?
|
126
|
+
request(:delete, "Projects/#{id}/Image")
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'insightly2/dsl'
|
2
|
+
|
3
|
+
module Insightly2
|
4
|
+
module DSL::Relationships
|
5
|
+
# GET /v2.1/Relationships
|
6
|
+
# Get a list of relationships.
|
7
|
+
# @return [Array, nil].
|
8
|
+
def get_relationships
|
9
|
+
Resources::Relationship.parse(request(:get, "Relationships"))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'insightly2/dsl'
|
2
|
+
|
3
|
+
module Insightly2
|
4
|
+
module DSL::Tags
|
5
|
+
# GET /v2.1/Tags/{id}
|
6
|
+
# Get a tag.
|
7
|
+
# @param [String, Fixnum] id A Tag's ID.
|
8
|
+
# @raise [ArgumentError] If the method arguments are blank.
|
9
|
+
# @return [Insightly2::Resources::Tag, nil].
|
10
|
+
def get_tag(id:)
|
11
|
+
raise ArgumentError, "ID cannot be blank" if id.blank?
|
12
|
+
Resources::Tag.parse(request(:get, "Tags/#{id}"))
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|