mailhub-sdk 0.1.0
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/.fern/metadata.json +11 -0
- data/.fernignore +3 -0
- data/.rubocop.yml +103 -0
- data/CONTRIBUTING.md +120 -0
- data/README.md +159 -0
- data/Rakefile +20 -0
- data/custom.gemspec.rb +18 -0
- data/lib/Mailhub/campaign/client.rb +730 -0
- data/lib/Mailhub/campaign/types/add_campaign_media_by_code_request.rb +13 -0
- data/lib/Mailhub/campaign/types/cancel_campaign_request.rb +11 -0
- data/lib/Mailhub/campaign/types/catch_up_campaign_request.rb +11 -0
- data/lib/Mailhub/campaign/types/create_campaign_by_code_request.rb +27 -0
- data/lib/Mailhub/campaign/types/delete_campaign_request.rb +11 -0
- data/lib/Mailhub/campaign/types/get_campaign_activity_request.rb +11 -0
- data/lib/Mailhub/campaign/types/get_campaign_analytics_request.rb +11 -0
- data/lib/Mailhub/campaign/types/get_campaign_link_stats_request.rb +11 -0
- data/lib/Mailhub/campaign/types/get_campaign_media_request.rb +11 -0
- data/lib/Mailhub/campaign/types/get_campaign_rendered_preview_by_code_request.rb +21 -0
- data/lib/Mailhub/campaign/types/get_campaign_request.rb +11 -0
- data/lib/Mailhub/campaign/types/get_campaigns_request.rb +19 -0
- data/lib/Mailhub/campaign/types/pause_campaign_request.rb +11 -0
- data/lib/Mailhub/campaign/types/preview_campaign_request.rb +11 -0
- data/lib/Mailhub/campaign/types/remove_campaign_media_request.rb +13 -0
- data/lib/Mailhub/campaign/types/schedule_campaign_request.rb +11 -0
- data/lib/Mailhub/campaign/types/send_campaign_request.rb +11 -0
- data/lib/Mailhub/campaign/types/test_campaign_by_code_request.rb +23 -0
- data/lib/Mailhub/campaign/types/update_campaign_by_code_request.rb +29 -0
- data/lib/Mailhub/client.rb +55 -0
- data/lib/Mailhub/contact/client.rb +385 -0
- data/lib/Mailhub/contact/types/block_contact_request.rb +11 -0
- data/lib/Mailhub/contact/types/block_contacts_by_guid_request.rb +11 -0
- data/lib/Mailhub/contact/types/create_contact_request.rb +15 -0
- data/lib/Mailhub/contact/types/delete_contact_request.rb +11 -0
- data/lib/Mailhub/contact/types/delete_contacts_by_guid_request.rb +11 -0
- data/lib/Mailhub/contact/types/get_contact_request.rb +11 -0
- data/lib/Mailhub/contact/types/get_contacts_request.rb +21 -0
- data/lib/Mailhub/contact/types/get_import_job_request.rb +11 -0
- data/lib/Mailhub/contact/types/import_contacts_request.rb +9 -0
- data/lib/Mailhub/contact/types/update_contact_request.rb +17 -0
- data/lib/Mailhub/custom_field/client.rb +188 -0
- data/lib/Mailhub/custom_field/types/create_custom_field_request.rb +15 -0
- data/lib/Mailhub/custom_field/types/delete_custom_field_request.rb +11 -0
- data/lib/Mailhub/custom_field/types/get_custom_field_request.rb +11 -0
- data/lib/Mailhub/custom_field/types/update_custom_field_request.rb +15 -0
- data/lib/Mailhub/errors/api_error.rb +8 -0
- data/lib/Mailhub/errors/client_error.rb +17 -0
- data/lib/Mailhub/errors/redirect_error.rb +8 -0
- data/lib/Mailhub/errors/response_error.rb +42 -0
- data/lib/Mailhub/errors/server_error.rb +11 -0
- data/lib/Mailhub/errors/timeout_error.rb +8 -0
- data/lib/Mailhub/internal/errors/constraint_error.rb +10 -0
- data/lib/Mailhub/internal/errors/type_error.rb +10 -0
- data/lib/Mailhub/internal/http/base_request.rb +51 -0
- data/lib/Mailhub/internal/http/raw_client.rb +248 -0
- data/lib/Mailhub/internal/iterators/cursor_item_iterator.rb +28 -0
- data/lib/Mailhub/internal/iterators/cursor_page_iterator.rb +63 -0
- data/lib/Mailhub/internal/iterators/item_iterator.rb +65 -0
- data/lib/Mailhub/internal/iterators/offset_item_iterator.rb +30 -0
- data/lib/Mailhub/internal/iterators/offset_page_iterator.rb +103 -0
- data/lib/Mailhub/internal/json/request.rb +41 -0
- data/lib/Mailhub/internal/json/serializable.rb +25 -0
- data/lib/Mailhub/internal/multipart/multipart_encoder.rb +141 -0
- data/lib/Mailhub/internal/multipart/multipart_form_data.rb +78 -0
- data/lib/Mailhub/internal/multipart/multipart_form_data_part.rb +51 -0
- data/lib/Mailhub/internal/multipart/multipart_request.rb +40 -0
- data/lib/Mailhub/internal/types/array.rb +47 -0
- data/lib/Mailhub/internal/types/boolean.rb +34 -0
- data/lib/Mailhub/internal/types/enum.rb +56 -0
- data/lib/Mailhub/internal/types/hash.rb +36 -0
- data/lib/Mailhub/internal/types/model/field.rb +38 -0
- data/lib/Mailhub/internal/types/model.rb +208 -0
- data/lib/Mailhub/internal/types/type.rb +35 -0
- data/lib/Mailhub/internal/types/union.rb +161 -0
- data/lib/Mailhub/internal/types/unknown.rb +15 -0
- data/lib/Mailhub/internal/types/utils.rb +116 -0
- data/lib/Mailhub/media/client.rb +241 -0
- data/lib/Mailhub/media/types/delete_media_request.rb +11 -0
- data/lib/Mailhub/media/types/download_media_request.rb +11 -0
- data/lib/Mailhub/media/types/get_media_request.rb +11 -0
- data/lib/Mailhub/media/types/get_medias_request.rb +19 -0
- data/lib/Mailhub/media/types/update_media_request.rb +13 -0
- data/lib/Mailhub/media/types/upload_media_request.rb +9 -0
- data/lib/Mailhub/message/client.rb +201 -0
- data/lib/Mailhub/message/types/cancel_message_request.rb +11 -0
- data/lib/Mailhub/message/types/get_message_events_request.rb +11 -0
- data/lib/Mailhub/message/types/get_message_request.rb +11 -0
- data/lib/Mailhub/message/types/get_messages_request.rb +21 -0
- data/lib/Mailhub/message/types/send_message_request.rb +23 -0
- data/lib/Mailhub/segment/client.rb +377 -0
- data/lib/Mailhub/segment/types/create_segment_request.rb +13 -0
- data/lib/Mailhub/segment/types/delete_segment_request.rb +11 -0
- data/lib/Mailhub/segment/types/delete_segments_by_code_request.rb +13 -0
- data/lib/Mailhub/segment/types/get_segment_contacts_request.rb +15 -0
- data/lib/Mailhub/segment/types/get_segment_preview_request.rb +11 -0
- data/lib/Mailhub/segment/types/get_segment_request.rb +11 -0
- data/lib/Mailhub/segment/types/get_segments_request.rb +19 -0
- data/lib/Mailhub/segment/types/get_segments_union_preview_by_code_request.rb +11 -0
- data/lib/Mailhub/segment/types/sync_segment_request.rb +11 -0
- data/lib/Mailhub/segment/types/update_segment_request.rb +15 -0
- data/lib/Mailhub/template/client.rb +301 -0
- data/lib/Mailhub/template/types/create_template_request.rb +13 -0
- data/lib/Mailhub/template/types/delete_template_request.rb +11 -0
- data/lib/Mailhub/template/types/get_template_rendered_preview_request.rb +11 -0
- data/lib/Mailhub/template/types/get_template_request.rb +11 -0
- data/lib/Mailhub/template/types/get_templates_request.rb +19 -0
- data/lib/Mailhub/template/types/preview_template_request.rb +11 -0
- data/lib/Mailhub/template/types/update_template_request.rb +15 -0
- data/lib/Mailhub/types/api_error.rb +16 -0
- data/lib/Mailhub/types/api_error_detail.rb +12 -0
- data/lib/Mailhub/types/campaign_activity_point_model.rb +18 -0
- data/lib/Mailhub/types/campaign_analytics_model.rb +30 -0
- data/lib/Mailhub/types/campaign_link_stat_model.rb +14 -0
- data/lib/Mailhub/types/campaign_media_model.rb +24 -0
- data/lib/Mailhub/types/campaign_model.rb +52 -0
- data/lib/Mailhub/types/campaign_model_paged_result.rb +16 -0
- data/lib/Mailhub/types/campaign_segment_model.rb +14 -0
- data/lib/Mailhub/types/campaign_status.rb +17 -0
- data/lib/Mailhub/types/campaign_type.rb +12 -0
- data/lib/Mailhub/types/contact_import_job_model.rb +22 -0
- data/lib/Mailhub/types/contact_import_model.rb +10 -0
- data/lib/Mailhub/types/contact_import_status.rb +14 -0
- data/lib/Mailhub/types/contact_model.rb +26 -0
- data/lib/Mailhub/types/contact_model_cursor_paged_result.rb +18 -0
- data/lib/Mailhub/types/contact_model_paged_result.rb +16 -0
- data/lib/Mailhub/types/contact_segment_model.rb +14 -0
- data/lib/Mailhub/types/contact_status.rb +13 -0
- data/lib/Mailhub/types/custom_field_model.rb +20 -0
- data/lib/Mailhub/types/custom_field_type.rb +14 -0
- data/lib/Mailhub/types/import_contact_error_model.rb +12 -0
- data/lib/Mailhub/types/media_model.rb +28 -0
- data/lib/Mailhub/types/media_model_paged_result.rb +16 -0
- data/lib/Mailhub/types/message_event_model.rb +16 -0
- data/lib/Mailhub/types/message_event_type.rb +18 -0
- data/lib/Mailhub/types/message_model.rb +36 -0
- data/lib/Mailhub/types/message_model_cursor_paged_result.rb +18 -0
- data/lib/Mailhub/types/preview_segment_model.rb +10 -0
- data/lib/Mailhub/types/running_campaign_stats_model.rb +32 -0
- data/lib/Mailhub/types/segment_filter_group_model.rb +12 -0
- data/lib/Mailhub/types/segment_filter_model.rb +10 -0
- data/lib/Mailhub/types/segment_filter_rule_model.rb +14 -0
- data/lib/Mailhub/types/segment_model.rb +32 -0
- data/lib/Mailhub/types/segment_model_paged_result.rb +16 -0
- data/lib/Mailhub/types/segment_sync_status.rb +14 -0
- data/lib/Mailhub/types/template_expression_model.rb +14 -0
- data/lib/Mailhub/types/template_model.rb +20 -0
- data/lib/Mailhub/types/template_model_paged_result.rb +16 -0
- data/lib/Mailhub/version.rb +5 -0
- data/lib/Mailhub.rb +145 -0
- data/reference.md +3691 -0
- metadata +193 -0
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Mailhub
|
|
4
|
+
module Template
|
|
5
|
+
class Client
|
|
6
|
+
# @param client [Mailhub::Internal::Http::RawClient]
|
|
7
|
+
#
|
|
8
|
+
# @return [void]
|
|
9
|
+
def initialize(client:)
|
|
10
|
+
@client = client
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# @param request_options [Hash]
|
|
14
|
+
# @param params [Hash]
|
|
15
|
+
# @option request_options [String] :base_url
|
|
16
|
+
# @option request_options [Hash{String => Object}] :additional_headers
|
|
17
|
+
# @option request_options [Hash{String => Object}] :additional_query_parameters
|
|
18
|
+
# @option request_options [Hash{String => Object}] :additional_body_parameters
|
|
19
|
+
# @option request_options [Integer] :timeout_in_seconds
|
|
20
|
+
# @option params [String, nil] :search
|
|
21
|
+
# @option params [String, nil] :sort_by
|
|
22
|
+
# @option params [String, nil] :sort_direction
|
|
23
|
+
# @option params [Integer, nil] :page_size
|
|
24
|
+
# @option params [Integer, nil] :page_index
|
|
25
|
+
#
|
|
26
|
+
# @example
|
|
27
|
+
# client.template.get_templates
|
|
28
|
+
#
|
|
29
|
+
# @return [Mailhub::Types::TemplateModelPagedResult]
|
|
30
|
+
def get_templates(request_options: {}, **params)
|
|
31
|
+
params = Mailhub::Internal::Types::Utils.normalize_keys(params)
|
|
32
|
+
query_params = {}
|
|
33
|
+
query_params["search"] = params[:search] if params.key?(:search)
|
|
34
|
+
query_params["sortBy"] = params[:sort_by] if params.key?(:sort_by)
|
|
35
|
+
query_params["sortDirection"] = params[:sort_direction] if params.key?(:sort_direction)
|
|
36
|
+
query_params["pageSize"] = params[:page_size] if params.key?(:page_size)
|
|
37
|
+
query_params["pageIndex"] = params[:page_index] if params.key?(:page_index)
|
|
38
|
+
|
|
39
|
+
request = Mailhub::Internal::JSON::Request.new(
|
|
40
|
+
base_url: request_options[:base_url],
|
|
41
|
+
method: "GET",
|
|
42
|
+
path: "v1/templates",
|
|
43
|
+
query: query_params,
|
|
44
|
+
request_options: request_options
|
|
45
|
+
)
|
|
46
|
+
begin
|
|
47
|
+
response = @client.send(request)
|
|
48
|
+
rescue Net::HTTPRequestTimeout
|
|
49
|
+
raise Mailhub::Errors::TimeoutError
|
|
50
|
+
end
|
|
51
|
+
code = response.code.to_i
|
|
52
|
+
if code.between?(200, 299)
|
|
53
|
+
Mailhub::Types::TemplateModelPagedResult.load(response.body)
|
|
54
|
+
else
|
|
55
|
+
error_class = Mailhub::Errors::ResponseError.subclass_for_code(code)
|
|
56
|
+
raise error_class.new(response.body, code: code)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# @param request_options [Hash]
|
|
61
|
+
# @param params [Mailhub::Template::Types::CreateTemplateRequest]
|
|
62
|
+
# @option request_options [String] :base_url
|
|
63
|
+
# @option request_options [Hash{String => Object}] :additional_headers
|
|
64
|
+
# @option request_options [Hash{String => Object}] :additional_query_parameters
|
|
65
|
+
# @option request_options [Hash{String => Object}] :additional_body_parameters
|
|
66
|
+
# @option request_options [Integer] :timeout_in_seconds
|
|
67
|
+
#
|
|
68
|
+
# @example
|
|
69
|
+
# client.template.create_template
|
|
70
|
+
#
|
|
71
|
+
# @return [Mailhub::Types::TemplateModel]
|
|
72
|
+
def create_template(request_options: {}, **params)
|
|
73
|
+
params = Mailhub::Internal::Types::Utils.normalize_keys(params)
|
|
74
|
+
request = Mailhub::Internal::JSON::Request.new(
|
|
75
|
+
base_url: request_options[:base_url],
|
|
76
|
+
method: "POST",
|
|
77
|
+
path: "v1/templates",
|
|
78
|
+
body: Mailhub::Template::Types::CreateTemplateRequest.new(params).to_h,
|
|
79
|
+
request_options: request_options
|
|
80
|
+
)
|
|
81
|
+
begin
|
|
82
|
+
response = @client.send(request)
|
|
83
|
+
rescue Net::HTTPRequestTimeout
|
|
84
|
+
raise Mailhub::Errors::TimeoutError
|
|
85
|
+
end
|
|
86
|
+
code = response.code.to_i
|
|
87
|
+
if code.between?(200, 299)
|
|
88
|
+
Mailhub::Types::TemplateModel.load(response.body)
|
|
89
|
+
else
|
|
90
|
+
error_class = Mailhub::Errors::ResponseError.subclass_for_code(code)
|
|
91
|
+
raise error_class.new(response.body, code: code)
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# @param request_options [Hash]
|
|
96
|
+
# @param _params [Hash]
|
|
97
|
+
# @option request_options [String] :base_url
|
|
98
|
+
# @option request_options [Hash{String => Object}] :additional_headers
|
|
99
|
+
# @option request_options [Hash{String => Object}] :additional_query_parameters
|
|
100
|
+
# @option request_options [Hash{String => Object}] :additional_body_parameters
|
|
101
|
+
# @option request_options [Integer] :timeout_in_seconds
|
|
102
|
+
#
|
|
103
|
+
# @example
|
|
104
|
+
# client.template.get_template_expressions
|
|
105
|
+
#
|
|
106
|
+
# @return [Array[Mailhub::Types::TemplateExpressionModel]]
|
|
107
|
+
def get_template_expressions(request_options: {}, **_params)
|
|
108
|
+
request = Mailhub::Internal::JSON::Request.new(
|
|
109
|
+
base_url: request_options[:base_url],
|
|
110
|
+
method: "GET",
|
|
111
|
+
path: "v1/templates/meta/expressions",
|
|
112
|
+
request_options: request_options
|
|
113
|
+
)
|
|
114
|
+
begin
|
|
115
|
+
response = @client.send(request)
|
|
116
|
+
rescue Net::HTTPRequestTimeout
|
|
117
|
+
raise Mailhub::Errors::TimeoutError
|
|
118
|
+
end
|
|
119
|
+
code = response.code.to_i
|
|
120
|
+
return if code.between?(200, 299)
|
|
121
|
+
|
|
122
|
+
error_class = Mailhub::Errors::ResponseError.subclass_for_code(code)
|
|
123
|
+
raise error_class.new(response.body, code: code)
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# @param request_options [Hash]
|
|
127
|
+
# @param params [Hash]
|
|
128
|
+
# @option request_options [String] :base_url
|
|
129
|
+
# @option request_options [Hash{String => Object}] :additional_headers
|
|
130
|
+
# @option request_options [Hash{String => Object}] :additional_query_parameters
|
|
131
|
+
# @option request_options [Hash{String => Object}] :additional_body_parameters
|
|
132
|
+
# @option request_options [Integer] :timeout_in_seconds
|
|
133
|
+
# @option params [String] :code
|
|
134
|
+
#
|
|
135
|
+
# @example
|
|
136
|
+
# client.template.get_template(code: "code")
|
|
137
|
+
#
|
|
138
|
+
# @return [Mailhub::Types::TemplateModel]
|
|
139
|
+
def get_template(request_options: {}, **params)
|
|
140
|
+
params = Mailhub::Internal::Types::Utils.normalize_keys(params)
|
|
141
|
+
request = Mailhub::Internal::JSON::Request.new(
|
|
142
|
+
base_url: request_options[:base_url],
|
|
143
|
+
method: "GET",
|
|
144
|
+
path: "v1/templates/#{URI.encode_uri_component(params[:code].to_s)}",
|
|
145
|
+
request_options: request_options
|
|
146
|
+
)
|
|
147
|
+
begin
|
|
148
|
+
response = @client.send(request)
|
|
149
|
+
rescue Net::HTTPRequestTimeout
|
|
150
|
+
raise Mailhub::Errors::TimeoutError
|
|
151
|
+
end
|
|
152
|
+
code = response.code.to_i
|
|
153
|
+
if code.between?(200, 299)
|
|
154
|
+
Mailhub::Types::TemplateModel.load(response.body)
|
|
155
|
+
else
|
|
156
|
+
error_class = Mailhub::Errors::ResponseError.subclass_for_code(code)
|
|
157
|
+
raise error_class.new(response.body, code: code)
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
# @param request_options [Hash]
|
|
162
|
+
# @param params [Mailhub::Template::Types::UpdateTemplateRequest]
|
|
163
|
+
# @option request_options [String] :base_url
|
|
164
|
+
# @option request_options [Hash{String => Object}] :additional_headers
|
|
165
|
+
# @option request_options [Hash{String => Object}] :additional_query_parameters
|
|
166
|
+
# @option request_options [Hash{String => Object}] :additional_body_parameters
|
|
167
|
+
# @option request_options [Integer] :timeout_in_seconds
|
|
168
|
+
# @option params [String] :code
|
|
169
|
+
#
|
|
170
|
+
# @example
|
|
171
|
+
# client.template.update_template(code: "code")
|
|
172
|
+
#
|
|
173
|
+
# @return [Mailhub::Types::TemplateModel]
|
|
174
|
+
def update_template(request_options: {}, **params)
|
|
175
|
+
params = Mailhub::Internal::Types::Utils.normalize_keys(params)
|
|
176
|
+
request_data = Mailhub::Template::Types::UpdateTemplateRequest.new(params).to_h
|
|
177
|
+
non_body_param_names = %w[code]
|
|
178
|
+
body = request_data.except(*non_body_param_names)
|
|
179
|
+
|
|
180
|
+
request = Mailhub::Internal::JSON::Request.new(
|
|
181
|
+
base_url: request_options[:base_url],
|
|
182
|
+
method: "PUT",
|
|
183
|
+
path: "v1/templates/#{URI.encode_uri_component(params[:code].to_s)}",
|
|
184
|
+
body: body,
|
|
185
|
+
request_options: request_options
|
|
186
|
+
)
|
|
187
|
+
begin
|
|
188
|
+
response = @client.send(request)
|
|
189
|
+
rescue Net::HTTPRequestTimeout
|
|
190
|
+
raise Mailhub::Errors::TimeoutError
|
|
191
|
+
end
|
|
192
|
+
code = response.code.to_i
|
|
193
|
+
if code.between?(200, 299)
|
|
194
|
+
Mailhub::Types::TemplateModel.load(response.body)
|
|
195
|
+
else
|
|
196
|
+
error_class = Mailhub::Errors::ResponseError.subclass_for_code(code)
|
|
197
|
+
raise error_class.new(response.body, code: code)
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
# @param request_options [Hash]
|
|
202
|
+
# @param params [Hash]
|
|
203
|
+
# @option request_options [String] :base_url
|
|
204
|
+
# @option request_options [Hash{String => Object}] :additional_headers
|
|
205
|
+
# @option request_options [Hash{String => Object}] :additional_query_parameters
|
|
206
|
+
# @option request_options [Hash{String => Object}] :additional_body_parameters
|
|
207
|
+
# @option request_options [Integer] :timeout_in_seconds
|
|
208
|
+
# @option params [String] :code
|
|
209
|
+
#
|
|
210
|
+
# @example
|
|
211
|
+
# client.template.delete_template(code: "code")
|
|
212
|
+
#
|
|
213
|
+
# @return [untyped]
|
|
214
|
+
def delete_template(request_options: {}, **params)
|
|
215
|
+
params = Mailhub::Internal::Types::Utils.normalize_keys(params)
|
|
216
|
+
request = Mailhub::Internal::JSON::Request.new(
|
|
217
|
+
base_url: request_options[:base_url],
|
|
218
|
+
method: "DELETE",
|
|
219
|
+
path: "v1/templates/#{URI.encode_uri_component(params[:code].to_s)}",
|
|
220
|
+
request_options: request_options
|
|
221
|
+
)
|
|
222
|
+
begin
|
|
223
|
+
response = @client.send(request)
|
|
224
|
+
rescue Net::HTTPRequestTimeout
|
|
225
|
+
raise Mailhub::Errors::TimeoutError
|
|
226
|
+
end
|
|
227
|
+
code = response.code.to_i
|
|
228
|
+
return if code.between?(200, 299)
|
|
229
|
+
|
|
230
|
+
error_class = Mailhub::Errors::ResponseError.subclass_for_code(code)
|
|
231
|
+
raise error_class.new(response.body, code: code)
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
# @param request_options [Hash]
|
|
235
|
+
# @param params [Hash]
|
|
236
|
+
# @option request_options [String] :base_url
|
|
237
|
+
# @option request_options [Hash{String => Object}] :additional_headers
|
|
238
|
+
# @option request_options [Hash{String => Object}] :additional_query_parameters
|
|
239
|
+
# @option request_options [Hash{String => Object}] :additional_body_parameters
|
|
240
|
+
# @option request_options [Integer] :timeout_in_seconds
|
|
241
|
+
# @option params [String] :code
|
|
242
|
+
#
|
|
243
|
+
# @example
|
|
244
|
+
# client.template.preview_template(code: "code")
|
|
245
|
+
#
|
|
246
|
+
# @return [String]
|
|
247
|
+
def preview_template(request_options: {}, **params)
|
|
248
|
+
params = Mailhub::Internal::Types::Utils.normalize_keys(params)
|
|
249
|
+
request = Mailhub::Internal::JSON::Request.new(
|
|
250
|
+
base_url: request_options[:base_url],
|
|
251
|
+
method: "GET",
|
|
252
|
+
path: "v1/templates/#{URI.encode_uri_component(params[:code].to_s)}/preview",
|
|
253
|
+
request_options: request_options
|
|
254
|
+
)
|
|
255
|
+
begin
|
|
256
|
+
response = @client.send(request)
|
|
257
|
+
rescue Net::HTTPRequestTimeout
|
|
258
|
+
raise Mailhub::Errors::TimeoutError
|
|
259
|
+
end
|
|
260
|
+
code = response.code.to_i
|
|
261
|
+
return if code.between?(200, 299)
|
|
262
|
+
|
|
263
|
+
error_class = Mailhub::Errors::ResponseError.subclass_for_code(code)
|
|
264
|
+
raise error_class.new(response.body, code: code)
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
# @param request_options [Hash]
|
|
268
|
+
# @param params [Mailhub::Template::Types::GetTemplateRenderedPreviewRequest]
|
|
269
|
+
# @option request_options [String] :base_url
|
|
270
|
+
# @option request_options [Hash{String => Object}] :additional_headers
|
|
271
|
+
# @option request_options [Hash{String => Object}] :additional_query_parameters
|
|
272
|
+
# @option request_options [Hash{String => Object}] :additional_body_parameters
|
|
273
|
+
# @option request_options [Integer] :timeout_in_seconds
|
|
274
|
+
#
|
|
275
|
+
# @example
|
|
276
|
+
# client.template.render_template_preview
|
|
277
|
+
#
|
|
278
|
+
# @return [String]
|
|
279
|
+
def render_template_preview(request_options: {}, **params)
|
|
280
|
+
params = Mailhub::Internal::Types::Utils.normalize_keys(params)
|
|
281
|
+
request = Mailhub::Internal::JSON::Request.new(
|
|
282
|
+
base_url: request_options[:base_url],
|
|
283
|
+
method: "POST",
|
|
284
|
+
path: "v1/templates/preview",
|
|
285
|
+
body: Mailhub::Template::Types::GetTemplateRenderedPreviewRequest.new(params).to_h,
|
|
286
|
+
request_options: request_options
|
|
287
|
+
)
|
|
288
|
+
begin
|
|
289
|
+
response = @client.send(request)
|
|
290
|
+
rescue Net::HTTPRequestTimeout
|
|
291
|
+
raise Mailhub::Errors::TimeoutError
|
|
292
|
+
end
|
|
293
|
+
code = response.code.to_i
|
|
294
|
+
return if code.between?(200, 299)
|
|
295
|
+
|
|
296
|
+
error_class = Mailhub::Errors::ResponseError.subclass_for_code(code)
|
|
297
|
+
raise error_class.new(response.body, code: code)
|
|
298
|
+
end
|
|
299
|
+
end
|
|
300
|
+
end
|
|
301
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Mailhub
|
|
4
|
+
module Template
|
|
5
|
+
module Types
|
|
6
|
+
class CreateTemplateRequest < Internal::Types::Model
|
|
7
|
+
field :name, -> { String }, optional: true, nullable: false
|
|
8
|
+
|
|
9
|
+
field :body, -> { String }, optional: true, nullable: false
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Mailhub
|
|
4
|
+
module Template
|
|
5
|
+
module Types
|
|
6
|
+
class GetTemplatesRequest < Internal::Types::Model
|
|
7
|
+
field :search, -> { String }, optional: true, nullable: false
|
|
8
|
+
|
|
9
|
+
field :sort_by, -> { String }, optional: true, nullable: false, api_name: "sortBy"
|
|
10
|
+
|
|
11
|
+
field :sort_direction, -> { String }, optional: true, nullable: false, api_name: "sortDirection"
|
|
12
|
+
|
|
13
|
+
field :page_size, -> { Integer }, optional: true, nullable: false, api_name: "pageSize"
|
|
14
|
+
|
|
15
|
+
field :page_index, -> { Integer }, optional: true, nullable: false, api_name: "pageIndex"
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Mailhub
|
|
4
|
+
module Template
|
|
5
|
+
module Types
|
|
6
|
+
class UpdateTemplateRequest < Internal::Types::Model
|
|
7
|
+
field :code, -> { String }, optional: false, nullable: false
|
|
8
|
+
|
|
9
|
+
field :name, -> { String }, optional: true, nullable: false
|
|
10
|
+
|
|
11
|
+
field :body, -> { String }, optional: true, nullable: false
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Mailhub
|
|
4
|
+
module Types
|
|
5
|
+
# API 오류 응답
|
|
6
|
+
class APIError < Internal::Types::Model
|
|
7
|
+
field :code, -> { String }, optional: true, nullable: false
|
|
8
|
+
|
|
9
|
+
field :status, -> { Integer }, optional: true, nullable: false
|
|
10
|
+
|
|
11
|
+
field :message, -> { String }, optional: true, nullable: false
|
|
12
|
+
|
|
13
|
+
field :errors, -> { Internal::Types::Array[Mailhub::Types::APIErrorDetail] }, optional: true, nullable: false
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Mailhub
|
|
4
|
+
module Types
|
|
5
|
+
# 필드 단위 오류 상세
|
|
6
|
+
class APIErrorDetail < Internal::Types::Model
|
|
7
|
+
field :field, -> { String }, optional: true, nullable: false
|
|
8
|
+
|
|
9
|
+
field :message, -> { String }, optional: true, nullable: false
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Mailhub
|
|
4
|
+
module Types
|
|
5
|
+
# 캠페인 활동 추이의 시점별 통계
|
|
6
|
+
class CampaignActivityPointModel < Internal::Types::Model
|
|
7
|
+
field :timestamp, -> { String }, optional: true, nullable: false
|
|
8
|
+
|
|
9
|
+
field :sent, -> { Integer }, optional: true, nullable: false
|
|
10
|
+
|
|
11
|
+
field :opens, -> { Integer }, optional: true, nullable: false
|
|
12
|
+
|
|
13
|
+
field :clicks, -> { Integer }, optional: true, nullable: false
|
|
14
|
+
|
|
15
|
+
field :bounced, -> { Integer }, optional: true, nullable: false
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Mailhub
|
|
4
|
+
module Types
|
|
5
|
+
# 캠페인 성과 분석 통계
|
|
6
|
+
class CampaignAnalyticsModel < Internal::Types::Model
|
|
7
|
+
field :campaign_id, -> { Integer }, optional: true, nullable: false, api_name: "campaignId"
|
|
8
|
+
|
|
9
|
+
field :campaign_code, -> { String }, optional: true, nullable: false, api_name: "campaignCode"
|
|
10
|
+
|
|
11
|
+
field :sent, -> { Integer }, optional: true, nullable: false
|
|
12
|
+
|
|
13
|
+
field :views, -> { Integer }, optional: true, nullable: false
|
|
14
|
+
|
|
15
|
+
field :unique_views, -> { Integer }, optional: true, nullable: false, api_name: "uniqueViews"
|
|
16
|
+
|
|
17
|
+
field :clicks, -> { Integer }, optional: true, nullable: false
|
|
18
|
+
|
|
19
|
+
field :unique_clicks, -> { Integer }, optional: true, nullable: false, api_name: "uniqueClicks"
|
|
20
|
+
|
|
21
|
+
field :open_rate, -> { Integer }, optional: true, nullable: false, api_name: "openRate"
|
|
22
|
+
|
|
23
|
+
field :unique_open_rate, -> { Integer }, optional: true, nullable: false, api_name: "uniqueOpenRate"
|
|
24
|
+
|
|
25
|
+
field :click_rate, -> { Integer }, optional: true, nullable: false, api_name: "clickRate"
|
|
26
|
+
|
|
27
|
+
field :unique_click_rate, -> { Integer }, optional: true, nullable: false, api_name: "uniqueClickRate"
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Mailhub
|
|
4
|
+
module Types
|
|
5
|
+
# 캠페인 본문 내 링크별 클릭 통계
|
|
6
|
+
class CampaignLinkStatModel < Internal::Types::Model
|
|
7
|
+
field :url, -> { String }, optional: true, nullable: false
|
|
8
|
+
|
|
9
|
+
field :clicks, -> { Integer }, optional: true, nullable: false
|
|
10
|
+
|
|
11
|
+
field :unique_clicks, -> { Integer }, optional: true, nullable: false, api_name: "uniqueClicks"
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Mailhub
|
|
4
|
+
module Types
|
|
5
|
+
# 캠페인에 첨부된 미디어 정보
|
|
6
|
+
class CampaignMediaModel < Internal::Types::Model
|
|
7
|
+
field :id, -> { Integer }, optional: true, nullable: false
|
|
8
|
+
|
|
9
|
+
field :campaign_id, -> { Integer }, optional: true, nullable: false, api_name: "campaignId"
|
|
10
|
+
|
|
11
|
+
field :media_id, -> { Integer }, optional: true, nullable: false, api_name: "mediaId"
|
|
12
|
+
|
|
13
|
+
field :media_code, -> { String }, optional: true, nullable: false, api_name: "mediaCode"
|
|
14
|
+
|
|
15
|
+
field :file_name, -> { String }, optional: true, nullable: false, api_name: "fileName"
|
|
16
|
+
|
|
17
|
+
field :content_type, -> { String }, optional: true, nullable: false, api_name: "contentType"
|
|
18
|
+
|
|
19
|
+
field :size, -> { Integer }, optional: true, nullable: false
|
|
20
|
+
|
|
21
|
+
field :created_at, -> { String }, optional: true, nullable: false, api_name: "createdAt"
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Mailhub
|
|
4
|
+
module Types
|
|
5
|
+
# 캠페인 정보
|
|
6
|
+
class CampaignModel < Internal::Types::Model
|
|
7
|
+
field :id, -> { Integer }, optional: true, nullable: false
|
|
8
|
+
|
|
9
|
+
field :code, -> { String }, optional: true, nullable: false
|
|
10
|
+
|
|
11
|
+
field :name, -> { String }, optional: true, nullable: false
|
|
12
|
+
|
|
13
|
+
field :subject, -> { String }, optional: true, nullable: false
|
|
14
|
+
|
|
15
|
+
field :type, -> { Mailhub::Types::CampaignType }, optional: true, nullable: false
|
|
16
|
+
|
|
17
|
+
field :from_email, -> { String }, optional: true, nullable: false, api_name: "fromEmail"
|
|
18
|
+
|
|
19
|
+
field :segments, -> { Internal::Types::Array[Mailhub::Types::CampaignSegmentModel] }, optional: true, nullable: false
|
|
20
|
+
|
|
21
|
+
field :template_id, -> { Integer }, optional: true, nullable: false, api_name: "templateId"
|
|
22
|
+
|
|
23
|
+
field :template_code, -> { String }, optional: true, nullable: false, api_name: "templateCode"
|
|
24
|
+
|
|
25
|
+
field :body, -> { String }, optional: true, nullable: false
|
|
26
|
+
|
|
27
|
+
field :send_at, -> { String }, optional: true, nullable: false, api_name: "sendAt"
|
|
28
|
+
|
|
29
|
+
field :to_send, -> { Integer }, optional: true, nullable: false, api_name: "toSend"
|
|
30
|
+
|
|
31
|
+
field :sent, -> { Integer }, optional: true, nullable: false
|
|
32
|
+
|
|
33
|
+
field :views, -> { Integer }, optional: true, nullable: false
|
|
34
|
+
|
|
35
|
+
field :unique_views, -> { Integer }, optional: true, nullable: false, api_name: "uniqueViews"
|
|
36
|
+
|
|
37
|
+
field :clicks, -> { Integer }, optional: true, nullable: false
|
|
38
|
+
|
|
39
|
+
field :unique_clicks, -> { Integer }, optional: true, nullable: false, api_name: "uniqueClicks"
|
|
40
|
+
|
|
41
|
+
field :bounces, -> { Integer }, optional: true, nullable: false
|
|
42
|
+
|
|
43
|
+
field :status, -> { Mailhub::Types::CampaignStatus }, optional: true, nullable: false
|
|
44
|
+
|
|
45
|
+
field :created_at, -> { String }, optional: true, nullable: false, api_name: "createdAt"
|
|
46
|
+
|
|
47
|
+
field :updated_at, -> { String }, optional: true, nullable: false, api_name: "updatedAt"
|
|
48
|
+
|
|
49
|
+
field :started_at, -> { String }, optional: true, nullable: false, api_name: "startedAt"
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Mailhub
|
|
4
|
+
module Types
|
|
5
|
+
# 페이지네이션 목록 결과
|
|
6
|
+
class CampaignModelPagedResult < Internal::Types::Model
|
|
7
|
+
field :page_index, -> { Integer }, optional: true, nullable: false, api_name: "pageIndex"
|
|
8
|
+
|
|
9
|
+
field :page_size, -> { Integer }, optional: true, nullable: false, api_name: "pageSize"
|
|
10
|
+
|
|
11
|
+
field :total_count, -> { Integer }, optional: true, nullable: false, api_name: "totalCount"
|
|
12
|
+
|
|
13
|
+
field :items, -> { Internal::Types::Array[Mailhub::Types::CampaignModel] }, optional: true, nullable: false
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Mailhub
|
|
4
|
+
module Types
|
|
5
|
+
# 캠페인의 대상 세그먼트 정보
|
|
6
|
+
class CampaignSegmentModel < Internal::Types::Model
|
|
7
|
+
field :id, -> { Integer }, optional: true, nullable: false
|
|
8
|
+
|
|
9
|
+
field :code, -> { String }, optional: true, nullable: false
|
|
10
|
+
|
|
11
|
+
field :name, -> { String }, optional: true, nullable: false
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Mailhub
|
|
4
|
+
module Types
|
|
5
|
+
module CampaignStatus
|
|
6
|
+
extend Mailhub::Internal::Types::Enum
|
|
7
|
+
|
|
8
|
+
DRAFT = "Draft"
|
|
9
|
+
SCHEDULED = "Scheduled"
|
|
10
|
+
PREPARE = "Prepare"
|
|
11
|
+
RUNNING = "Running"
|
|
12
|
+
PAUSED = "Paused"
|
|
13
|
+
FINISHED = "Finished"
|
|
14
|
+
CANCELLED = "Cancelled"
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Mailhub
|
|
4
|
+
module Types
|
|
5
|
+
# 연락처 가져오기 작업 진행 상태
|
|
6
|
+
class ContactImportJobModel < Internal::Types::Model
|
|
7
|
+
field :job_id, -> { String }, optional: true, nullable: false, api_name: "jobId"
|
|
8
|
+
|
|
9
|
+
field :status, -> { Mailhub::Types::ContactImportStatus }, optional: true, nullable: false
|
|
10
|
+
|
|
11
|
+
field :total_rows, -> { Integer }, optional: true, nullable: false, api_name: "totalRows"
|
|
12
|
+
|
|
13
|
+
field :processed_rows, -> { Integer }, optional: true, nullable: false, api_name: "processedRows"
|
|
14
|
+
|
|
15
|
+
field :imported_count, -> { Integer }, optional: true, nullable: false, api_name: "importedCount"
|
|
16
|
+
|
|
17
|
+
field :updated_count, -> { Integer }, optional: true, nullable: false, api_name: "updatedCount"
|
|
18
|
+
|
|
19
|
+
field :errors, -> { Internal::Types::Array[Mailhub::Types::ImportContactErrorModel] }, optional: true, nullable: false
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|