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,58 @@
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
+ module Sendpost
14
+ class ApiError < StandardError
15
+ attr_reader :code, :response_headers, :response_body
16
+
17
+ # Usage examples:
18
+ # ApiError.new
19
+ # ApiError.new("message")
20
+ # ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
21
+ # ApiError.new(:code => 404, :message => "Not Found")
22
+ def initialize(arg = nil)
23
+ if arg.is_a? Hash
24
+ if arg.key?(:message) || arg.key?('message')
25
+ super(arg[:message] || arg['message'])
26
+ else
27
+ super arg
28
+ end
29
+
30
+ arg.each do |k, v|
31
+ instance_variable_set "@#{k}", v
32
+ end
33
+ else
34
+ super arg
35
+ @message = arg
36
+ end
37
+ end
38
+
39
+ # Override to_s to display a friendly error message
40
+ def to_s
41
+ message
42
+ end
43
+
44
+ def message
45
+ if @message.nil?
46
+ msg = "Error message: the server returns an error"
47
+ else
48
+ msg = @message
49
+ end
50
+
51
+ msg += "\nHTTP status code: #{code}" if code
52
+ msg += "\nResponse headers: #{response_headers}" if response_headers
53
+ msg += "\nResponse body: #{response_body}" if response_body
54
+
55
+ msg
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,288 @@
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
+ module Sendpost
14
+ class Configuration
15
+ # Defines url scheme
16
+ attr_accessor :scheme
17
+
18
+ # Defines url host
19
+ attr_accessor :host
20
+
21
+ # Defines url base path
22
+ attr_accessor :base_path
23
+
24
+ # Define server configuration index
25
+ attr_accessor :server_index
26
+
27
+ # Define server operation configuration index
28
+ attr_accessor :server_operation_index
29
+
30
+ # Default server variables
31
+ attr_accessor :server_variables
32
+
33
+ # Default server operation variables
34
+ attr_accessor :server_operation_variables
35
+
36
+ # Defines API keys used with API Key authentications.
37
+ #
38
+ # @return [Hash] key: parameter name, value: parameter value (API key)
39
+ #
40
+ # @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
41
+ # config.api_key['api_key'] = 'xxx'
42
+ attr_accessor :api_key
43
+
44
+ # Defines API key prefixes used with API Key authentications.
45
+ #
46
+ # @return [Hash] key: parameter name, value: API key prefix
47
+ #
48
+ # @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
49
+ # config.api_key_prefix['api_key'] = 'Token'
50
+ attr_accessor :api_key_prefix
51
+
52
+ # Defines the username used with HTTP basic authentication.
53
+ #
54
+ # @return [String]
55
+ attr_accessor :username
56
+
57
+ # Defines the password used with HTTP basic authentication.
58
+ #
59
+ # @return [String]
60
+ attr_accessor :password
61
+
62
+ # Defines the access token (Bearer) used with OAuth2.
63
+ attr_accessor :access_token
64
+
65
+ # Defines a Proc used to fetch or refresh access tokens (Bearer) used with OAuth2.
66
+ # Overrides the access_token if set
67
+ # @return [Proc]
68
+ attr_accessor :access_token_getter
69
+
70
+ # Set this to return data as binary instead of downloading a temp file. When enabled (set to true)
71
+ # HTTP responses with return type `File` will be returned as a stream of binary data.
72
+ # Default to false.
73
+ attr_accessor :return_binary_data
74
+
75
+ # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
76
+ # details will be logged with `logger.debug` (see the `logger` attribute).
77
+ # Default to false.
78
+ #
79
+ # @return [true, false]
80
+ attr_accessor :debugging
81
+
82
+ # Defines the logger used for debugging.
83
+ # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
84
+ #
85
+ # @return [#debug]
86
+ attr_accessor :logger
87
+
88
+ # Defines the temporary folder to store downloaded files
89
+ # (for API endpoints that have file response).
90
+ # Default to use `Tempfile`.
91
+ #
92
+ # @return [String]
93
+ attr_accessor :temp_folder_path
94
+
95
+ # The time limit for HTTP request in seconds.
96
+ # Default to 0 (never times out).
97
+ attr_accessor :timeout
98
+
99
+ # Set this to false to skip client side validation in the operation.
100
+ # Default to true.
101
+ # @return [true, false]
102
+ attr_accessor :client_side_validation
103
+
104
+ ### TLS/SSL setting
105
+ # Set this to false to skip verifying SSL certificate when calling API from https server.
106
+ # Default to true.
107
+ #
108
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
109
+ #
110
+ # @return [true, false]
111
+ attr_accessor :verify_ssl
112
+
113
+ ### TLS/SSL setting
114
+ # Set this to false to skip verifying SSL host name
115
+ # Default to true.
116
+ #
117
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
118
+ #
119
+ # @return [true, false]
120
+ attr_accessor :verify_ssl_host
121
+
122
+ ### TLS/SSL setting
123
+ # Set this to customize the certificate file to verify the peer.
124
+ #
125
+ # @return [String] the path to the certificate file
126
+ #
127
+ # @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
128
+ # https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
129
+ attr_accessor :ssl_ca_cert
130
+
131
+ ### TLS/SSL setting
132
+ # Client certificate file (for client certificate)
133
+ attr_accessor :cert_file
134
+
135
+ ### TLS/SSL setting
136
+ # Client private key file (for client certificate)
137
+ attr_accessor :key_file
138
+
139
+ # Set this to customize parameters encoding of array parameter with multi collectionFormat.
140
+ # Default to nil.
141
+ #
142
+ # @see The params_encoding option of Ethon. Related source code:
143
+ # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
144
+ attr_accessor :params_encoding
145
+
146
+
147
+ attr_accessor :inject_format
148
+
149
+ attr_accessor :force_ending_format
150
+
151
+ def initialize
152
+ @scheme = 'https'
153
+ @host = 'api.sendpost.io'
154
+ @base_path = '/api/v1'
155
+ @server_index = 0
156
+ @server_operation_index = {}
157
+ @server_variables = {}
158
+ @server_operation_variables = {}
159
+ @api_key = {}
160
+ @api_key_prefix = {}
161
+ @client_side_validation = true
162
+ @verify_ssl = true
163
+ @verify_ssl_host = true
164
+ @cert_file = nil
165
+ @key_file = nil
166
+ @timeout = 0
167
+ @params_encoding = nil
168
+ @debugging = false
169
+ @inject_format = false
170
+ @force_ending_format = false
171
+ @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
172
+
173
+ yield(self) if block_given?
174
+ end
175
+
176
+ # The default Configuration object.
177
+ def self.default
178
+ @@default ||= Configuration.new
179
+ end
180
+
181
+ def configure
182
+ yield(self) if block_given?
183
+ end
184
+
185
+ def scheme=(scheme)
186
+ # remove :// from scheme
187
+ @scheme = scheme.sub(/:\/\//, '')
188
+ end
189
+
190
+ def host=(host)
191
+ # remove http(s):// and anything after a slash
192
+ @host = host.sub(/https?:\/\//, '').split('/').first
193
+ end
194
+
195
+ def base_path=(base_path)
196
+ # Add leading and trailing slashes to base_path
197
+ @base_path = "/#{base_path}".gsub(/\/+/, '/')
198
+ @base_path = '' if @base_path == '/'
199
+ end
200
+
201
+ # Returns base URL for specified operation based on server settings
202
+ def base_url(operation = nil)
203
+ index = server_operation_index[operation]
204
+ return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if index == nil
205
+
206
+ server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
207
+ end
208
+
209
+ # Gets API key (with prefix if set).
210
+ # @param [String] param_name the parameter name of API key auth
211
+ def api_key_with_prefix(param_name, param_alias = nil)
212
+ key = @api_key[param_name]
213
+ key = @api_key.fetch(param_alias, key) unless param_alias.nil?
214
+ if @api_key_prefix[param_name]
215
+ "#{@api_key_prefix[param_name]} #{key}"
216
+ else
217
+ key
218
+ end
219
+ end
220
+
221
+ # Gets access_token using access_token_getter or uses the static access_token
222
+ def access_token_with_refresh
223
+ return access_token if access_token_getter.nil?
224
+ access_token_getter.call
225
+ end
226
+
227
+ # Gets Basic Auth token string
228
+ def basic_auth_token
229
+ 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
230
+ end
231
+
232
+ # Returns Auth Settings hash for api client.
233
+ def auth_settings
234
+ {
235
+ }
236
+ end
237
+
238
+ # Returns an array of Server setting
239
+ def server_settings
240
+ [
241
+ {
242
+ url: "https://api.sendpost.io/api/v1",
243
+ description: "No description provided",
244
+ }
245
+ ]
246
+ end
247
+
248
+ def operation_server_settings
249
+ {
250
+ }
251
+ end
252
+
253
+ # Returns URL based on server settings
254
+ #
255
+ # @param index array index of the server settings
256
+ # @param variables hash of variable and the corresponding value
257
+ def server_url(index, variables = {}, servers = nil)
258
+ servers = server_settings if servers == nil
259
+
260
+ # check array index out of bound
261
+ if (index < 0 || index >= servers.size)
262
+ fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
263
+ end
264
+
265
+ server = servers[index]
266
+ url = server[:url]
267
+
268
+ return url unless server.key? :variables
269
+
270
+ # go through variable and assign a value
271
+ server[:variables].each do |name, variable|
272
+ if variables.key?(name)
273
+ if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
274
+ url.gsub! "{" + name.to_s + "}", variables[name]
275
+ else
276
+ fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
277
+ end
278
+ else
279
+ # use default value
280
+ url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
281
+ end
282
+ end
283
+
284
+ url
285
+ end
286
+
287
+ end
288
+ end
@@ -0,0 +1,228 @@
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 Attachment
18
+ attr_accessor :content
19
+
20
+ attr_accessor :filename
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'content' => :'content',
26
+ :'filename' => :'filename'
27
+ }
28
+ end
29
+
30
+ # Returns all the JSON keys this model knows about
31
+ def self.acceptable_attributes
32
+ attribute_map.values
33
+ end
34
+
35
+ # Attribute type mapping.
36
+ def self.openapi_types
37
+ {
38
+ :'content' => :'String',
39
+ :'filename' => :'String'
40
+ }
41
+ end
42
+
43
+ # List of attributes with nullable: true
44
+ def self.openapi_nullable
45
+ Set.new([
46
+ ])
47
+ end
48
+
49
+ # Initializes the object
50
+ # @param [Hash] attributes Model attributes in the form of hash
51
+ def initialize(attributes = {})
52
+ if (!attributes.is_a?(Hash))
53
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Sendpost::Attachment` initialize method"
54
+ end
55
+
56
+ # check to see if the attribute exists and convert string to symbol for hash key
57
+ attributes = attributes.each_with_object({}) { |(k, v), h|
58
+ if (!self.class.attribute_map.key?(k.to_sym))
59
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Sendpost::Attachment`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
60
+ end
61
+ h[k.to_sym] = v
62
+ }
63
+
64
+ if attributes.key?(:'content')
65
+ self.content = attributes[:'content']
66
+ end
67
+
68
+ if attributes.key?(:'filename')
69
+ self.filename = attributes[:'filename']
70
+ end
71
+ end
72
+
73
+ # Show invalid properties with the reasons. Usually used together with valid?
74
+ # @return Array for valid properties with the reasons
75
+ def list_invalid_properties
76
+ invalid_properties = Array.new
77
+ invalid_properties
78
+ end
79
+
80
+ # Check to see if the all the properties in the model are valid
81
+ # @return true if the model is valid
82
+ def valid?
83
+ true
84
+ end
85
+
86
+ # Checks equality by comparing each attribute.
87
+ # @param [Object] Object to be compared
88
+ def ==(o)
89
+ return true if self.equal?(o)
90
+ self.class == o.class &&
91
+ content == o.content &&
92
+ filename == o.filename
93
+ end
94
+
95
+ # @see the `==` method
96
+ # @param [Object] Object to be compared
97
+ def eql?(o)
98
+ self == o
99
+ end
100
+
101
+ # Calculates hash code according to all attributes.
102
+ # @return [Integer] Hash code
103
+ def hash
104
+ [content, filename].hash
105
+ end
106
+
107
+ # Builds the object from hash
108
+ # @param [Hash] attributes Model attributes in the form of hash
109
+ # @return [Object] Returns the model itself
110
+ def self.build_from_hash(attributes)
111
+ new.build_from_hash(attributes)
112
+ end
113
+
114
+ # Builds the object from hash
115
+ # @param [Hash] attributes Model attributes in the form of hash
116
+ # @return [Object] Returns the model itself
117
+ def build_from_hash(attributes)
118
+ return nil unless attributes.is_a?(Hash)
119
+ attributes = attributes.transform_keys(&:to_sym)
120
+ self.class.openapi_types.each_pair do |key, type|
121
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
122
+ self.send("#{key}=", nil)
123
+ elsif type =~ /\AArray<(.*)>/i
124
+ # check to ensure the input is an array given that the attribute
125
+ # is documented as an array but the input is not
126
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
127
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
128
+ end
129
+ elsif !attributes[self.class.attribute_map[key]].nil?
130
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
131
+ end
132
+ end
133
+
134
+ self
135
+ end
136
+
137
+ # Deserializes the data based on type
138
+ # @param string type Data type
139
+ # @param string value Value to be deserialized
140
+ # @return [Object] Deserialized data
141
+ def _deserialize(type, value)
142
+ case type.to_sym
143
+ when :Time
144
+ Time.parse(value)
145
+ when :Date
146
+ Date.parse(value)
147
+ when :String
148
+ value.to_s
149
+ when :Integer
150
+ value.to_i
151
+ when :Float
152
+ value.to_f
153
+ when :Boolean
154
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
155
+ true
156
+ else
157
+ false
158
+ end
159
+ when :Object
160
+ # generic object (usually a Hash), return directly
161
+ value
162
+ when /\AArray<(?<inner_type>.+)>\z/
163
+ inner_type = Regexp.last_match[:inner_type]
164
+ value.map { |v| _deserialize(inner_type, v) }
165
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
166
+ k_type = Regexp.last_match[:k_type]
167
+ v_type = Regexp.last_match[:v_type]
168
+ {}.tap do |hash|
169
+ value.each do |k, v|
170
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
171
+ end
172
+ end
173
+ else # model
174
+ # models (e.g. Pet) or oneOf
175
+ klass = Sendpost.const_get(type)
176
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
177
+ end
178
+ end
179
+
180
+ # Returns the string representation of the object
181
+ # @return [String] String presentation of the object
182
+ def to_s
183
+ to_hash.to_s
184
+ end
185
+
186
+ # to_body is an alias to to_hash (backward compatibility)
187
+ # @return [Hash] Returns the object in the form of hash
188
+ def to_body
189
+ to_hash
190
+ end
191
+
192
+ # Returns the object in the form of hash
193
+ # @return [Hash] Returns the object in the form of hash
194
+ def to_hash
195
+ hash = {}
196
+ self.class.attribute_map.each_pair do |attr, param|
197
+ value = self.send(attr)
198
+ if value.nil?
199
+ is_nullable = self.class.openapi_nullable.include?(attr)
200
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
201
+ end
202
+
203
+ hash[param] = _to_hash(value)
204
+ end
205
+ hash
206
+ end
207
+
208
+ # Outputs non-array value in the form of hash
209
+ # For object, use to_hash. Otherwise, just return the value
210
+ # @param [Object] value Any valid value
211
+ # @return [Hash] Returns the value in the form of hash
212
+ def _to_hash(value)
213
+ if value.is_a?(Array)
214
+ value.compact.map { |v| _to_hash(v) }
215
+ elsif value.is_a?(Hash)
216
+ {}.tap do |hash|
217
+ value.each { |k, v| hash[k] = _to_hash(v) }
218
+ end
219
+ elsif value.respond_to? :to_hash
220
+ value.to_hash
221
+ else
222
+ value
223
+ end
224
+ end
225
+
226
+ end
227
+
228
+ end