Module: Insightly2::DSL::OpportunityCategories

Included in:
Insightly2::DSL
Defined in:
lib/insightly2/dsl/opportunity_categories.rb

Instance Method Summary collapse

Instance Method Details

#create_opportunity_category(category: nil) ⇒ Insightly2::Resources::OpportunityCategory?

POST /v2.1/OpportunityCategories Create an opportunity category.

Parameters:

  • category (Hash) (defaults to: nil)

    The opportunity category to create.

Returns:

Raises:

  • (ArgumentError)

    If the method arguments are blank.



27
28
29
30
# File 'lib/insightly2/dsl/opportunity_categories.rb', line 27

def create_opportunity_category(category: nil)
  raise ArgumentError, "Category cannot be blank" if category.blank?
  Resources::OpportunityCategory.parse(request(:post, "OpportunityCategories", category))
end

#delete_opportunity_category(id: nil) ⇒ Faraday::Response

DELETE /v2.1/OpportunityCategories/id Delete an opportunity category.

Parameters:

  • id (String, Fixnum) (defaults to: nil)

    A OpportunityCategory’s ID.

Returns:

  • (Faraday::Response)

    .

Raises:

  • (ArgumentError)

    If the method arguments are blank.



47
48
49
50
# File 'lib/insightly2/dsl/opportunity_categories.rb', line 47

def delete_opportunity_category(id: nil)
  raise ArgumentError, "ID cannot be blank" if id.blank?
  request(:delete, "OpportunityCategories/#{id}")
end

#get_opportunity_categoriesArray?

GET /v2.1/OpportunityCategories Get a list of opportunity categories.

Returns:

  • (Array, nil)

    .



18
19
20
# File 'lib/insightly2/dsl/opportunity_categories.rb', line 18

def get_opportunity_categories
  Resources::OpportunityCategory.parse(request(:get, "OpportunityCategories"))
end

#get_opportunity_category(id: nil) ⇒ Insightly2::Resources::OpportunityCategory?

GET /v2.1/OpportunityCategories/id Get an opportunity category.

Parameters:

  • id (String, Fixnum) (defaults to: nil)

    An opportunity category’s ID.

Returns:

Raises:

  • (ArgumentError)

    If the method arguments are blank.



10
11
12
13
# File 'lib/insightly2/dsl/opportunity_categories.rb', line 10

def get_opportunity_category(id: nil)
  raise ArgumentError, "ID cannot be blank" if id.blank?
  Resources::OpportunityCategory.parse(request(:get, "OpportunityCategories/#{id}"))
end

#update_opportunity_category(category: nil) ⇒ Insightly2::Resources::OpportunityCategory?

PUT /v2.1/OpportunityCategories Update an opportunity category.

Parameters:

  • category (Hash) (defaults to: nil)

    The opportunity category to update.

Returns:

Raises:

  • (ArgumentError)

    If the method arguments are blank.



37
38
39
40
# File 'lib/insightly2/dsl/opportunity_categories.rb', line 37

def update_opportunity_category(category: nil)
  raise ArgumentError, "Category cannot be blank" if category.blank?
  Resources::OpportunityCategory.parse(request(:put, "OpportunityCategories", category))
end