tremendous_ruby 5.14.0 → 5.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,7 +20,7 @@ module Tremendous
20
20
  # Label of the field
21
21
  attr_accessor :label
22
22
 
23
- # Type of the values of the field
23
+ # Type of the values of the field <table> <thead> <tr> <th>Type</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><code>Checkbox</code></td> <td>A boolean value (true/false)</td> </tr> <tr> <td><code>Currency</code></td> <td>A monetary value</td> </tr> <tr> <td><code>Date</code></td> <td>A date value</td> </tr> <tr> <td><code>Dropdown</code></td> <td>A single selection from predefined options (see <code>data.options</code>)</td> </tr> <tr> <td><code>Email</code></td> <td>An email address</td> </tr> <tr> <td><code>List</code></td> <td>Multiple selections from predefined options (see <code>data.options</code>)</td> </tr> <tr> <td><code>Number</code></td> <td>A numeric value</td> </tr> <tr> <td><code>Phone</code></td> <td>A phone number</td> </tr> <tr> <td><code>Text</code></td> <td>A single-line text value</td> </tr> <tr> <td><code>TextArea</code></td> <td>A multi-line text value</td> </tr> </tbody> </table>
24
24
  attr_accessor :data_type
25
25
 
26
26
  attr_accessor :data
@@ -31,6 +31,28 @@ module Tremendous
31
31
  # Type of objects this field gets associated with
32
32
  attr_accessor :scope
33
33
 
34
+ class EnumAttributeValidator
35
+ attr_reader :datatype
36
+ attr_reader :allowable_values
37
+
38
+ def initialize(datatype, allowable_values)
39
+ @allowable_values = allowable_values.map do |value|
40
+ case datatype.to_s
41
+ when /Integer/i
42
+ value.to_i
43
+ when /Float/i
44
+ value.to_f
45
+ else
46
+ value
47
+ end
48
+ end
49
+ end
50
+
51
+ def valid?(value)
52
+ !value || allowable_values.include?(value)
53
+ end
54
+ end
55
+
34
56
  # Attribute mapping from ruby-style variable name to JSON key.
35
57
  def self.attribute_map
36
58
  {
@@ -59,7 +81,7 @@ module Tremendous
59
81
  :'id' => :'String',
60
82
  :'label' => :'String',
61
83
  :'data_type' => :'String',
62
- :'data' => :'Hash<String, Object>',
84
+ :'data' => :'ListFields200ResponseFieldsInnerData',
63
85
  :'required' => :'Boolean',
64
86
  :'scope' => :'String'
65
87
  }
@@ -100,9 +122,7 @@ module Tremendous
100
122
  end
101
123
 
102
124
  if attributes.key?(:'data')
103
- if (value = attributes[:'data']).is_a?(Hash)
104
- self.data = value
105
- end
125
+ self.data = attributes[:'data']
106
126
  end
107
127
 
108
128
  if attributes.key?(:'required')
@@ -132,6 +152,8 @@ module Tremendous
132
152
  def valid?
133
153
  warn '[DEPRECATED] the `valid?` method is obsolete'
134
154
  return false if !@id.nil? && @id !~ Regexp.new(/[A-Z0-9]{4,20}/)
155
+ data_type_validator = EnumAttributeValidator.new('String', ["Checkbox", "Currency", "Date", "Dropdown", "Email", "List", "Number", "Phone", "Text", "TextArea"])
156
+ return false unless data_type_validator.valid?(@data_type)
135
157
  true
136
158
  end
137
159
 
@@ -150,6 +172,16 @@ module Tremendous
150
172
  @id = id
151
173
  end
152
174
 
175
+ # Custom attribute writer method checking allowed values (enum).
176
+ # @param [Object] data_type Object to be assigned
177
+ def data_type=(data_type)
178
+ validator = EnumAttributeValidator.new('String', ["Checkbox", "Currency", "Date", "Dropdown", "Email", "List", "Number", "Phone", "Text", "TextArea"])
179
+ unless validator.valid?(data_type)
180
+ fail ArgumentError, "invalid value for \"data_type\", must be one of #{validator.allowable_values}."
181
+ end
182
+ @data_type = data_type
183
+ end
184
+
153
185
  # Checks equality by comparing each attribute.
154
186
  # @param [Object] Object to be compared
155
187
  def ==(o)
@@ -0,0 +1,236 @@
1
+ =begin
2
+ #API Endpoints
3
+
4
+ #Deliver monetary rewards and incentives to employees, customers, survey participants, and more through the Tremendous API. For organizational tasks, like managing your organization and its members within Tremendous, please see the Tremendous Organizational API.
5
+
6
+ The version of the OpenAPI document: 2
7
+ Contact: developers@tremendous.com
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.12.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Tremendous
17
+ # Additional configuration for the field. Only used for `Dropdown` and `List` data types.
18
+ class ListFields200ResponseFieldsInnerData
19
+ # List of valid options for `Dropdown` and `List` field types. For `Dropdown`, the user selects one option. For `List`, the user can select multiple options.
20
+ attr_accessor :options
21
+
22
+ # Optional human-readable labels for each option. Keys are the option values, values are the display labels. If not provided, the option values are used as labels.
23
+ attr_accessor :labels
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'options' => :'options',
29
+ :'labels' => :'labels'
30
+ }
31
+ end
32
+
33
+ # Returns attribute mapping this model knows about
34
+ def self.acceptable_attribute_map
35
+ attribute_map
36
+ end
37
+
38
+ # Returns all the JSON keys this model knows about
39
+ def self.acceptable_attributes
40
+ acceptable_attribute_map.values
41
+ end
42
+
43
+ # Attribute type mapping.
44
+ def self.openapi_types
45
+ {
46
+ :'options' => :'Array<String>',
47
+ :'labels' => :'Hash<String, String>'
48
+ }
49
+ end
50
+
51
+ # List of attributes with nullable: true
52
+ def self.openapi_nullable
53
+ Set.new([
54
+ ])
55
+ end
56
+
57
+ # Initializes the object
58
+ # @param [Hash] attributes Model attributes in the form of hash
59
+ def initialize(attributes = {})
60
+ if (!attributes.is_a?(Hash))
61
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Tremendous::ListFields200ResponseFieldsInnerData` initialize method"
62
+ end
63
+
64
+ # check to see if the attribute exists and convert string to symbol for hash key
65
+ acceptable_attribute_map = self.class.acceptable_attribute_map
66
+ attributes = attributes.each_with_object({}) { |(k, v), h|
67
+ if (!acceptable_attribute_map.key?(k.to_sym))
68
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Tremendous::ListFields200ResponseFieldsInnerData`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
69
+ end
70
+ h[k.to_sym] = v
71
+ }
72
+
73
+ if attributes.key?(:'options')
74
+ if (value = attributes[:'options']).is_a?(Array)
75
+ self.options = value
76
+ end
77
+ end
78
+
79
+ if attributes.key?(:'labels')
80
+ if (value = attributes[:'labels']).is_a?(Hash)
81
+ self.labels = value
82
+ end
83
+ end
84
+ end
85
+
86
+ # Show invalid properties with the reasons. Usually used together with valid?
87
+ # @return Array for valid properties with the reasons
88
+ def list_invalid_properties
89
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
90
+ invalid_properties = Array.new
91
+ invalid_properties
92
+ end
93
+
94
+ # Check to see if the all the properties in the model are valid
95
+ # @return true if the model is valid
96
+ def valid?
97
+ warn '[DEPRECATED] the `valid?` method is obsolete'
98
+ true
99
+ end
100
+
101
+ # Checks equality by comparing each attribute.
102
+ # @param [Object] Object to be compared
103
+ def ==(o)
104
+ return true if self.equal?(o)
105
+ self.class == o.class &&
106
+ options == o.options &&
107
+ labels == o.labels
108
+ end
109
+
110
+ # @see the `==` method
111
+ # @param [Object] Object to be compared
112
+ def eql?(o)
113
+ self == o
114
+ end
115
+
116
+ # Calculates hash code according to all attributes.
117
+ # @return [Integer] Hash code
118
+ def hash
119
+ [options, labels].hash
120
+ end
121
+
122
+ # Builds the object from hash
123
+ # @param [Hash] attributes Model attributes in the form of hash
124
+ # @return [Object] Returns the model itself
125
+ def self.build_from_hash(attributes)
126
+ return nil unless attributes.is_a?(Hash)
127
+ attributes = attributes.transform_keys(&:to_sym)
128
+ transformed_hash = {}
129
+ openapi_types.each_pair do |key, type|
130
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
131
+ transformed_hash["#{key}"] = nil
132
+ elsif type =~ /\AArray<(.*)>/i
133
+ # check to ensure the input is an array given that the attribute
134
+ # is documented as an array but the input is not
135
+ if attributes[attribute_map[key]].is_a?(Array)
136
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
137
+ end
138
+ elsif !attributes[attribute_map[key]].nil?
139
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
140
+ end
141
+ end
142
+ new(transformed_hash)
143
+ end
144
+
145
+ # Deserializes the data based on type
146
+ # @param string type Data type
147
+ # @param string value Value to be deserialized
148
+ # @return [Object] Deserialized data
149
+ def self._deserialize(type, value)
150
+ case type.to_sym
151
+ when :Time
152
+ Time.parse(value)
153
+ when :Date
154
+ Date.parse(value)
155
+ when :String
156
+ value.to_s
157
+ when :Integer
158
+ value.to_i
159
+ when :Float
160
+ value.to_f
161
+ when :Boolean
162
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
163
+ true
164
+ else
165
+ false
166
+ end
167
+ when :Object
168
+ # generic object (usually a Hash), return directly
169
+ value
170
+ when /\AArray<(?<inner_type>.+)>\z/
171
+ inner_type = Regexp.last_match[:inner_type]
172
+ value.map { |v| _deserialize(inner_type, v) }
173
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
174
+ k_type = Regexp.last_match[:k_type]
175
+ v_type = Regexp.last_match[:v_type]
176
+ {}.tap do |hash|
177
+ value.each do |k, v|
178
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
179
+ end
180
+ end
181
+ else # model
182
+ # models (e.g. Pet) or oneOf
183
+ klass = Tremendous.const_get(type)
184
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
185
+ end
186
+ end
187
+
188
+ # Returns the string representation of the object
189
+ # @return [String] String presentation of the object
190
+ def to_s
191
+ to_hash.to_s
192
+ end
193
+
194
+ # to_body is an alias to to_hash (backward compatibility)
195
+ # @return [Hash] Returns the object in the form of hash
196
+ def to_body
197
+ to_hash
198
+ end
199
+
200
+ # Returns the object in the form of hash
201
+ # @return [Hash] Returns the object in the form of hash
202
+ def to_hash
203
+ hash = {}
204
+ self.class.attribute_map.each_pair do |attr, param|
205
+ value = self.send(attr)
206
+ if value.nil?
207
+ is_nullable = self.class.openapi_nullable.include?(attr)
208
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
209
+ end
210
+
211
+ hash[param] = _to_hash(value)
212
+ end
213
+ hash
214
+ end
215
+
216
+ # Outputs non-array value in the form of hash
217
+ # For object, use to_hash. Otherwise, just return the value
218
+ # @param [Object] value Any valid value
219
+ # @return [Hash] Returns the value in the form of hash
220
+ def _to_hash(value)
221
+ if value.is_a?(Array)
222
+ value.compact.map { |v| _to_hash(v) }
223
+ elsif value.is_a?(Hash)
224
+ {}.tap do |hash|
225
+ value.each { |k, v| hash[k] = _to_hash(v) }
226
+ end
227
+ elsif value.respond_to? :to_hash
228
+ value.to_hash
229
+ else
230
+ value
231
+ end
232
+ end
233
+
234
+ end
235
+
236
+ end
@@ -1,3 +1,3 @@
1
1
  module Tremendous
2
- VERSION = "5.14.0"
2
+ VERSION = "5.15.0"
3
3
  end
data/lib/tremendous.rb CHANGED
@@ -43,6 +43,10 @@ require 'tremendous/models/create_connected_organization_member_session200_respo
43
43
  require 'tremendous/models/create_connected_organization_member_session200_response_connected_organization_member_session'
44
44
  require 'tremendous/models/create_connected_organization_member_session_request'
45
45
  require 'tremendous/models/create_connected_organization_request'
46
+ require 'tremendous/models/create_field'
47
+ require 'tremendous/models/create_field200_response'
48
+ require 'tremendous/models/create_field_request'
49
+ require 'tremendous/models/create_field_request_data'
46
50
  require 'tremendous/models/create_invoice200_response'
47
51
  require 'tremendous/models/create_invoice_request'
48
52
  require 'tremendous/models/create_member'
@@ -140,6 +144,7 @@ require 'tremendous/models/list_connected_organizations200_response_connected_or
140
144
  require 'tremendous/models/list_connected_organizations200_response_connected_organizations_inner_organization'
141
145
  require 'tremendous/models/list_fields200_response'
142
146
  require 'tremendous/models/list_fields200_response_fields_inner'
147
+ require 'tremendous/models/list_fields200_response_fields_inner_data'
143
148
  require 'tremendous/models/list_forex_response'
144
149
  require 'tremendous/models/list_fraud_reviews200_response'
145
150
  require 'tremendous/models/list_fraud_reviews200_response_fraud_reviews_inner'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tremendous_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.14.0
4
+ version: 5.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tremendous Developers
@@ -81,6 +81,10 @@ files:
81
81
  - lib/tremendous/models/create_connected_organization_member_session200_response_connected_organization_member_session.rb
82
82
  - lib/tremendous/models/create_connected_organization_member_session_request.rb
83
83
  - lib/tremendous/models/create_connected_organization_request.rb
84
+ - lib/tremendous/models/create_field.rb
85
+ - lib/tremendous/models/create_field200_response.rb
86
+ - lib/tremendous/models/create_field_request.rb
87
+ - lib/tremendous/models/create_field_request_data.rb
84
88
  - lib/tremendous/models/create_invoice200_response.rb
85
89
  - lib/tremendous/models/create_invoice_request.rb
86
90
  - lib/tremendous/models/create_member.rb
@@ -184,6 +188,7 @@ files:
184
188
  - lib/tremendous/models/list_connected_organizations200_response_connected_organizations_inner_organization.rb
185
189
  - lib/tremendous/models/list_fields200_response.rb
186
190
  - lib/tremendous/models/list_fields200_response_fields_inner.rb
191
+ - lib/tremendous/models/list_fields200_response_fields_inner_data.rb
187
192
  - lib/tremendous/models/list_forex_response.rb
188
193
  - lib/tremendous/models/list_fraud_reviews200_response.rb
189
194
  - lib/tremendous/models/list_fraud_reviews200_response_fraud_reviews_inner.rb