MailchimpMarketing 3.0.5 → 3.0.10
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 +2 -2
- data/README.md +22 -26
- data/lib/MailchimpMarketing.rb +1 -1
- data/lib/MailchimpMarketing/api/activity_feed_api.rb +10 -71
- data/lib/MailchimpMarketing/api/authorized_apps_api.rb +16 -116
- data/lib/MailchimpMarketing/api/automations_api.rb +110 -704
- data/lib/MailchimpMarketing/api/batch_webhooks_api.rb +27 -187
- data/lib/MailchimpMarketing/api/batches_api.rb +21 -150
- data/lib/MailchimpMarketing/api/campaign_folders_api.rb +27 -187
- data/lib/MailchimpMarketing/api/campaigns_api.rb +124 -828
- data/lib/MailchimpMarketing/api/connected_sites_api.rb +26 -184
- data/lib/MailchimpMarketing/api/conversations_api.rb +30 -210
- data/lib/MailchimpMarketing/api/dashboard_api.rb +25 -227
- data/lib/MailchimpMarketing/api/ecommerce_api.rb +387 -2371
- data/lib/MailchimpMarketing/api/external_auths_api.rb +16 -116
- data/lib/MailchimpMarketing/api/facebook_ads_api.rb +13 -85
- data/lib/MailchimpMarketing/api/file_manager_api.rb +59 -424
- data/lib/MailchimpMarketing/api/landing_pages_api.rb +44 -296
- data/lib/MailchimpMarketing/api/lists_api.rb +420 -2707
- data/lib/MailchimpMarketing/api/ping_api.rb +5 -34
- data/lib/MailchimpMarketing/api/postcards_api.rb +7 -42
- data/lib/MailchimpMarketing/api/reporting_api.rb +34 -243
- data/lib/MailchimpMarketing/api/reports_api.rb +130 -925
- data/lib/MailchimpMarketing/api/root_api.rb +5 -38
- data/lib/MailchimpMarketing/api/search_campaigns_api.rb +6 -40
- data/lib/MailchimpMarketing/api/search_members_api.rb +6 -42
- data/lib/MailchimpMarketing/api/template_folders_api.rb +27 -187
- data/lib/MailchimpMarketing/api/templates_api.rb +33 -240
- data/lib/MailchimpMarketing/api/verified_domains_api.rb +26 -175
- data/lib/MailchimpMarketing/api_client.rb +15 -161
- data/lib/MailchimpMarketing/api_error.rb +1 -1
- data/lib/MailchimpMarketing/configuration.rb +1 -1
- data/lib/MailchimpMarketing/version.rb +2 -2
- metadata +5 -11
@@ -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.10
|
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,24 +11,13 @@ Swagger Codegen version: 2.4.12
|
|
11
11
|
=end
|
12
12
|
|
13
13
|
require 'json'
|
14
|
-
require '
|
14
|
+
require 'excon'
|
15
15
|
|
16
16
|
module MailchimpMarketing
|
17
17
|
class ApiClient
|
18
|
-
# Defines the headers to be used in HTTP requests of all API calls by default.
|
19
|
-
#
|
20
|
-
# @return [Hash]
|
21
|
-
attr_accessor :default_headers
|
22
|
-
|
23
|
-
# Initializes the ApiClient
|
24
18
|
def initialize(config = {})
|
25
19
|
@host = "https://server.api.mailchimp.com/3.0"
|
26
20
|
@user_agent = "Swagger-Codegen/#{VERSION}/ruby"
|
27
|
-
@default_headers = {
|
28
|
-
'Content-Type' => 'application/json',
|
29
|
-
'User-Agent' => @user_agent
|
30
|
-
}
|
31
|
-
|
32
21
|
set_config(config)
|
33
22
|
end
|
34
23
|
|
@@ -40,11 +29,9 @@ module MailchimpMarketing
|
|
40
29
|
begin
|
41
30
|
split = api_key.split('-')
|
42
31
|
server = 'invalid-server'
|
43
|
-
|
44
32
|
if split.length == 2
|
45
33
|
server = split[1]
|
46
34
|
end
|
47
|
-
|
48
35
|
server
|
49
36
|
rescue
|
50
37
|
""
|
@@ -52,11 +39,9 @@ module MailchimpMarketing
|
|
52
39
|
end
|
53
40
|
|
54
41
|
def set_config(config = {})
|
55
|
-
# Basic Auth
|
56
42
|
@api_key = config[:api_key] || ''
|
57
43
|
@is_basic_auth = @api_key.to_s.strip.empty? == false
|
58
44
|
|
59
|
-
# OAuth
|
60
45
|
@access_token = config[:access_token] || ''
|
61
46
|
@is_oauth = @access_token.to_s.strip.empty? == false
|
62
47
|
|
@@ -69,146 +54,31 @@ module MailchimpMarketing
|
|
69
54
|
end
|
70
55
|
|
71
56
|
def call_api(http_method, path, opts = {})
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
body = {}
|
77
|
-
if [:post, :patch, :put, :delete].include?(http_method.to_sym.downcase)
|
78
|
-
body = build_request_body(header_params, form_params, opts[:body])
|
79
|
-
end
|
80
|
-
|
81
|
-
res = request(http_method, path, query_params, header_params, body)
|
82
|
-
|
83
|
-
data = nil
|
84
|
-
if res.headers['content-type'] && res.headers['content-type'].include?('application/json')
|
85
|
-
data = JSON.parse(res.body)
|
86
|
-
else
|
87
|
-
data = res.body
|
88
|
-
end
|
57
|
+
headers = {'Content-Type' => "application/json"}
|
58
|
+
headers[:Authorization] = "Basic #{@api_key}" if @is_basic_auth
|
59
|
+
headers[:Authorization] = "Bearer #@access_token" if @is_oauth
|
89
60
|
|
90
|
-
if data
|
91
|
-
if res.status <= 200
|
92
|
-
data
|
93
|
-
else
|
94
|
-
fail ApiError.new(res.body)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
def request(http_method, path, query_params = nil, header_params = nil, body = nil)
|
100
61
|
host = @server.length > 0 ? @host.sub('server', @server) : @host
|
101
|
-
|
102
|
-
|
103
|
-
# Basic Authentication
|
104
|
-
conn = Faraday.new(url) do |conn|
|
105
|
-
conn.params = query_params
|
106
|
-
|
107
|
-
if @is_basic_auth
|
108
|
-
conn.headers = header_params
|
109
|
-
conn.basic_auth('user', @api_key)
|
110
|
-
end
|
111
|
-
|
112
|
-
if @is_oauth
|
113
|
-
conn.headers["Authorization"] = "Bearer #{@access_token}"
|
114
|
-
end
|
115
|
-
end
|
62
|
+
conn = Excon.new(host + path, :headers => headers)
|
116
63
|
|
64
|
+
res = nil
|
117
65
|
case http_method.to_sym.downcase
|
118
|
-
when :delete
|
119
|
-
conn.
|
120
|
-
req.body = body.to_json
|
121
|
-
end
|
66
|
+
when :post, :put, :delete
|
67
|
+
res = conn.request(:method => http_method, :body => opts[:body])
|
122
68
|
when :get
|
123
|
-
conn.get
|
124
|
-
when :head
|
125
|
-
conn.head
|
126
|
-
when :options
|
127
|
-
conn.options
|
128
|
-
when :post
|
129
|
-
conn.post do |req|
|
130
|
-
req.body = body.to_json
|
131
|
-
end
|
132
|
-
when :put
|
133
|
-
conn.put do |req|
|
134
|
-
req.body = body.to_json
|
135
|
-
end
|
136
|
-
when :patch
|
137
|
-
conn.patch do |req|
|
138
|
-
req.body = body.to_json
|
139
|
-
end
|
140
|
-
else
|
141
|
-
fail ApiError.new('Invalid http_method')
|
69
|
+
res = conn.get(:query => opts[:query_params])
|
142
70
|
end
|
143
|
-
end
|
144
|
-
|
145
|
-
# Sanitize filename by removing path.
|
146
|
-
# e.g. ../../sun.gif becomes sun.gif
|
147
|
-
#
|
148
|
-
# @param [String] filename the filename to be sanitized
|
149
|
-
# @return [String] the sanitized filename
|
150
|
-
def sanitize_filename(filename)
|
151
|
-
filename.gsub(/.*[\/\\]/, '')
|
152
|
-
end
|
153
71
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
end
|
159
|
-
|
160
|
-
# Builds the HTTP request body
|
161
|
-
#
|
162
|
-
# @param [Hash] header_params Header parameters
|
163
|
-
# @param [Hash] form_params Query parameters
|
164
|
-
# @param [Object] body HTTP body (JSON/XML)
|
165
|
-
# @return [String] HTTP body data in the form of string
|
166
|
-
def build_request_body(header_params, form_params, body)
|
167
|
-
# http form
|
168
|
-
if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
|
169
|
-
header_params['Content-Type'] == 'multipart/form-data'
|
170
|
-
data = {}
|
171
|
-
form_params.each do |key, value|
|
172
|
-
case value
|
173
|
-
when ::File, ::Array, nil
|
174
|
-
# let typhoeus handle File, Array and nil parameters
|
175
|
-
data[key] = value
|
176
|
-
else
|
177
|
-
data[key] = value.to_s
|
178
|
-
end
|
179
|
-
end
|
180
|
-
elsif body
|
181
|
-
data = body.is_a?(String) ? body : body.to_json
|
72
|
+
if res.status == 204
|
73
|
+
return "success"
|
74
|
+
elsif res.status == 200
|
75
|
+
return JSON.parse(res.body)
|
182
76
|
else
|
183
|
-
|
77
|
+
return res.body
|
184
78
|
end
|
185
|
-
data
|
186
|
-
end
|
187
|
-
|
188
|
-
# Return Accept header based on an array of accepts provided.
|
189
|
-
# @param [Array] accepts array for Accept
|
190
|
-
# @return [String] the Accept header (e.g. application/json)
|
191
|
-
def select_header_accept(accepts)
|
192
|
-
return nil if accepts.nil? || accepts.empty?
|
193
|
-
# use JSON when present, otherwise use all of the provided
|
194
|
-
json_accept = accepts.find { |s| json_mime?(s) }
|
195
|
-
json_accept || accepts.join(',')
|
196
|
-
end
|
197
|
-
|
198
|
-
# Return Content-Type header based on an array of content types provided.
|
199
|
-
# @param [Array] content_types array for Content-Type
|
200
|
-
# @return [String] the Content-Type header (e.g. application/json)
|
201
|
-
def select_header_content_type(content_types)
|
202
|
-
# use application/json by default
|
203
|
-
return 'application/json' if content_types.nil? || content_types.empty?
|
204
|
-
# use JSON when present, otherwise use the first one
|
205
|
-
json_content_type = content_types.find { |s| json_mime?(s) }
|
206
|
-
json_content_type || content_types.first
|
207
79
|
end
|
208
80
|
|
209
81
|
# Convert object (array, hash, object, etc) to JSON string.
|
210
|
-
# @param [Object] model object to be converted into JSON string
|
211
|
-
# @return [String] JSON string representation of the object
|
212
82
|
def object_to_http_body(model)
|
213
83
|
return model if model.nil? || model.is_a?(String)
|
214
84
|
local_body = nil
|
@@ -221,8 +91,6 @@ module MailchimpMarketing
|
|
221
91
|
end
|
222
92
|
|
223
93
|
# Convert object(non-array) to hash.
|
224
|
-
# @param [Object] obj object to be converted into JSON string
|
225
|
-
# @return [String] JSON string representation of the object
|
226
94
|
def object_to_hash(obj)
|
227
95
|
if obj.respond_to?(:to_hash)
|
228
96
|
obj.to_hash
|
@@ -232,7 +100,6 @@ module MailchimpMarketing
|
|
232
100
|
end
|
233
101
|
|
234
102
|
# Build parameter value according to the given collection format.
|
235
|
-
# @param [String] collection_format one of :csv, :ssv, :tsv, :pipes and :multi
|
236
103
|
def build_collection_param(param, collection_format)
|
237
104
|
case collection_format
|
238
105
|
when :csv
|
@@ -244,23 +111,10 @@ module MailchimpMarketing
|
|
244
111
|
when :pipes
|
245
112
|
param.join('|')
|
246
113
|
when :multi
|
247
|
-
# return the array directly as typhoeus will handle it as expected
|
248
114
|
param
|
249
115
|
else
|
250
116
|
fail "unknown collection format: #{collection_format.inspect}"
|
251
117
|
end
|
252
118
|
end
|
253
|
-
|
254
|
-
# Check if the given MIME is a JSON MIME.
|
255
|
-
# JSON MIME examples:
|
256
|
-
# application/json
|
257
|
-
# application/json; charset=UTF8
|
258
|
-
# APPLICATION/JSON
|
259
|
-
# */*
|
260
|
-
# @param [String] mime MIME
|
261
|
-
# @return [Boolean] True if the MIME is application/json
|
262
|
-
def json_mime?(mime)
|
263
|
-
(mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
|
264
|
-
end
|
265
119
|
end
|
266
120
|
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.10
|
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.10
|
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.10
|
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.10'
|
15
15
|
end
|
metadata
CHANGED
@@ -1,35 +1,29 @@
|
|
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.10
|
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-08-
|
11
|
+
date: 2020-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: excon
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
- - ">="
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 1.0.1
|
19
|
+
version: 0.76.0
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
24
|
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
30
|
-
- - ">="
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: 1.0.1
|
26
|
+
version: 0.76.0
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: json
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|