unione-ruby 0.0.2 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +90 -10
  3. data/Rakefile +49 -0
  4. data/config/response_schema/domain.yml +74 -0
  5. data/config/response_schema/email.yml +23 -0
  6. data/config/response_schema/event_dump.yml +75 -0
  7. data/config/response_schema/project.yml +59 -0
  8. data/config/response_schema/suppression.yml +71 -0
  9. data/config/response_schema/system.yml +33 -0
  10. data/config/response_schema/tag.yml +26 -0
  11. data/config/response_schema/template.yml +134 -0
  12. data/config/response_schema/unsubscribed.yml +45 -0
  13. data/config/response_schema/webhook.yml +141 -0
  14. data/examples/api/custom_api.rb +13 -0
  15. data/examples/api/domain.rb +13 -7
  16. data/examples/api/email/attachments.rb +27 -0
  17. data/examples/api/email/multiple_recipients.rb +23 -0
  18. data/examples/api/email/send.rb +25 -0
  19. data/examples/api/email/settings.rb +40 -0
  20. data/examples/api/email/subscribe.rb +13 -0
  21. data/examples/api/email/template.rb +25 -0
  22. data/examples/api/event_dump.rb +43 -0
  23. data/examples/api/project.rb +29 -23
  24. data/examples/api/suppression.rb +33 -0
  25. data/examples/api/system.rb +5 -6
  26. data/examples/api/tag.rb +14 -0
  27. data/examples/api/template.rb +39 -28
  28. data/examples/api/unsubscribed.rb +16 -11
  29. data/examples/api/webhook.rb +27 -25
  30. data/examples/helpers.rb +28 -0
  31. data/examples/send_mail.rb +44 -0
  32. data/examples/setup.rb +20 -14
  33. data/lib/unione/client/domain.rb +21 -45
  34. data/lib/unione/client/email.rb +16 -15
  35. data/lib/unione/client/event_dump.rb +37 -0
  36. data/lib/unione/client/project.rb +19 -61
  37. data/lib/unione/client/suppression.rb +38 -0
  38. data/lib/unione/client/system.rb +12 -17
  39. data/lib/unione/client/tag.rb +24 -0
  40. data/lib/unione/client/template.rb +19 -66
  41. data/lib/unione/client/unsubscribed.rb +18 -31
  42. data/lib/unione/client/webhook.rb +19 -65
  43. data/lib/unione/client.rb +34 -12
  44. data/lib/unione/connection.rb +7 -3
  45. data/lib/unione/helpers.rb +22 -0
  46. data/lib/unione/response/raise_error.rb +4 -5
  47. data/lib/unione/validation.rb +34 -9
  48. data/lib/unione/version.rb +1 -1
  49. data/lib/unione-ruby.rb +0 -3
  50. data/test/CONFIGFILE.yml +71 -0
  51. data/unione-ruby.gemspec +2 -2
  52. metadata +33 -9
  53. data/examples/api/email.rb +0 -51
  54. data/examples/sending_mail.rb +0 -32
@@ -1,39 +1,41 @@
1
1
  require 'unione-ruby'
2
2
  require 'json'
3
3
 
4
- unione = UniOne::Client.new(data_center: 'eu1', lang: 'en', api_key: ENV['UNIONE_API_KEY'])
4
+ unione = UniOne::Client.new(
5
+ hostname: 'eu1.unione.io',
6
+ api_key: ENV['UNIONE_API_KEY']
7
+ )
5
8
 
6
- # set webhook
7
- webhook = UniOne::Webhook.new
9
+ # Set webhook
10
+ params = {}
8
11
 
9
- webhook.url = 'http://example.com'
10
- webhook.status = :active
12
+ params[:url] = 'http://example.com'
13
+ params[:status] = :active
11
14
 
12
- webhook.settings = {
13
- event_format: :json_post,
14
- delivery_info: 1,
15
- single_event: 0,
16
- max_parallel: 10
17
- }
15
+ params[:event_format] = :json_post
16
+ params[:delivery_info] = 1
17
+ params[:single_event] = 0
18
+ params[:max_parallel] = 10
18
19
 
19
- webhook.events = {
20
+ params[:events] = {
20
21
  email_status: %w(sent delivered opened hard_bounced soft_bounced spam clicked unsubscribed),
21
22
  spam_block: ["*"]
22
23
  }
23
24
 
24
- puts webhook.to_json
25
-
26
- response = unione.set_webhook(webhook.to_json)
27
-
28
- puts response.status
29
- puts response.body.to_h
30
- puts response.headers
25
+ response = unione.set_webhook(params)
31
26
 
32
- # get webhook
33
- response = unione.get_webhook('http://example.com')
27
+ # Get webhook
28
+ response = unione.get_webhook(
29
+ url: 'http://example.com'
30
+ )
34
31
 
35
- # list all webhooks
36
- response = unione.list_webhooks(50, 0)
32
+ # List all webhooks
33
+ response = unione.list_webhooks(
34
+ limit: 50,
35
+ offset: 0
36
+ )
37
37
 
38
- # delete webhook
39
- response = unione.delete_webhook('http://example.com')
38
+ # Delete webhook
39
+ response = unione.delete_webhook(
40
+ url: 'http://example.com'
41
+ )
@@ -0,0 +1,28 @@
1
+ require 'unione-ruby'
2
+
3
+ unione = UniOne::Client.new(
4
+ hostname: 'eu1.unione.io',
5
+ api_key: ENV['UNIONE_API_KEY']
6
+ )
7
+
8
+ # Verify webhook callback message
9
+ # Will raise Unione::Client::InvalidCallbackAuth error unless `auth' field is correct.
10
+ unione.verify_callback_auth!(params)
11
+
12
+ # Callback helper usage
13
+ # Will raise Unione::Client::InvalidCallbackAuth error unless `auth' field is correct.
14
+ unione.callback_helper(params) do |events|
15
+ # [
16
+ # {
17
+ # 'event_name' => 'transactional_email_status',
18
+ # 'event_data' =>
19
+ # {
20
+ # 'email' => 'recipient.email@example.com',
21
+ # 'status' => 'sent',
22
+ # 'event_time' => '2015-11-30 15:09:42',
23
+ # ...
24
+ # }
25
+ # },
26
+ # ...
27
+ # ]
28
+ end
@@ -0,0 +1,44 @@
1
+ require 'unione-ruby'
2
+ require 'json'
3
+
4
+ unione = UniOne::Client.new(
5
+ hostname: 'eu1.unione.io',
6
+ lang: 'en',
7
+ api_key: ENV['UNIONE_API_KEY'],
8
+ enable_logging: true
9
+ )
10
+
11
+ message = {}
12
+
13
+ message[:template_engine] = 'simple'
14
+ message[:template_id] = 'template_id'
15
+
16
+ # In case template_id is not specified, subject and body are mandatory
17
+ message[:subject] = 'test letter'
18
+ message[:body] = {"html": "tests", "plaintext": "plaintext"}
19
+
20
+ message[:from_email] = 'test@qadns.net'
21
+ message[:from_name] = 'userName'
22
+
23
+ message[:recipients] = []
24
+ message[:recipients] << {
25
+ email: 'test1@example.com',
26
+ substitutions: { 'substitutionName' => 'substitutionVal', to_name: 'Name Surname' },
27
+ metadata: { key1: 'val' },
28
+ }
29
+
30
+ message[:global_metadata] = { key1: 'val' }
31
+ message[:headers] = { 'X-ReplyTo' => 'reply@example.com' }
32
+ message[:options] = { unsubscribe_url: 'someurl' }
33
+
34
+ message[:attachments] = []
35
+ message[:attachments] << { type: 'text/plain', name: 'myfile.txt', content: 'ZXhhbXBsZSBmaWxl' }
36
+
37
+ message[:inline_attachments] = []
38
+ message[:inline_attachments] << { type: 'image/png', name: 'IMAGECID', content: 'iVBORw0KGgo' }
39
+
40
+ response = unione.send_email(message: message)
41
+
42
+ puts response.status
43
+ puts response.body.to_h
44
+ puts response.headers
data/examples/setup.rb CHANGED
@@ -1,27 +1,33 @@
1
1
  require 'unione-ruby'
2
2
  require 'json'
3
3
 
4
- unione = UniOne::Client.new(data_center: 'eu1', lang: 'en', api_key: ENV['UNIONE_API_KEY'])
4
+ unione = UniOne::Client.new(
5
+ hostname: 'eu1.unione.io',
6
+ api_key: ENV['UNIONE_API_KEY']
7
+ )
5
8
 
6
9
  # Validate domain verification record
7
- unione.validate_verification_record('example.com')
10
+ unione.validate_verification_record(domain: 'qadns.net')
8
11
 
9
12
  # Create template
10
- template = UniOne::Template.new
13
+ template = {}
11
14
 
12
- template.name = 'Template Name'
13
- template.subject = 'Email Subject'
14
- template.template_engine = 'simple'
15
- template.headers = { 'X-ReplyTo' => 'reply@example.com' }
16
- template.global_substitutions = { 'someVar' => 'someVal' }
15
+ template[:name] = 'Template Name'
16
+ template[:subject] = 'Email Subject'
17
+ template[:template_engine] = 'simple'
18
+ template[:headers] = {'X-ReplyTo' => 'reply@example.com'}
17
19
 
18
- template.from = { from_email: 'test@example.com', from_name: 'userName' }
19
- template.body = { html: '<b>Hello {{substitutionName}}</b>' }
20
+ template[:global_substitutions] = { 'someVar' => 'someVal' }
21
+ template[:from_email] = 'test@example.com'
22
+ template[:from_name] = 'userName'
23
+ template[:body] = { html: '<b>Hello {{substitutionName}}</b>' }
24
+ template[:options] = { unsubscribe_url: 'someurl' }
20
25
 
21
- template.attachments << { type: 'text/plain', name: 'myfile.txt', content: 'ZXhhbXBsZSBmaWxl' }
22
- template.inline_attachments << { type: 'image/png', name: 'IMAGECID', content: 'iVBORw0KGgo' }
26
+ template[:attachments] = []
27
+ template[:attachments] << { type: 'text/plain', name: 'myfile.txt', content: 'ZXhhbXBsZSBmaWxl' }
23
28
 
24
- template.options = { unsubscribe_url: 'someurl' }
29
+ template[:inline_attachments] = []
30
+ template[:inline_attachments] << { type: 'image/png', name: 'IMAGECID', content: 'iVBORw0KGgo' }
25
31
 
26
- response = unione.set_template(template.to_json)
32
+ response = unione.set_template(template: template)
27
33
  template_id = response.body.template.id
@@ -1,58 +1,34 @@
1
1
  module UniOne
2
2
  class Client
3
3
  module Domain
4
- def get_dns_records(domain)
5
- params = { domain: domain }
6
- post 'domain/get-dns-records.json', params
7
- validate_response({
8
- 'type' => 'object', 'required' => ['status', 'domain', 'verification-record', 'dkim'], 'properties' => {
9
- 'status' => {'type' => 'string'},
10
- 'domain' => {'type' => 'string'},
11
- 'verification-record' => {'type' => 'string'},
12
- 'dkim' => {'type' => 'string'}}
13
- })
4
+ extend UniOne::Validation::ClassMethods
5
+ include UniOne::Validation::InstanceMethods
6
+
7
+ def get_dns_records(params = {})
8
+ post('domain/get-dns-records.json', params)
14
9
  end
15
10
 
16
- def validate_verification_record(domain)
17
- params = { domain: domain }
18
- post 'domain/validate-verification-record.json', params
19
- validate_response({
20
- 'type' => 'object', 'required' => ['status', 'message'], 'properties' => {
21
- 'status' => {'type' => 'string'},
22
- 'message' => {'type' => 'string'}}
23
- })
11
+ def validate_verification_record(params = {})
12
+ post('domain/validate-verification-record.json', params)
24
13
  end
25
14
 
26
- def validate_dkim(domain)
27
- params = { domain: domain }
28
- post 'domain/validate-dkim.json', params
29
- validate_response({
30
- 'type' => 'object', 'required' => ['status', 'message'], 'properties' => {
31
- 'status' => {'type' => 'string'},
32
- 'message' => {'type' => 'string'}}
33
- })
15
+ def validate_dkim(params = {})
16
+ post('domain/validate-dkim.json', params)
34
17
  end
35
18
 
36
- def list_domains
37
- post 'domain/list.json', {}
38
- validate_response({
39
- 'type' => 'object', 'required' => ['status', 'domains'], 'properties' => {
40
- 'status' => {'type' => 'string'},
41
- 'domains' =>
42
- {'items' =>
43
- {'type' => 'object', 'required' => ['domain', 'verification-record', 'dkim'], 'properties' => [
44
- 'domain' => {'type' => 'string'},
45
- 'verification-record' =>
46
- {'type' => 'object', 'required' => ['value', 'status'], 'properties' => [
47
- 'value' => {'type' => 'string'},
48
- 'status' => {'type' => 'string'}]},
49
- 'dkim' =>
50
- {'type' => 'object', 'required' => ['key', 'status'], 'properties' => [
51
- 'key' => {'type' => 'string'},
52
- 'status' => {'type' => 'string'}]}
53
- ]}}}
54
- })
19
+ def list_domains(params = {})
20
+ post('domain/list.json', params)
55
21
  end
22
+
23
+ add_response_validations(
24
+ :domain,
25
+ %w(
26
+ get_dns_records
27
+ validate_verification_record
28
+ validate_dkim
29
+ list_domains
30
+ )
31
+ )
56
32
  end
57
33
  end
58
34
  end
@@ -1,24 +1,25 @@
1
1
  module UniOne
2
2
  class Client
3
3
  module Email
4
- def send_email(message)
5
- post 'email/send.json', message
6
- validate_response({
7
- 'type' => 'object', 'required' => ['status', 'job_id', 'emails'], 'properties' => {
8
- 'status' => {'type' => 'string'},
9
- 'job_id' => {'type' => 'string'},
10
- 'emails' => {'items' => {'type' => 'string'}},
11
- 'failed_emails' => {'type' => 'object'}}
12
- })
4
+ extend UniOne::Validation::ClassMethods
5
+ include UniOne::Validation::InstanceMethods
6
+
7
+ def send_email(params = {})
8
+ params[:message][:options][:send_at] = handle_time_param(params.dig(:message, :options, :send_at)) if params.dig(:message, :options, :send_at)
9
+ post('email/send.json', params)
13
10
  end
14
11
 
15
- def subscribe_email(params)
16
- post 'email/subscribe.json', params
17
- validate_response({
18
- 'type' => 'object', 'required' => ['status'], 'properties' => {
19
- 'status' => {'type' => 'string'}}
20
- })
12
+ def subscribe_email(params = {})
13
+ post('email/subscribe.json', params)
21
14
  end
15
+
16
+ add_response_validations(
17
+ :email,
18
+ %w(
19
+ send_email
20
+ subscribe_email
21
+ )
22
+ )
22
23
  end
23
24
  end
24
25
  end
@@ -0,0 +1,37 @@
1
+ module UniOne
2
+ class Client
3
+ module EventDump
4
+ extend UniOne::Validation::ClassMethods
5
+ include UniOne::Validation::InstanceMethods
6
+
7
+ def create_event_dump(params = {})
8
+ params[:start_time] = handle_time_param(params[:start_time]) if params[:start_time]
9
+ params[:end_time] = handle_time_param(params[:end_time]) if params[:end_time]
10
+
11
+ post('event-dump/create.json', params)
12
+ end
13
+
14
+ def get_event_dump(params = {})
15
+ post('event-dump/get.json', params)
16
+ end
17
+
18
+ def list_event_dumps(params = {})
19
+ post('event-dump/list.json', params)
20
+ end
21
+
22
+ def delete_event_dump(params = {})
23
+ post('event-dump/delete.json', params)
24
+ end
25
+
26
+ add_response_validations(
27
+ :event_dump,
28
+ %w(
29
+ create_event_dump
30
+ get_event_dump
31
+ list_event_dumps
32
+ delete_event_dump
33
+ )
34
+ )
35
+ end
36
+ end
37
+ end
@@ -1,76 +1,34 @@
1
1
  module UniOne
2
2
  class Client
3
3
  module Project
4
- def create_project(project)
5
- params = { project: project }
6
- post 'project/create.json', params
7
- validate_response({
8
- 'type' => 'object', 'required' => ['status', 'project_id', 'project_api_key'], 'properties' => {
9
- 'status' => {'type' => 'string'},
10
- 'project_id' => {'type' => 'string'},
11
- 'project_api_key' => {'type' => 'string'}}
12
- })
13
- end
4
+ extend UniOne::Validation::ClassMethods
5
+ include UniOne::Validation::InstanceMethods
14
6
 
15
- def update_project(project_identity, project)
16
- params = get_identity(project_identity).merge(project: project)
17
- post 'project/update.json', params
18
- validate_response({
19
- 'type' => 'object', 'required' => ['status'], 'properties' => {
20
- 'status' => {'type' => 'string'},
21
- 'project_api_key' => {'type' => 'string'}}
22
- })
7
+ def create_project(params = {})
8
+ post('project/create.json', params)
23
9
  end
24
10
 
25
- def list_projects(project_identity = nil)
26
- params = get_identity(project_identity)
27
- post 'project/list.json', params
28
- validate_response({
29
- 'type' => 'object',
30
- 'required' => %w{ status },
31
- 'properties' => {
32
- 'status' => { 'type' => 'string' },
33
- 'projects' => { 'items' => project_schema }
34
- }
35
- })
11
+ def update_project(params = {})
12
+ post('project/update.json', params)
36
13
  end
37
14
 
38
- def delete_project(project_identity)
39
- params = get_identity(project_identity)
40
- post 'project/delete.json', params
41
- validate_response({
42
- 'type' => 'object',
43
- 'required' => %w{ status },
44
- 'properties' => {
45
- 'status' => { 'type' => 'string' }
46
- }
47
- })
15
+ def list_projects(params = {})
16
+ post('project/list.json', params)
48
17
  end
49
18
 
50
- private
51
-
52
- def get_identity(project_identity)
53
- if project_identity.is_a?(Hash)
54
- project_identity
55
- elsif project_identity
56
- { project_api_key: project_identity }
57
- else
58
- {}
59
- end
19
+ def delete_project(params = {})
20
+ post('project/delete.json', params)
60
21
  end
61
22
 
62
- def project_schema
63
- {'type' => 'object',
64
- 'required' => %w{ id api_key name reg_time send_enabled custom_unsubscribe_url_enabled },
65
- 'properties' => {
66
- 'id' => {'type' => 'string'},
67
- 'api_key' => {'type' => 'string'},
68
- 'name' => {'type' => 'string'},
69
- 'reg_time' => {'type' => 'string'},
70
- 'send_enabled' => {'type' => 'boolean'},
71
- 'custom_unsubscribe_url_enabled' => {'type' => 'boolean'}
72
- }}
73
- end
23
+ add_response_validations(
24
+ :project,
25
+ %w(
26
+ create_project
27
+ update_project
28
+ list_projects
29
+ delete_project
30
+ )
31
+ )
74
32
  end
75
33
  end
76
34
  end
@@ -0,0 +1,38 @@
1
+ module UniOne
2
+ class Client
3
+ module Suppression
4
+ extend UniOne::Validation::ClassMethods
5
+ include UniOne::Validation::InstanceMethods
6
+
7
+ def set_suppression(params = {})
8
+ params[:created] = handle_time_param(params[:created]) if params[:created]
9
+
10
+ post('suppression/set.json', params)
11
+ end
12
+
13
+ def get_suppression(params = {})
14
+ post('suppression/get.json', params)
15
+ end
16
+
17
+ def list_suppressions(params = {})
18
+ params[:start_time] = handle_time_param(params[:start_time]) if params[:start_time]
19
+
20
+ post('suppression/list.json', params)
21
+ end
22
+
23
+ def delete_suppression(params = {})
24
+ post('suppression/delete.json', params)
25
+ end
26
+
27
+ add_response_validations(
28
+ :suppression,
29
+ %w(
30
+ set_suppression
31
+ get_suppression
32
+ list_suppressions
33
+ delete_suppression
34
+ )
35
+ )
36
+ end
37
+ end
38
+ end
@@ -1,24 +1,19 @@
1
1
  module UniOne
2
2
  class Client
3
3
  module System
4
- def info
5
- post 'system/info.json', {}
6
- validate_response({
7
- 'type' => 'object', 'required' => ['status', 'user_id', 'email'], 'properties' => {
8
- 'status' => {'type' => 'string'},
9
- 'user_id' => {'type' => 'integer'},
10
- 'email' => {'type' => 'string'},
11
- 'accounting' =>
12
- {'type' => 'object', 'required' => ['period_start', 'period_end', 'emails_included', 'emails_sent'], 'properties' => [
13
- 'period_start' => {'type' => 'string'},
14
- 'period_end' => {'type' => 'string'},
15
- 'emails_included' => {'type' => 'integer'},
16
- 'emails_sent' => {'type' => 'integer'}
17
- ]},
18
- 'project_id' => {'type' => 'string'},
19
- 'project_name' => {'type' => 'string'}}
20
- })
4
+ extend UniOne::Validation::ClassMethods
5
+ include UniOne::Validation::InstanceMethods
6
+
7
+ def info(params = {})
8
+ post('system/info.json', params)
21
9
  end
10
+
11
+ add_response_validations(
12
+ :system,
13
+ %w(
14
+ info
15
+ )
16
+ )
22
17
  end
23
18
  end
24
19
  end
@@ -0,0 +1,24 @@
1
+ module UniOne
2
+ class Client
3
+ module Tag
4
+ extend UniOne::Validation::ClassMethods
5
+ include UniOne::Validation::InstanceMethods
6
+
7
+ def list_tags(params = {})
8
+ post('tag/list.json', params)
9
+ end
10
+
11
+ def delete_tag(params = {})
12
+ post('tag/delete.json', params)
13
+ end
14
+
15
+ add_response_validations(
16
+ :tag,
17
+ %w(
18
+ list_tags
19
+ delete_tag
20
+ )
21
+ )
22
+ end
23
+ end
24
+ end
@@ -1,81 +1,34 @@
1
1
  module UniOne
2
2
  class Client
3
-
4
3
  module Template
4
+ extend UniOne::Validation::ClassMethods
5
+ include UniOne::Validation::InstanceMethods
5
6
 
6
- def set_template(template)
7
- post 'template/set.json', template
8
- validate_response({
9
- 'type' => 'object', 'required' => ['status', 'template'], 'properties' => {
10
- 'status' => {'type' => 'string'},
11
- 'template' => template_schema}
12
- })
13
- end
14
-
15
- def get_template(id)
16
- params = { id: id }
17
- post 'template/get.json', params
18
- validate_response({
19
- 'type' => 'object', 'required' => ['status', 'template'], 'properties' => {
20
- 'status' => {'type' => 'string'},
21
- 'template' => template_schema}
22
- })
23
- end
24
-
25
- def list_templates(limit, offset)
26
- params = { limit: limit, offset: offset }
27
- post 'template/list.json', params
28
- list_template_schema = remove_fields_from_schema(template_schema, ['from_name', 'headers'])
29
- validate_response({
30
- 'type' => 'object', 'required' => ['status', 'templates'], 'properties' => {
31
- 'status' => {'type' => 'string'},
32
- 'templates' => {'items' => list_template_schema}}
33
- })
34
- end
35
-
36
- def delete_template(id)
37
- params = { id: id }
38
- post 'template/delete.json', params
39
- validate_response({
40
- 'type' => 'object', 'required' => ['status'], 'properties' => {
41
- 'status' => {'type' => 'string'}}
42
- })
7
+ def set_template(params = {})
8
+ post('template/set.json', params)
43
9
  end
44
10
 
45
- private
46
-
47
- def template_schema
48
- {'type' => 'object', 'required' => ['id', 'name', 'editor_type', 'subject', 'from_name', 'body', 'headers', 'attachments',
49
- 'inline_attachments', 'created', 'user_id'], 'properties' => {
50
- 'id' => {'type' => 'string'},
51
- 'name' => {'type' => 'string'},
52
- 'editor_type' => {'type' => 'string'},
53
- 'subject' => {'type' => 'string'},
54
- 'from_name' => {'type' => 'string'},
55
- 'body' => template_body_schema,
56
- 'headers' => {'type' => 'object'},
57
- 'attachments' => {'items' => {'type' => 'object'}},
58
- 'inline_attachments' => {'items' => {'type' => 'object'}},
59
- 'options' => template_options_schema,
60
- 'created' => {'type' => 'string'},
61
- 'user_id' => {'type' => 'integer'},
62
- }}
11
+ def get_template(params = {})
12
+ post('template/get.json', params)
63
13
  end
64
14
 
65
- def template_body_schema
66
- {'type' => 'object', 'required' => ['html', 'plaintext', 'amp'], 'properties' => {
67
- 'html' => {'type' => 'string, null'},
68
- 'plaintext' => {'type' => 'string, null'},
69
- 'amp' => {'type' => 'string, null'}
70
- }}
15
+ def list_templates(params = {})
16
+ post('template/list.json', params)
71
17
  end
72
18
 
73
- def template_options_schema
74
- {'type' => 'object', 'required' => ['unsubscribe_url'], 'properties' => {
75
- 'unsubscribe_url' => {'type' => 'string'}
76
- }}
19
+ def delete_template(params = {})
20
+ post('template/delete.json', params)
77
21
  end
78
22
 
23
+ add_response_validations(
24
+ :template,
25
+ %w(
26
+ set_template
27
+ get_template
28
+ list_templates
29
+ delete_template
30
+ )
31
+ )
79
32
  end
80
33
  end
81
34
  end