MailchimpTransactional 1.0.8 → 1.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/LICENSE +53 -0
- data/MailchimpTransactional.gemspec +4 -4
- data/README.md +9 -9
- data/lib/MailchimpTransactional.rb +60 -76
- data/lib/MailchimpTransactional/api/exports_api.rb +14 -97
- data/lib/MailchimpTransactional/api/inbound_api.rb +22 -169
- data/lib/MailchimpTransactional/api/ips_api.rb +30 -241
- data/lib/MailchimpTransactional/api/messages_api.rb +26 -205
- data/lib/MailchimpTransactional/api/metadata_api.rb +12 -79
- data/lib/MailchimpTransactional/api/rejects_api.rb +10 -61
- data/lib/MailchimpTransactional/api/senders_api.rb +18 -133
- data/lib/MailchimpTransactional/api/subaccounts_api.rb +18 -133
- data/lib/MailchimpTransactional/api/tags_api.rb +14 -97
- data/lib/MailchimpTransactional/api/templates_api.rb +20 -151
- data/lib/MailchimpTransactional/api/urls_api.rb +16 -115
- data/lib/MailchimpTransactional/api/users_api.rb +12 -79
- data/lib/MailchimpTransactional/api/webhooks_api.rb +14 -97
- data/lib/MailchimpTransactional/api/whitelists_api.rb +10 -61
- data/lib/MailchimpTransactional/api_client.rb +31 -116
- data/lib/MailchimpTransactional/api_error.rb +2 -2
- data/lib/MailchimpTransactional/configuration.rb +2 -2
- data/lib/MailchimpTransactional/version.rb +3 -3
- metadata +7 -12
@@ -3,8 +3,8 @@
|
|
3
3
|
|
4
4
|
#No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
5
5
|
|
6
|
-
OpenAPI spec version: 1.0.
|
7
|
-
Contact: apihelp@
|
6
|
+
OpenAPI spec version: 1.0.14
|
7
|
+
Contact: apihelp@mailchimp.com
|
8
8
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
9
|
Swagger Codegen version: 2.4.12
|
10
10
|
|
@@ -16,45 +16,17 @@ module MailchimpTransactional
|
|
16
16
|
class WebhooksApi
|
17
17
|
attr_accessor :api_client
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
def initialize(api_key = '', api_client = ApiClient.default)
|
22
|
-
@api_key = api_key
|
19
|
+
def initialize(api_client = ApiClient.default)
|
23
20
|
@api_client = api_client
|
24
21
|
end
|
25
|
-
# Add webhook
|
26
|
-
# Add a new webhook.
|
27
|
-
# @param body
|
28
|
-
# @param [Hash] opts the optional parameters
|
29
|
-
# @return [InlineResponse20072]
|
30
|
-
def add(body = {}, opts = {})
|
31
|
-
data = add_with_http_info(body, opts)
|
32
|
-
data
|
33
|
-
end
|
34
22
|
|
35
23
|
# Add webhook
|
36
24
|
# Add a new webhook.
|
37
25
|
# @param body
|
38
26
|
# @param [Hash] opts the optional parameters
|
39
27
|
# @return [Array<(InlineResponse20072, Fixnum, Hash)>] InlineResponse20072 data, response status code and response headers
|
40
|
-
def
|
41
|
-
|
42
|
-
body[:key] = @api_key
|
43
|
-
|
44
|
-
# resource path
|
45
|
-
local_var_path = '/webhooks/add'
|
46
|
-
|
47
|
-
# http body (model)
|
48
|
-
data = @api_client.call_api(:POST, local_var_path, :body => body)
|
49
|
-
return data
|
50
|
-
end
|
51
|
-
# Delete webhook
|
52
|
-
# Delete an existing webhook.
|
53
|
-
# @param body
|
54
|
-
# @param [Hash] opts the optional parameters
|
55
|
-
# @return [InlineResponse20075]
|
56
|
-
def delete(body = {}, opts = {})
|
57
|
-
data = delete_with_http_info(body, opts)
|
28
|
+
def add(body = {})
|
29
|
+
data = @api_client.call_api(:POST, '/webhooks/add', body)
|
58
30
|
data
|
59
31
|
end
|
60
32
|
|
@@ -63,24 +35,8 @@ module MailchimpTransactional
|
|
63
35
|
# @param body
|
64
36
|
# @param [Hash] opts the optional parameters
|
65
37
|
# @return [Array<(InlineResponse20075, Fixnum, Hash)>] InlineResponse20075 data, response status code and response headers
|
66
|
-
def
|
67
|
-
|
68
|
-
body[:key] = @api_key
|
69
|
-
|
70
|
-
# resource path
|
71
|
-
local_var_path = '/webhooks/delete'
|
72
|
-
|
73
|
-
# http body (model)
|
74
|
-
data = @api_client.call_api(:POST, local_var_path, :body => body)
|
75
|
-
return data
|
76
|
-
end
|
77
|
-
# Get webhook info
|
78
|
-
# Given the ID of an existing webhook, return the data about it.
|
79
|
-
# @param body
|
80
|
-
# @param [Hash] opts the optional parameters
|
81
|
-
# @return [InlineResponse20073]
|
82
|
-
def info(body = {}, opts = {})
|
83
|
-
data = info_with_http_info(body, opts)
|
38
|
+
def delete(body = {})
|
39
|
+
data = @api_client.call_api(:POST, '/webhooks/delete', body)
|
84
40
|
data
|
85
41
|
end
|
86
42
|
|
@@ -89,24 +45,8 @@ module MailchimpTransactional
|
|
89
45
|
# @param body
|
90
46
|
# @param [Hash] opts the optional parameters
|
91
47
|
# @return [Array<(InlineResponse20073, Fixnum, Hash)>] InlineResponse20073 data, response status code and response headers
|
92
|
-
def
|
93
|
-
|
94
|
-
body[:key] = @api_key
|
95
|
-
|
96
|
-
# resource path
|
97
|
-
local_var_path = '/webhooks/info'
|
98
|
-
|
99
|
-
# http body (model)
|
100
|
-
data = @api_client.call_api(:POST, local_var_path, :body => body)
|
101
|
-
return data
|
102
|
-
end
|
103
|
-
# List webhooks
|
104
|
-
# Get the list of all webhooks defined on the account.
|
105
|
-
# @param body
|
106
|
-
# @param [Hash] opts the optional parameters
|
107
|
-
# @return [Array<InlineResponse20071>]
|
108
|
-
def list(body = {}, opts = {})
|
109
|
-
data = list_with_http_info(body, opts)
|
48
|
+
def info(body = {})
|
49
|
+
data = @api_client.call_api(:POST, '/webhooks/info', body)
|
110
50
|
data
|
111
51
|
end
|
112
52
|
|
@@ -115,24 +55,8 @@ module MailchimpTransactional
|
|
115
55
|
# @param body
|
116
56
|
# @param [Hash] opts the optional parameters
|
117
57
|
# @return [Array<(Array<InlineResponse20071>, Fixnum, Hash)>] Array<InlineResponse20071> data, response status code and response headers
|
118
|
-
def
|
119
|
-
|
120
|
-
body[:key] = @api_key
|
121
|
-
|
122
|
-
# resource path
|
123
|
-
local_var_path = '/webhooks/list'
|
124
|
-
|
125
|
-
# http body (model)
|
126
|
-
data = @api_client.call_api(:POST, local_var_path, :body => body)
|
127
|
-
return data
|
128
|
-
end
|
129
|
-
# Update webhook
|
130
|
-
# Update an existing webhook.
|
131
|
-
# @param body
|
132
|
-
# @param [Hash] opts the optional parameters
|
133
|
-
# @return [InlineResponse20074]
|
134
|
-
def update(body = {}, opts = {})
|
135
|
-
data = update_with_http_info(body, opts)
|
58
|
+
def list(body = {})
|
59
|
+
data = @api_client.call_api(:POST, '/webhooks/list', body)
|
136
60
|
data
|
137
61
|
end
|
138
62
|
|
@@ -141,16 +65,9 @@ module MailchimpTransactional
|
|
141
65
|
# @param body
|
142
66
|
# @param [Hash] opts the optional parameters
|
143
67
|
# @return [Array<(InlineResponse20074, Fixnum, Hash)>] InlineResponse20074 data, response status code and response headers
|
144
|
-
def
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
# resource path
|
149
|
-
local_var_path = '/webhooks/update'
|
150
|
-
|
151
|
-
# http body (model)
|
152
|
-
data = @api_client.call_api(:POST, local_var_path, :body => body)
|
153
|
-
return data
|
68
|
+
def update(body = {})
|
69
|
+
data = @api_client.call_api(:POST, '/webhooks/update', body)
|
70
|
+
data
|
154
71
|
end
|
155
72
|
end
|
156
73
|
end
|
@@ -3,8 +3,8 @@
|
|
3
3
|
|
4
4
|
#No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
5
5
|
|
6
|
-
OpenAPI spec version: 1.0.
|
7
|
-
Contact: apihelp@
|
6
|
+
OpenAPI spec version: 1.0.14
|
7
|
+
Contact: apihelp@mailchimp.com
|
8
8
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
9
|
Swagger Codegen version: 2.4.12
|
10
10
|
|
@@ -16,45 +16,17 @@ module MailchimpTransactional
|
|
16
16
|
class WhitelistsApi
|
17
17
|
attr_accessor :api_client
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
def initialize(api_key = '', api_client = ApiClient.default)
|
22
|
-
@api_key = api_key
|
19
|
+
def initialize(api_client = ApiClient.default)
|
23
20
|
@api_client = api_client
|
24
21
|
end
|
25
|
-
# Add email to whitelist
|
26
|
-
# Adds an email to your email rejection whitelist. If the address is currently on your blacklist, that blacklist entry will be removed automatically.
|
27
|
-
# @param body
|
28
|
-
# @param [Hash] opts the optional parameters
|
29
|
-
# @return [InlineResponse20076]
|
30
|
-
def add(body = {}, opts = {})
|
31
|
-
data = add_with_http_info(body, opts)
|
32
|
-
data
|
33
|
-
end
|
34
22
|
|
35
23
|
# Add email to whitelist
|
36
24
|
# Adds an email to your email rejection whitelist. If the address is currently on your blacklist, that blacklist entry will be removed automatically.
|
37
25
|
# @param body
|
38
26
|
# @param [Hash] opts the optional parameters
|
39
27
|
# @return [Array<(InlineResponse20076, Fixnum, Hash)>] InlineResponse20076 data, response status code and response headers
|
40
|
-
def
|
41
|
-
|
42
|
-
body[:key] = @api_key
|
43
|
-
|
44
|
-
# resource path
|
45
|
-
local_var_path = '/whitelists/add'
|
46
|
-
|
47
|
-
# http body (model)
|
48
|
-
data = @api_client.call_api(:POST, local_var_path, :body => body)
|
49
|
-
return data
|
50
|
-
end
|
51
|
-
# Remove email from whitelist
|
52
|
-
# Removes an email address from the whitelist.
|
53
|
-
# @param body
|
54
|
-
# @param [Hash] opts the optional parameters
|
55
|
-
# @return [InlineResponse20078]
|
56
|
-
def delete(body = {}, opts = {})
|
57
|
-
data = delete_with_http_info(body, opts)
|
28
|
+
def add(body = {})
|
29
|
+
data = @api_client.call_api(:POST, '/whitelists/add', body)
|
58
30
|
data
|
59
31
|
end
|
60
32
|
|
@@ -63,24 +35,8 @@ module MailchimpTransactional
|
|
63
35
|
# @param body
|
64
36
|
# @param [Hash] opts the optional parameters
|
65
37
|
# @return [Array<(InlineResponse20078, Fixnum, Hash)>] InlineResponse20078 data, response status code and response headers
|
66
|
-
def
|
67
|
-
|
68
|
-
body[:key] = @api_key
|
69
|
-
|
70
|
-
# resource path
|
71
|
-
local_var_path = '/whitelists/delete'
|
72
|
-
|
73
|
-
# http body (model)
|
74
|
-
data = @api_client.call_api(:POST, local_var_path, :body => body)
|
75
|
-
return data
|
76
|
-
end
|
77
|
-
# List whitelisted emails
|
78
|
-
# Retrieves your email rejection whitelist. You can provide an email address or search prefix to limit the results. Returns up to 1000 results.
|
79
|
-
# @param body
|
80
|
-
# @param [Hash] opts the optional parameters
|
81
|
-
# @return [Array<InlineResponse20077>]
|
82
|
-
def list(body = {}, opts = {})
|
83
|
-
data = list_with_http_info(body, opts)
|
38
|
+
def delete(body = {})
|
39
|
+
data = @api_client.call_api(:POST, '/whitelists/delete', body)
|
84
40
|
data
|
85
41
|
end
|
86
42
|
|
@@ -89,16 +45,9 @@ module MailchimpTransactional
|
|
89
45
|
# @param body
|
90
46
|
# @param [Hash] opts the optional parameters
|
91
47
|
# @return [Array<(Array<InlineResponse20077>, Fixnum, Hash)>] Array<InlineResponse20077> data, response status code and response headers
|
92
|
-
def
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
# resource path
|
97
|
-
local_var_path = '/whitelists/list'
|
98
|
-
|
99
|
-
# http body (model)
|
100
|
-
data = @api_client.call_api(:POST, local_var_path, :body => body)
|
101
|
-
return data
|
48
|
+
def list(body = {})
|
49
|
+
data = @api_client.call_api(:POST, '/whitelists/list', body)
|
50
|
+
data
|
102
51
|
end
|
103
52
|
end
|
104
53
|
end
|
@@ -3,170 +3,85 @@
|
|
3
3
|
|
4
4
|
#No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
5
5
|
|
6
|
-
OpenAPI spec version: 1.0.
|
7
|
-
Contact: apihelp@
|
6
|
+
OpenAPI spec version: 1.0.14
|
7
|
+
Contact: apihelp@mailchimp.com
|
8
8
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
9
|
Swagger Codegen version: 2.4.12
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
13
13
|
require 'json'
|
14
|
-
require '
|
14
|
+
require 'excon'
|
15
15
|
|
16
16
|
module MailchimpTransactional
|
17
17
|
class ApiClient
|
18
|
-
|
19
|
-
#
|
20
|
-
# @return [Hash]
|
21
|
-
attr_accessor :default_headers
|
22
|
-
|
23
|
-
# Initializes the ApiClient
|
24
|
-
def initialize()
|
18
|
+
def initialize(api_key = '')
|
25
19
|
@host = "https://mandrillapp.com/api/1.0"
|
26
|
-
@user_agent = "Swagger-Codegen/#{VERSION}/ruby"
|
27
|
-
@default_headers = {
|
28
|
-
'Content-Type' => 'application/json',
|
29
|
-
'User-Agent' => @user_agent
|
30
|
-
}
|
31
20
|
@format_list = ['json', 'xml', 'php', 'yaml']
|
32
|
-
@content_type = 'application/json'
|
33
21
|
@default_output_format = 'json'
|
34
22
|
@accepts = ['application/json', 'application/xml', 'application/x-php', 'application/x-yaml; charset=utf-8']
|
23
|
+
set_api_key(api_key)
|
35
24
|
end
|
36
25
|
|
37
26
|
def self.default
|
38
27
|
@@default ||= ApiClient.new
|
39
28
|
end
|
40
29
|
|
30
|
+
def set_api_key(api_key = '')
|
31
|
+
@api_key = api_key
|
32
|
+
end
|
33
|
+
|
41
34
|
def set_default_output_format(output_format)
|
42
35
|
if @format_list.include? output_format
|
43
36
|
@default_output_format = output_format
|
44
37
|
end
|
45
38
|
end
|
46
39
|
|
47
|
-
def call_api(http_method, path,
|
48
|
-
header_params = @default_headers.merge(opts[:header_params] || {})
|
49
|
-
url = @host + path
|
50
|
-
|
40
|
+
def call_api(http_method, path, body = {})
|
51
41
|
use_default_output_format = true
|
42
|
+
active_output_format = @default_output_format
|
43
|
+
url = @host + path
|
52
44
|
|
53
|
-
|
54
|
-
|
55
|
-
if body && body[:outputFormat]
|
45
|
+
# format body
|
46
|
+
if body[:outputFormat]
|
56
47
|
format = body[:outputFormat].downcase
|
57
48
|
if @format_list.include? format
|
58
49
|
url += ".#{format}"
|
59
50
|
body.delete(:outputFormat)
|
60
51
|
use_default_output_format = false
|
52
|
+
active_output_format = format
|
61
53
|
end
|
62
54
|
end
|
63
55
|
|
56
|
+
# apply output format
|
64
57
|
if use_default_output_format && @format_list.include?(@default_output_format)
|
65
58
|
url += '.%s' % @default_output_format
|
59
|
+
active_output_format = @default_output_format
|
66
60
|
end
|
67
61
|
|
68
|
-
|
62
|
+
# apply api key
|
63
|
+
body[:key] = @api_key
|
64
|
+
|
65
|
+
# send request
|
66
|
+
conn = Excon.new(url, :headers => {'Content-Type' => 'application/json'})
|
67
|
+
res = conn.post(:body => body.to_json)
|
69
68
|
|
69
|
+
# handle response
|
70
70
|
data = nil
|
71
|
-
if res.headers['content-type'] && res.headers['content-type'].include?('application/json')
|
72
|
-
data = JSON.parse(res.body)
|
73
|
-
else
|
74
|
-
data = res.body
|
75
|
-
end
|
76
71
|
|
77
|
-
if
|
78
|
-
if
|
79
|
-
data
|
72
|
+
if res.status == 200
|
73
|
+
if active_output_format == 'json'
|
74
|
+
data = JSON.parse(res.body)
|
80
75
|
else
|
81
|
-
|
76
|
+
data = res.body
|
82
77
|
end
|
83
78
|
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def request(http_method, url, body = nil, headers = nil)
|
87
|
-
if http_method.to_sym.downcase == :post
|
88
|
-
Faraday.post(url, body.to_json, headers)
|
89
|
-
else
|
90
|
-
fail ApiError.new('http_method must be :post')
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
# Return Accept header based on an array of accepts provided.
|
95
|
-
# @param [Array] accepts array for Accept
|
96
|
-
# @return [String] the Accept header (e.g. application/json)
|
97
|
-
def select_header_accept(accepts)
|
98
|
-
return nil if accepts.nil? || accepts.empty?
|
99
|
-
# use JSON when present, otherwise use all of the provided
|
100
|
-
json_accept = accepts.find { |s| json_mime?(s) }
|
101
|
-
json_accept || accepts.join(',')
|
102
|
-
end
|
103
|
-
|
104
|
-
# Return Content-Type header based on an array of content types provided.
|
105
|
-
# @param [Array] content_types array for Content-Type
|
106
|
-
# @return [String] the Content-Type header (e.g. application/json)
|
107
|
-
def select_header_content_type(content_types)
|
108
|
-
# use application/json by default
|
109
|
-
return 'application/json' if content_types.nil? || content_types.empty?
|
110
|
-
# use JSON when present, otherwise use the first one
|
111
|
-
json_content_type = content_types.find { |s| json_mime?(s) }
|
112
|
-
json_content_type || content_types.first
|
113
|
-
end
|
114
|
-
|
115
|
-
# Convert object (array, hash, object, etc) to JSON string.
|
116
|
-
# @param [Object] model object to be converted into JSON string
|
117
|
-
# @return [String] JSON string representation of the object
|
118
|
-
def object_to_http_body(model)
|
119
|
-
return model if model.nil? || model.is_a?(String)
|
120
|
-
local_body = nil
|
121
|
-
if model.is_a?(Array)
|
122
|
-
local_body = model.map { |m| object_to_hash(m) }
|
123
|
-
else
|
124
|
-
local_body = object_to_hash(model)
|
125
|
-
end
|
126
|
-
local_body.to_json
|
127
|
-
end
|
128
|
-
|
129
|
-
# Convert object(non-array) to hash.
|
130
|
-
# @param [Object] obj object to be converted into JSON string
|
131
|
-
# @return [String] JSON string representation of the object
|
132
|
-
def object_to_hash(obj)
|
133
|
-
if obj.respond_to?(:to_hash)
|
134
|
-
obj.to_hash
|
135
|
-
else
|
136
|
-
obj
|
137
|
-
end
|
138
|
-
end
|
139
79
|
|
140
|
-
|
141
|
-
|
142
|
-
def build_collection_param(param, collection_format)
|
143
|
-
case collection_format
|
144
|
-
when :csv
|
145
|
-
param.join(',')
|
146
|
-
when :ssv
|
147
|
-
param.join(' ')
|
148
|
-
when :tsv
|
149
|
-
param.join("\t")
|
150
|
-
when :pipes
|
151
|
-
param.join('|')
|
152
|
-
when :multi
|
153
|
-
# return the array directly as typhoeus will handle it as expected
|
154
|
-
param
|
155
|
-
else
|
156
|
-
fail "unknown collection format: #{collection_format.inspect}"
|
80
|
+
if (!data)
|
81
|
+
fail ApiError.new(:status => res.status, :response_body => res.body)
|
157
82
|
end
|
158
|
-
end
|
159
83
|
|
160
|
-
|
161
|
-
# JSON MIME examples:
|
162
|
-
# application/json
|
163
|
-
# application/json; charset=UTF8
|
164
|
-
# APPLICATION/JSON
|
165
|
-
# */*
|
166
|
-
# @param [String] mime MIME
|
167
|
-
# @return [Boolean] True if the MIME is application/json
|
168
|
-
def json_mime?(mime)
|
169
|
-
(mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
|
84
|
+
return data
|
170
85
|
end
|
171
86
|
end
|
172
87
|
end
|