Module: Insightly2::DSL::Opportunities
- Included in:
- Insightly2::DSL
- Defined in:
- lib/insightly2/dsl/opportunities.rb
Instance Method Summary collapse
-
#create_opportunity(opportunity: nil) ⇒ Insightly2::Resources::Opportunity?
POST /v2.1/Opportunities Create an opportunity.
-
#create_opportunity_image(id: nil, filename: nil) ⇒ Faraday::Response
POST /v2.1/Opportunities/c_id/Image/filename Add an attachment to an opportunity.
-
#delete_opportunity(id: nil) ⇒ Faraday::Response
DELETE /v2.1/Opportunities/id.
-
#delete_opportunity_image(id: nil) ⇒ Faraday::Response
DELETE /v2.1/Opportunities/c_id/Image.
-
#get_opportunities(ids: [], tag: '') ⇒ Array?
GET /v2.1/Opportunities?ids=ids&tag=tag Get a list of opportunities.
-
#get_opportunity(id: nil) ⇒ Insightly2::Resources::Opportunity?
GET /v2.1/Opportunities/id Get an opportunity.
-
#get_opportunity_emails(id: nil) ⇒ Array?
GET /v2.1/Opportunities/c_id/Emails Get an opportunity’s emails.
-
#get_opportunity_image(id: nil) ⇒ Faraday::Response
GET /v2.1/Opportunities/c_id/Image.
-
#get_opportunity_notes(id: nil) ⇒ Array?
GET /v2.1/Opportunities/c_id/Notes Get an opportunity’s notes.
-
#get_opportunity_state_history(id: nil) ⇒ Array?
GET /v2.1/Opportunities/c_id/StateHistory Get an opportunity’s state history.
-
#get_opportunity_tasks(id: nil) ⇒ Array?
GET /v2.1/Opportunities/c_id/Tasks Get an opportunity’s tasks.
-
#update_opportunity(opportunity: nil) ⇒ Insightly2::Resources::Opportunity?
PUT /v2.1/Opportunities Update an opportunity.
-
#update_opportunity_image(id: nil, filename: nil) ⇒ Faraday::Response
PUT /v2.1/Opportunities/c_id/Image/filename.
Instance Method Details
#create_opportunity(opportunity: nil) ⇒ Insightly2::Resources::Opportunity?
POST /v2.1/Opportunities Create an opportunity.
78 79 80 81 |
# File 'lib/insightly2/dsl/opportunities.rb', line 78 def create_opportunity(opportunity: nil) raise ArgumentError, "Opportunity cannot be blank" if opportunity.blank? Resources::Opportunity.parse(request(:post, "Opportunities", opportunity)) end |
#create_opportunity_image(id: nil, filename: nil) ⇒ Faraday::Response
POST /v2.1/Opportunities/c_id/Image/filename Add an attachment to an opportunity.
89 90 91 92 93 |
# File 'lib/insightly2/dsl/opportunities.rb', line 89 def create_opportunity_image(id: nil, filename: nil) raise ArgumentError, "ID cannot be blank" if id.blank? raise ArgumentError, "Filename cannot be blank" if filename.blank? request(:post, "Opportunities/#{id}/Image/#{filename}") end |
#delete_opportunity(id: nil) ⇒ Faraday::Response
DELETE /v2.1/Opportunities/id
120 121 122 123 |
# File 'lib/insightly2/dsl/opportunities.rb', line 120 def delete_opportunity(id: nil) raise ArgumentError, "ID cannot be blank" if id.blank? request(:delete, "Opportunities/#{id}") end |
#delete_opportunity_image(id: nil) ⇒ Faraday::Response
DELETE /v2.1/Opportunities/c_id/Image
129 130 131 132 |
# File 'lib/insightly2/dsl/opportunities.rb', line 129 def delete_opportunity_image(id: nil) raise ArgumentError, "ID cannot be blank" if id.blank? request(:delete, "Opportunities/#{id}/Image") end |
#get_opportunities(ids: [], tag: '') ⇒ Array?
GET /v2.1/Opportunities?ids=ids&tag=tag Get a list of opportunities.
68 69 70 71 |
# File 'lib/insightly2/dsl/opportunities.rb', line 68 def get_opportunities(ids: [], tag: '') url = Utils::UrlHelper.build_url(path: "Opportunities", params: {ids: ids.join(','), tag: tag}) Resources::Opportunity.parse(request(:get, url)) end |
#get_opportunity(id: nil) ⇒ Insightly2::Resources::Opportunity?
GET /v2.1/Opportunities/id Get an opportunity.
10 11 12 13 |
# File 'lib/insightly2/dsl/opportunities.rb', line 10 def get_opportunity(id: nil) raise ArgumentError, "ID cannot be blank" if id.blank? Resources::Opportunity.parse(request(:get, "Opportunities/#{id}")) end |
#get_opportunity_emails(id: nil) ⇒ Array?
GET /v2.1/Opportunities/c_id/Emails Get an opportunity’s emails.
20 21 22 23 |
# File 'lib/insightly2/dsl/opportunities.rb', line 20 def get_opportunity_emails(id: nil) raise ArgumentError, "ID cannot be blank" if id.blank? Resources::Email.parse(request(:get, "Opportunities/#{id}/Emails")) end |
#get_opportunity_image(id: nil) ⇒ Faraday::Response
GET /v2.1/Opportunities/c_id/Image
29 30 31 |
# File 'lib/insightly2/dsl/opportunities.rb', line 29 def get_opportunity_image(id: nil) request(:get, "Opportunities/#{id}/Image") end |
#get_opportunity_notes(id: nil) ⇒ Array?
GET /v2.1/Opportunities/c_id/Notes Get an opportunity’s notes.
38 39 40 41 |
# File 'lib/insightly2/dsl/opportunities.rb', line 38 def get_opportunity_notes(id: nil) raise ArgumentError, "ID cannot be blank" if id.blank? Resources::Note.parse(request(:get, "Opportunities/#{id}/Notes")) end |
#get_opportunity_state_history(id: nil) ⇒ Array?
GET /v2.1/Opportunities/c_id/StateHistory Get an opportunity’s state history.
48 49 50 51 |
# File 'lib/insightly2/dsl/opportunities.rb', line 48 def get_opportunity_state_history(id: nil) raise ArgumentError, "ID cannot be blank" if id.blank? Resources::OpportunityStateReason.parse(request(:get, "Opportunities/#{id}/StateHistory")) end |
#get_opportunity_tasks(id: nil) ⇒ Array?
GET /v2.1/Opportunities/c_id/Tasks Get an opportunity’s tasks.
58 59 60 61 |
# File 'lib/insightly2/dsl/opportunities.rb', line 58 def get_opportunity_tasks(id: nil) raise ArgumentError, "ID cannot be blank" if id.blank? Resources::Task.parse(request(:get, "Opportunities/#{id}/Tasks")) end |
#update_opportunity(opportunity: nil) ⇒ Insightly2::Resources::Opportunity?
PUT /v2.1/Opportunities Update an opportunity.
100 101 102 103 |
# File 'lib/insightly2/dsl/opportunities.rb', line 100 def update_opportunity(opportunity: nil) raise ArgumentError, "Opportunity cannot be blank" if opportunity.blank? Resources::Opportunity.parse(request(:put, "Opportunities", opportunity)) end |
#update_opportunity_image(id: nil, filename: nil) ⇒ Faraday::Response
PUT /v2.1/Opportunities/c_id/Image/filename
110 111 112 113 114 |
# File 'lib/insightly2/dsl/opportunities.rb', line 110 def update_opportunity_image(id: nil, filename: nil) raise ArgumentError, "ID cannot be blank" if id.blank? raise ArgumentError, "Filename cannot be blank" if filename.blank? request(:put, "Opportunities/#{id}/Image/#{filename}") end |