Module: Insightly2::DSL::Organisations
- Included in:
- Insightly2::DSL
- Defined in:
- lib/insightly2/dsl/organisations.rb
Instance Method Summary collapse
-
#create_organisation(organisation:) ⇒ Insightly2::Resources::Organisation
POST /v2.1/Organisations Create an organisation.
-
#create_organisation_image(id:, filename:) ⇒ Faraday::Response
POST /v2.1/Organisations/c_id/Image/filename Create an organisation image.
-
#delete_organisation(id:) ⇒ Faraday::Response
DELETE /v2.1/Organisations/id Delete an organisation.
-
#delete_organisation_image(id:) ⇒ Faraday::Response
DELETE /v2.1/Organisations/c_id/Image Delete an organisation image.
-
#get_organisation(id:) ⇒ Insightly2::Resources::Organisation?
GET /v2.1/Organisations/id Get an organisation.
-
#get_organisation_emails(id:) ⇒ Array?
GET /v2.1/Organisations/c_id/Emails Get an organisation’s emails.
-
#get_organisation_image(id:) ⇒ Faraday::Response
GET /v2.1/Organisations/c_id/Image Get an organisations image.
-
#get_organisation_notes(id:) ⇒ Array?
GET /v2.1/Organisations/c_id/Notes Get an organisations notes.
-
#get_organisation_tasks(id:) ⇒ Array?
GET /v2.1/Organisations/c_id/Tasks Get an organisations tasks.
-
#get_organisations(ids: [], domain: '', tag: '') ⇒ Array?
GET /v2.1/Organisations?ids=ids&domain=domain&tag=tag.
-
#update_organisation(organisation:) ⇒ Insightly2::Resources::Organisation?
PUT /v2.1/Organisations Update an organisation.
-
#update_organisation_image(id:, filename:) ⇒ Faraday::Response
PUT /v2.1/Organisations/c_id/Image/filename Update an organisation’s image.
Instance Method Details
#create_organisation(organisation:) ⇒ Insightly2::Resources::Organisation
POST /v2.1/Organisations Create an organisation.
69 70 71 72 |
# File 'lib/insightly2/dsl/organisations.rb', line 69 def create_organisation(organisation:) raise ArgumentError, "Organisation cannot be blank" if organisation.blank? Resources::Organisation.parse(request(:post, "Organisations", organisation)) end |
#create_organisation_image(id:, filename:) ⇒ Faraday::Response
POST /v2.1/Organisations/c_id/Image/filename Create an organisation image.
80 81 82 83 84 |
# File 'lib/insightly2/dsl/organisations.rb', line 80 def create_organisation_image(id:, filename:) raise ArgumentError, "ID cannot be blank" if id.blank? raise ArgumentError, "Filename cannot be blank" if filename.blank? request(:post, "Organisations/#{id}/Image/#{filename}") end |
#delete_organisation(id:) ⇒ Faraday::Response
DELETE /v2.1/Organisations/id Delete an organisation.
113 114 115 116 |
# File 'lib/insightly2/dsl/organisations.rb', line 113 def delete_organisation(id:) raise ArgumentError, "ID cannot be blank" if id.blank? request(:delete, "Organisations/#{id}") end |
#delete_organisation_image(id:) ⇒ Faraday::Response
DELETE /v2.1/Organisations/c_id/Image Delete an organisation image.
123 124 125 126 |
# File 'lib/insightly2/dsl/organisations.rb', line 123 def delete_organisation_image(id:) raise ArgumentError, "ID cannot be blank" if id.blank? request(:delete, "Organisations/#{id}/Image") end |
#get_organisation(id:) ⇒ Insightly2::Resources::Organisation?
GET /v2.1/Organisations/id Get an organisation.
10 11 12 13 |
# File 'lib/insightly2/dsl/organisations.rb', line 10 def get_organisation(id:) raise ArgumentError, "ID cannot be blank" if id.blank? Resources::Organisation.parse(request(:get, "Organisations/#{id}")) end |
#get_organisation_emails(id:) ⇒ Array?
GET /v2.1/Organisations/c_id/Emails Get an organisation’s emails.
20 21 22 23 |
# File 'lib/insightly2/dsl/organisations.rb', line 20 def get_organisation_emails(id:) raise ArgumentError, "ID cannot be blank" if id.blank? Resources::Email.parse(request(:get, "Organisations/#{id}/Emails")) end |
#get_organisation_image(id:) ⇒ Faraday::Response
GET /v2.1/Organisations/c_id/Image Get an organisations image.
30 31 32 |
# File 'lib/insightly2/dsl/organisations.rb', line 30 def get_organisation_image(id:) request(:get, "Organisations/#{id}/Image") end |
#get_organisation_notes(id:) ⇒ Array?
GET /v2.1/Organisations/c_id/Notes Get an organisations notes.
39 40 41 42 |
# File 'lib/insightly2/dsl/organisations.rb', line 39 def get_organisation_notes(id:) raise ArgumentError, "ID cannot be blank" if id.blank? Resources::Note.parse(request(:get, "Organisations/#{id}/Notes")) end |
#get_organisation_tasks(id:) ⇒ Array?
GET /v2.1/Organisations/c_id/Tasks Get an organisations tasks.
49 50 51 52 |
# File 'lib/insightly2/dsl/organisations.rb', line 49 def get_organisation_tasks(id:) raise ArgumentError, "ID cannot be blank" if id.blank? Resources::Task.parse(request(:get, "Organisations/#{id}/Tasks")) end |
#get_organisations(ids: [], domain: '', tag: '') ⇒ Array?
GET /v2.1/Organisations?ids=ids&domain=domain&tag=tag
59 60 61 62 |
# File 'lib/insightly2/dsl/organisations.rb', line 59 def get_organisations(ids: [], domain: '', tag: '') url = Utils::UrlHelper.build_url(path: "Organisations", params: {ids: ids.join(','), domain: domain, tag: tag}) Resources::Organisation.parse(request(:get, url)) end |
#update_organisation(organisation:) ⇒ Insightly2::Resources::Organisation?
PUT /v2.1/Organisations Update an organisation.
91 92 93 94 |
# File 'lib/insightly2/dsl/organisations.rb', line 91 def update_organisation(organisation:) raise ArgumentError, "Organisation cannot be blank" if organisation.blank? Resources::Organisation.parse(request(:put, "Organisations", organisation)) end |
#update_organisation_image(id:, filename:) ⇒ Faraday::Response
PUT /v2.1/Organisations/c_id/Image/filename Update an organisation’s image.
102 103 104 105 106 |
# File 'lib/insightly2/dsl/organisations.rb', line 102 def update_organisation_image(id:, filename:) raise ArgumentError, "ID cannot be blank" if id.blank? raise ArgumentError, "Filename cannot be blank" if filename.blank? request(:put, "Organisations/#{id}/Image/#{filename}") end |