MailchimpMarketing 3.0.1 → 3.0.8
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/MailchimpMarketing.gemspec +1 -1
- data/README.md +55 -46
- data/lib/MailchimpMarketing.rb +5 -6
- data/lib/MailchimpMarketing/api/activity_feed_api.rb +13 -69
- data/lib/MailchimpMarketing/api/authorized_apps_api.rb +20 -113
- data/lib/MailchimpMarketing/api/automations_api.rb +130 -685
- data/lib/MailchimpMarketing/api/batch_webhooks_api.rb +33 -182
- data/lib/MailchimpMarketing/api/batches_api.rb +26 -146
- data/lib/MailchimpMarketing/api/campaign_folders_api.rb +33 -182
- data/lib/MailchimpMarketing/api/campaigns_api.rb +144 -803
- data/lib/MailchimpMarketing/api/connected_sites_api.rb +32 -179
- data/lib/MailchimpMarketing/api/conversations_api.rb +36 -205
- data/lib/MailchimpMarketing/api/dashboard_api.rb +32 -221
- data/lib/MailchimpMarketing/api/ecommerce_api.rb +447 -2312
- data/lib/MailchimpMarketing/api/external_auths_api.rb +20 -113
- data/lib/MailchimpMarketing/api/facebook_ads_api.rb +16 -83
- data/lib/MailchimpMarketing/api/file_manager_api.rb +71 -413
- data/lib/MailchimpMarketing/api/landing_pages_api.rb +51 -286
- data/lib/MailchimpMarketing/api/lists_api.rb +721 -2876
- data/lib/MailchimpMarketing/api/ping_api.rb +7 -33
- data/lib/MailchimpMarketing/api/postcards_api.rb +9 -41
- data/lib/MailchimpMarketing/api/reporting_api.rb +41 -237
- data/lib/MailchimpMarketing/api/reports_api.rb +153 -903
- data/lib/MailchimpMarketing/api/root_api.rb +7 -37
- data/lib/MailchimpMarketing/api/search_campaigns_api.rb +8 -39
- data/lib/MailchimpMarketing/api/search_members_api.rb +8 -41
- data/lib/MailchimpMarketing/api/template_folders_api.rb +33 -182
- data/lib/MailchimpMarketing/api/templates_api.rb +40 -234
- data/lib/MailchimpMarketing/api/verified_domains_api.rb +32 -170
- data/lib/MailchimpMarketing/api_client.rb +94 -64
- data/lib/MailchimpMarketing/api_error.rb +4 -4
- data/lib/MailchimpMarketing/configuration.rb +1 -1
- data/lib/MailchimpMarketing/version.rb +2 -2
- metadata +2 -2
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
#No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
5
5
|
|
6
|
-
OpenAPI spec version: 3.0.
|
6
|
+
OpenAPI spec version: 3.0.8
|
7
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
|
@@ -15,22 +15,10 @@ require 'faraday'
|
|
15
15
|
|
16
16
|
module MailchimpMarketing
|
17
17
|
class ApiClient
|
18
|
-
|
19
|
-
#
|
20
|
-
# @return [Hash]
|
21
|
-
attr_accessor :default_headers
|
22
|
-
|
23
|
-
# Initializes the ApiClient
|
24
|
-
def initialize(api_key, server = '')
|
18
|
+
def initialize(config = {})
|
25
19
|
@host = "https://server.api.mailchimp.com/3.0"
|
26
20
|
@user_agent = "Swagger-Codegen/#{VERSION}/ruby"
|
27
|
-
|
28
|
-
'Content-Type' => 'application/json',
|
29
|
-
'User-Agent' => @user_agent
|
30
|
-
}
|
31
|
-
|
32
|
-
@api_key = api_key
|
33
|
-
@server = server || get_server_from_api_key(api_key)
|
21
|
+
set_config(config)
|
34
22
|
end
|
35
23
|
|
36
24
|
def self.default
|
@@ -39,27 +27,41 @@ module MailchimpMarketing
|
|
39
27
|
|
40
28
|
def get_server_from_api_key(api_key = '')
|
41
29
|
begin
|
42
|
-
split = api_key.split('-
|
43
|
-
|
44
|
-
|
30
|
+
split = api_key.split('-')
|
31
|
+
server = 'invalid-server'
|
32
|
+
if split.length == 2
|
33
|
+
server = split[1]
|
34
|
+
end
|
45
35
|
server
|
46
36
|
rescue
|
47
37
|
""
|
48
38
|
end
|
49
39
|
end
|
50
40
|
|
51
|
-
def set_config(
|
52
|
-
@api_key = api_key ||
|
53
|
-
@
|
41
|
+
def set_config(config = {})
|
42
|
+
@api_key = config[:api_key] || ''
|
43
|
+
@is_basic_auth = @api_key.to_s.strip.empty? == false
|
44
|
+
@access_token = config[:access_token] || ''
|
45
|
+
@is_oauth = @access_token.to_s.strip.empty? == false
|
46
|
+
|
47
|
+
# If using Basic auth and no server is provided,
|
48
|
+
# attempt to extract it from the api_key directy.
|
49
|
+
@server = config[:server] || 'invalid-server'
|
50
|
+
if @server == 'invalid-server' && @is_basic_auth
|
51
|
+
@server = get_server_from_api_key(@api_key)
|
52
|
+
end
|
54
53
|
end
|
55
54
|
|
56
55
|
def call_api(http_method, path, opts = {})
|
57
|
-
header_params =
|
56
|
+
header_params = {
|
57
|
+
'Content-Type' => 'application/json',
|
58
|
+
'User-Agent' => @user_agent
|
59
|
+
}
|
58
60
|
query_params = opts[:query_params] || {}
|
59
61
|
form_params = opts[:form_params] || {}
|
60
62
|
|
61
|
-
body =
|
62
|
-
if [:post, :patch, :put, :delete].include?(http_method)
|
63
|
+
body = {}
|
64
|
+
if [:post, :patch, :put, :delete].include?(http_method.to_sym.downcase)
|
63
65
|
body = build_request_body(header_params, form_params, opts[:body])
|
64
66
|
end
|
65
67
|
|
@@ -85,60 +87,66 @@ module MailchimpMarketing
|
|
85
87
|
host = @server.length > 0 ? @host.sub('server', @server) : @host
|
86
88
|
url = host + path
|
87
89
|
|
88
|
-
|
89
|
-
|
90
|
+
# Apply Authentication
|
91
|
+
conn = Faraday.new(url) do |conn|
|
92
|
+
conn.headers = header_params
|
93
|
+
conn.params = query_params
|
94
|
+
|
95
|
+
if @is_basic_auth
|
96
|
+
conn.basic_auth('user', @api_key)
|
97
|
+
elsif @is_oauth
|
98
|
+
conn.headers["Authorization"] = "Bearer #{@access_token}"
|
99
|
+
end
|
90
100
|
end
|
91
101
|
|
92
102
|
case http_method.to_sym.downcase
|
93
103
|
when :delete
|
94
|
-
conn.delete
|
104
|
+
conn.delete do |req|
|
105
|
+
req.body = body.to_json
|
106
|
+
end
|
95
107
|
when :get
|
96
|
-
conn.get
|
108
|
+
conn.get
|
97
109
|
when :head
|
98
|
-
conn.head
|
110
|
+
conn.head
|
99
111
|
when :options
|
100
|
-
conn.options
|
112
|
+
conn.options
|
101
113
|
when :post
|
102
|
-
conn.post
|
114
|
+
conn.post do |req|
|
115
|
+
req.body = body.to_json
|
116
|
+
end
|
103
117
|
when :put
|
104
|
-
conn.put
|
118
|
+
conn.put do |req|
|
119
|
+
req.body = body.to_json
|
120
|
+
end
|
105
121
|
when :patch
|
106
|
-
conn.patch
|
122
|
+
conn.patch do |req|
|
123
|
+
req.body = body.to_json
|
124
|
+
end
|
107
125
|
else
|
108
|
-
fail ApiError.new('http_method
|
126
|
+
fail ApiError.new('Invalid http_method')
|
109
127
|
end
|
110
128
|
end
|
111
129
|
|
112
130
|
# Sanitize filename by removing path.
|
113
131
|
# e.g. ../../sun.gif becomes sun.gif
|
114
|
-
#
|
115
|
-
# @param [String] filename the filename to be sanitized
|
116
|
-
# @return [String] the sanitized filename
|
117
132
|
def sanitize_filename(filename)
|
118
133
|
filename.gsub(/.*[\/\\]/, '')
|
119
134
|
end
|
120
135
|
|
136
|
+
# Add leading and trailing slashes to path
|
121
137
|
def build_request_url(path)
|
122
|
-
# Add leading and trailing slashes to path
|
123
138
|
path = "/#{path}".gsub(/\/+/, '/')
|
124
139
|
URI.encode(@config.base_url + path)
|
125
140
|
end
|
126
141
|
|
127
|
-
#
|
128
|
-
#
|
129
|
-
# @param [Hash] header_params Header parameters
|
130
|
-
# @param [Hash] form_params Query parameters
|
131
|
-
# @param [Object] body HTTP body (JSON/XML)
|
132
|
-
# @return [String] HTTP body data in the form of string
|
142
|
+
# Format HTTP request body as string
|
133
143
|
def build_request_body(header_params, form_params, body)
|
134
|
-
# http form
|
135
144
|
if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
|
136
145
|
header_params['Content-Type'] == 'multipart/form-data'
|
137
146
|
data = {}
|
138
147
|
form_params.each do |key, value|
|
139
148
|
case value
|
140
149
|
when ::File, ::Array, nil
|
141
|
-
# let typhoeus handle File, Array and nil parameters
|
142
150
|
data[key] = value
|
143
151
|
else
|
144
152
|
data[key] = value.to_s
|
@@ -153,40 +161,62 @@ module MailchimpMarketing
|
|
153
161
|
end
|
154
162
|
|
155
163
|
# Return Accept header based on an array of accepts provided.
|
156
|
-
# @param [Array] accepts array for Accept
|
157
|
-
# @return [String] the Accept header (e.g. application/json)
|
158
164
|
def select_header_accept(accepts)
|
159
165
|
return nil if accepts.nil? || accepts.empty?
|
160
|
-
# use JSON when present, otherwise use all of the provided
|
161
166
|
json_accept = accepts.find { |s| json_mime?(s) }
|
162
167
|
json_accept || accepts.join(',')
|
163
168
|
end
|
164
169
|
|
165
170
|
# Return Content-Type header based on an array of content types provided.
|
166
|
-
# @param [Array] content_types array for Content-Type
|
167
|
-
# @return [String] the Content-Type header (e.g. application/json)
|
168
171
|
def select_header_content_type(content_types)
|
169
|
-
# use application/json by default
|
170
172
|
return 'application/json' if content_types.nil? || content_types.empty?
|
171
|
-
|
173
|
+
|
172
174
|
json_content_type = content_types.find { |s| json_mime?(s) }
|
173
175
|
json_content_type || content_types.first
|
174
176
|
end
|
175
177
|
|
176
|
-
#
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
178
|
+
# Convert object (array, hash, object, etc) to JSON string.
|
179
|
+
def object_to_http_body(model)
|
180
|
+
return model if model.nil? || model.is_a?(String)
|
181
|
+
local_body = nil
|
182
|
+
if model.is_a?(Array)
|
183
|
+
local_body = model.map { |m| object_to_hash(m) }
|
184
|
+
else
|
185
|
+
local_body = object_to_hash(model)
|
186
|
+
end
|
187
|
+
local_body.to_json
|
186
188
|
end
|
187
189
|
|
190
|
+
# Convert object(non-array) to hash.
|
191
|
+
def object_to_hash(obj)
|
192
|
+
if obj.respond_to?(:to_hash)
|
193
|
+
obj.to_hash
|
194
|
+
else
|
195
|
+
obj
|
196
|
+
end
|
197
|
+
end
|
188
198
|
|
199
|
+
# Build parameter value according to the given collection format.
|
200
|
+
def build_collection_param(param, collection_format)
|
201
|
+
case collection_format
|
202
|
+
when :csv
|
203
|
+
param.join(',')
|
204
|
+
when :ssv
|
205
|
+
param.join(' ')
|
206
|
+
when :tsv
|
207
|
+
param.join("\t")
|
208
|
+
when :pipes
|
209
|
+
param.join('|')
|
210
|
+
when :multi
|
211
|
+
param
|
212
|
+
else
|
213
|
+
fail "unknown collection format: #{collection_format.inspect}"
|
214
|
+
end
|
215
|
+
end
|
189
216
|
|
190
|
-
|
217
|
+
# Check if the given MIME is a JSON MIME.
|
218
|
+
def json_mime?(mime)
|
219
|
+
(mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
|
220
|
+
end
|
191
221
|
end
|
192
222
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
#No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
5
5
|
|
6
|
-
OpenAPI spec version: 3.0.
|
6
|
+
OpenAPI spec version: 3.0.8
|
7
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
|
@@ -12,13 +12,13 @@ Swagger Codegen version: 2.4.12
|
|
12
12
|
|
13
13
|
module MailchimpMarketing
|
14
14
|
class ApiError < StandardError
|
15
|
-
attr_reader :
|
15
|
+
attr_reader :status, :type, :title, :detail, :instance, :errors
|
16
16
|
|
17
17
|
# Usage examples:
|
18
18
|
# ApiError.new
|
19
19
|
# ApiError.new("message")
|
20
|
-
# ApiError.new(:
|
21
|
-
# ApiError.new(:
|
20
|
+
# ApiError.new(:status => 500, :response_headers => {}, :response_body => "")
|
21
|
+
# ApiError.new(:status => 404, :message => "Not Found")
|
22
22
|
def initialize(arg = nil)
|
23
23
|
if arg.is_a? Hash
|
24
24
|
if arg.key?(:message) || arg.key?('message')
|
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
#No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
5
5
|
|
6
|
-
OpenAPI spec version: 3.0.
|
6
|
+
OpenAPI spec version: 3.0.8
|
7
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
|
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
#No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
5
5
|
|
6
|
-
OpenAPI spec version: 3.0.
|
6
|
+
OpenAPI spec version: 3.0.8
|
7
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
|
@@ -11,5 +11,5 @@ Swagger Codegen version: 2.4.12
|
|
11
11
|
=end
|
12
12
|
|
13
13
|
module MailchimpMarketing
|
14
|
-
VERSION = '3.0.
|
14
|
+
VERSION = '3.0.8'
|
15
15
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: MailchimpMarketing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Swagger-Codegen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|