sendpost_ruby_sdk 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +79 -0
  4. data/Rakefile +10 -0
  5. data/config-ruby.json +11 -0
  6. data/docs/Attachment.md +20 -0
  7. data/docs/City.md +26 -0
  8. data/docs/CopyTo.md +22 -0
  9. data/docs/Device.md +18 -0
  10. data/docs/EmailApi.md +145 -0
  11. data/docs/EmailMessage.md +46 -0
  12. data/docs/EmailResponse.md +26 -0
  13. data/docs/EventMetadata.md +30 -0
  14. data/docs/From.md +20 -0
  15. data/docs/Os.md +26 -0
  16. data/docs/QEmailMessage.md +70 -0
  17. data/docs/QEvent.md +42 -0
  18. data/docs/ReplyTo.md +20 -0
  19. data/docs/To.md +26 -0
  20. data/docs/UserAgent.md +24 -0
  21. data/docs/WebhookEvent.md +20 -0
  22. data/generate-libs.bash +1 -0
  23. data/git_push.sh +57 -0
  24. data/lib/sendpost_ruby_sdk/api/email_api.rb +160 -0
  25. data/lib/sendpost_ruby_sdk/api_client.rb +391 -0
  26. data/lib/sendpost_ruby_sdk/api_error.rb +58 -0
  27. data/lib/sendpost_ruby_sdk/configuration.rb +288 -0
  28. data/lib/sendpost_ruby_sdk/models/attachment.rb +228 -0
  29. data/lib/sendpost_ruby_sdk/models/city.rb +255 -0
  30. data/lib/sendpost_ruby_sdk/models/copy_to.rb +237 -0
  31. data/lib/sendpost_ruby_sdk/models/device.rb +219 -0
  32. data/lib/sendpost_ruby_sdk/models/email_message.rb +351 -0
  33. data/lib/sendpost_ruby_sdk/models/email_response.rb +255 -0
  34. data/lib/sendpost_ruby_sdk/models/event_metadata.rb +273 -0
  35. data/lib/sendpost_ruby_sdk/models/from.rb +228 -0
  36. data/lib/sendpost_ruby_sdk/models/os.rb +255 -0
  37. data/lib/sendpost_ruby_sdk/models/q_email_message.rb +461 -0
  38. data/lib/sendpost_ruby_sdk/models/q_event.rb +329 -0
  39. data/lib/sendpost_ruby_sdk/models/reply_to.rb +228 -0
  40. data/lib/sendpost_ruby_sdk/models/to.rb +259 -0
  41. data/lib/sendpost_ruby_sdk/models/user_agent.rb +246 -0
  42. data/lib/sendpost_ruby_sdk/models/webhook_event.rb +228 -0
  43. data/lib/sendpost_ruby_sdk/version.rb +15 -0
  44. data/lib/sendpost_ruby_sdk.rb +55 -0
  45. data/sendpost.yaml +438 -0
  46. data/sendpost_ruby_sdk.gemspec +38 -0
  47. data/spec/api/email_api_spec.rb +59 -0
  48. data/spec/api_client_spec.rb +228 -0
  49. data/spec/configuration_spec.rb +42 -0
  50. data/spec/models/attachment_spec.rb +40 -0
  51. data/spec/models/city_spec.rb +58 -0
  52. data/spec/models/copy_to_spec.rb +46 -0
  53. data/spec/models/device_spec.rb +34 -0
  54. data/spec/models/email_message_spec.rb +118 -0
  55. data/spec/models/email_response_spec.rb +58 -0
  56. data/spec/models/event_metadata_spec.rb +70 -0
  57. data/spec/models/from_spec.rb +40 -0
  58. data/spec/models/os_spec.rb +58 -0
  59. data/spec/models/q_email_message_spec.rb +190 -0
  60. data/spec/models/q_event_spec.rb +106 -0
  61. data/spec/models/reply_to_spec.rb +40 -0
  62. data/spec/models/to_spec.rb +58 -0
  63. data/spec/models/user_agent_spec.rb +52 -0
  64. data/spec/models/webhook_event_spec.rb +40 -0
  65. data/spec/spec_helper.rb +111 -0
  66. metadata +168 -0
@@ -0,0 +1,259 @@
1
+ =begin
2
+ #SendPost API
3
+
4
+ #Email API and SMTP relay to not just send and measure email sending, but also alert and optimise. We provide you with tools, expertise and support needed to reliably deliver emails to your customers inboxes on time, every time.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: hello@sendpost.io
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.6.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Sendpost
17
+ class To
18
+ attr_accessor :name
19
+
20
+ attr_accessor :email
21
+
22
+ attr_accessor :cc
23
+
24
+ attr_accessor :bcc
25
+
26
+ attr_accessor :custom_fields
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'name' => :'name',
32
+ :'email' => :'email',
33
+ :'cc' => :'cc',
34
+ :'bcc' => :'bcc',
35
+ :'custom_fields' => :'customFields'
36
+ }
37
+ end
38
+
39
+ # Returns all the JSON keys this model knows about
40
+ def self.acceptable_attributes
41
+ attribute_map.values
42
+ end
43
+
44
+ # Attribute type mapping.
45
+ def self.openapi_types
46
+ {
47
+ :'name' => :'String',
48
+ :'email' => :'String',
49
+ :'cc' => :'Array<CopyTo>',
50
+ :'bcc' => :'Array<CopyTo>',
51
+ :'custom_fields' => :'Object'
52
+ }
53
+ end
54
+
55
+ # List of attributes with nullable: true
56
+ def self.openapi_nullable
57
+ Set.new([
58
+ ])
59
+ end
60
+
61
+ # Initializes the object
62
+ # @param [Hash] attributes Model attributes in the form of hash
63
+ def initialize(attributes = {})
64
+ if (!attributes.is_a?(Hash))
65
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Sendpost::To` initialize method"
66
+ end
67
+
68
+ # check to see if the attribute exists and convert string to symbol for hash key
69
+ attributes = attributes.each_with_object({}) { |(k, v), h|
70
+ if (!self.class.attribute_map.key?(k.to_sym))
71
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Sendpost::To`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
72
+ end
73
+ h[k.to_sym] = v
74
+ }
75
+
76
+ if attributes.key?(:'name')
77
+ self.name = attributes[:'name']
78
+ end
79
+
80
+ if attributes.key?(:'email')
81
+ self.email = attributes[:'email']
82
+ end
83
+
84
+ if attributes.key?(:'cc')
85
+ if (value = attributes[:'cc']).is_a?(Array)
86
+ self.cc = value
87
+ end
88
+ end
89
+
90
+ if attributes.key?(:'bcc')
91
+ if (value = attributes[:'bcc']).is_a?(Array)
92
+ self.bcc = value
93
+ end
94
+ end
95
+
96
+ if attributes.key?(:'custom_fields')
97
+ self.custom_fields = attributes[:'custom_fields']
98
+ end
99
+ end
100
+
101
+ # Show invalid properties with the reasons. Usually used together with valid?
102
+ # @return Array for valid properties with the reasons
103
+ def list_invalid_properties
104
+ invalid_properties = Array.new
105
+ invalid_properties
106
+ end
107
+
108
+ # Check to see if the all the properties in the model are valid
109
+ # @return true if the model is valid
110
+ def valid?
111
+ true
112
+ end
113
+
114
+ # Checks equality by comparing each attribute.
115
+ # @param [Object] Object to be compared
116
+ def ==(o)
117
+ return true if self.equal?(o)
118
+ self.class == o.class &&
119
+ name == o.name &&
120
+ email == o.email &&
121
+ cc == o.cc &&
122
+ bcc == o.bcc &&
123
+ custom_fields == o.custom_fields
124
+ end
125
+
126
+ # @see the `==` method
127
+ # @param [Object] Object to be compared
128
+ def eql?(o)
129
+ self == o
130
+ end
131
+
132
+ # Calculates hash code according to all attributes.
133
+ # @return [Integer] Hash code
134
+ def hash
135
+ [name, email, cc, bcc, custom_fields].hash
136
+ end
137
+
138
+ # Builds the object from hash
139
+ # @param [Hash] attributes Model attributes in the form of hash
140
+ # @return [Object] Returns the model itself
141
+ def self.build_from_hash(attributes)
142
+ new.build_from_hash(attributes)
143
+ end
144
+
145
+ # Builds the object from hash
146
+ # @param [Hash] attributes Model attributes in the form of hash
147
+ # @return [Object] Returns the model itself
148
+ def build_from_hash(attributes)
149
+ return nil unless attributes.is_a?(Hash)
150
+ attributes = attributes.transform_keys(&:to_sym)
151
+ self.class.openapi_types.each_pair do |key, type|
152
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
153
+ self.send("#{key}=", nil)
154
+ elsif type =~ /\AArray<(.*)>/i
155
+ # check to ensure the input is an array given that the attribute
156
+ # is documented as an array but the input is not
157
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
158
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
159
+ end
160
+ elsif !attributes[self.class.attribute_map[key]].nil?
161
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
162
+ end
163
+ end
164
+
165
+ self
166
+ end
167
+
168
+ # Deserializes the data based on type
169
+ # @param string type Data type
170
+ # @param string value Value to be deserialized
171
+ # @return [Object] Deserialized data
172
+ def _deserialize(type, value)
173
+ case type.to_sym
174
+ when :Time
175
+ Time.parse(value)
176
+ when :Date
177
+ Date.parse(value)
178
+ when :String
179
+ value.to_s
180
+ when :Integer
181
+ value.to_i
182
+ when :Float
183
+ value.to_f
184
+ when :Boolean
185
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
186
+ true
187
+ else
188
+ false
189
+ end
190
+ when :Object
191
+ # generic object (usually a Hash), return directly
192
+ value
193
+ when /\AArray<(?<inner_type>.+)>\z/
194
+ inner_type = Regexp.last_match[:inner_type]
195
+ value.map { |v| _deserialize(inner_type, v) }
196
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
197
+ k_type = Regexp.last_match[:k_type]
198
+ v_type = Regexp.last_match[:v_type]
199
+ {}.tap do |hash|
200
+ value.each do |k, v|
201
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
202
+ end
203
+ end
204
+ else # model
205
+ # models (e.g. Pet) or oneOf
206
+ klass = Sendpost.const_get(type)
207
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
208
+ end
209
+ end
210
+
211
+ # Returns the string representation of the object
212
+ # @return [String] String presentation of the object
213
+ def to_s
214
+ to_hash.to_s
215
+ end
216
+
217
+ # to_body is an alias to to_hash (backward compatibility)
218
+ # @return [Hash] Returns the object in the form of hash
219
+ def to_body
220
+ to_hash
221
+ end
222
+
223
+ # Returns the object in the form of hash
224
+ # @return [Hash] Returns the object in the form of hash
225
+ def to_hash
226
+ hash = {}
227
+ self.class.attribute_map.each_pair do |attr, param|
228
+ value = self.send(attr)
229
+ if value.nil?
230
+ is_nullable = self.class.openapi_nullable.include?(attr)
231
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
232
+ end
233
+
234
+ hash[param] = _to_hash(value)
235
+ end
236
+ hash
237
+ end
238
+
239
+ # Outputs non-array value in the form of hash
240
+ # For object, use to_hash. Otherwise, just return the value
241
+ # @param [Object] value Any valid value
242
+ # @return [Hash] Returns the value in the form of hash
243
+ def _to_hash(value)
244
+ if value.is_a?(Array)
245
+ value.compact.map { |v| _to_hash(v) }
246
+ elsif value.is_a?(Hash)
247
+ {}.tap do |hash|
248
+ value.each { |k, v| hash[k] = _to_hash(v) }
249
+ end
250
+ elsif value.respond_to? :to_hash
251
+ value.to_hash
252
+ else
253
+ value
254
+ end
255
+ end
256
+
257
+ end
258
+
259
+ end
@@ -0,0 +1,246 @@
1
+ =begin
2
+ #SendPost API
3
+
4
+ #Email API and SMTP relay to not just send and measure email sending, but also alert and optimise. We provide you with tools, expertise and support needed to reliably deliver emails to your customers inboxes on time, every time.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: hello@sendpost.io
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.6.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Sendpost
17
+ class UserAgent
18
+ attr_accessor :family
19
+
20
+ attr_accessor :major
21
+
22
+ attr_accessor :minor
23
+
24
+ attr_accessor :patch
25
+
26
+ # Attribute mapping from ruby-style variable name to JSON key.
27
+ def self.attribute_map
28
+ {
29
+ :'family' => :'Family',
30
+ :'major' => :'Major',
31
+ :'minor' => :'Minor',
32
+ :'patch' => :'Patch'
33
+ }
34
+ end
35
+
36
+ # Returns all the JSON keys this model knows about
37
+ def self.acceptable_attributes
38
+ attribute_map.values
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.openapi_types
43
+ {
44
+ :'family' => :'String',
45
+ :'major' => :'String',
46
+ :'minor' => :'String',
47
+ :'patch' => :'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 `Sendpost::UserAgent` initialize method"
62
+ end
63
+
64
+ # check to see if the attribute exists and convert string to symbol for hash key
65
+ attributes = attributes.each_with_object({}) { |(k, v), h|
66
+ if (!self.class.attribute_map.key?(k.to_sym))
67
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Sendpost::UserAgent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
68
+ end
69
+ h[k.to_sym] = v
70
+ }
71
+
72
+ if attributes.key?(:'family')
73
+ self.family = attributes[:'family']
74
+ end
75
+
76
+ if attributes.key?(:'major')
77
+ self.major = attributes[:'major']
78
+ end
79
+
80
+ if attributes.key?(:'minor')
81
+ self.minor = attributes[:'minor']
82
+ end
83
+
84
+ if attributes.key?(:'patch')
85
+ self.patch = attributes[:'patch']
86
+ end
87
+ end
88
+
89
+ # Show invalid properties with the reasons. Usually used together with valid?
90
+ # @return Array for valid properties with the reasons
91
+ def list_invalid_properties
92
+ invalid_properties = Array.new
93
+ invalid_properties
94
+ end
95
+
96
+ # Check to see if the all the properties in the model are valid
97
+ # @return true if the model is valid
98
+ def valid?
99
+ true
100
+ end
101
+
102
+ # Checks equality by comparing each attribute.
103
+ # @param [Object] Object to be compared
104
+ def ==(o)
105
+ return true if self.equal?(o)
106
+ self.class == o.class &&
107
+ family == o.family &&
108
+ major == o.major &&
109
+ minor == o.minor &&
110
+ patch == o.patch
111
+ end
112
+
113
+ # @see the `==` method
114
+ # @param [Object] Object to be compared
115
+ def eql?(o)
116
+ self == o
117
+ end
118
+
119
+ # Calculates hash code according to all attributes.
120
+ # @return [Integer] Hash code
121
+ def hash
122
+ [family, major, minor, patch].hash
123
+ end
124
+
125
+ # Builds the object from hash
126
+ # @param [Hash] attributes Model attributes in the form of hash
127
+ # @return [Object] Returns the model itself
128
+ def self.build_from_hash(attributes)
129
+ new.build_from_hash(attributes)
130
+ end
131
+
132
+ # Builds the object from hash
133
+ # @param [Hash] attributes Model attributes in the form of hash
134
+ # @return [Object] Returns the model itself
135
+ def build_from_hash(attributes)
136
+ return nil unless attributes.is_a?(Hash)
137
+ attributes = attributes.transform_keys(&:to_sym)
138
+ self.class.openapi_types.each_pair do |key, type|
139
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
140
+ self.send("#{key}=", nil)
141
+ elsif type =~ /\AArray<(.*)>/i
142
+ # check to ensure the input is an array given that the attribute
143
+ # is documented as an array but the input is not
144
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
145
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
146
+ end
147
+ elsif !attributes[self.class.attribute_map[key]].nil?
148
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
149
+ end
150
+ end
151
+
152
+ self
153
+ end
154
+
155
+ # Deserializes the data based on type
156
+ # @param string type Data type
157
+ # @param string value Value to be deserialized
158
+ # @return [Object] Deserialized data
159
+ def _deserialize(type, value)
160
+ case type.to_sym
161
+ when :Time
162
+ Time.parse(value)
163
+ when :Date
164
+ Date.parse(value)
165
+ when :String
166
+ value.to_s
167
+ when :Integer
168
+ value.to_i
169
+ when :Float
170
+ value.to_f
171
+ when :Boolean
172
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
173
+ true
174
+ else
175
+ false
176
+ end
177
+ when :Object
178
+ # generic object (usually a Hash), return directly
179
+ value
180
+ when /\AArray<(?<inner_type>.+)>\z/
181
+ inner_type = Regexp.last_match[:inner_type]
182
+ value.map { |v| _deserialize(inner_type, v) }
183
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
184
+ k_type = Regexp.last_match[:k_type]
185
+ v_type = Regexp.last_match[:v_type]
186
+ {}.tap do |hash|
187
+ value.each do |k, v|
188
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
189
+ end
190
+ end
191
+ else # model
192
+ # models (e.g. Pet) or oneOf
193
+ klass = Sendpost.const_get(type)
194
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
195
+ end
196
+ end
197
+
198
+ # Returns the string representation of the object
199
+ # @return [String] String presentation of the object
200
+ def to_s
201
+ to_hash.to_s
202
+ end
203
+
204
+ # to_body is an alias to to_hash (backward compatibility)
205
+ # @return [Hash] Returns the object in the form of hash
206
+ def to_body
207
+ to_hash
208
+ end
209
+
210
+ # Returns the object in the form of hash
211
+ # @return [Hash] Returns the object in the form of hash
212
+ def to_hash
213
+ hash = {}
214
+ self.class.attribute_map.each_pair do |attr, param|
215
+ value = self.send(attr)
216
+ if value.nil?
217
+ is_nullable = self.class.openapi_nullable.include?(attr)
218
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
219
+ end
220
+
221
+ hash[param] = _to_hash(value)
222
+ end
223
+ hash
224
+ end
225
+
226
+ # Outputs non-array value in the form of hash
227
+ # For object, use to_hash. Otherwise, just return the value
228
+ # @param [Object] value Any valid value
229
+ # @return [Hash] Returns the value in the form of hash
230
+ def _to_hash(value)
231
+ if value.is_a?(Array)
232
+ value.compact.map { |v| _to_hash(v) }
233
+ elsif value.is_a?(Hash)
234
+ {}.tap do |hash|
235
+ value.each { |k, v| hash[k] = _to_hash(v) }
236
+ end
237
+ elsif value.respond_to? :to_hash
238
+ value.to_hash
239
+ else
240
+ value
241
+ end
242
+ end
243
+
244
+ end
245
+
246
+ end