Class: Files::NpsResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/files.com/models/nps_response.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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 = {}, options = {})
  @attributes = attributes || {}
  @options = options || {}
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



5
6
7
# File 'lib/files.com/models/nps_response.rb', line 5

def attributes
  @attributes
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/files.com/models/nps_response.rb', line 5

def options
  @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 = {}, options = {})
  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, options = Api.send_request("/nps_responses", :post, params, options)
  NpsResponse.new(response.data, options)
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 = {}, options = {})
  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, options = Api.send_request("/nps_responses/#{params[:id]}", :patch, params, options)
  NpsResponse.new(response.data, options)
end

Instance Method Details

#commentObject

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_meObject

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

#idObject

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_stepObject

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

#saveObject



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

#scoreObject

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

#skippedObject

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_idObject

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