sendpost_ruby 1.0.1

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 (63) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +106 -0
  4. data/Rakefile +10 -0
  5. data/docs/Attachment.md +20 -0
  6. data/docs/City.md +26 -0
  7. data/docs/CopyTo.md +22 -0
  8. data/docs/Device.md +18 -0
  9. data/docs/EmailApi.md +145 -0
  10. data/docs/EmailMessage.md +46 -0
  11. data/docs/EmailResponse.md +26 -0
  12. data/docs/EventMetadata.md +30 -0
  13. data/docs/From.md +20 -0
  14. data/docs/Os.md +26 -0
  15. data/docs/QEmailMessage.md +70 -0
  16. data/docs/QEvent.md +42 -0
  17. data/docs/ReplyTo.md +20 -0
  18. data/docs/To.md +26 -0
  19. data/docs/UserAgent.md +24 -0
  20. data/docs/WebhookEvent.md +20 -0
  21. data/git_push.sh +57 -0
  22. data/lib/sendpost_ruby/api/email_api.rb +160 -0
  23. data/lib/sendpost_ruby/api_client.rb +391 -0
  24. data/lib/sendpost_ruby/api_error.rb +58 -0
  25. data/lib/sendpost_ruby/configuration.rb +288 -0
  26. data/lib/sendpost_ruby/models/attachment.rb +228 -0
  27. data/lib/sendpost_ruby/models/city.rb +255 -0
  28. data/lib/sendpost_ruby/models/copy_to.rb +237 -0
  29. data/lib/sendpost_ruby/models/device.rb +219 -0
  30. data/lib/sendpost_ruby/models/email_message.rb +351 -0
  31. data/lib/sendpost_ruby/models/email_response.rb +255 -0
  32. data/lib/sendpost_ruby/models/event_metadata.rb +273 -0
  33. data/lib/sendpost_ruby/models/from.rb +228 -0
  34. data/lib/sendpost_ruby/models/os.rb +255 -0
  35. data/lib/sendpost_ruby/models/q_email_message.rb +461 -0
  36. data/lib/sendpost_ruby/models/q_event.rb +329 -0
  37. data/lib/sendpost_ruby/models/reply_to.rb +228 -0
  38. data/lib/sendpost_ruby/models/to.rb +259 -0
  39. data/lib/sendpost_ruby/models/user_agent.rb +246 -0
  40. data/lib/sendpost_ruby/models/webhook_event.rb +228 -0
  41. data/lib/sendpost_ruby/version.rb +15 -0
  42. data/lib/sendpost_ruby.rb +55 -0
  43. data/sendpost_ruby.gemspec +38 -0
  44. data/spec/api/email_api_spec.rb +59 -0
  45. data/spec/api_client_spec.rb +228 -0
  46. data/spec/configuration_spec.rb +42 -0
  47. data/spec/models/attachment_spec.rb +40 -0
  48. data/spec/models/city_spec.rb +58 -0
  49. data/spec/models/copy_to_spec.rb +46 -0
  50. data/spec/models/device_spec.rb +34 -0
  51. data/spec/models/email_message_spec.rb +118 -0
  52. data/spec/models/email_response_spec.rb +58 -0
  53. data/spec/models/event_metadata_spec.rb +70 -0
  54. data/spec/models/from_spec.rb +40 -0
  55. data/spec/models/os_spec.rb +58 -0
  56. data/spec/models/q_email_message_spec.rb +190 -0
  57. data/spec/models/q_event_spec.rb +106 -0
  58. data/spec/models/reply_to_spec.rb +40 -0
  59. data/spec/models/to_spec.rb +58 -0
  60. data/spec/models/user_agent_spec.rb +52 -0
  61. data/spec/models/webhook_event_spec.rb +40 -0
  62. data/spec/spec_helper.rb +111 -0
  63. metadata +165 -0
@@ -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 WebhookEvent
18
+ attr_accessor :event
19
+
20
+ attr_accessor :email_message
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'event' => :'event',
26
+ :'email_message' => :'emailMessage'
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
+ :'event' => :'QEvent',
39
+ :'email_message' => :'QEmailMessage'
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::WebhookEvent` 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::WebhookEvent`. 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?(:'event')
65
+ self.event = attributes[:'event']
66
+ end
67
+
68
+ if attributes.key?(:'email_message')
69
+ self.email_message = attributes[:'email_message']
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
+ event == o.event &&
92
+ email_message == o.email_message
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
+ [event, email_message].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
@@ -0,0 +1,15 @@
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
+ VERSION = '1.0.1'
15
+ end
@@ -0,0 +1,55 @@
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
+ # Common files
14
+ require 'sendpost_ruby/api_client'
15
+ require 'sendpost_ruby/api_error'
16
+ require 'sendpost_ruby/version'
17
+ require 'sendpost_ruby/configuration'
18
+
19
+ # Models
20
+ require 'sendpost_ruby/models/attachment'
21
+ require 'sendpost_ruby/models/city'
22
+ require 'sendpost_ruby/models/copy_to'
23
+ require 'sendpost_ruby/models/device'
24
+ require 'sendpost_ruby/models/email_message'
25
+ require 'sendpost_ruby/models/email_response'
26
+ require 'sendpost_ruby/models/event_metadata'
27
+ require 'sendpost_ruby/models/from'
28
+ require 'sendpost_ruby/models/os'
29
+ require 'sendpost_ruby/models/q_email_message'
30
+ require 'sendpost_ruby/models/q_event'
31
+ require 'sendpost_ruby/models/reply_to'
32
+ require 'sendpost_ruby/models/to'
33
+ require 'sendpost_ruby/models/user_agent'
34
+ require 'sendpost_ruby/models/webhook_event'
35
+
36
+ # APIs
37
+ require 'sendpost_ruby/api/email_api'
38
+
39
+ module Sendpost
40
+ class << self
41
+ # Customize default settings for the SDK using block.
42
+ # Sendpost.configure do |config|
43
+ # config.username = "xxx"
44
+ # config.password = "xxx"
45
+ # end
46
+ # If no block given, return the default Configuration object.
47
+ def configure
48
+ if block_given?
49
+ yield(Configuration.default)
50
+ else
51
+ Configuration.default
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,38 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ =begin
4
+ #SendPost API
5
+
6
+ #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.
7
+
8
+ The version of the OpenAPI document: 1.0.0
9
+ Contact: hello@sendpost.io
10
+ Generated by: https://openapi-generator.tech
11
+ OpenAPI Generator version: 6.6.0
12
+
13
+ =end
14
+
15
+ $:.push File.expand_path("../lib", __FILE__)
16
+ require "sendpost_ruby/version"
17
+
18
+ Gem::Specification.new do |s|
19
+ s.name = "sendpost_ruby"
20
+ s.version = Sendpost::VERSION
21
+ s.platform = Gem::Platform::RUBY
22
+ s.authors = ["Sendpost"]
23
+ s.email = ["hello@sendpost.io"]
24
+ s.homepage = "https://sendpost.io/"
25
+ s.summary = "SendPost Ruby API"
26
+ s.description = "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."
27
+ s.license = "Unlicense"
28
+ s.required_ruby_version = ">= 2.7"
29
+
30
+ s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
31
+
32
+ s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0'
33
+
34
+ s.files = `find *`.split("\n").uniq.sort.select { |f| !f.empty? }
35
+ s.test_files = `find spec/*`.split("\n")
36
+ s.executables = []
37
+ s.require_paths = ["lib"]
38
+ end
@@ -0,0 +1,59 @@
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 'spec_helper'
14
+ require 'json'
15
+
16
+ # Unit tests for Sendpost::EmailApi
17
+ # Automatically generated by openapi-generator (https://openapi-generator.tech)
18
+ # Please update as you see appropriate
19
+ describe 'EmailApi' do
20
+ before do
21
+ # run before each test
22
+ @api_instance = Sendpost::EmailApi.new
23
+ end
24
+
25
+ after do
26
+ # run after each test
27
+ end
28
+
29
+ describe 'test an instance of EmailApi' do
30
+ it 'should create an instance of EmailApi' do
31
+ expect(@api_instance).to be_instance_of(Sendpost::EmailApi)
32
+ end
33
+ end
34
+
35
+ # unit tests for send_email
36
+ # Send Email To Contacts
37
+ # @param x_sub_account_api_key Sub-Account API Key
38
+ # @param [Hash] opts the optional parameters
39
+ # @option opts [EmailMessage] :email_message Email message
40
+ # @return [Array<EmailResponse>]
41
+ describe 'send_email test' do
42
+ it 'should work' do
43
+ # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
44
+ end
45
+ end
46
+
47
+ # unit tests for send_email_with_template
48
+ # Send Email To Contacts With Template
49
+ # @param x_sub_account_api_key Sub-Account API Key
50
+ # @param [Hash] opts the optional parameters
51
+ # @option opts [EmailMessage] :email_message Email message
52
+ # @return [Array<EmailResponse>]
53
+ describe 'send_email_with_template test' do
54
+ it 'should work' do
55
+ # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
56
+ end
57
+ end
58
+
59
+ 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 'spec_helper'
14
+
15
+ describe Sendpost::ApiClient do
16
+ context 'initialization' do
17
+ context 'URL stuff' do
18
+ context 'host' do
19
+ it 'removes http from host' do
20
+ Sendpost.configure { |c| c.host = 'http://example.com' }
21
+ expect(Sendpost::Configuration.default.host).to eq('example.com')
22
+ end
23
+
24
+ it 'removes https from host' do
25
+ Sendpost.configure { |c| c.host = 'https://wookiee.com' }
26
+ expect(Sendpost::ApiClient.default.config.host).to eq('wookiee.com')
27
+ end
28
+
29
+ it 'removes trailing path from host' do
30
+ Sendpost.configure { |c| c.host = 'hobo.com/v4' }
31
+ expect(Sendpost::Configuration.default.host).to eq('hobo.com')
32
+ end
33
+ end
34
+
35
+ context 'base_path' do
36
+ it "prepends a slash to base_path" do
37
+ Sendpost.configure { |c| c.base_path = 'v4/dog' }
38
+ expect(Sendpost::Configuration.default.base_path).to eq('/v4/dog')
39
+ end
40
+
41
+ it "doesn't prepend a slash if one is already there" do
42
+ Sendpost.configure { |c| c.base_path = '/v4/dog' }
43
+ expect(Sendpost::Configuration.default.base_path).to eq('/v4/dog')
44
+ end
45
+
46
+ it "ends up as a blank string if nil" do
47
+ Sendpost.configure { |c| c.base_path = nil }
48
+ expect(Sendpost::Configuration.default.base_path).to eq('')
49
+ end
50
+ end
51
+ end
52
+ end
53
+
54
+ describe 'params_encoding in #build_request' do
55
+ let(:config) { Sendpost::Configuration.new }
56
+ let(:api_client) { Sendpost::ApiClient.new(config) }
57
+
58
+ it 'defaults to nil' do
59
+ expect(Sendpost::Configuration.default.params_encoding).to eq(nil)
60
+ expect(config.params_encoding).to eq(nil)
61
+
62
+ request = api_client.build_request(:get, '/test')
63
+ expect(request.options[:params_encoding]).to eq(nil)
64
+ end
65
+
66
+ it 'can be customized' do
67
+ config.params_encoding = :multi
68
+ request = api_client.build_request(:get, '/test')
69
+ expect(request.options[:params_encoding]).to eq(:multi)
70
+ end
71
+ end
72
+
73
+ describe 'timeout in #build_request' do
74
+ let(:config) { Sendpost::Configuration.new }
75
+ let(:api_client) { Sendpost::ApiClient.new(config) }
76
+
77
+ it 'defaults to 0' do
78
+ expect(Sendpost::Configuration.default.timeout).to eq(0)
79
+ expect(config.timeout).to eq(0)
80
+
81
+ request = api_client.build_request(:get, '/test')
82
+ expect(request.options[:timeout]).to eq(0)
83
+ end
84
+
85
+ it 'can be customized' do
86
+ config.timeout = 100
87
+ request = api_client.build_request(:get, '/test')
88
+ expect(request.options[:timeout]).to eq(100)
89
+ end
90
+ end
91
+
92
+
93
+
94
+ describe '#deserialize' do
95
+ it "handles Array<Integer>" do
96
+ api_client = Sendpost::ApiClient.new
97
+ headers = { 'Content-Type' => 'application/json' }
98
+ response = double('response', headers: headers, body: '[12, 34]')
99
+ data = api_client.deserialize(response, 'Array<Integer>')
100
+ expect(data).to be_instance_of(Array)
101
+ expect(data).to eq([12, 34])
102
+ end
103
+
104
+ it 'handles Array<Array<Integer>>' do
105
+ api_client = Sendpost::ApiClient.new
106
+ headers = { 'Content-Type' => 'application/json' }
107
+ response = double('response', headers: headers, body: '[[12, 34], [56]]')
108
+ data = api_client.deserialize(response, 'Array<Array<Integer>>')
109
+ expect(data).to be_instance_of(Array)
110
+ expect(data).to eq([[12, 34], [56]])
111
+ end
112
+
113
+ it 'handles Hash<String, String>' do
114
+ api_client = Sendpost::ApiClient.new
115
+ headers = { 'Content-Type' => 'application/json' }
116
+ response = double('response', headers: headers, body: '{"message": "Hello"}')
117
+ data = api_client.deserialize(response, 'Hash<String, String>')
118
+ expect(data).to be_instance_of(Hash)
119
+ expect(data).to eq(:message => 'Hello')
120
+ end
121
+ end
122
+
123
+ describe "#object_to_hash" do
124
+ it 'ignores nils and includes empty arrays' do
125
+ # uncomment below to test object_to_hash for model
126
+ # api_client = Sendpost::ApiClient.new
127
+ # _model = Sendpost::ModelName.new
128
+ # update the model attribute below
129
+ # _model.id = 1
130
+ # update the expected value (hash) below
131
+ # expected = {id: 1, name: '', tags: []}
132
+ # expect(api_client.object_to_hash(_model)).to eq(expected)
133
+ end
134
+ end
135
+
136
+ describe '#build_collection_param' do
137
+ let(:param) { ['aa', 'bb', 'cc'] }
138
+ let(:api_client) { Sendpost::ApiClient.new }
139
+
140
+ it 'works for csv' do
141
+ expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc')
142
+ end
143
+
144
+ it 'works for ssv' do
145
+ expect(api_client.build_collection_param(param, :ssv)).to eq('aa bb cc')
146
+ end
147
+
148
+ it 'works for tsv' do
149
+ expect(api_client.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc")
150
+ end
151
+
152
+ it 'works for pipes' do
153
+ expect(api_client.build_collection_param(param, :pipes)).to eq('aa|bb|cc')
154
+ end
155
+
156
+ it 'works for multi' do
157
+ expect(api_client.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc'])
158
+ end
159
+
160
+ it 'fails for invalid collection format' do
161
+ expect { api_client.build_collection_param(param, :INVALID) }.to raise_error(RuntimeError, 'unknown collection format: :INVALID')
162
+ end
163
+ end
164
+
165
+ describe '#json_mime?' do
166
+ let(:api_client) { Sendpost::ApiClient.new }
167
+
168
+ it 'works' do
169
+ expect(api_client.json_mime?(nil)).to eq false
170
+ expect(api_client.json_mime?('')).to eq false
171
+
172
+ expect(api_client.json_mime?('application/json')).to eq true
173
+ expect(api_client.json_mime?('application/json; charset=UTF8')).to eq true
174
+ expect(api_client.json_mime?('APPLICATION/JSON')).to eq true
175
+
176
+ expect(api_client.json_mime?('application/xml')).to eq false
177
+ expect(api_client.json_mime?('text/plain')).to eq false
178
+ expect(api_client.json_mime?('application/jsonp')).to eq false
179
+ end
180
+ end
181
+
182
+ describe '#select_header_accept' do
183
+ let(:api_client) { Sendpost::ApiClient.new }
184
+
185
+ it 'works' do
186
+ expect(api_client.select_header_accept(nil)).to be_nil
187
+ expect(api_client.select_header_accept([])).to be_nil
188
+
189
+ expect(api_client.select_header_accept(['application/json'])).to eq('application/json')
190
+ expect(api_client.select_header_accept(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
191
+ expect(api_client.select_header_accept(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
192
+
193
+ expect(api_client.select_header_accept(['application/xml'])).to eq('application/xml')
194
+ expect(api_client.select_header_accept(['text/html', 'application/xml'])).to eq('text/html,application/xml')
195
+ end
196
+ end
197
+
198
+ describe '#select_header_content_type' do
199
+ let(:api_client) { Sendpost::ApiClient.new }
200
+
201
+ it 'works' do
202
+ expect(api_client.select_header_content_type(nil)).to be_nil
203
+ expect(api_client.select_header_content_type([])).to be_nil
204
+
205
+ expect(api_client.select_header_content_type(['application/json'])).to eq('application/json')
206
+ expect(api_client.select_header_content_type(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
207
+ expect(api_client.select_header_content_type(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
208
+ expect(api_client.select_header_content_type(['application/xml'])).to eq('application/xml')
209
+ expect(api_client.select_header_content_type(['text/plain', 'application/xml'])).to eq('text/plain')
210
+ end
211
+ end
212
+
213
+ describe '#sanitize_filename' do
214
+ let(:api_client) { Sendpost::ApiClient.new }
215
+
216
+ it 'works' do
217
+ expect(api_client.sanitize_filename('sun')).to eq('sun')
218
+ expect(api_client.sanitize_filename('sun.gif')).to eq('sun.gif')
219
+ expect(api_client.sanitize_filename('../sun.gif')).to eq('sun.gif')
220
+ expect(api_client.sanitize_filename('/var/tmp/sun.gif')).to eq('sun.gif')
221
+ expect(api_client.sanitize_filename('./sun.gif')).to eq('sun.gif')
222
+ expect(api_client.sanitize_filename('..\sun.gif')).to eq('sun.gif')
223
+ expect(api_client.sanitize_filename('\var\tmp\sun.gif')).to eq('sun.gif')
224
+ expect(api_client.sanitize_filename('c:\var\tmp\sun.gif')).to eq('sun.gif')
225
+ expect(api_client.sanitize_filename('.\sun.gif')).to eq('sun.gif')
226
+ end
227
+ end
228
+ end
@@ -0,0 +1,42 @@
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 'spec_helper'
14
+
15
+ describe Sendpost::Configuration do
16
+ let(:config) { Sendpost::Configuration.default }
17
+
18
+ before(:each) do
19
+ # uncomment below to setup host and base_path
20
+ # require 'URI'
21
+ # uri = URI.parse("https://api.sendpost.io/api/v1")
22
+ # Sendpost.configure do |c|
23
+ # c.host = uri.host
24
+ # c.base_path = uri.path
25
+ # end
26
+ end
27
+
28
+ describe '#base_url' do
29
+ it 'should have the default value' do
30
+ # uncomment below to test default value of the base path
31
+ # expect(config.base_url).to eq("https://api.sendpost.io/api/v1")
32
+ end
33
+
34
+ it 'should remove trailing slashes' do
35
+ [nil, '', '/', '//'].each do |base_path|
36
+ config.base_path = base_path
37
+ # uncomment below to test trailing slashes
38
+ # expect(config.base_url).to eq("https://api.sendpost.io/api/v1")
39
+ end
40
+ end
41
+ end
42
+ end