Class: Files::NpsResponse
- Inherits:
-
Object
- Object
- Files::NpsResponse
- Defined in:
- lib/files.com/models/nps_response.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
-
.create(params = {}, options = {}) ⇒ Object
Parameters: user_id - int64 - User ID.
-
.update(id, params = {}, options = {}) ⇒ Object
Parameters: comment (required) - string - NPS comment contact_me - boolean - NPS contact_me.
Instance Method Summary collapse
-
#comment ⇒ Object
string - NPS comment.
- #comment=(value) ⇒ Object
-
#contact_me ⇒ Object
boolean - NPS contact_me.
- #contact_me=(value) ⇒ Object
-
#id ⇒ Object
int64 - NPS response id.
- #id=(value) ⇒ Object
-
#initialize(attributes = {}, options = {}) ⇒ NpsResponse
constructor
A new instance of NpsResponse.
-
#next_step ⇒ Object
string.
- #next_step=(value) ⇒ Object
- #save ⇒ Object
-
#score ⇒ Object
int64 - NPS score.
- #score=(value) ⇒ Object
-
#skipped ⇒ Object
boolean - NPS skipped.
- #skipped=(value) ⇒ Object
-
#update(params = {}) ⇒ Object
Parameters: comment (required) - string - NPS comment contact_me - boolean - NPS contact_me.
-
#user_id ⇒ Object
int64 - User ID.
- #user_id=(value) ⇒ Object
Constructor Details
#initialize(attributes = {}, options = {}) ⇒ NpsResponse
Returns a new instance of NpsResponse.
7 8 9 10 |
# File 'lib/files.com/models/nps_response.rb', line 7 def initialize(attributes = {}, = {}) @attributes = attributes || {} @options = || {} end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
5 6 7 |
# File 'lib/files.com/models/nps_response.rb', line 5 def attributes @attributes end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/files.com/models/nps_response.rb', line 5 def @options end |
Class Method Details
.create(params = {}, options = {}) ⇒ Object
Parameters:
user_id - int64 - User ID. Provide a value of `0` to operate the current session's user.
score - int64 - NPS score
skipped - boolean - NPS skipped
105 106 107 108 109 110 111 |
# File 'lib/files.com/models/nps_response.rb', line 105 def self.create(params = {}, = {}) raise InvalidParameterError.new("Bad parameter: user_id must be an Integer") if params[:user_id] and !params[:user_id].is_a?(Integer) raise InvalidParameterError.new("Bad parameter: score must be an Integer") if params[:score] and !params[:score].is_a?(Integer) response, = Api.send_request("/nps_responses", :post, params, ) NpsResponse.new(response.data, ) end |
.update(id, params = {}, options = {}) ⇒ Object
Parameters:
comment (required) - string - NPS comment
contact_me - boolean - NPS contact_me
116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/files.com/models/nps_response.rb', line 116 def self.update(id, params = {}, = {}) params ||= {} params[:id] = id raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer) raise InvalidParameterError.new("Bad parameter: comment must be an String") if params[:comment] and !params[:comment].is_a?(String) raise MissingParameterError.new("Parameter missing: id") unless params[:id] raise MissingParameterError.new("Parameter missing: comment") unless params[:comment] response, = Api.send_request("/nps_responses/#{params[:id]}", :patch, params, ) NpsResponse.new(response.data, ) end |
Instance Method Details
#comment ⇒ Object
string - NPS comment
58 59 60 |
# File 'lib/files.com/models/nps_response.rb', line 58 def comment @attributes[:comment] end |
#comment=(value) ⇒ Object
62 63 64 |
# File 'lib/files.com/models/nps_response.rb', line 62 def comment=(value) @attributes[:comment] = value end |
#contact_me ⇒ Object
boolean - NPS contact_me
67 68 69 |
# File 'lib/files.com/models/nps_response.rb', line 67 def contact_me @attributes[:contact_me] end |
#contact_me=(value) ⇒ Object
71 72 73 |
# File 'lib/files.com/models/nps_response.rb', line 71 def contact_me=(value) @attributes[:contact_me] = value end |
#id ⇒ Object
int64 - NPS response id
13 14 15 |
# File 'lib/files.com/models/nps_response.rb', line 13 def id @attributes[:id] end |
#id=(value) ⇒ Object
17 18 19 |
# File 'lib/files.com/models/nps_response.rb', line 17 def id=(value) @attributes[:id] = value end |
#next_step ⇒ Object
string
22 23 24 |
# File 'lib/files.com/models/nps_response.rb', line 22 def next_step @attributes[:next_step] end |
#next_step=(value) ⇒ Object
26 27 28 |
# File 'lib/files.com/models/nps_response.rb', line 26 def next_step=(value) @attributes[:next_step] = value end |
#save ⇒ Object
90 91 92 93 94 95 96 97 98 99 |
# File 'lib/files.com/models/nps_response.rb', line 90 def save if @attributes[:id] new_obj = update(@attributes) else new_obj = NpsResponse.create(@attributes, @options) end @attributes = new_obj.attributes true end |
#score ⇒ Object
int64 - NPS score
40 41 42 |
# File 'lib/files.com/models/nps_response.rb', line 40 def score @attributes[:score] end |
#score=(value) ⇒ Object
44 45 46 |
# File 'lib/files.com/models/nps_response.rb', line 44 def score=(value) @attributes[:score] = value end |
#skipped ⇒ Object
boolean - NPS skipped
49 50 51 |
# File 'lib/files.com/models/nps_response.rb', line 49 def skipped @attributes[:skipped] end |
#skipped=(value) ⇒ Object
53 54 55 |
# File 'lib/files.com/models/nps_response.rb', line 53 def skipped=(value) @attributes[:skipped] = value end |
#update(params = {}) ⇒ Object
Parameters:
comment (required) - string - NPS comment
contact_me - boolean - NPS contact_me
78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/files.com/models/nps_response.rb', line 78 def update(params = {}) params ||= {} params[:id] = @attributes[:id] raise MissingParameterError.new("Current object doesn't have a id") unless @attributes[:id] raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer) raise InvalidParameterError.new("Bad parameter: comment must be an String") if params[:comment] and !params[:comment].is_a?(String) raise MissingParameterError.new("Parameter missing: id") unless params[:id] raise MissingParameterError.new("Parameter missing: comment") unless params[:comment] Api.send_request("/nps_responses/#{@attributes[:id]}", :patch, params, @options) end |
#user_id ⇒ Object
int64 - User ID. Provide a value of 0 to operate the current session's user.
31 32 33 |
# File 'lib/files.com/models/nps_response.rb', line 31 def user_id @attributes[:user_id] end |
#user_id=(value) ⇒ Object
35 36 37 |
# File 'lib/files.com/models/nps_response.rb', line 35 def user_id=(value) @attributes[:user_id] = value end |