MailchimpTransactional 1.0.4
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.
- checksums.yaml +7 -0
- data/Gemfile +7 -0
- data/MailchimpTransactional.gemspec +45 -0
- data/README.md +174 -0
- data/lib/MailchimpTransactional.rb +123 -0
- data/lib/MailchimpTransactional/api/exports_api.rb +176 -0
- data/lib/MailchimpTransactional/api/inbound_api.rb +296 -0
- data/lib/MailchimpTransactional/api/ips_api.rb +416 -0
- data/lib/MailchimpTransactional/api/messages_api.rb +356 -0
- data/lib/MailchimpTransactional/api/metadata_api.rb +146 -0
- data/lib/MailchimpTransactional/api/rejects_api.rb +116 -0
- data/lib/MailchimpTransactional/api/senders_api.rb +236 -0
- data/lib/MailchimpTransactional/api/subaccounts_api.rb +236 -0
- data/lib/MailchimpTransactional/api/tags_api.rb +176 -0
- data/lib/MailchimpTransactional/api/templates_api.rb +266 -0
- data/lib/MailchimpTransactional/api/urls_api.rb +206 -0
- data/lib/MailchimpTransactional/api/users_api.rb +146 -0
- data/lib/MailchimpTransactional/api/webhooks_api.rb +176 -0
- data/lib/MailchimpTransactional/api/whitelists_api.rb +116 -0
- data/lib/MailchimpTransactional/api_client.rb +94 -0
- data/lib/MailchimpTransactional/api_error.rb +38 -0
- data/lib/MailchimpTransactional/configuration.rb +202 -0
- data/lib/MailchimpTransactional/version.rb +15 -0
- metadata +245 -0
@@ -0,0 +1,146 @@
|
|
1
|
+
=begin
|
2
|
+
#Mailchimp Transactional API
|
3
|
+
|
4
|
+
#No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0.4
|
7
|
+
Contact: apihelp@mandrill.com
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.4.12
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'uri'
|
14
|
+
|
15
|
+
module MailchimpTransactional
|
16
|
+
class UsersApi
|
17
|
+
attr_accessor :api_client
|
18
|
+
|
19
|
+
attr_accessor :api_key
|
20
|
+
|
21
|
+
def initialize(api_key = '', api_client = ApiClient.default)
|
22
|
+
@api_key = api_key
|
23
|
+
@api_client = api_client
|
24
|
+
end
|
25
|
+
# /users/info
|
26
|
+
# Return the information about the API-connected user
|
27
|
+
# @param body
|
28
|
+
# @param [Hash] opts the optional parameters
|
29
|
+
# @return [InlineResponse20069]
|
30
|
+
def info(body = {}, opts = {})
|
31
|
+
data, _status_code, _headers = info_with_http_info(body, opts)
|
32
|
+
data
|
33
|
+
end
|
34
|
+
|
35
|
+
# /users/info
|
36
|
+
# Return the information about the API-connected user
|
37
|
+
# @param body
|
38
|
+
# @param [Hash] opts the optional parameters
|
39
|
+
# @return [Array<(InlineResponse20069, Fixnum, Hash)>] InlineResponse20069 data, response status code and response headers
|
40
|
+
def info_with_http_info(body, opts = {})
|
41
|
+
# add api key to request body
|
42
|
+
body[:key] = @api_key
|
43
|
+
|
44
|
+
# resource path
|
45
|
+
local_var_path = '/users/info'
|
46
|
+
|
47
|
+
# http body (model)
|
48
|
+
auth_names = []
|
49
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
|
50
|
+
:body => body,
|
51
|
+
:auth_names => auth_names,
|
52
|
+
:return_type => 'InlineResponse20069')
|
53
|
+
return data, status_code, headers
|
54
|
+
end
|
55
|
+
# /users/ping
|
56
|
+
# Validate an API key and respond to a ping
|
57
|
+
# @param body
|
58
|
+
# @param [Hash] opts the optional parameters
|
59
|
+
# @return [String]
|
60
|
+
def ping(body = {}, opts = {})
|
61
|
+
data, _status_code, _headers = ping_with_http_info(body, opts)
|
62
|
+
data
|
63
|
+
end
|
64
|
+
|
65
|
+
# /users/ping
|
66
|
+
# Validate an API key and respond to a ping
|
67
|
+
# @param body
|
68
|
+
# @param [Hash] opts the optional parameters
|
69
|
+
# @return [Array<(String, Fixnum, Hash)>] String data, response status code and response headers
|
70
|
+
def ping_with_http_info(body, opts = {})
|
71
|
+
# add api key to request body
|
72
|
+
body[:key] = @api_key
|
73
|
+
|
74
|
+
# resource path
|
75
|
+
local_var_path = '/users/ping'
|
76
|
+
|
77
|
+
# http body (model)
|
78
|
+
auth_names = []
|
79
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
|
80
|
+
:body => body,
|
81
|
+
:auth_names => auth_names,
|
82
|
+
:return_type => 'String')
|
83
|
+
return data, status_code, headers
|
84
|
+
end
|
85
|
+
# /users/ping2
|
86
|
+
# Validate an API key and respond to a ping (anal JSON parser version)
|
87
|
+
# @param body
|
88
|
+
# @param [Hash] opts the optional parameters
|
89
|
+
# @return [InlineResponse20070]
|
90
|
+
def ping2(body = {}, opts = {})
|
91
|
+
data, _status_code, _headers = ping2_with_http_info(body, opts)
|
92
|
+
data
|
93
|
+
end
|
94
|
+
|
95
|
+
# /users/ping2
|
96
|
+
# Validate an API key and respond to a ping (anal JSON parser version)
|
97
|
+
# @param body
|
98
|
+
# @param [Hash] opts the optional parameters
|
99
|
+
# @return [Array<(InlineResponse20070, Fixnum, Hash)>] InlineResponse20070 data, response status code and response headers
|
100
|
+
def ping2_with_http_info(body, opts = {})
|
101
|
+
# add api key to request body
|
102
|
+
body[:key] = @api_key
|
103
|
+
|
104
|
+
# resource path
|
105
|
+
local_var_path = '/users/ping2'
|
106
|
+
|
107
|
+
# http body (model)
|
108
|
+
auth_names = []
|
109
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
|
110
|
+
:body => body,
|
111
|
+
:auth_names => auth_names,
|
112
|
+
:return_type => 'InlineResponse20070')
|
113
|
+
return data, status_code, headers
|
114
|
+
end
|
115
|
+
# /users/senders
|
116
|
+
# Return the senders that have tried to use this account, both verified and unverified
|
117
|
+
# @param body
|
118
|
+
# @param [Hash] opts the optional parameters
|
119
|
+
# @return [Array<InlineResponse20040>]
|
120
|
+
def senders(body = {}, opts = {})
|
121
|
+
data, _status_code, _headers = senders_with_http_info(body, opts)
|
122
|
+
data
|
123
|
+
end
|
124
|
+
|
125
|
+
# /users/senders
|
126
|
+
# Return the senders that have tried to use this account, both verified and unverified
|
127
|
+
# @param body
|
128
|
+
# @param [Hash] opts the optional parameters
|
129
|
+
# @return [Array<(Array<InlineResponse20040>, Fixnum, Hash)>] Array<InlineResponse20040> data, response status code and response headers
|
130
|
+
def senders_with_http_info(body, opts = {})
|
131
|
+
# add api key to request body
|
132
|
+
body[:key] = @api_key
|
133
|
+
|
134
|
+
# resource path
|
135
|
+
local_var_path = '/users/senders'
|
136
|
+
|
137
|
+
# http body (model)
|
138
|
+
auth_names = []
|
139
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
|
140
|
+
:body => body,
|
141
|
+
:auth_names => auth_names,
|
142
|
+
:return_type => 'Array<InlineResponse20040>')
|
143
|
+
return data, status_code, headers
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
@@ -0,0 +1,176 @@
|
|
1
|
+
=begin
|
2
|
+
#Mailchimp Transactional API
|
3
|
+
|
4
|
+
#No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0.4
|
7
|
+
Contact: apihelp@mandrill.com
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.4.12
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'uri'
|
14
|
+
|
15
|
+
module MailchimpTransactional
|
16
|
+
class WebhooksApi
|
17
|
+
attr_accessor :api_client
|
18
|
+
|
19
|
+
attr_accessor :api_key
|
20
|
+
|
21
|
+
def initialize(api_key = '', api_client = ApiClient.default)
|
22
|
+
@api_key = api_key
|
23
|
+
@api_client = api_client
|
24
|
+
end
|
25
|
+
# /webhooks/add
|
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, _status_code, _headers = add_with_http_info(body, opts)
|
32
|
+
data
|
33
|
+
end
|
34
|
+
|
35
|
+
# /webhooks/add
|
36
|
+
# Add a new webhook
|
37
|
+
# @param body
|
38
|
+
# @param [Hash] opts the optional parameters
|
39
|
+
# @return [Array<(InlineResponse20072, Fixnum, Hash)>] InlineResponse20072 data, response status code and response headers
|
40
|
+
def add_with_http_info(body, opts = {})
|
41
|
+
# add api key to request body
|
42
|
+
body[:key] = @api_key
|
43
|
+
|
44
|
+
# resource path
|
45
|
+
local_var_path = '/webhooks/add'
|
46
|
+
|
47
|
+
# http body (model)
|
48
|
+
auth_names = []
|
49
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
|
50
|
+
:body => body,
|
51
|
+
:auth_names => auth_names,
|
52
|
+
:return_type => 'InlineResponse20072')
|
53
|
+
return data, status_code, headers
|
54
|
+
end
|
55
|
+
# /webhooks/delete
|
56
|
+
# Delete an existing webhook
|
57
|
+
# @param body
|
58
|
+
# @param [Hash] opts the optional parameters
|
59
|
+
# @return [InlineResponse20075]
|
60
|
+
def delete(body = {}, opts = {})
|
61
|
+
data, _status_code, _headers = delete_with_http_info(body, opts)
|
62
|
+
data
|
63
|
+
end
|
64
|
+
|
65
|
+
# /webhooks/delete
|
66
|
+
# Delete an existing webhook
|
67
|
+
# @param body
|
68
|
+
# @param [Hash] opts the optional parameters
|
69
|
+
# @return [Array<(InlineResponse20075, Fixnum, Hash)>] InlineResponse20075 data, response status code and response headers
|
70
|
+
def delete_with_http_info(body, opts = {})
|
71
|
+
# add api key to request body
|
72
|
+
body[:key] = @api_key
|
73
|
+
|
74
|
+
# resource path
|
75
|
+
local_var_path = '/webhooks/delete'
|
76
|
+
|
77
|
+
# http body (model)
|
78
|
+
auth_names = []
|
79
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
|
80
|
+
:body => body,
|
81
|
+
:auth_names => auth_names,
|
82
|
+
:return_type => 'InlineResponse20075')
|
83
|
+
return data, status_code, headers
|
84
|
+
end
|
85
|
+
# /webhooks/info
|
86
|
+
# Given the ID of an existing webhook, return the data about it
|
87
|
+
# @param body
|
88
|
+
# @param [Hash] opts the optional parameters
|
89
|
+
# @return [InlineResponse20073]
|
90
|
+
def info(body = {}, opts = {})
|
91
|
+
data, _status_code, _headers = info_with_http_info(body, opts)
|
92
|
+
data
|
93
|
+
end
|
94
|
+
|
95
|
+
# /webhooks/info
|
96
|
+
# Given the ID of an existing webhook, return the data about it
|
97
|
+
# @param body
|
98
|
+
# @param [Hash] opts the optional parameters
|
99
|
+
# @return [Array<(InlineResponse20073, Fixnum, Hash)>] InlineResponse20073 data, response status code and response headers
|
100
|
+
def info_with_http_info(body, opts = {})
|
101
|
+
# add api key to request body
|
102
|
+
body[:key] = @api_key
|
103
|
+
|
104
|
+
# resource path
|
105
|
+
local_var_path = '/webhooks/info'
|
106
|
+
|
107
|
+
# http body (model)
|
108
|
+
auth_names = []
|
109
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
|
110
|
+
:body => body,
|
111
|
+
:auth_names => auth_names,
|
112
|
+
:return_type => 'InlineResponse20073')
|
113
|
+
return data, status_code, headers
|
114
|
+
end
|
115
|
+
# /webhooks/list
|
116
|
+
# Get the list of all webhooks defined on the account
|
117
|
+
# @param body
|
118
|
+
# @param [Hash] opts the optional parameters
|
119
|
+
# @return [Array<InlineResponse20071>]
|
120
|
+
def list(body = {}, opts = {})
|
121
|
+
data, _status_code, _headers = list_with_http_info(body, opts)
|
122
|
+
data
|
123
|
+
end
|
124
|
+
|
125
|
+
# /webhooks/list
|
126
|
+
# Get the list of all webhooks defined on the account
|
127
|
+
# @param body
|
128
|
+
# @param [Hash] opts the optional parameters
|
129
|
+
# @return [Array<(Array<InlineResponse20071>, Fixnum, Hash)>] Array<InlineResponse20071> data, response status code and response headers
|
130
|
+
def list_with_http_info(body, opts = {})
|
131
|
+
# add api key to request body
|
132
|
+
body[:key] = @api_key
|
133
|
+
|
134
|
+
# resource path
|
135
|
+
local_var_path = '/webhooks/list'
|
136
|
+
|
137
|
+
# http body (model)
|
138
|
+
auth_names = []
|
139
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
|
140
|
+
:body => body,
|
141
|
+
:auth_names => auth_names,
|
142
|
+
:return_type => 'Array<InlineResponse20071>')
|
143
|
+
return data, status_code, headers
|
144
|
+
end
|
145
|
+
# /webhooks/update
|
146
|
+
# Update an existing webhook
|
147
|
+
# @param body
|
148
|
+
# @param [Hash] opts the optional parameters
|
149
|
+
# @return [InlineResponse20074]
|
150
|
+
def update(body = {}, opts = {})
|
151
|
+
data, _status_code, _headers = update_with_http_info(body, opts)
|
152
|
+
data
|
153
|
+
end
|
154
|
+
|
155
|
+
# /webhooks/update
|
156
|
+
# Update an existing webhook
|
157
|
+
# @param body
|
158
|
+
# @param [Hash] opts the optional parameters
|
159
|
+
# @return [Array<(InlineResponse20074, Fixnum, Hash)>] InlineResponse20074 data, response status code and response headers
|
160
|
+
def update_with_http_info(body, opts = {})
|
161
|
+
# add api key to request body
|
162
|
+
body[:key] = @api_key
|
163
|
+
|
164
|
+
# resource path
|
165
|
+
local_var_path = '/webhooks/update'
|
166
|
+
|
167
|
+
# http body (model)
|
168
|
+
auth_names = []
|
169
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
|
170
|
+
:body => body,
|
171
|
+
:auth_names => auth_names,
|
172
|
+
:return_type => 'InlineResponse20074')
|
173
|
+
return data, status_code, headers
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
=begin
|
2
|
+
#Mailchimp Transactional API
|
3
|
+
|
4
|
+
#No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0.4
|
7
|
+
Contact: apihelp@mandrill.com
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.4.12
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'uri'
|
14
|
+
|
15
|
+
module MailchimpTransactional
|
16
|
+
class WhitelistsApi
|
17
|
+
attr_accessor :api_client
|
18
|
+
|
19
|
+
attr_accessor :api_key
|
20
|
+
|
21
|
+
def initialize(api_key = '', api_client = ApiClient.default)
|
22
|
+
@api_key = api_key
|
23
|
+
@api_client = api_client
|
24
|
+
end
|
25
|
+
# /whitelists/add
|
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, _status_code, _headers = add_with_http_info(body, opts)
|
32
|
+
data
|
33
|
+
end
|
34
|
+
|
35
|
+
# /whitelists/add
|
36
|
+
# Adds an email to your email rejection whitelist. If the address is currently on your blacklist, that blacklist entry will be removed automatically.
|
37
|
+
# @param body
|
38
|
+
# @param [Hash] opts the optional parameters
|
39
|
+
# @return [Array<(InlineResponse20076, Fixnum, Hash)>] InlineResponse20076 data, response status code and response headers
|
40
|
+
def add_with_http_info(body, opts = {})
|
41
|
+
# add api key to request body
|
42
|
+
body[:key] = @api_key
|
43
|
+
|
44
|
+
# resource path
|
45
|
+
local_var_path = '/whitelists/add'
|
46
|
+
|
47
|
+
# http body (model)
|
48
|
+
auth_names = []
|
49
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
|
50
|
+
:body => body,
|
51
|
+
:auth_names => auth_names,
|
52
|
+
:return_type => 'InlineResponse20076')
|
53
|
+
return data, status_code, headers
|
54
|
+
end
|
55
|
+
# /whitelists/delete
|
56
|
+
# Removes an email address from the whitelist.
|
57
|
+
# @param body
|
58
|
+
# @param [Hash] opts the optional parameters
|
59
|
+
# @return [InlineResponse20078]
|
60
|
+
def delete(body = {}, opts = {})
|
61
|
+
data, _status_code, _headers = delete_with_http_info(body, opts)
|
62
|
+
data
|
63
|
+
end
|
64
|
+
|
65
|
+
# /whitelists/delete
|
66
|
+
# Removes an email address from the whitelist.
|
67
|
+
# @param body
|
68
|
+
# @param [Hash] opts the optional parameters
|
69
|
+
# @return [Array<(InlineResponse20078, Fixnum, Hash)>] InlineResponse20078 data, response status code and response headers
|
70
|
+
def delete_with_http_info(body, opts = {})
|
71
|
+
# add api key to request body
|
72
|
+
body[:key] = @api_key
|
73
|
+
|
74
|
+
# resource path
|
75
|
+
local_var_path = '/whitelists/delete'
|
76
|
+
|
77
|
+
# http body (model)
|
78
|
+
auth_names = []
|
79
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
|
80
|
+
:body => body,
|
81
|
+
:auth_names => auth_names,
|
82
|
+
:return_type => 'InlineResponse20078')
|
83
|
+
return data, status_code, headers
|
84
|
+
end
|
85
|
+
# /whitelists/list
|
86
|
+
# Retrieves your email rejection whitelist. You can provide an email address or search prefix to limit the results. Returns up to 1000 results.
|
87
|
+
# @param body
|
88
|
+
# @param [Hash] opts the optional parameters
|
89
|
+
# @return [Array<InlineResponse20077>]
|
90
|
+
def list(body = {}, opts = {})
|
91
|
+
data, _status_code, _headers = list_with_http_info(body, opts)
|
92
|
+
data
|
93
|
+
end
|
94
|
+
|
95
|
+
# /whitelists/list
|
96
|
+
# Retrieves your email rejection whitelist. You can provide an email address or search prefix to limit the results. Returns up to 1000 results.
|
97
|
+
# @param body
|
98
|
+
# @param [Hash] opts the optional parameters
|
99
|
+
# @return [Array<(Array<InlineResponse20077>, Fixnum, Hash)>] Array<InlineResponse20077> data, response status code and response headers
|
100
|
+
def list_with_http_info(body, opts = {})
|
101
|
+
# add api key to request body
|
102
|
+
body[:key] = @api_key
|
103
|
+
|
104
|
+
# resource path
|
105
|
+
local_var_path = '/whitelists/list'
|
106
|
+
|
107
|
+
# http body (model)
|
108
|
+
auth_names = []
|
109
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
|
110
|
+
:body => body,
|
111
|
+
:auth_names => auth_names,
|
112
|
+
:return_type => 'Array<InlineResponse20077>')
|
113
|
+
return data, status_code, headers
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
=begin
|
2
|
+
#Mailchimp Transactional API
|
3
|
+
|
4
|
+
#No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0.4
|
7
|
+
Contact: apihelp@mandrill.com
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.4.12
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'json'
|
14
|
+
require 'faraday'
|
15
|
+
|
16
|
+
module MailchimpTransactional
|
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
|
+
def initialize()
|
25
|
+
@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
|
+
@format_list = ['json', 'xml', 'php', 'yaml']
|
32
|
+
@content_type = 'application/json'
|
33
|
+
@default_output_format = 'json'
|
34
|
+
@accepts = ['application/json', 'application/xml', 'application/x-php', 'application/x-yaml; charset=utf-8']
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.default
|
38
|
+
@@default ||= ApiClient.new
|
39
|
+
end
|
40
|
+
|
41
|
+
def set_default_output_format(output_format)
|
42
|
+
if @format_list.include? output_format
|
43
|
+
@default_output_format = output_format
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def call_api(http_method, path, opts = {})
|
48
|
+
header_params = @default_headers.merge(opts[:header_params] || {})
|
49
|
+
url = @host + path
|
50
|
+
|
51
|
+
use_default_output_format = true
|
52
|
+
|
53
|
+
body = opts[:body]
|
54
|
+
|
55
|
+
if body && body[:outputFormat]
|
56
|
+
format = body[:outputFormat].downcase
|
57
|
+
if @format_list.include? format
|
58
|
+
url += ".#{format}"
|
59
|
+
body.delete(:outputFormat)
|
60
|
+
use_default_output_format = false
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
if use_default_output_format && @format_list.include?(@default_output_format)
|
65
|
+
url += '.%s' % @default_output_format
|
66
|
+
end
|
67
|
+
|
68
|
+
res = request(http_method, url, body, header_params)
|
69
|
+
|
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
|
+
|
77
|
+
if data
|
78
|
+
if res.status <= 200
|
79
|
+
data
|
80
|
+
else
|
81
|
+
fail ApiError.new(res.body)
|
82
|
+
end
|
83
|
+
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
|
+
end
|
94
|
+
end
|