sendpost_ruby_sdk 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,305 @@
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 'cgi'
14
+
15
+ module Sendpost
16
+ class SuppressionApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+ # Count Total Suppressions
23
+ # @param x_sub_account_api_key [String] Sub-Account API Key
24
+ # @param [Hash] opts the optional parameters
25
+ # @option opts [String] :from from date
26
+ # @option opts [String] :to to date
27
+ # @return [CountStat]
28
+ def count(x_sub_account_api_key, opts = {})
29
+ data, _status_code, _headers = count_with_http_info(x_sub_account_api_key, opts)
30
+ data
31
+ end
32
+
33
+ # Count Total Suppressions
34
+ # @param x_sub_account_api_key [String] Sub-Account API Key
35
+ # @param [Hash] opts the optional parameters
36
+ # @option opts [String] :from from date
37
+ # @option opts [String] :to to date
38
+ # @return [Array<(CountStat, Integer, Hash)>] CountStat data, response status code and response headers
39
+ def count_with_http_info(x_sub_account_api_key, opts = {})
40
+ if @api_client.config.debugging
41
+ @api_client.config.logger.debug 'Calling API: SuppressionApi.count ...'
42
+ end
43
+ # verify the required parameter 'x_sub_account_api_key' is set
44
+ if @api_client.config.client_side_validation && x_sub_account_api_key.nil?
45
+ fail ArgumentError, "Missing the required parameter 'x_sub_account_api_key' when calling SuppressionApi.count"
46
+ end
47
+ # resource path
48
+ local_var_path = '/subaccount/suppression/count'
49
+
50
+ # query parameters
51
+ query_params = opts[:query_params] || {}
52
+ query_params[:'from'] = opts[:'from'] if !opts[:'from'].nil?
53
+ query_params[:'to'] = opts[:'to'] if !opts[:'to'].nil?
54
+
55
+ # header parameters
56
+ header_params = opts[:header_params] || {}
57
+ # HTTP header 'Accept' (if needed)
58
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
59
+ header_params[:'X-SubAccount-ApiKey'] = x_sub_account_api_key
60
+
61
+ # form parameters
62
+ form_params = opts[:form_params] || {}
63
+
64
+ # http body (model)
65
+ post_body = opts[:debug_body]
66
+
67
+ # return_type
68
+ return_type = opts[:debug_return_type] || 'CountStat'
69
+
70
+ # auth_names
71
+ auth_names = opts[:debug_auth_names] || []
72
+
73
+ new_options = opts.merge(
74
+ :operation => :"SuppressionApi.count",
75
+ :header_params => header_params,
76
+ :query_params => query_params,
77
+ :form_params => form_params,
78
+ :body => post_body,
79
+ :auth_names => auth_names,
80
+ :return_type => return_type
81
+ )
82
+
83
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
84
+ if @api_client.config.debugging
85
+ @api_client.config.logger.debug "API called: SuppressionApi#count\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
86
+ end
87
+ return data, status_code, headers
88
+ end
89
+
90
+ # Add Email Addresses To Suppression List
91
+ # @param x_sub_account_api_key [String] Sub-Account API Key
92
+ # @param [Hash] opts the optional parameters
93
+ # @option opts [RSuppression] :r_suppression Suppression content
94
+ # @return [Array<Suppression>]
95
+ def create_suppressions(x_sub_account_api_key, opts = {})
96
+ data, _status_code, _headers = create_suppressions_with_http_info(x_sub_account_api_key, opts)
97
+ data
98
+ end
99
+
100
+ # Add Email Addresses To Suppression List
101
+ # @param x_sub_account_api_key [String] Sub-Account API Key
102
+ # @param [Hash] opts the optional parameters
103
+ # @option opts [RSuppression] :r_suppression Suppression content
104
+ # @return [Array<(Array<Suppression>, Integer, Hash)>] Array<Suppression> data, response status code and response headers
105
+ def create_suppressions_with_http_info(x_sub_account_api_key, opts = {})
106
+ if @api_client.config.debugging
107
+ @api_client.config.logger.debug 'Calling API: SuppressionApi.create_suppressions ...'
108
+ end
109
+ # verify the required parameter 'x_sub_account_api_key' is set
110
+ if @api_client.config.client_side_validation && x_sub_account_api_key.nil?
111
+ fail ArgumentError, "Missing the required parameter 'x_sub_account_api_key' when calling SuppressionApi.create_suppressions"
112
+ end
113
+ # resource path
114
+ local_var_path = '/subaccount/suppression/'
115
+
116
+ # query parameters
117
+ query_params = opts[:query_params] || {}
118
+
119
+ # header parameters
120
+ header_params = opts[:header_params] || {}
121
+ # HTTP header 'Accept' (if needed)
122
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
123
+ # HTTP header 'Content-Type'
124
+ content_type = @api_client.select_header_content_type(['application/json'])
125
+ if !content_type.nil?
126
+ header_params['Content-Type'] = content_type
127
+ end
128
+ header_params[:'X-SubAccount-ApiKey'] = x_sub_account_api_key
129
+
130
+ # form parameters
131
+ form_params = opts[:form_params] || {}
132
+
133
+ # http body (model)
134
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'r_suppression'])
135
+
136
+ # return_type
137
+ return_type = opts[:debug_return_type] || 'Array<Suppression>'
138
+
139
+ # auth_names
140
+ auth_names = opts[:debug_auth_names] || []
141
+
142
+ new_options = opts.merge(
143
+ :operation => :"SuppressionApi.create_suppressions",
144
+ :header_params => header_params,
145
+ :query_params => query_params,
146
+ :form_params => form_params,
147
+ :body => post_body,
148
+ :auth_names => auth_names,
149
+ :return_type => return_type
150
+ )
151
+
152
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
153
+ if @api_client.config.debugging
154
+ @api_client.config.logger.debug "API called: SuppressionApi#create_suppressions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
155
+ end
156
+ return data, status_code, headers
157
+ end
158
+
159
+ # Delete specific emails which are in suppression list
160
+ # @param x_sub_account_api_key [String] Sub-Account API Key
161
+ # @param [Hash] opts the optional parameters
162
+ # @option opts [RDSuppression] :rd_suppression Suppression content
163
+ # @return [Array<DeleteResponse>]
164
+ def delete_suppression(x_sub_account_api_key, opts = {})
165
+ data, _status_code, _headers = delete_suppression_with_http_info(x_sub_account_api_key, opts)
166
+ data
167
+ end
168
+
169
+ # Delete specific emails which are in suppression list
170
+ # @param x_sub_account_api_key [String] Sub-Account API Key
171
+ # @param [Hash] opts the optional parameters
172
+ # @option opts [RDSuppression] :rd_suppression Suppression content
173
+ # @return [Array<(Array<DeleteResponse>, Integer, Hash)>] Array<DeleteResponse> data, response status code and response headers
174
+ def delete_suppression_with_http_info(x_sub_account_api_key, opts = {})
175
+ if @api_client.config.debugging
176
+ @api_client.config.logger.debug 'Calling API: SuppressionApi.delete_suppression ...'
177
+ end
178
+ # verify the required parameter 'x_sub_account_api_key' is set
179
+ if @api_client.config.client_side_validation && x_sub_account_api_key.nil?
180
+ fail ArgumentError, "Missing the required parameter 'x_sub_account_api_key' when calling SuppressionApi.delete_suppression"
181
+ end
182
+ # resource path
183
+ local_var_path = '/subaccount/suppression/'
184
+
185
+ # query parameters
186
+ query_params = opts[:query_params] || {}
187
+
188
+ # header parameters
189
+ header_params = opts[:header_params] || {}
190
+ # HTTP header 'Accept' (if needed)
191
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
192
+ # HTTP header 'Content-Type'
193
+ content_type = @api_client.select_header_content_type(['application/json'])
194
+ if !content_type.nil?
195
+ header_params['Content-Type'] = content_type
196
+ end
197
+ header_params[:'X-SubAccount-ApiKey'] = x_sub_account_api_key
198
+
199
+ # form parameters
200
+ form_params = opts[:form_params] || {}
201
+
202
+ # http body (model)
203
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'rd_suppression'])
204
+
205
+ # return_type
206
+ return_type = opts[:debug_return_type] || 'Array<DeleteResponse>'
207
+
208
+ # auth_names
209
+ auth_names = opts[:debug_auth_names] || []
210
+
211
+ new_options = opts.merge(
212
+ :operation => :"SuppressionApi.delete_suppression",
213
+ :header_params => header_params,
214
+ :query_params => query_params,
215
+ :form_params => form_params,
216
+ :body => post_body,
217
+ :auth_names => auth_names,
218
+ :return_type => return_type
219
+ )
220
+
221
+ data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
222
+ if @api_client.config.debugging
223
+ @api_client.config.logger.debug "API called: SuppressionApi#delete_suppression\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
224
+ end
225
+ return data, status_code, headers
226
+ end
227
+
228
+ # Get all suppressions
229
+ # @param x_sub_account_api_key [String] Sub-Account API Key
230
+ # @param [Hash] opts the optional parameters
231
+ # @option opts [Integer] :offset offset
232
+ # @option opts [Integer] :limit limit
233
+ # @option opts [String] :search search
234
+ # @option opts [String] :from from date
235
+ # @option opts [String] :to to date
236
+ # @return [Array<Suppression>]
237
+ def get_suppressions(x_sub_account_api_key, opts = {})
238
+ data, _status_code, _headers = get_suppressions_with_http_info(x_sub_account_api_key, opts)
239
+ data
240
+ end
241
+
242
+ # Get all suppressions
243
+ # @param x_sub_account_api_key [String] Sub-Account API Key
244
+ # @param [Hash] opts the optional parameters
245
+ # @option opts [Integer] :offset offset
246
+ # @option opts [Integer] :limit limit
247
+ # @option opts [String] :search search
248
+ # @option opts [String] :from from date
249
+ # @option opts [String] :to to date
250
+ # @return [Array<(Array<Suppression>, Integer, Hash)>] Array<Suppression> data, response status code and response headers
251
+ def get_suppressions_with_http_info(x_sub_account_api_key, opts = {})
252
+ if @api_client.config.debugging
253
+ @api_client.config.logger.debug 'Calling API: SuppressionApi.get_suppressions ...'
254
+ end
255
+ # verify the required parameter 'x_sub_account_api_key' is set
256
+ if @api_client.config.client_side_validation && x_sub_account_api_key.nil?
257
+ fail ArgumentError, "Missing the required parameter 'x_sub_account_api_key' when calling SuppressionApi.get_suppressions"
258
+ end
259
+ # resource path
260
+ local_var_path = '/subaccount/suppression/'
261
+
262
+ # query parameters
263
+ query_params = opts[:query_params] || {}
264
+ query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
265
+ query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
266
+ query_params[:'search'] = opts[:'search'] if !opts[:'search'].nil?
267
+ query_params[:'from'] = opts[:'from'] if !opts[:'from'].nil?
268
+ query_params[:'to'] = opts[:'to'] if !opts[:'to'].nil?
269
+
270
+ # header parameters
271
+ header_params = opts[:header_params] || {}
272
+ # HTTP header 'Accept' (if needed)
273
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
274
+ header_params[:'X-SubAccount-ApiKey'] = x_sub_account_api_key
275
+
276
+ # form parameters
277
+ form_params = opts[:form_params] || {}
278
+
279
+ # http body (model)
280
+ post_body = opts[:debug_body]
281
+
282
+ # return_type
283
+ return_type = opts[:debug_return_type] || 'Array<Suppression>'
284
+
285
+ # auth_names
286
+ auth_names = opts[:debug_auth_names] || []
287
+
288
+ new_options = opts.merge(
289
+ :operation => :"SuppressionApi.get_suppressions",
290
+ :header_params => header_params,
291
+ :query_params => query_params,
292
+ :form_params => form_params,
293
+ :body => post_body,
294
+ :auth_names => auth_names,
295
+ :return_type => return_type
296
+ )
297
+
298
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
299
+ if @api_client.config.debugging
300
+ @api_client.config.logger.debug "API called: SuppressionApi#get_suppressions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
301
+ end
302
+ return data, status_code, headers
303
+ end
304
+ end
305
+ end
@@ -0,0 +1,219 @@
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 CountStat
18
+ attr_accessor :count
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :'count' => :'count'
24
+ }
25
+ end
26
+
27
+ # Returns all the JSON keys this model knows about
28
+ def self.acceptable_attributes
29
+ attribute_map.values
30
+ end
31
+
32
+ # Attribute type mapping.
33
+ def self.openapi_types
34
+ {
35
+ :'count' => :'Integer'
36
+ }
37
+ end
38
+
39
+ # List of attributes with nullable: true
40
+ def self.openapi_nullable
41
+ Set.new([
42
+ ])
43
+ end
44
+
45
+ # Initializes the object
46
+ # @param [Hash] attributes Model attributes in the form of hash
47
+ def initialize(attributes = {})
48
+ if (!attributes.is_a?(Hash))
49
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Sendpost::CountStat` initialize method"
50
+ end
51
+
52
+ # check to see if the attribute exists and convert string to symbol for hash key
53
+ attributes = attributes.each_with_object({}) { |(k, v), h|
54
+ if (!self.class.attribute_map.key?(k.to_sym))
55
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Sendpost::CountStat`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
56
+ end
57
+ h[k.to_sym] = v
58
+ }
59
+
60
+ if attributes.key?(:'count')
61
+ self.count = attributes[:'count']
62
+ end
63
+ end
64
+
65
+ # Show invalid properties with the reasons. Usually used together with valid?
66
+ # @return Array for valid properties with the reasons
67
+ def list_invalid_properties
68
+ invalid_properties = Array.new
69
+ invalid_properties
70
+ end
71
+
72
+ # Check to see if the all the properties in the model are valid
73
+ # @return true if the model is valid
74
+ def valid?
75
+ true
76
+ end
77
+
78
+ # Checks equality by comparing each attribute.
79
+ # @param [Object] Object to be compared
80
+ def ==(o)
81
+ return true if self.equal?(o)
82
+ self.class == o.class &&
83
+ count == o.count
84
+ end
85
+
86
+ # @see the `==` method
87
+ # @param [Object] Object to be compared
88
+ def eql?(o)
89
+ self == o
90
+ end
91
+
92
+ # Calculates hash code according to all attributes.
93
+ # @return [Integer] Hash code
94
+ def hash
95
+ [count].hash
96
+ end
97
+
98
+ # Builds the object from hash
99
+ # @param [Hash] attributes Model attributes in the form of hash
100
+ # @return [Object] Returns the model itself
101
+ def self.build_from_hash(attributes)
102
+ new.build_from_hash(attributes)
103
+ end
104
+
105
+ # Builds the object from hash
106
+ # @param [Hash] attributes Model attributes in the form of hash
107
+ # @return [Object] Returns the model itself
108
+ def build_from_hash(attributes)
109
+ return nil unless attributes.is_a?(Hash)
110
+ attributes = attributes.transform_keys(&:to_sym)
111
+ self.class.openapi_types.each_pair do |key, type|
112
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
113
+ self.send("#{key}=", nil)
114
+ elsif type =~ /\AArray<(.*)>/i
115
+ # check to ensure the input is an array given that the attribute
116
+ # is documented as an array but the input is not
117
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
118
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
119
+ end
120
+ elsif !attributes[self.class.attribute_map[key]].nil?
121
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
122
+ end
123
+ end
124
+
125
+ self
126
+ end
127
+
128
+ # Deserializes the data based on type
129
+ # @param string type Data type
130
+ # @param string value Value to be deserialized
131
+ # @return [Object] Deserialized data
132
+ def _deserialize(type, value)
133
+ case type.to_sym
134
+ when :Time
135
+ Time.parse(value)
136
+ when :Date
137
+ Date.parse(value)
138
+ when :String
139
+ value.to_s
140
+ when :Integer
141
+ value.to_i
142
+ when :Float
143
+ value.to_f
144
+ when :Boolean
145
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
146
+ true
147
+ else
148
+ false
149
+ end
150
+ when :Object
151
+ # generic object (usually a Hash), return directly
152
+ value
153
+ when /\AArray<(?<inner_type>.+)>\z/
154
+ inner_type = Regexp.last_match[:inner_type]
155
+ value.map { |v| _deserialize(inner_type, v) }
156
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
157
+ k_type = Regexp.last_match[:k_type]
158
+ v_type = Regexp.last_match[:v_type]
159
+ {}.tap do |hash|
160
+ value.each do |k, v|
161
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
162
+ end
163
+ end
164
+ else # model
165
+ # models (e.g. Pet) or oneOf
166
+ klass = Sendpost.const_get(type)
167
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
168
+ end
169
+ end
170
+
171
+ # Returns the string representation of the object
172
+ # @return [String] String presentation of the object
173
+ def to_s
174
+ to_hash.to_s
175
+ end
176
+
177
+ # to_body is an alias to to_hash (backward compatibility)
178
+ # @return [Hash] Returns the object in the form of hash
179
+ def to_body
180
+ to_hash
181
+ end
182
+
183
+ # Returns the object in the form of hash
184
+ # @return [Hash] Returns the object in the form of hash
185
+ def to_hash
186
+ hash = {}
187
+ self.class.attribute_map.each_pair do |attr, param|
188
+ value = self.send(attr)
189
+ if value.nil?
190
+ is_nullable = self.class.openapi_nullable.include?(attr)
191
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
192
+ end
193
+
194
+ hash[param] = _to_hash(value)
195
+ end
196
+ hash
197
+ end
198
+
199
+ # Outputs non-array value in the form of hash
200
+ # For object, use to_hash. Otherwise, just return the value
201
+ # @param [Object] value Any valid value
202
+ # @return [Hash] Returns the value in the form of hash
203
+ def _to_hash(value)
204
+ if value.is_a?(Array)
205
+ value.compact.map { |v| _to_hash(v) }
206
+ elsif value.is_a?(Hash)
207
+ {}.tap do |hash|
208
+ value.each { |k, v| hash[k] = _to_hash(v) }
209
+ end
210
+ elsif value.respond_to? :to_hash
211
+ value.to_hash
212
+ else
213
+ value
214
+ end
215
+ end
216
+
217
+ end
218
+
219
+ end