approveapi_swagger 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
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,232 @@
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 PromptMetadata
17
+ # The date/time of the action.
18
+ attr_accessor :time
19
+
20
+ # The operating system initiating the action, i.e. Mac OS X.
21
+ attr_accessor :operating_system
22
+
23
+ # The IP address of the computer initiating the action.
24
+ attr_accessor :ip_address
25
+
26
+ # The physical location, like Oakland, CA, of the action.
27
+ attr_accessor :location
28
+
29
+ # The web browser initiating the action, i.e. Chrome.
30
+ attr_accessor :browser
31
+
32
+ # Attribute mapping from ruby-style variable name to JSON key.
33
+ def self.attribute_map
34
+ {
35
+ :'time' => :'time',
36
+ :'operating_system' => :'operating_system',
37
+ :'ip_address' => :'ip_address',
38
+ :'location' => :'location',
39
+ :'browser' => :'browser'
40
+ }
41
+ end
42
+
43
+ # Attribute type mapping.
44
+ def self.openapi_types
45
+ {
46
+ :'time' => :'String',
47
+ :'operating_system' => :'String',
48
+ :'ip_address' => :'String',
49
+ :'location' => :'String',
50
+ :'browser' => :'String'
51
+ }
52
+ end
53
+
54
+ # Initializes the object
55
+ # @param [Hash] attributes Model attributes in the form of hash
56
+ def initialize(attributes = {})
57
+ return unless attributes.is_a?(Hash)
58
+
59
+ # convert string to symbol for hash key
60
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
61
+
62
+ if attributes.has_key?(:'time')
63
+ self.time = attributes[:'time']
64
+ end
65
+
66
+ if attributes.has_key?(:'operating_system')
67
+ self.operating_system = attributes[:'operating_system']
68
+ end
69
+
70
+ if attributes.has_key?(:'ip_address')
71
+ self.ip_address = attributes[:'ip_address']
72
+ end
73
+
74
+ if attributes.has_key?(:'location')
75
+ self.location = attributes[:'location']
76
+ end
77
+
78
+ if attributes.has_key?(:'browser')
79
+ self.browser = attributes[:'browser']
80
+ end
81
+ end
82
+
83
+ # Show invalid properties with the reasons. Usually used together with valid?
84
+ # @return Array for valid properties with the reasons
85
+ def list_invalid_properties
86
+ invalid_properties = Array.new
87
+ invalid_properties
88
+ end
89
+
90
+ # Check to see if the all the properties in the model are valid
91
+ # @return true if the model is valid
92
+ def valid?
93
+ true
94
+ end
95
+
96
+ # Checks equality by comparing each attribute.
97
+ # @param [Object] Object to be compared
98
+ def ==(o)
99
+ return true if self.equal?(o)
100
+ self.class == o.class &&
101
+ time == o.time &&
102
+ operating_system == o.operating_system &&
103
+ ip_address == o.ip_address &&
104
+ location == o.location &&
105
+ browser == o.browser
106
+ end
107
+
108
+ # @see the `==` method
109
+ # @param [Object] Object to be compared
110
+ def eql?(o)
111
+ self == o
112
+ end
113
+
114
+ # Calculates hash code according to all attributes.
115
+ # @return [Fixnum] Hash code
116
+ def hash
117
+ [time, operating_system, ip_address, location, browser].hash
118
+ end
119
+
120
+ # Builds the object from hash
121
+ # @param [Hash] attributes Model attributes in the form of hash
122
+ # @return [Object] Returns the model itself
123
+ def self.build_from_hash(attributes)
124
+ new.build_from_hash(attributes)
125
+ end
126
+
127
+ # Builds the object from hash
128
+ # @param [Hash] attributes Model attributes in the form of hash
129
+ # @return [Object] Returns the model itself
130
+ def build_from_hash(attributes)
131
+ return nil unless attributes.is_a?(Hash)
132
+ self.class.openapi_types.each_pair do |key, type|
133
+ if type =~ /\AArray<(.*)>/i
134
+ # check to ensure the input is an array given that the attribute
135
+ # is documented as an array but the input is not
136
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
137
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
138
+ end
139
+ elsif !attributes[self.class.attribute_map[key]].nil?
140
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
141
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
142
+ end
143
+
144
+ self
145
+ end
146
+
147
+ # Deserializes the data based on type
148
+ # @param string type Data type
149
+ # @param string value Value to be deserialized
150
+ # @return [Object] Deserialized data
151
+ def _deserialize(type, value)
152
+ case type.to_sym
153
+ when :DateTime
154
+ DateTime.parse(value)
155
+ when :Date
156
+ Date.parse(value)
157
+ when :String
158
+ value.to_s
159
+ when :Integer
160
+ value.to_i
161
+ when :Float
162
+ value.to_f
163
+ when :BOOLEAN
164
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
165
+ true
166
+ else
167
+ false
168
+ end
169
+ when :Object
170
+ # generic object (usually a Hash), return directly
171
+ value
172
+ when /\AArray<(?<inner_type>.+)>\z/
173
+ inner_type = Regexp.last_match[:inner_type]
174
+ value.map { |v| _deserialize(inner_type, v) }
175
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
176
+ k_type = Regexp.last_match[:k_type]
177
+ v_type = Regexp.last_match[:v_type]
178
+ {}.tap do |hash|
179
+ value.each do |k, v|
180
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
181
+ end
182
+ end
183
+ else # model
184
+ ApproveAPISwagger.const_get(type).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
+ next if value.nil?
207
+ hash[param] = _to_hash(value)
208
+ end
209
+ hash
210
+ end
211
+
212
+ # Outputs non-array value in the form of hash
213
+ # For object, use to_hash. Otherwise, just return the value
214
+ # @param [Object] value Any valid value
215
+ # @return [Hash] Returns the value in the form of hash
216
+ def _to_hash(value)
217
+ if value.is_a?(Array)
218
+ value.compact.map { |v| _to_hash(v) }
219
+ elsif value.is_a?(Hash)
220
+ {}.tap do |hash|
221
+ value.each { |k, v| hash[k] = _to_hash(v) }
222
+ end
223
+ elsif value.respond_to? :to_hash
224
+ value.to_hash
225
+ else
226
+ value
227
+ end
228
+ end
229
+
230
+ end
231
+
232
+ 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 PromptStatus
17
+ # Whether the prompt has been answered or not.
18
+ attr_accessor :is_answered
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :'is_answered' => :'is_answered'
24
+ }
25
+ end
26
+
27
+ # Attribute type mapping.
28
+ def self.openapi_types
29
+ {
30
+ :'is_answered' => :'BOOLEAN'
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?(:'is_answered')
43
+ self.is_answered = attributes[:'is_answered']
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 @is_answered.nil?
52
+ invalid_properties.push('invalid value for "is_answered", is_answered 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 @is_answered.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
+ is_answered == o.is_answered
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
+ [is_answered].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
@@ -0,0 +1,15 @@
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
+ module ApproveAPISwagger
14
+ VERSION = '1.0.0'
15
+ end
@@ -0,0 +1,72 @@
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 'spec_helper'
14
+ require 'json'
15
+
16
+ # Unit tests for ApproveAPISwagger::ApproveApi
17
+ # Automatically generated by openapi-generator (https://openapi-generator.tech)
18
+ # Please update as you see appropriate
19
+ describe 'ApproveApi' do
20
+ before do
21
+ # run before each test
22
+ @instance = ApproveAPISwagger::ApproveApi.new
23
+ end
24
+
25
+ after do
26
+ # run after each test
27
+ end
28
+
29
+ describe 'test an instance of ApproveApi' do
30
+ it 'should create an instance of ApproveApi' do
31
+ expect(@instance).to be_instance_of(ApproveAPISwagger::ApproveApi)
32
+ end
33
+ end
34
+
35
+ # unit tests for create_prompt
36
+ # Sending a prompt
37
+ # Creates a prompt and pushes it to the user (sends via email, sms, or other supported protocols).
38
+ # @param create_prompt_request
39
+ # @param [Hash] opts the optional parameters
40
+ # @return [Prompt]
41
+ describe 'create_prompt test' do
42
+ it 'should work' do
43
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
44
+ end
45
+ end
46
+
47
+ # unit tests for get_prompt
48
+ # Retrieve a prompt
49
+ # Retrieve the prompt object with the given ID.
50
+ # @param id The identifier for a pending or completed prompt. This is returned when you create a prompt.
51
+ # @param [Hash] opts the optional parameters
52
+ # @option opts [BOOLEAN] :long_poll If true, the request waits (long-polls) until the user responds to the prompt or more than 10 minutes pass. Defaults to false.
53
+ # @return [Prompt]
54
+ describe 'get_prompt test' do
55
+ it 'should work' do
56
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
57
+ end
58
+ end
59
+
60
+ # unit tests for get_prompt_status
61
+ # Check prompt status
62
+ # Returns whether a prompt has been completed by the user. This request does not require authentication, and so can be used client-side without sharing API credentials.
63
+ # @param id The prompt identifier.
64
+ # @param [Hash] opts the optional parameters
65
+ # @return [PromptStatus]
66
+ describe 'get_prompt_status test' do
67
+ it 'should work' do
68
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
69
+ end
70
+ end
71
+
72
+ end