unione-ruby 0.0.2 → 1.0.1
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 +4 -4
- data/README.md +90 -10
- data/Rakefile +49 -0
- data/config/response_schema/domain.yml +74 -0
- data/config/response_schema/email.yml +23 -0
- data/config/response_schema/event_dump.yml +75 -0
- data/config/response_schema/project.yml +59 -0
- data/config/response_schema/suppression.yml +71 -0
- data/config/response_schema/system.yml +33 -0
- data/config/response_schema/tag.yml +26 -0
- data/config/response_schema/template.yml +134 -0
- data/config/response_schema/unsubscribed.yml +45 -0
- data/config/response_schema/webhook.yml +141 -0
- data/examples/api/custom_api.rb +13 -0
- data/examples/api/domain.rb +13 -7
- data/examples/api/email/attachments.rb +27 -0
- data/examples/api/email/multiple_recipients.rb +23 -0
- data/examples/api/email/send.rb +25 -0
- data/examples/api/email/settings.rb +40 -0
- data/examples/api/email/subscribe.rb +13 -0
- data/examples/api/email/template.rb +25 -0
- data/examples/api/event_dump.rb +43 -0
- data/examples/api/project.rb +29 -23
- data/examples/api/suppression.rb +33 -0
- data/examples/api/system.rb +5 -6
- data/examples/api/tag.rb +14 -0
- data/examples/api/template.rb +39 -28
- data/examples/api/unsubscribed.rb +16 -11
- data/examples/api/webhook.rb +27 -25
- data/examples/helpers.rb +28 -0
- data/examples/send_mail.rb +44 -0
- data/examples/setup.rb +20 -14
- data/lib/unione/client/domain.rb +21 -45
- data/lib/unione/client/email.rb +16 -15
- data/lib/unione/client/event_dump.rb +37 -0
- data/lib/unione/client/project.rb +19 -61
- data/lib/unione/client/suppression.rb +38 -0
- data/lib/unione/client/system.rb +12 -17
- data/lib/unione/client/tag.rb +24 -0
- data/lib/unione/client/template.rb +19 -66
- data/lib/unione/client/unsubscribed.rb +18 -31
- data/lib/unione/client/webhook.rb +19 -65
- data/lib/unione/client.rb +34 -12
- data/lib/unione/connection.rb +7 -3
- data/lib/unione/helpers.rb +22 -0
- data/lib/unione/response/raise_error.rb +4 -5
- data/lib/unione/validation.rb +34 -9
- data/lib/unione/version.rb +1 -1
- data/lib/unione-ruby.rb +0 -3
- data/test/CONFIGFILE.yml +71 -0
- data/unione-ruby.gemspec +2 -2
- metadata +33 -9
- data/examples/api/email.rb +0 -51
- data/examples/sending_mail.rb +0 -32
@@ -1,44 +1,31 @@
|
|
1
1
|
module UniOne
|
2
2
|
class Client
|
3
|
-
|
4
3
|
module Unsubscribed
|
4
|
+
extend UniOne::Validation::ClassMethods
|
5
|
+
include UniOne::Validation::InstanceMethods
|
5
6
|
|
6
|
-
def unsubscribe(
|
7
|
-
params
|
8
|
-
post 'unsubscribed/set.json', params
|
9
|
-
validate_response({
|
10
|
-
'type' => 'object', 'required' => ['status', 'address', 'message'], 'properties' => {
|
11
|
-
'status' => {'type' => 'string'},
|
12
|
-
'address' => {'type' => 'string'},
|
13
|
-
'message' => {'type' => 'string'}}
|
14
|
-
})
|
7
|
+
def unsubscribe(params = {})
|
8
|
+
post('unsubscribed/set.json', params)
|
15
9
|
end
|
16
10
|
|
17
|
-
def check_unsubscribed(
|
18
|
-
params
|
19
|
-
post 'unsubscribed/check.json', params
|
20
|
-
validate_response({
|
21
|
-
'type' => 'object', 'required' => ['status', 'address', 'is_unsubscribed'], 'properties' => {
|
22
|
-
'status' => {'type' => 'string'},
|
23
|
-
'address' => {'type' => 'string'},
|
24
|
-
'is_unsubscribed' => {'type' => 'boolean'}}
|
25
|
-
})
|
11
|
+
def check_unsubscribed(params = {})
|
12
|
+
post('unsubscribed/check.json', params)
|
26
13
|
end
|
27
14
|
|
28
|
-
def list_unsubscribed(
|
29
|
-
params =
|
30
|
-
|
31
|
-
|
32
|
-
'type' => 'object', 'required' => ['status', 'unsubscribed'], 'properties' => {
|
33
|
-
'status' => {'type' => 'string'},
|
34
|
-
'unsubscribed' => {
|
35
|
-
'items' => {'type' => 'object'}, 'required' => ['address', 'unsubscribed_on'], 'properties' => {
|
36
|
-
'address' => {'type' => 'string'},
|
37
|
-
'unsubscribed_on' => {'type' => 'string'}
|
38
|
-
}}}
|
39
|
-
})
|
15
|
+
def list_unsubscribed(params = {})
|
16
|
+
params[:date_from] = handle_date_param(params[:date_from]) if params[:date_from]
|
17
|
+
|
18
|
+
post('unsubscribed/list.json', params)
|
40
19
|
end
|
41
20
|
|
21
|
+
add_response_validations(
|
22
|
+
:unsubscribed,
|
23
|
+
%w(
|
24
|
+
unsubscribe
|
25
|
+
check_unsubscribed
|
26
|
+
list_unsubscribed
|
27
|
+
)
|
28
|
+
)
|
42
29
|
end
|
43
30
|
end
|
44
31
|
end
|
@@ -1,80 +1,34 @@
|
|
1
1
|
module UniOne
|
2
2
|
class Client
|
3
|
-
|
4
3
|
module Webhook
|
4
|
+
extend UniOne::Validation::ClassMethods
|
5
|
+
include UniOne::Validation::InstanceMethods
|
5
6
|
|
6
|
-
def set_webhook(
|
7
|
-
post
|
8
|
-
validate_response({'type' => 'object', 'required' => ['status', 'object'], 'properties' => {
|
9
|
-
'status' => {'type' => 'string'},
|
10
|
-
'object' => webhook_schema
|
11
|
-
}})
|
7
|
+
def set_webhook(params = {})
|
8
|
+
post('webhook/set.json', params)
|
12
9
|
end
|
13
10
|
|
14
|
-
def get_webhook(
|
15
|
-
params
|
16
|
-
post 'webhook/get.json', params
|
17
|
-
get_webhook_schema = remove_fields_from_schema(webhook_schema, ['delivery_info', 'single_event'])
|
18
|
-
validate_response({'type' => 'object', 'required' => ['status', 'object'], 'properties' => {
|
19
|
-
'status' => {'type' => 'string'},
|
20
|
-
'object' => get_webhook_schema
|
21
|
-
}})
|
11
|
+
def get_webhook(params = {})
|
12
|
+
post('webhook/get.json', params)
|
22
13
|
end
|
23
14
|
|
24
|
-
def list_webhooks(
|
25
|
-
|
26
|
-
post 'webhook/list.json', params
|
27
|
-
validate_response({
|
28
|
-
'type' => 'object', 'required' => ['status', 'objects'], 'properties' => {
|
29
|
-
'status' => {'type' => 'string'},
|
30
|
-
'objects' =>
|
31
|
-
{'items' =>
|
32
|
-
{'type' => 'object', 'required' => ['id', 'url', 'status', 'updated_at', 'events', 'event_format', 'delivery_info', 'single_event', 'max_parallel'], 'properties' => [
|
33
|
-
'id' => {'type' => 'integer'},
|
34
|
-
'url' => {'type' => 'string'},
|
35
|
-
'status' => {'type' => 'string'},
|
36
|
-
'updated_at' => {'type' => 'string'},
|
37
|
-
'events' =>
|
38
|
-
{'type' => 'object', 'required' => ['email_status', 'spam_block'], 'properties' => [
|
39
|
-
'email_status' => {'items' => {'type' => 'string'}},
|
40
|
-
'spam_block' => {'items' => {'type' => 'string'}}]},
|
41
|
-
'event_format' => {'type' => 'string'},
|
42
|
-
'delivery_info' => {'type' => 'integer'},
|
43
|
-
'single_event' => {'type' => 'integer'},
|
44
|
-
'max_parallel' => {'type' => 'integer'}
|
45
|
-
]}}}
|
46
|
-
})
|
15
|
+
def list_webhooks(params = {})
|
16
|
+
post('webhook/list.json', params)
|
47
17
|
end
|
48
18
|
|
49
|
-
def delete_webhook(
|
50
|
-
params
|
51
|
-
post 'webhook/delete.json', params
|
52
|
-
validate_response({'type' => 'object', 'required' => ['status'], 'properties' => {
|
53
|
-
'status' => {'type' => 'string'}
|
54
|
-
}})
|
19
|
+
def delete_webhook(params = {})
|
20
|
+
post('webhook/delete.json', params)
|
55
21
|
end
|
56
22
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
'single_event' => {'type' => 'integer'},
|
67
|
-
'max_parallel' => {'type' => 'integer'},
|
68
|
-
'events' => webhook_events_schema,
|
69
|
-
}}
|
70
|
-
end
|
71
|
-
|
72
|
-
def webhook_events_schema
|
73
|
-
{'type' => 'object', 'required' => ['email_status', 'spam_block'], 'properties' => {
|
74
|
-
'email_status' => {'items' => {'type' => 'string'}},
|
75
|
-
'spam_block' => {'items' => {'type' => 'string'}}
|
76
|
-
}}
|
77
|
-
end
|
23
|
+
add_response_validations(
|
24
|
+
:webhook,
|
25
|
+
%w(
|
26
|
+
set_webhook
|
27
|
+
get_webhook
|
28
|
+
list_webhooks
|
29
|
+
delete_webhook
|
30
|
+
)
|
31
|
+
)
|
78
32
|
end
|
79
33
|
end
|
80
34
|
end
|
data/lib/unione/client.rb
CHANGED
@@ -1,47 +1,69 @@
|
|
1
1
|
require_relative 'connection'
|
2
2
|
require_relative 'validation'
|
3
|
+
require_relative 'helpers'
|
3
4
|
require_relative 'client/domain'
|
4
5
|
require_relative 'client/email'
|
6
|
+
require_relative 'client/event_dump'
|
5
7
|
require_relative 'client/project'
|
8
|
+
require_relative 'client/suppression'
|
6
9
|
require_relative 'client/system'
|
10
|
+
require_relative 'client/tag'
|
7
11
|
require_relative 'client/template'
|
8
12
|
require_relative 'client/unsubscribed'
|
9
13
|
require_relative 'client/webhook'
|
10
14
|
|
11
15
|
module UniOne
|
12
|
-
|
13
16
|
class Client
|
14
|
-
|
15
17
|
include UniOne::Connection
|
16
|
-
|
18
|
+
extend UniOne::Validation::ClassMethods
|
19
|
+
include UniOne::Validation::InstanceMethods
|
20
|
+
include UniOne::Client::Helpers
|
17
21
|
include UniOne::Client::Domain
|
18
22
|
include UniOne::Client::Email
|
23
|
+
include UniOne::Client::EventDump
|
19
24
|
include UniOne::Client::Project
|
25
|
+
include UniOne::Client::Suppression
|
20
26
|
include UniOne::Client::System
|
27
|
+
include UniOne::Client::Tag
|
21
28
|
include UniOne::Client::Template
|
22
29
|
include UniOne::Client::Unsubscribed
|
23
30
|
include UniOne::Client::Webhook
|
24
31
|
|
32
|
+
class BaseException < StandardError; end
|
33
|
+
class InvalidCallbackAuth < BaseException; end
|
34
|
+
|
25
35
|
API_ENDPOINT =
|
26
|
-
'https://%{
|
36
|
+
'https://%{hostname}/%{lang}/transactional/api/v1/'
|
27
37
|
|
28
38
|
# * *Args* :
|
29
|
-
# - +
|
30
|
-
# - +lang+
|
31
|
-
# - +api_key+
|
32
|
-
# - +
|
39
|
+
# - +hostname+ -> string, API hostname, for example 'eu1.unione.io'
|
40
|
+
# - +lang+ -> string, two-letter ISO 639-1 language abbreviation, e.g. 'en'
|
41
|
+
# - +api_key+ -> string, your UniOne API key
|
42
|
+
# - +timeout+ -> integer, timeout in seconds, 5 by default
|
43
|
+
# - +api_key_in_params+ -> boolean, pass API key in parameters, otherwise pass in headers (default)
|
44
|
+
# - +enable_logging+ -> boolean, enable logging
|
33
45
|
def initialize(params = {})
|
34
|
-
@
|
35
|
-
@lang = params[:lang]
|
46
|
+
@hostname = params[:hostname]
|
47
|
+
@lang = params[:lang] || 'en'
|
36
48
|
@api_key = params[:api_key]
|
37
|
-
@
|
49
|
+
@timeout = params[:timeout] || 5
|
50
|
+
@api_key_in_params = params[:api_key_in_params]
|
51
|
+
@enable_logging = params[:enable_logging] || ENV['ENABLE_LOGGING']
|
38
52
|
end
|
39
53
|
|
40
54
|
private
|
41
55
|
|
42
56
|
def api_endpoint
|
43
57
|
@api_endpoint ||=
|
44
|
-
API_ENDPOINT % {
|
58
|
+
API_ENDPOINT % { hostname: @hostname, lang: @lang }
|
59
|
+
end
|
60
|
+
|
61
|
+
def handle_time_param(param)
|
62
|
+
param.respond_to?(:strftime) ? param.strftime('%Y-%m-%d %H:%M:%S') : param
|
63
|
+
end
|
64
|
+
|
65
|
+
def handle_date_param(param)
|
66
|
+
param.respond_to?(:strftime) ? param.strftime('%Y-%m-%d') : param
|
45
67
|
end
|
46
68
|
end
|
47
69
|
end
|
data/lib/unione/connection.rb
CHANGED
@@ -6,14 +6,14 @@ require 'hashie'
|
|
6
6
|
module UniOne
|
7
7
|
module Connection
|
8
8
|
|
9
|
-
def get(url, params)
|
9
|
+
def get(url, params = {})
|
10
10
|
prepare_params!(params)
|
11
11
|
|
12
12
|
# Assume HTTP library receives params as Hash
|
13
13
|
request(:get, url, params)
|
14
14
|
end
|
15
15
|
|
16
|
-
def post(url, params)
|
16
|
+
def post(url, params = {})
|
17
17
|
prepare_params!(params)
|
18
18
|
|
19
19
|
# Assume HTTP library receives payload body as String
|
@@ -34,12 +34,16 @@ module UniOne
|
|
34
34
|
@conn ||= Faraday.new(
|
35
35
|
url: api_endpoint,
|
36
36
|
headers: headers,
|
37
|
-
request: { timeout:
|
37
|
+
request: { timeout: @timeout }
|
38
38
|
) do |conn|
|
39
39
|
conn.response :mashify, content_type: /\bjson$/
|
40
40
|
conn.response :json, content_type: /\bjson$/
|
41
41
|
conn.response :raise_error
|
42
42
|
conn.adapter :net_http_persistent
|
43
|
+
|
44
|
+
if @enable_logging
|
45
|
+
conn.response(:logger, nil, { headers: true, bodies: true, errors: true })
|
46
|
+
end
|
43
47
|
end
|
44
48
|
end
|
45
49
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'digest'
|
2
|
+
|
3
|
+
module UniOne
|
4
|
+
class Client
|
5
|
+
module Helpers
|
6
|
+
# Helper function for webhooks callback. It is checking auth field
|
7
|
+
# and if it is invalid, raises Unione::Client::InvalidCallbackAuth exception
|
8
|
+
def verify_callback_auth!(params)
|
9
|
+
params = params.transform_keys(&:to_sym)
|
10
|
+
auth = params[:auth]
|
11
|
+
unless auth == Digest::MD5.hexdigest(params.merge(auth: @api_key).to_json)
|
12
|
+
raise InvalidCallbackAuth
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def callback_helper(params)
|
17
|
+
verify_callback_auth!(params)
|
18
|
+
yield params.dig('events_by_user', 0, 'events')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -1,14 +1,13 @@
|
|
1
|
+
# UniOne response middleware
|
2
|
+
|
1
3
|
require 'faraday'
|
2
4
|
require 'unione/error'
|
3
5
|
|
4
6
|
module UniOne
|
5
|
-
# UniOne response middleware
|
6
7
|
module Response
|
7
|
-
|
8
|
-
#
|
9
|
-
# HTTP status codes returned by the API
|
8
|
+
# This class raises an UniOne-flavored exception based on HTTP
|
9
|
+
# status codes returned by the API
|
10
10
|
class RaiseError < Faraday::Response::Middleware
|
11
|
-
|
12
11
|
private
|
13
12
|
|
14
13
|
def on_complete(response)
|
data/lib/unione/validation.rb
CHANGED
@@ -1,19 +1,44 @@
|
|
1
1
|
require 'json-schema'
|
2
|
+
require 'yaml'
|
2
3
|
|
3
4
|
module UniOne
|
4
5
|
module Validation
|
6
|
+
module ClassMethods
|
7
|
+
def add_response_validations(klass, methods)
|
8
|
+
methods.each do |method|
|
9
|
+
orig = "#{method}_without_hook"
|
10
|
+
alias_method orig, method
|
5
11
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
12
|
+
define_method method do |*args|
|
13
|
+
send(orig, *args)
|
14
|
+
schema = get_response_schema(klass, method)
|
15
|
+
validate_response(schema)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
11
19
|
end
|
12
20
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
21
|
+
module InstanceMethods
|
22
|
+
private
|
23
|
+
|
24
|
+
def validate_response(schema)
|
25
|
+
JSON::Validator.validate!(schema, @last_response.body)
|
26
|
+
@last_response
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_response_schema(klass, method)
|
30
|
+
@response_schemas ||= {}
|
31
|
+
@response_schemas[klass] ||= begin
|
32
|
+
directory = File.join(File.dirname(__FILE__), '..', '..', 'config', 'response_schema')
|
33
|
+
filename = "#{klass}.yml"
|
34
|
+
YAML.load_file(File.join(directory, filename))
|
35
|
+
end
|
36
|
+
|
37
|
+
@response_schemas[klass][method]
|
38
|
+
end
|
39
|
+
|
40
|
+
def undescore_class_name(class_name)
|
41
|
+
class_name.gsub(/([^\^])([A-Z])/,'\1_\2').downcase
|
17
42
|
end
|
18
43
|
end
|
19
44
|
end
|
data/lib/unione/version.rb
CHANGED
data/lib/unione-ruby.rb
CHANGED
data/test/CONFIGFILE.yml
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
- method: send_email
|
2
|
+
params:
|
3
|
+
message:
|
4
|
+
recipients:
|
5
|
+
- email: test@qadns.net
|
6
|
+
substitutions:
|
7
|
+
CustomerId: 12452
|
8
|
+
to_name: John Smith
|
9
|
+
metadata:
|
10
|
+
campaign_id: c77f4f4e-3561-49f7-9f07-c35be01b4f43
|
11
|
+
customer_hash: b253ac7
|
12
|
+
tags:
|
13
|
+
- string1
|
14
|
+
skip_unsubscribe: 0
|
15
|
+
global_language: en
|
16
|
+
template_engine: simple
|
17
|
+
global_substitutions:
|
18
|
+
property1: string
|
19
|
+
property2: string
|
20
|
+
global_metadata:
|
21
|
+
property1: string
|
22
|
+
property2: string
|
23
|
+
body:
|
24
|
+
html: "<b>Hello, {{to_name}}</b>"
|
25
|
+
plaintext: Hello, {{to_name}}
|
26
|
+
amp: <!doctype html><html amp4email><head> <meta charset="utf-8"><script async
|
27
|
+
src="https://cdn.ampproject.org/v0.js"></script> <style amp4email-boilerplate>body{visibility:hidden}</style></head><body>
|
28
|
+
Hello, AMP4EMAIL world.</body></html>
|
29
|
+
subject: string
|
30
|
+
from_email: test@qadns.net
|
31
|
+
from_name: John Smith
|
32
|
+
reply_to: test@qadns.net
|
33
|
+
track_links: 0
|
34
|
+
track_read: 0
|
35
|
+
bypass_global: 0
|
36
|
+
bypass_unavailable: 0
|
37
|
+
bypass_unsubscribed: 0
|
38
|
+
bypass_complained: 0
|
39
|
+
headers:
|
40
|
+
X-MyHeader: some data
|
41
|
+
List-Unsubscribe: "<mailto: unsubscribe@example.com?subject=unsubscribe>, <http://www.example.com/unsubscribe/{{CustomerId}}>"
|
42
|
+
attachments:
|
43
|
+
- type: text/plain
|
44
|
+
name: readme.txt
|
45
|
+
content: SGVsbG8sIHdvcmxkIQ==
|
46
|
+
inline_attachments:
|
47
|
+
- type: image/gif
|
48
|
+
name: IMAGECID1
|
49
|
+
content: R0lGODdhAwADAIABAP+rAP///ywAAAAAAwADAAACBIQRBwUAOw==
|
50
|
+
options:
|
51
|
+
unsubscribe_url: https://example.org/unsubscribe/{{CustomerId}}
|
52
|
+
- method: set_webhook
|
53
|
+
params:
|
54
|
+
url: http://example.com
|
55
|
+
status: active
|
56
|
+
event_format: json_post
|
57
|
+
delivery_info: 1
|
58
|
+
single_event: 0
|
59
|
+
max_parallel: 10
|
60
|
+
events:
|
61
|
+
email_status:
|
62
|
+
- sent
|
63
|
+
- delivered
|
64
|
+
- opened
|
65
|
+
- hard_bounced
|
66
|
+
- soft_bounced
|
67
|
+
- spam
|
68
|
+
- clicked
|
69
|
+
- unsubscribed
|
70
|
+
spam_block:
|
71
|
+
- '*'
|
data/unione-ruby.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.add_dependency 'json', '~> 2.0'
|
8
8
|
spec.add_dependency 'faraday', '~> 1.0'
|
9
9
|
spec.add_dependency 'faraday_middleware', '~> 1.0'
|
10
|
-
spec.add_dependency 'net-http-persistent', '~>
|
10
|
+
spec.add_dependency 'net-http-persistent', '~> 4.0'
|
11
11
|
spec.add_dependency 'hashie', '~> 4.0'
|
12
12
|
spec.add_dependency 'json-schema', '~> 2.0'
|
13
13
|
spec.authors = ['UniOne developer']
|
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.licenses = ['MIT']
|
19
19
|
spec.name = 'unione-ruby'
|
20
20
|
spec.require_paths = ['lib']
|
21
|
-
spec.required_ruby_version = '>= 2.
|
21
|
+
spec.required_ruby_version = '>= 2.5'
|
22
22
|
spec.summary = 'Official UniOne Gem'
|
23
23
|
spec.version = UniOne::VERSION
|
24
24
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unione-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- UniOne developer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '4.0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '4.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: hashie
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -103,31 +103,56 @@ files:
|
|
103
103
|
- LICENSE
|
104
104
|
- README.md
|
105
105
|
- Rakefile
|
106
|
+
- config/response_schema/domain.yml
|
107
|
+
- config/response_schema/email.yml
|
108
|
+
- config/response_schema/event_dump.yml
|
109
|
+
- config/response_schema/project.yml
|
110
|
+
- config/response_schema/suppression.yml
|
111
|
+
- config/response_schema/system.yml
|
112
|
+
- config/response_schema/tag.yml
|
113
|
+
- config/response_schema/template.yml
|
114
|
+
- config/response_schema/unsubscribed.yml
|
115
|
+
- config/response_schema/webhook.yml
|
116
|
+
- examples/api/custom_api.rb
|
106
117
|
- examples/api/domain.rb
|
107
|
-
- examples/api/email.rb
|
118
|
+
- examples/api/email/attachments.rb
|
119
|
+
- examples/api/email/multiple_recipients.rb
|
120
|
+
- examples/api/email/send.rb
|
121
|
+
- examples/api/email/settings.rb
|
122
|
+
- examples/api/email/subscribe.rb
|
123
|
+
- examples/api/email/template.rb
|
124
|
+
- examples/api/event_dump.rb
|
108
125
|
- examples/api/project.rb
|
126
|
+
- examples/api/suppression.rb
|
109
127
|
- examples/api/system.rb
|
128
|
+
- examples/api/tag.rb
|
110
129
|
- examples/api/template.rb
|
111
130
|
- examples/api/unsubscribed.rb
|
112
131
|
- examples/api/webhook.rb
|
113
|
-
- examples/
|
132
|
+
- examples/helpers.rb
|
133
|
+
- examples/send_mail.rb
|
114
134
|
- examples/setup.rb
|
115
135
|
- lib/unione-ruby.rb
|
116
136
|
- lib/unione/client.rb
|
117
137
|
- lib/unione/client/domain.rb
|
118
138
|
- lib/unione/client/email.rb
|
139
|
+
- lib/unione/client/event_dump.rb
|
119
140
|
- lib/unione/client/project.rb
|
141
|
+
- lib/unione/client/suppression.rb
|
120
142
|
- lib/unione/client/system.rb
|
143
|
+
- lib/unione/client/tag.rb
|
121
144
|
- lib/unione/client/template.rb
|
122
145
|
- lib/unione/client/unsubscribed.rb
|
123
146
|
- lib/unione/client/webhook.rb
|
124
147
|
- lib/unione/connection.rb
|
148
|
+
- lib/unione/helpers.rb
|
125
149
|
- lib/unione/helpers/mail/mail.rb
|
126
150
|
- lib/unione/helpers/template/template.rb
|
127
151
|
- lib/unione/helpers/webhook/webhook.rb
|
128
152
|
- lib/unione/response/raise_error.rb
|
129
153
|
- lib/unione/validation.rb
|
130
154
|
- lib/unione/version.rb
|
155
|
+
- test/CONFIGFILE.yml
|
131
156
|
- unione-ruby.gemspec
|
132
157
|
homepage: https://github.com/unione-repo/unione-ruby
|
133
158
|
licenses:
|
@@ -141,15 +166,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
141
166
|
requirements:
|
142
167
|
- - ">="
|
143
168
|
- !ruby/object:Gem::Version
|
144
|
-
version: '2.
|
169
|
+
version: '2.5'
|
145
170
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
171
|
requirements:
|
147
172
|
- - ">="
|
148
173
|
- !ruby/object:Gem::Version
|
149
174
|
version: '0'
|
150
175
|
requirements: []
|
151
|
-
|
152
|
-
rubygems_version: 2.7.6
|
176
|
+
rubygems_version: 3.0.3.1
|
153
177
|
signing_key:
|
154
178
|
specification_version: 4
|
155
179
|
summary: Official UniOne Gem
|
data/examples/api/email.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
require 'unione-ruby'
|
2
|
-
require 'json'
|
3
|
-
|
4
|
-
unione = UniOne::Client.new(data_center: 'eu1', lang: 'en', api_key: ENV['UNIONE_API_KEY'])
|
5
|
-
|
6
|
-
# sending mail
|
7
|
-
mail = UniOne::Mail.new
|
8
|
-
|
9
|
-
mail.subject = 'Email Subject'
|
10
|
-
mail.from = { from_email: 'test@qadns.net', from_name: 'userName' }
|
11
|
-
|
12
|
-
# Using body
|
13
|
-
mail.body = { html: '<b>Hello {{substitutionName}}</b>' }
|
14
|
-
|
15
|
-
# Using template
|
16
|
-
# mail.template = { template_engine: 'simple', template_id: 'template_id' }
|
17
|
-
|
18
|
-
substitutions = { 'substitutionName' => 'substitutionVal', to_name: 'Name Surname 1' }
|
19
|
-
recipient1 = { email: 'test1@example.com', substitutions: substitutions, metadata: { key1: 'val1' } }
|
20
|
-
mail.recipients << recipient1
|
21
|
-
|
22
|
-
substitutions = { 'substitutionName' => 'substitutionVal', to_name: 'Name Surname 2' }
|
23
|
-
recipient2 = { email: 'test2@example.com', substitutions: substitutions, metadata: { key1: 'val1' } }
|
24
|
-
mail.recipients << recipient2
|
25
|
-
|
26
|
-
mail.global_metadata = { key1: 'val1' }
|
27
|
-
mail.headers = { 'X-ReplyTo' => 'reply@qadns.net' }
|
28
|
-
mail.track = { track_links: 1, track_read: 1 }
|
29
|
-
mail.options = { unsubscribe_url: 'someurl' }
|
30
|
-
|
31
|
-
# Should have rights to use this option
|
32
|
-
# mail.skip_unsubscribe = 1
|
33
|
-
mail.force_send = 0
|
34
|
-
|
35
|
-
mail.attachments << { type: 'text/plain', name: 'myfile.txt', content: 'ZXhhbXBsZSBmaWxl' }
|
36
|
-
mail.inline_attachments << { type: 'image/png', name: 'IMAGECID', content: 'iVBORw0KGgo' }
|
37
|
-
|
38
|
-
puts mail.to_json
|
39
|
-
|
40
|
-
response = unione.send_email(mail.to_json)
|
41
|
-
|
42
|
-
puts response.status
|
43
|
-
puts response.body
|
44
|
-
puts response.headers
|
45
|
-
|
46
|
-
# subscribe email
|
47
|
-
response = unione.subscribe_email(
|
48
|
-
from_email: 'from@qadns.net',
|
49
|
-
from_name: 'Example Sender',
|
50
|
-
to_email: 'blackhole@example.com'
|
51
|
-
)
|