approveapi_swagger 1.0.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.
Files changed (41) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +8 -0
  3. data/Gemfile.lock +79 -0
  4. data/README.md +105 -0
  5. data/Rakefile +10 -0
  6. data/approveapi_swagger.gemspec +45 -0
  7. data/docs/AnswerMetadata.md +10 -0
  8. data/docs/ApproveApi.md +162 -0
  9. data/docs/CreatePromptRequest.md +14 -0
  10. data/docs/Error.md +8 -0
  11. data/docs/Prompt.md +11 -0
  12. data/docs/PromptAnswer.md +10 -0
  13. data/docs/PromptMetadata.md +12 -0
  14. data/docs/PromptStatus.md +8 -0
  15. data/git_push.sh +55 -0
  16. data/lib/approveapi_swagger.rb +47 -0
  17. data/lib/approveapi_swagger/api/approve_api.rb +187 -0
  18. data/lib/approveapi_swagger/api_client.rb +387 -0
  19. data/lib/approveapi_swagger/api_error.rb +38 -0
  20. data/lib/approveapi_swagger/configuration.rb +251 -0
  21. data/lib/approveapi_swagger/models/answer_metadata.rb +209 -0
  22. data/lib/approveapi_swagger/models/create_prompt_request.rb +261 -0
  23. data/lib/approveapi_swagger/models/error.rb +197 -0
  24. data/lib/approveapi_swagger/models/prompt.rb +230 -0
  25. data/lib/approveapi_swagger/models/prompt_answer.rb +221 -0
  26. data/lib/approveapi_swagger/models/prompt_metadata.rb +232 -0
  27. data/lib/approveapi_swagger/models/prompt_status.rb +197 -0
  28. data/lib/approveapi_swagger/version.rb +15 -0
  29. data/pkg/approveapi_swagger-1.0.0.gem +0 -0
  30. data/spec/api/approve_api_spec.rb +72 -0
  31. data/spec/api_client_spec.rb +226 -0
  32. data/spec/configuration_spec.rb +42 -0
  33. data/spec/models/answer_metadata_spec.rb +53 -0
  34. data/spec/models/create_prompt_request_spec.rb +77 -0
  35. data/spec/models/error_spec.rb +41 -0
  36. data/spec/models/prompt_answer_spec.rb +53 -0
  37. data/spec/models/prompt_metadata_spec.rb +65 -0
  38. data/spec/models/prompt_spec.rb +59 -0
  39. data/spec/models/prompt_status_spec.rb +41 -0
  40. data/spec/spec_helper.rb +111 -0
  41. metadata +274 -0
@@ -0,0 +1,261 @@
1
+ =begin
2
+ #ApproveAPISwagger
3
+
4
+ #The simple API to request a user's approval on anything via email + sms.
5
+
6
+ OpenAPI spec version: 1.0.0
7
+ Contact: dev@approveapi.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.0.0-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module ApproveAPISwagger
16
+ class CreatePromptRequest
17
+ # The body of the approval request to show the user.
18
+ attr_accessor :body
19
+
20
+ # The user to send the approval request to. Can be either an email address or a phone number.
21
+ attr_accessor :user
22
+
23
+ # The title of an approval request. Defaults to an empty string.
24
+ attr_accessor :title
25
+
26
+ # The reject action text. Defaults to 'Reject'.
27
+ attr_accessor :reject_text
28
+
29
+ # The approve action text. Defaults to 'Approve'.
30
+ attr_accessor :approve_text
31
+
32
+ attr_accessor :metadata
33
+
34
+ # If true, the request waits (long-polls) until the user responds to the prompt or more than 10 minutes pass. Defaults to false.
35
+ attr_accessor :long_poll
36
+
37
+ # Attribute mapping from ruby-style variable name to JSON key.
38
+ def self.attribute_map
39
+ {
40
+ :'body' => :'body',
41
+ :'user' => :'user',
42
+ :'title' => :'title',
43
+ :'reject_text' => :'reject_text',
44
+ :'approve_text' => :'approve_text',
45
+ :'metadata' => :'metadata',
46
+ :'long_poll' => :'long_poll'
47
+ }
48
+ end
49
+
50
+ # Attribute type mapping.
51
+ def self.openapi_types
52
+ {
53
+ :'body' => :'String',
54
+ :'user' => :'String',
55
+ :'title' => :'String',
56
+ :'reject_text' => :'String',
57
+ :'approve_text' => :'String',
58
+ :'metadata' => :'PromptMetadata',
59
+ :'long_poll' => :'BOOLEAN'
60
+ }
61
+ end
62
+
63
+ # Initializes the object
64
+ # @param [Hash] attributes Model attributes in the form of hash
65
+ def initialize(attributes = {})
66
+ return unless attributes.is_a?(Hash)
67
+
68
+ # convert string to symbol for hash key
69
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
70
+
71
+ if attributes.has_key?(:'body')
72
+ self.body = attributes[:'body']
73
+ end
74
+
75
+ if attributes.has_key?(:'user')
76
+ self.user = attributes[:'user']
77
+ end
78
+
79
+ if attributes.has_key?(:'title')
80
+ self.title = attributes[:'title']
81
+ end
82
+
83
+ if attributes.has_key?(:'reject_text')
84
+ self.reject_text = attributes[:'reject_text']
85
+ end
86
+
87
+ if attributes.has_key?(:'approve_text')
88
+ self.approve_text = attributes[:'approve_text']
89
+ end
90
+
91
+ if attributes.has_key?(:'metadata')
92
+ self.metadata = attributes[:'metadata']
93
+ end
94
+
95
+ if attributes.has_key?(:'long_poll')
96
+ self.long_poll = attributes[:'long_poll']
97
+ end
98
+ end
99
+
100
+ # Show invalid properties with the reasons. Usually used together with valid?
101
+ # @return Array for valid properties with the reasons
102
+ def list_invalid_properties
103
+ invalid_properties = Array.new
104
+ if @body.nil?
105
+ invalid_properties.push('invalid value for "body", body cannot be nil.')
106
+ end
107
+
108
+ if @user.nil?
109
+ invalid_properties.push('invalid value for "user", user cannot be nil.')
110
+ end
111
+
112
+ invalid_properties
113
+ end
114
+
115
+ # Check to see if the all the properties in the model are valid
116
+ # @return true if the model is valid
117
+ def valid?
118
+ return false if @body.nil?
119
+ return false if @user.nil?
120
+ true
121
+ end
122
+
123
+ # Checks equality by comparing each attribute.
124
+ # @param [Object] Object to be compared
125
+ def ==(o)
126
+ return true if self.equal?(o)
127
+ self.class == o.class &&
128
+ body == o.body &&
129
+ user == o.user &&
130
+ title == o.title &&
131
+ reject_text == o.reject_text &&
132
+ approve_text == o.approve_text &&
133
+ metadata == o.metadata &&
134
+ long_poll == o.long_poll
135
+ end
136
+
137
+ # @see the `==` method
138
+ # @param [Object] Object to be compared
139
+ def eql?(o)
140
+ self == o
141
+ end
142
+
143
+ # Calculates hash code according to all attributes.
144
+ # @return [Fixnum] Hash code
145
+ def hash
146
+ [body, user, title, reject_text, approve_text, metadata, long_poll].hash
147
+ end
148
+
149
+ # Builds the object from hash
150
+ # @param [Hash] attributes Model attributes in the form of hash
151
+ # @return [Object] Returns the model itself
152
+ def self.build_from_hash(attributes)
153
+ new.build_from_hash(attributes)
154
+ end
155
+
156
+ # Builds the object from hash
157
+ # @param [Hash] attributes Model attributes in the form of hash
158
+ # @return [Object] Returns the model itself
159
+ def build_from_hash(attributes)
160
+ return nil unless attributes.is_a?(Hash)
161
+ self.class.openapi_types.each_pair do |key, type|
162
+ if type =~ /\AArray<(.*)>/i
163
+ # check to ensure the input is an array given that the attribute
164
+ # is documented as an array but the input is not
165
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
166
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
167
+ end
168
+ elsif !attributes[self.class.attribute_map[key]].nil?
169
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
170
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
171
+ end
172
+
173
+ self
174
+ end
175
+
176
+ # Deserializes the data based on type
177
+ # @param string type Data type
178
+ # @param string value Value to be deserialized
179
+ # @return [Object] Deserialized data
180
+ def _deserialize(type, value)
181
+ case type.to_sym
182
+ when :DateTime
183
+ DateTime.parse(value)
184
+ when :Date
185
+ Date.parse(value)
186
+ when :String
187
+ value.to_s
188
+ when :Integer
189
+ value.to_i
190
+ when :Float
191
+ value.to_f
192
+ when :BOOLEAN
193
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
194
+ true
195
+ else
196
+ false
197
+ end
198
+ when :Object
199
+ # generic object (usually a Hash), return directly
200
+ value
201
+ when /\AArray<(?<inner_type>.+)>\z/
202
+ inner_type = Regexp.last_match[:inner_type]
203
+ value.map { |v| _deserialize(inner_type, v) }
204
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
205
+ k_type = Regexp.last_match[:k_type]
206
+ v_type = Regexp.last_match[:v_type]
207
+ {}.tap do |hash|
208
+ value.each do |k, v|
209
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
210
+ end
211
+ end
212
+ else # model
213
+ ApproveAPISwagger.const_get(type).build_from_hash(value)
214
+ end
215
+ end
216
+
217
+ # Returns the string representation of the object
218
+ # @return [String] String presentation of the object
219
+ def to_s
220
+ to_hash.to_s
221
+ end
222
+
223
+ # to_body is an alias to to_hash (backward compatibility)
224
+ # @return [Hash] Returns the object in the form of hash
225
+ def to_body
226
+ to_hash
227
+ end
228
+
229
+ # Returns the object in the form of hash
230
+ # @return [Hash] Returns the object in the form of hash
231
+ def to_hash
232
+ hash = {}
233
+ self.class.attribute_map.each_pair do |attr, param|
234
+ value = self.send(attr)
235
+ next if value.nil?
236
+ hash[param] = _to_hash(value)
237
+ end
238
+ hash
239
+ end
240
+
241
+ # Outputs non-array value in the form of hash
242
+ # For object, use to_hash. Otherwise, just return the value
243
+ # @param [Object] value Any valid value
244
+ # @return [Hash] Returns the value in the form of hash
245
+ def _to_hash(value)
246
+ if value.is_a?(Array)
247
+ value.compact.map { |v| _to_hash(v) }
248
+ elsif value.is_a?(Hash)
249
+ {}.tap do |hash|
250
+ value.each { |k, v| hash[k] = _to_hash(v) }
251
+ end
252
+ elsif value.respond_to? :to_hash
253
+ value.to_hash
254
+ else
255
+ value
256
+ end
257
+ end
258
+
259
+ end
260
+
261
+ end
@@ -0,0 +1,197 @@
1
+ =begin
2
+ #ApproveAPISwagger
3
+
4
+ #The simple API to request a user's approval on anything via email + sms.
5
+
6
+ OpenAPI spec version: 1.0.0
7
+ Contact: dev@approveapi.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.0.0-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module ApproveAPISwagger
16
+ class Error
17
+ # A human readable API error message.
18
+ attr_accessor :error
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :'error' => :'error'
24
+ }
25
+ end
26
+
27
+ # Attribute type mapping.
28
+ def self.openapi_types
29
+ {
30
+ :'error' => :'String'
31
+ }
32
+ end
33
+
34
+ # Initializes the object
35
+ # @param [Hash] attributes Model attributes in the form of hash
36
+ def initialize(attributes = {})
37
+ return unless attributes.is_a?(Hash)
38
+
39
+ # convert string to symbol for hash key
40
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
41
+
42
+ if attributes.has_key?(:'error')
43
+ self.error = attributes[:'error']
44
+ end
45
+ end
46
+
47
+ # Show invalid properties with the reasons. Usually used together with valid?
48
+ # @return Array for valid properties with the reasons
49
+ def list_invalid_properties
50
+ invalid_properties = Array.new
51
+ if @error.nil?
52
+ invalid_properties.push('invalid value for "error", error cannot be nil.')
53
+ end
54
+
55
+ invalid_properties
56
+ end
57
+
58
+ # Check to see if the all the properties in the model are valid
59
+ # @return true if the model is valid
60
+ def valid?
61
+ return false if @error.nil?
62
+ true
63
+ end
64
+
65
+ # Checks equality by comparing each attribute.
66
+ # @param [Object] Object to be compared
67
+ def ==(o)
68
+ return true if self.equal?(o)
69
+ self.class == o.class &&
70
+ error == o.error
71
+ end
72
+
73
+ # @see the `==` method
74
+ # @param [Object] Object to be compared
75
+ def eql?(o)
76
+ self == o
77
+ end
78
+
79
+ # Calculates hash code according to all attributes.
80
+ # @return [Fixnum] Hash code
81
+ def hash
82
+ [error].hash
83
+ end
84
+
85
+ # Builds the object from hash
86
+ # @param [Hash] attributes Model attributes in the form of hash
87
+ # @return [Object] Returns the model itself
88
+ def self.build_from_hash(attributes)
89
+ new.build_from_hash(attributes)
90
+ end
91
+
92
+ # Builds the object from hash
93
+ # @param [Hash] attributes Model attributes in the form of hash
94
+ # @return [Object] Returns the model itself
95
+ def build_from_hash(attributes)
96
+ return nil unless attributes.is_a?(Hash)
97
+ self.class.openapi_types.each_pair do |key, type|
98
+ if type =~ /\AArray<(.*)>/i
99
+ # check to ensure the input is an array given that the attribute
100
+ # is documented as an array but the input is not
101
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
102
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
103
+ end
104
+ elsif !attributes[self.class.attribute_map[key]].nil?
105
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
106
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
107
+ end
108
+
109
+ self
110
+ end
111
+
112
+ # Deserializes the data based on type
113
+ # @param string type Data type
114
+ # @param string value Value to be deserialized
115
+ # @return [Object] Deserialized data
116
+ def _deserialize(type, value)
117
+ case type.to_sym
118
+ when :DateTime
119
+ DateTime.parse(value)
120
+ when :Date
121
+ Date.parse(value)
122
+ when :String
123
+ value.to_s
124
+ when :Integer
125
+ value.to_i
126
+ when :Float
127
+ value.to_f
128
+ when :BOOLEAN
129
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
130
+ true
131
+ else
132
+ false
133
+ end
134
+ when :Object
135
+ # generic object (usually a Hash), return directly
136
+ value
137
+ when /\AArray<(?<inner_type>.+)>\z/
138
+ inner_type = Regexp.last_match[:inner_type]
139
+ value.map { |v| _deserialize(inner_type, v) }
140
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
141
+ k_type = Regexp.last_match[:k_type]
142
+ v_type = Regexp.last_match[:v_type]
143
+ {}.tap do |hash|
144
+ value.each do |k, v|
145
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
146
+ end
147
+ end
148
+ else # model
149
+ ApproveAPISwagger.const_get(type).build_from_hash(value)
150
+ end
151
+ end
152
+
153
+ # Returns the string representation of the object
154
+ # @return [String] String presentation of the object
155
+ def to_s
156
+ to_hash.to_s
157
+ end
158
+
159
+ # to_body is an alias to to_hash (backward compatibility)
160
+ # @return [Hash] Returns the object in the form of hash
161
+ def to_body
162
+ to_hash
163
+ end
164
+
165
+ # Returns the object in the form of hash
166
+ # @return [Hash] Returns the object in the form of hash
167
+ def to_hash
168
+ hash = {}
169
+ self.class.attribute_map.each_pair do |attr, param|
170
+ value = self.send(attr)
171
+ next if value.nil?
172
+ hash[param] = _to_hash(value)
173
+ end
174
+ hash
175
+ end
176
+
177
+ # Outputs non-array value in the form of hash
178
+ # For object, use to_hash. Otherwise, just return the value
179
+ # @param [Object] value Any valid value
180
+ # @return [Hash] Returns the value in the form of hash
181
+ def _to_hash(value)
182
+ if value.is_a?(Array)
183
+ value.compact.map { |v| _to_hash(v) }
184
+ elsif value.is_a?(Hash)
185
+ {}.tap do |hash|
186
+ value.each { |k, v| hash[k] = _to_hash(v) }
187
+ end
188
+ elsif value.respond_to? :to_hash
189
+ value.to_hash
190
+ else
191
+ value
192
+ end
193
+ end
194
+
195
+ end
196
+
197
+ end