emarsys 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.
- data/.gitignore +18 -0
- data/.rspec +1 -0
- data/Gemfile +11 -0
- data/LICENSE.txt +22 -0
- data/README.md +171 -0
- data/Rakefile +7 -0
- data/emarsys.gemspec +25 -0
- data/lib/emarsys.rb +60 -0
- data/lib/emarsys/client.rb +40 -0
- data/lib/emarsys/data_object.rb +78 -0
- data/lib/emarsys/data_objects/condition.rb +20 -0
- data/lib/emarsys/data_objects/contact.rb +121 -0
- data/lib/emarsys/data_objects/contact_list.rb +47 -0
- data/lib/emarsys/data_objects/email.rb +133 -0
- data/lib/emarsys/data_objects/email_category.rb +20 -0
- data/lib/emarsys/data_objects/email_launch_status.rb +38 -0
- data/lib/emarsys/data_objects/email_status_code.rb +39 -0
- data/lib/emarsys/data_objects/event.rb +44 -0
- data/lib/emarsys/data_objects/export.rb +22 -0
- data/lib/emarsys/data_objects/field.rb +39 -0
- data/lib/emarsys/data_objects/file.rb +39 -0
- data/lib/emarsys/data_objects/folder.rb +24 -0
- data/lib/emarsys/data_objects/form.rb +21 -0
- data/lib/emarsys/data_objects/language.rb +20 -0
- data/lib/emarsys/data_objects/segment.rb +21 -0
- data/lib/emarsys/data_objects/source.rb +40 -0
- data/lib/emarsys/error.rb +24 -0
- data/lib/emarsys/extensions.rb +8 -0
- data/lib/emarsys/field_mapping.rb +55 -0
- data/lib/emarsys/params_converter.rb +29 -0
- data/lib/emarsys/request.rb +46 -0
- data/lib/emarsys/response.rb +24 -0
- data/lib/emarsys/version.rb +3 -0
- data/spec/emarsys/client_spec.rb +85 -0
- data/spec/emarsys/data_object_spec.rb +55 -0
- data/spec/emarsys/data_objects/condition_spec.rb +9 -0
- data/spec/emarsys/data_objects/contact_list_spec.rb +9 -0
- data/spec/emarsys/data_objects/contact_spec.rb +79 -0
- data/spec/emarsys/data_objects/email_category_spec.rb +9 -0
- data/spec/emarsys/data_objects/email_launch_status_spec.rb +25 -0
- data/spec/emarsys/data_objects/email_spec.rb +84 -0
- data/spec/emarsys/data_objects/email_status_code_spec.rb +25 -0
- data/spec/emarsys/data_objects/event_spec.rb +23 -0
- data/spec/emarsys/data_objects/export_spec.rb +9 -0
- data/spec/emarsys/data_objects/field_spec.rb +19 -0
- data/spec/emarsys/data_objects/file_spec.rb +29 -0
- data/spec/emarsys/data_objects/folder_spec.rb +13 -0
- data/spec/emarsys/data_objects/form_spec.rb +9 -0
- data/spec/emarsys/data_objects/language_spec.rb +9 -0
- data/spec/emarsys/data_objects/segment_spec.rb +9 -0
- data/spec/emarsys/data_objects/source_spec.rb +25 -0
- data/spec/emarsys/extensions_spec.rb +24 -0
- data/spec/emarsys/field_mapping_spec.rb +14 -0
- data/spec/emarsys/params_converter_spec.rb +52 -0
- data/spec/emarsys/request_spec.rb +27 -0
- data/spec/emarsys/response_spec.rb +35 -0
- data/spec/emarsys_spec.rb +22 -0
- data/spec/spec_helper.rb +28 -0
- metadata +178 -0
@@ -0,0 +1,20 @@
|
|
1
|
+
module Emarsys
|
2
|
+
|
3
|
+
# Methods for the Condition API
|
4
|
+
#
|
5
|
+
#
|
6
|
+
class Condition < DataObject
|
7
|
+
class << self
|
8
|
+
|
9
|
+
# List conditions
|
10
|
+
#
|
11
|
+
# @return [Hash] List of conditions
|
12
|
+
# @example
|
13
|
+
# Emarsys::Condition.collection
|
14
|
+
def collection
|
15
|
+
get 'condition', {}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
module Emarsys
|
2
|
+
|
3
|
+
# Methods for the Contact API
|
4
|
+
#
|
5
|
+
#
|
6
|
+
class Contact < DataObject
|
7
|
+
class << self
|
8
|
+
|
9
|
+
# Create a new contact. The given params are transformed to emarsys ids.
|
10
|
+
#
|
11
|
+
# @param key_id [Integer, String] internal id of key field
|
12
|
+
# @param key_value [Integer, String] value of interal id field
|
13
|
+
# @param params [Hash] Contact information to create
|
14
|
+
# @return [Hash] internal id of the contact
|
15
|
+
# @example
|
16
|
+
# Emarsys::Contact.create('app_id', 23, {:firstname => "Jon", :lastname => "Doe"})
|
17
|
+
# Emarsys::Contact.create('3', 'john.doe@example.com', {'1' => "Jon", '2' => "Doe"})
|
18
|
+
def create(key_id, key_value, params = {})
|
19
|
+
transformed_key_id = transform_key_id(key_id)
|
20
|
+
post "contact", params.merge!({'key_id' => transformed_key_id, transformed_key_id => key_value})
|
21
|
+
end
|
22
|
+
|
23
|
+
# Get the interal emarsys id of a contact. The given params are transformed to emarsys ids.
|
24
|
+
#
|
25
|
+
# @param key_id [Integer, String] internal id of key field
|
26
|
+
# @param key_value [Integer, String] value of interal id field
|
27
|
+
# @return [Hash] internal emarsys id of the contact
|
28
|
+
# @example
|
29
|
+
# Emarsys::Contact.emarsys_id('email', 'john.dow@example.com')
|
30
|
+
# Emarsys::Contact.emarsys_id(1, 'John')
|
31
|
+
def emarsys_id(key_id, key_value)
|
32
|
+
get "contact/#{transform_key_id(key_id).to_s}=#{key_value.to_s}", {}
|
33
|
+
end
|
34
|
+
|
35
|
+
# Update a contact. The given params are transformed to emarsys ids.
|
36
|
+
#
|
37
|
+
# @param key_id [Integer, String] internal id of key field
|
38
|
+
# @param key_value [Integer, String] value of interal id field
|
39
|
+
# @param params [Hash] Contact information to update
|
40
|
+
# @return [Hash] internal id of the contact
|
41
|
+
# @example
|
42
|
+
# Emarsys::Contact.update('app_id', 23, {:firstname => "Jon", :lastname => "Doe"})
|
43
|
+
# Emarsys::Contact.update('3', 'john.doe@example.com', {'1' => "Jon", '2' => "Doe"})
|
44
|
+
def update(key_id, key_value, params = {})
|
45
|
+
transformed_key_id = transform_key_id(key_id)
|
46
|
+
put "contact", params.merge!({'key_id' => transformed_key_id, transformed_key_id => key_value})
|
47
|
+
end
|
48
|
+
|
49
|
+
# Batch creation of contacts.
|
50
|
+
#
|
51
|
+
# @param key_id [Integer, String] internal id of key field
|
52
|
+
# @param params [Hash] Contact information of each new contact
|
53
|
+
# @example
|
54
|
+
# Emarsys::Contact.create_batch(
|
55
|
+
# 'email', {:app_id => 1, :firstname => "Jon", :lastname => "Doe"},
|
56
|
+
# {:app_id => 2, :firstname => "Jane", :lastname => "Doe"}
|
57
|
+
# )
|
58
|
+
#
|
59
|
+
# TODO params should be parameterized with field mappings
|
60
|
+
def create_batch(key_id, params = [])
|
61
|
+
post "contact", {'key_id' => transform_key_id(key_id), 'contacts' => params}
|
62
|
+
end
|
63
|
+
|
64
|
+
# Batch update of contacts.
|
65
|
+
#
|
66
|
+
# @param key_id [Integer, String] internal id of key field
|
67
|
+
# @param params [Hash] Contact information of each new contact
|
68
|
+
# @example
|
69
|
+
# Emarsys::Contact.update_batch(
|
70
|
+
# 'email', {:app_id => 1, :firstname => "Jon", :lastname => "Doe"},
|
71
|
+
# {:app_id => 2, :firstname => "Jane", :lastname => "Doe"}
|
72
|
+
# )
|
73
|
+
#
|
74
|
+
# TODO params should be parameterized with field mappings
|
75
|
+
def update_batch(key_id, params = [])
|
76
|
+
put "contact", {'key_id' => transform_key_id(key_id), 'contacts' => params}
|
77
|
+
end
|
78
|
+
|
79
|
+
# Get list of emails send to a contact
|
80
|
+
#
|
81
|
+
# @param contact_ids_array [array] Array of contact ids
|
82
|
+
# @return [Hash] result data
|
83
|
+
# @example
|
84
|
+
# Emarsys::Contact.contact_history([1,2,3]
|
85
|
+
def contact_history(contact_ids_array)
|
86
|
+
post "contact/getcontacthistory", {'contacts' => contact_ids_array}
|
87
|
+
end
|
88
|
+
|
89
|
+
# Get contact data by custom search
|
90
|
+
#
|
91
|
+
# @param key_id [Integer, String] Array of contact ids
|
92
|
+
# @param key_values [array] Array of key field values
|
93
|
+
# @param fields [array] requested fields. If empty, all are considered
|
94
|
+
# @return [Hash] result data
|
95
|
+
# @example
|
96
|
+
# Emarsys::Contact.search('3', ['john.doe@example.com'], [1,2,3]
|
97
|
+
#
|
98
|
+
# TODO transform fields to numeric fields
|
99
|
+
def search(key_id, key_values = [], fields = [])
|
100
|
+
post "contact/getdata", {'keyId' => key_id, 'keyValues' => key_values, 'fields' => fields}
|
101
|
+
end
|
102
|
+
|
103
|
+
# Exports the selected fields of contacts whoch registered in the specified time range
|
104
|
+
#
|
105
|
+
# @param params [hash] hash of parameters according to emarsys API
|
106
|
+
# @return [Hash] result data
|
107
|
+
# @example
|
108
|
+
# Emarsys::Contact.export_registrations(distribution_method: 'local', time_range: ["2013-01-01","2013-12-31"], contact_fields: [1,2,3])
|
109
|
+
def export_registrations(params = {})
|
110
|
+
post "contact/getregistrations", params
|
111
|
+
end
|
112
|
+
|
113
|
+
# @private
|
114
|
+
def transform_key_id(key_id)
|
115
|
+
matching_attributes = Emarsys::FieldMapping::ATTRIBUTES.find{|elem| elem[:identifier] == key_id.to_s}
|
116
|
+
matching_attributes.nil? ? key_id : matching_attributes[:id]
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Emarsys
|
2
|
+
|
3
|
+
# Methods for the ContactList API
|
4
|
+
#
|
5
|
+
#
|
6
|
+
class ContactList < DataObject
|
7
|
+
class << self
|
8
|
+
|
9
|
+
# List contact lists
|
10
|
+
#
|
11
|
+
# @return [Hash] List of contact_lists
|
12
|
+
# @example
|
13
|
+
# Emarsys::ContactList.collection
|
14
|
+
def collection
|
15
|
+
get 'contactlist', {}
|
16
|
+
end
|
17
|
+
|
18
|
+
# Create a new contact list
|
19
|
+
#
|
20
|
+
# @param params [Hash] Contact list information to create
|
21
|
+
# @option params [String] :name Name of the list
|
22
|
+
# @option params [String] :description Detailed description of the list
|
23
|
+
|
24
|
+
# @return [Hash] internal id of the contact list
|
25
|
+
# @example
|
26
|
+
# Emarsys::ContactList.create(key_id: "3", name: 'Test-Liste', description: 'Something')
|
27
|
+
def create(params = {})
|
28
|
+
post "contactlist", params
|
29
|
+
end
|
30
|
+
|
31
|
+
# Add a contacts to a specific contact list
|
32
|
+
#
|
33
|
+
# This cannot be an instance method, because the API does not allow to retrieve a single resource. How crappy is that?
|
34
|
+
def add_contacts(contact_list_id, key_id, external_ids = [])
|
35
|
+
post "contactlist/#{contact_list_id}/add", {'key_id' => key_id, 'external_ids' => external_ids}
|
36
|
+
end
|
37
|
+
|
38
|
+
# Remove contacts from a specific contact list
|
39
|
+
#
|
40
|
+
# This cannot be an instance method, because the API does not allow to retrieve a single resource. How crappy is that?
|
41
|
+
def remove_contacts(contact_list_id, key_id, external_ids = [])
|
42
|
+
post "contactlist/#{contact_list_id}/remove", {'key_id' => key_id, 'external_ids' => external_ids}
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,133 @@
|
|
1
|
+
module Emarsys
|
2
|
+
|
3
|
+
# Methods for the Email API
|
4
|
+
#
|
5
|
+
#
|
6
|
+
class Email < DataObject
|
7
|
+
class << self
|
8
|
+
|
9
|
+
# List email campaigns
|
10
|
+
#
|
11
|
+
# @param params [Hash] Optional filter for the emails
|
12
|
+
# @option params [String] :status filter by status
|
13
|
+
# @option params [String] :contactlist filter by contactlist
|
14
|
+
# @return [Hash] List of emails
|
15
|
+
# @example
|
16
|
+
# Emarsys::Email.collection
|
17
|
+
# Emarsys::Email.collection(:status => 3)
|
18
|
+
# Emarsys::Email.collection(:contactlist => 5)
|
19
|
+
def collection(params = {})
|
20
|
+
get 'email', params
|
21
|
+
end
|
22
|
+
|
23
|
+
# Get Email attirbutes of a specific email
|
24
|
+
#
|
25
|
+
# @param id [Integer, String] The internal id of an email
|
26
|
+
# @return [Hash] Attributes hash
|
27
|
+
# @example
|
28
|
+
# Emarsys::Email.resource(1)
|
29
|
+
def resource(id)
|
30
|
+
get "email/#{id}", {}
|
31
|
+
end
|
32
|
+
|
33
|
+
# Create a new email campaign
|
34
|
+
#
|
35
|
+
# @param params [Hash] Email information to create
|
36
|
+
# @option params [String] :name Name of the email campagin
|
37
|
+
# @option params [String] :language Language Code
|
38
|
+
# @option params [String] :fromemail sets the from-header email
|
39
|
+
# @option params [String] :fromname sets the from-header name
|
40
|
+
# @option params [String] :subject Subject of the email
|
41
|
+
# @option params [Integer] :email_category associated Email-Category-Id
|
42
|
+
# @option params [Integer] :segment associated Segment-id
|
43
|
+
# @option params [Integer] :contactlist associated Contactlist-id
|
44
|
+
# @option params [String] :html_source
|
45
|
+
# @option params [String] :text_source
|
46
|
+
# @option params [Integer] :unsubscribe (optional)
|
47
|
+
# @option params [Integer] :browse (optional)
|
48
|
+
# @return [Hash] internal id of the campaign
|
49
|
+
# @example
|
50
|
+
# Emarsys::Email.create(
|
51
|
+
# name: 'Test', language: 'de', fromemail: 'john.doe@example.com', fromname: 'John Doe',
|
52
|
+
# subject: 'Test Subject', :email_category: 3, segment: 1121, contactlist: 0,
|
53
|
+
# html_source: '<h1>Test</h1>', text_source: 'Test'
|
54
|
+
# )
|
55
|
+
def create(params = {})
|
56
|
+
post "email", params
|
57
|
+
end
|
58
|
+
|
59
|
+
# Launches an email
|
60
|
+
#
|
61
|
+
# @param id [Integer, String] Internal email id
|
62
|
+
# @param params [hash] Optional launch parmeters
|
63
|
+
# @option params [Datetime] :schedule launch time
|
64
|
+
# @option params [String] :timezone
|
65
|
+
# @return [Hash] Result data
|
66
|
+
# @example
|
67
|
+
# Emarsys::Email.launch(1)
|
68
|
+
def launch(id, params = {})
|
69
|
+
post "email/#{id}/launch", params
|
70
|
+
end
|
71
|
+
|
72
|
+
# Preview an email
|
73
|
+
#
|
74
|
+
# @param id [Integer, String] Internal email id
|
75
|
+
# @param version [String] 'html' or 'text' version
|
76
|
+
# @return [Hash] Result data
|
77
|
+
# @example
|
78
|
+
# Emarsys::Email.preview(1)
|
79
|
+
def preview(id, version = 'html')
|
80
|
+
post "email/#{id}/preview", {:version => version}
|
81
|
+
end
|
82
|
+
|
83
|
+
# View response summary of an email
|
84
|
+
#
|
85
|
+
# @param id [Integer, String] Internal email id
|
86
|
+
# @return [Hash] Result data
|
87
|
+
# @example
|
88
|
+
# Emarsys::Email.response_summary(1)
|
89
|
+
def response_summary(id)
|
90
|
+
get "email/#{id}/responsesummary", {}
|
91
|
+
end
|
92
|
+
|
93
|
+
# Instruct emarsys to send a test mail
|
94
|
+
#
|
95
|
+
# @param id [Integer, String] Internal email id
|
96
|
+
# @param params [hash] recipient parmeters
|
97
|
+
# @option params [String] :recipientlist email_addresses separated by ';'
|
98
|
+
# @option params [Integer] :segment_id custom segement id
|
99
|
+
# @option params [Integer] :contactlist_id custom contactlist id
|
100
|
+
# Only one of the three parameters must be sent.
|
101
|
+
#
|
102
|
+
# @return [Hash] Result data
|
103
|
+
# @example
|
104
|
+
# Emarsys::Email.send_test_mail(1, {:recipientlist => 'john.doe@example.com;jane.doe@example.com'})
|
105
|
+
def send_test_mail(id, params = {})
|
106
|
+
post "email/#{id}/sendtestmail", params
|
107
|
+
end
|
108
|
+
|
109
|
+
# Returns the delivery status of an email
|
110
|
+
#
|
111
|
+
# @param id [Integer, String] Internal email id
|
112
|
+
# @param params [hash] recipient parmeters
|
113
|
+
# @option params [String] 'lastId'
|
114
|
+
# @option params [Integer] 'launchId'
|
115
|
+
# @return [Hash] Result data
|
116
|
+
# @example
|
117
|
+
# Emarsys::Email.delivery_status(1)
|
118
|
+
def delivery_status(id, params = {})
|
119
|
+
post "email/#{id}/getdeliverystatus", params
|
120
|
+
end
|
121
|
+
|
122
|
+
# TODO POST /getlaunchesofemail
|
123
|
+
def email_launches(id)
|
124
|
+
raise "Not implemented yet"
|
125
|
+
end
|
126
|
+
|
127
|
+
# TODO POST /getresponses
|
128
|
+
def export_responses(params = {})
|
129
|
+
raise "Not implemented yet"
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Emarsys
|
2
|
+
|
3
|
+
# Methods for the EmailCategory API
|
4
|
+
#
|
5
|
+
#
|
6
|
+
class EmailCategory < DataObject
|
7
|
+
class << self
|
8
|
+
|
9
|
+
# List email categories
|
10
|
+
#
|
11
|
+
# @return [Hash] List of email_categories
|
12
|
+
# @example
|
13
|
+
# Emarsys::EmailCategory.collection
|
14
|
+
def collection
|
15
|
+
get 'emailcategory', {}
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Emarsys
|
2
|
+
|
3
|
+
# Internal helper class for valid email launch status.
|
4
|
+
# Emarsys has no implementation for this data resource.
|
5
|
+
#
|
6
|
+
class EmailLaunchStatus < DataObject
|
7
|
+
|
8
|
+
CODES = [
|
9
|
+
{'0' => 'Not launched'},
|
10
|
+
{'1' => 'Launch called via API, launching in Progress'},
|
11
|
+
{'2' => 'Email launched or scheduled for future launch'},
|
12
|
+
{'10' => 'Error (details in api_error)'}
|
13
|
+
]
|
14
|
+
|
15
|
+
class << self
|
16
|
+
|
17
|
+
# List email launch status codes
|
18
|
+
#
|
19
|
+
# @return [Hash] List of email launch status
|
20
|
+
# @example
|
21
|
+
# Emarsys::EmailLaunchStatus.collection
|
22
|
+
def collection
|
23
|
+
CODES
|
24
|
+
end
|
25
|
+
|
26
|
+
# Get a specific email launch status
|
27
|
+
#
|
28
|
+
# @param [Integer, String] id of the code
|
29
|
+
# @return [Hash] Key-Value-Pair of the launch code
|
30
|
+
# @example
|
31
|
+
# Emarsys::EmailLaunchStatus.resource('1')
|
32
|
+
def resource(id)
|
33
|
+
CODES.select{|hash| hash.has_key?(id.to_s)}[0]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Emarsys
|
2
|
+
|
3
|
+
# Internal helper class for valid email status codes.
|
4
|
+
# Emarsys has no implementation for this data resource.
|
5
|
+
#
|
6
|
+
class EmailStatusCode < DataObject
|
7
|
+
|
8
|
+
CODES = [
|
9
|
+
{'1' => 'In design'},
|
10
|
+
{'2' => 'Tested'},
|
11
|
+
{'3' => 'Launched'},
|
12
|
+
{'4' => 'Ready to launch'},
|
13
|
+
{'-3' => 'Deactivated'}
|
14
|
+
]
|
15
|
+
|
16
|
+
class << self
|
17
|
+
|
18
|
+
# List email status codes
|
19
|
+
#
|
20
|
+
# @return [Hash] List of email status codes
|
21
|
+
# @example
|
22
|
+
# Emarsys::EmailStatusCode.collection
|
23
|
+
def collection
|
24
|
+
CODES
|
25
|
+
end
|
26
|
+
|
27
|
+
# Get a specific email status codes
|
28
|
+
#
|
29
|
+
# @param [Integer, String] id of the code
|
30
|
+
# @return [Hash] Key-Value-Pair of the status code
|
31
|
+
# @example
|
32
|
+
# Emarsys::EmailStatusCode.resource('1')
|
33
|
+
def resource(id)
|
34
|
+
CODES.select{|hash| hash.has_key?(id.to_s)}[0]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Emarsys
|
2
|
+
|
3
|
+
# Methods for the Event API
|
4
|
+
#
|
5
|
+
#
|
6
|
+
class Event < DataObject
|
7
|
+
|
8
|
+
class << self
|
9
|
+
|
10
|
+
# List events
|
11
|
+
#
|
12
|
+
# @return [Hash] List of events
|
13
|
+
# @example
|
14
|
+
# Emarsys::Event.collection
|
15
|
+
def collection
|
16
|
+
get 'event', {}
|
17
|
+
end
|
18
|
+
|
19
|
+
# Trigger an external event
|
20
|
+
#
|
21
|
+
# @param event_id [Integer, String] The internal emarsys id
|
22
|
+
# @param key_id [Integer, String] The identifer of the key field (e.g. 3 for 'email')
|
23
|
+
# @param external_id [String] The id of the given filed specified with key_id (e.g. 'test@example.com')
|
24
|
+
# @option data [Hash] data hash for transactional mails
|
25
|
+
# @return [Hash] Result data
|
26
|
+
# @example
|
27
|
+
# Emarsys::Event.trigger(2, 3, 'test@example.com')
|
28
|
+
# Emarsys::Event.trigger(2, 'user_id', 57687, {:global => {:name => "Special Name"}})
|
29
|
+
def trigger(event_id, key_id, external_id, data = {})
|
30
|
+
transformed_key_id = transform_key_id(key_id)
|
31
|
+
params = {:key_id => transformed_key_id, :external_id => external_id}
|
32
|
+
params.merge!(:data => data) if not data.empty?
|
33
|
+
post "event/#{event_id}/trigger", params
|
34
|
+
end
|
35
|
+
|
36
|
+
# @private
|
37
|
+
def transform_key_id(key_id)
|
38
|
+
matching_attributes = Emarsys::FieldMapping::ATTRIBUTES.find{|elem| elem[:identifier] == key_id.to_s}
|
39
|
+
matching_attributes.nil? ? key_id : matching_attributes[:id]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|