Class: BaseCRM::DealUnqualifiedReasonsService
- Inherits:
-
Object
- Object
- BaseCRM::DealUnqualifiedReasonsService
- Defined in:
- lib/basecrm/services/deal_unqualified_reasons_service.rb
Constant Summary collapse
- OPTS_KEYS_TO_PERSIST =
Set[:name]
Instance Method Summary collapse
-
#all ⇒ Enumerable
Retrieve all deal unqualified reasons.
-
#create(deal_unqualified_reason) ⇒ DealUnqualifiedReason
Create a deal unqualified reason.
-
#destroy(id) ⇒ Boolean
Delete a deal unqualified reason.
-
#find(id) ⇒ DealUnqualifiedReason
Retrieve a single deal unqualified reason.
-
#initialize(client) ⇒ DealUnqualifiedReasonsService
constructor
A new instance of DealUnqualifiedReasonsService.
-
#update(deal_unqualified_reason) ⇒ DealUnqualifiedReason
Update a deal unqualified reason.
-
#where(options = {}) ⇒ Array<DealUnqualifiedReason>
Retrieve all deal unqualified reasons.
Constructor Details
#initialize(client) ⇒ DealUnqualifiedReasonsService
Returns a new instance of DealUnqualifiedReasonsService.
7 8 9 |
# File 'lib/basecrm/services/deal_unqualified_reasons_service.rb', line 7 def initialize(client) @client = client end |
Instance Method Details
#all ⇒ Enumerable
Retrieve all deal unqualified reasons
get ‘/deal_unqualified_reasons’
If you want to use filtering or sorting (see #where).
17 18 19 |
# File 'lib/basecrm/services/deal_unqualified_reasons_service.rb', line 17 def all PaginatedResource.new(self) end |
#create(deal_unqualified_reason) ⇒ DealUnqualifiedReason
Create a deal unqualified reason
post ‘/deal_unqualified_reasons’
Create a new deal unqualified reason <figure class=“notice”> Deal unqualified reason’s name must be unique </figure>
52 53 54 55 56 57 58 59 |
# File 'lib/basecrm/services/deal_unqualified_reasons_service.rb', line 52 def create(deal_unqualified_reason) validate_type!(deal_unqualified_reason) attributes = sanitize(deal_unqualified_reason) _, _, root = @client.post("/deal_unqualified_reasons", attributes) DealUnqualifiedReason.new(root[:data]) end |
#destroy(id) ⇒ Boolean
Delete a deal unqualified reason
delete ‘/deal_unqualified_reasons/BaseCRM#id’
Delete an existing deal unqualified reason If the reason with supplied unique identifier does not exist it returns an error This operation cannot be undone
112 113 114 115 |
# File 'lib/basecrm/services/deal_unqualified_reasons_service.rb', line 112 def destroy(id) status, _, _ = @client.delete("/deal_unqualified_reasons/#{id}") status == 204 end |
#find(id) ⇒ DealUnqualifiedReason
Retrieve a single deal unqualified reason
get ‘/deal_unqualified_reasons/BaseCRM#id’
Returns a single deal unqualified reason available to the user by the provided id If a loss reason with the supplied unique identifier does not exist, it returns an error
71 72 73 74 75 |
# File 'lib/basecrm/services/deal_unqualified_reasons_service.rb', line 71 def find(id) _, _, root = @client.get("/deal_unqualified_reasons/#{id}") DealUnqualifiedReason.new(root[:data]) end |
#update(deal_unqualified_reason) ⇒ DealUnqualifiedReason
Update a deal unqualified reason
put ‘/deal_unqualified_reasons/BaseCRM#id’
Updates a deal unqualified reason information If the specified deal unqualified reason does not exist, the request will return an error <figure class=“notice”> If you want to update deal unqualified reason you must make sure name of the reason is unique </figure>
90 91 92 93 94 95 96 97 98 99 |
# File 'lib/basecrm/services/deal_unqualified_reasons_service.rb', line 90 def update(deal_unqualified_reason) validate_type!(deal_unqualified_reason) params = extract_params!(deal_unqualified_reason, :id) id = params[:id] attributes = sanitize(deal_unqualified_reason) _, _, root = @client.put("/deal_unqualified_reasons/#{id}", attributes) DealUnqualifiedReason.new(root[:data]) end |
#where(options = {}) ⇒ Array<DealUnqualifiedReason>
Retrieve all deal unqualified reasons
get ‘/deal_unqualified_reasons’
Returns all deal unqualified reasons available to the user according to the parameters provided
34 35 36 37 38 |
# File 'lib/basecrm/services/deal_unqualified_reasons_service.rb', line 34 def where( = {}) _, _, root = @client.get("/deal_unqualified_reasons", ) root[:items].map{ |item| DealUnqualifiedReason.new(item[:data]) } end |