emarsys 0.3.7 → 0.3.8
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/lib/emarsys/data_objects/contact.rb +5 -5
- data/lib/emarsys/data_objects/email.rb +32 -10
- data/lib/emarsys/data_objects/field.rb +22 -0
- data/lib/emarsys/data_objects/file.rb +1 -1
- data/lib/emarsys/version.rb +1 -1
- data/spec/emarsys/data_objects/email_spec.rb +28 -2
- data/spec/emarsys/data_objects/field_spec.rb +10 -0
- data/spec/spec_helper.rb +6 -0
- metadata +18 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7bf69d01042a7b64304940391651c7fe3a99d96c
|
4
|
+
data.tar.gz: c7aa084a93d3f0201e617bfe6d2f040c7eddde84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 702951ca24054c4bbf36e5442e6346e5ab112a778c91b53f1b1ebd24be9a1fdaae6bbfc10550408665c40edf55b02a60e67ffb5cdb9e55630f4c6f05831b01e8
|
7
|
+
data.tar.gz: 7913423d7bc03c272f187ba172f9f80b77aa69eb90c2738b62d48a591292d71b594ba37a32b1aeb27a2af41d6a9310703772153e999bc791a04dbe1de1b9d8ae
|
@@ -10,7 +10,7 @@ module Emarsys
|
|
10
10
|
# Create a new contact. The given params are transformed to emarsys ids.
|
11
11
|
#
|
12
12
|
# @param key_id [Integer, String] internal id of key field
|
13
|
-
# @param key_value [Integer, String] value of
|
13
|
+
# @param key_value [Integer, String] value of internal id field
|
14
14
|
# @param params [Hash] Contact information to create
|
15
15
|
# @return [Hash] internal id of the contact
|
16
16
|
# @example
|
@@ -21,10 +21,10 @@ module Emarsys
|
|
21
21
|
post account, "contact", params.merge!({'key_id' => transformed_key_id, transformed_key_id => key_value})
|
22
22
|
end
|
23
23
|
|
24
|
-
# Get the
|
24
|
+
# Get the internal emarsys id of a contact. The given params are transformed to emarsys ids.
|
25
25
|
#
|
26
26
|
# @param key_id [Integer, String] internal id of key field
|
27
|
-
# @param key_value [Integer, String] value of
|
27
|
+
# @param key_value [Integer, String] value of internal id field
|
28
28
|
# @return [Hash] internal emarsys id of the contact
|
29
29
|
# @example
|
30
30
|
# Emarsys::Contact.emarsys_id('email', 'john.dow@example.com')
|
@@ -36,7 +36,7 @@ module Emarsys
|
|
36
36
|
# Update a contact. The given params are transformed to emarsys ids.
|
37
37
|
#
|
38
38
|
# @param key_id [Integer, String] internal id of key field
|
39
|
-
# @param key_value [Integer, String] value of
|
39
|
+
# @param key_value [Integer, String] value of internal id field
|
40
40
|
# @param params [Hash] Contact information to update
|
41
41
|
# @param create_if_not_exists [Boolean] Whether to create contact if it does not exist
|
42
42
|
# @return [Hash] internal id of the contact
|
@@ -84,7 +84,7 @@ module Emarsys
|
|
84
84
|
# Delete a contact. The given params are transformed to emarsys ids.
|
85
85
|
#
|
86
86
|
# @param key_id [Integer, String] internal id of key field
|
87
|
-
# @param key_value [Integer, String] value of
|
87
|
+
# @param key_value [Integer, String] value of internal id field
|
88
88
|
# @return [Hash]
|
89
89
|
# @example
|
90
90
|
# Emarsys::Contact.update('app_id', 23, {:firstname => "Jon", :lastname => "Doe"})
|
@@ -81,14 +81,23 @@ module Emarsys
|
|
81
81
|
post account, "email/#{id}/preview", {:version => version}
|
82
82
|
end
|
83
83
|
|
84
|
-
#
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
84
|
+
# http://documentation.emarsys.com/resource/developers/endpoints/email/response-summary/
|
85
|
+
def response_summary(id, launch_id: nil, start_date: nil, end_date: nil, account: nil)
|
86
|
+
params = {}
|
87
|
+
|
88
|
+
if !launch_id.nil?
|
89
|
+
params.merge!(launch_id: launch_id)
|
90
|
+
end
|
91
|
+
|
92
|
+
if !start_date.nil?
|
93
|
+
params.merge!(start_date: start_date)
|
94
|
+
end
|
95
|
+
|
96
|
+
if !end_date.nil?
|
97
|
+
params.merge!(end_date: end_date)
|
98
|
+
end
|
99
|
+
|
100
|
+
get account, "email/#{id}/responsesummary", params
|
92
101
|
end
|
93
102
|
|
94
103
|
# Instruct emarsys to send a test mail
|
@@ -120,9 +129,22 @@ module Emarsys
|
|
120
129
|
post account, "email/#{id}/getdeliverystatus", params
|
121
130
|
end
|
122
131
|
|
123
|
-
#
|
132
|
+
# Tracking email campaign unsubscribes
|
133
|
+
#
|
134
|
+
# @param params [hash] unsubscribe parameters
|
135
|
+
# @option params [String] 'contact_uid'
|
136
|
+
# @option params [String] 'email_id'
|
137
|
+
# @option params [String] 'launch_list_id'
|
138
|
+
# @return [Hash] Result data
|
139
|
+
# @example
|
140
|
+
# Emarsys::Email.unsubscribe({contact_uid: '1', email_id: '1', launch_list_id: '1'})
|
141
|
+
def unsubscribe(account: nil, **params)
|
142
|
+
post account, "email/unsubscribe", params
|
143
|
+
end
|
144
|
+
|
145
|
+
# https://help.emarsys.com/hc/en-us/articles/115004523714
|
124
146
|
def email_launches(id, account: nil)
|
125
|
-
|
147
|
+
post account, "email/getlaunchesofemail", emailId: id
|
126
148
|
end
|
127
149
|
|
128
150
|
# Exports the selected fields of all contacts who responded to emails
|
@@ -33,6 +33,28 @@ module Emarsys
|
|
33
33
|
def choice(id, account: nil)
|
34
34
|
get account, "field/#{id}/choice", {}
|
35
35
|
end
|
36
|
+
|
37
|
+
# Create a new custom field
|
38
|
+
#
|
39
|
+
# @param name [String] name of the new field
|
40
|
+
# @param application_type [String] type of the new field
|
41
|
+
# @param string_id [String] optional string_id for the new field
|
42
|
+
# @return [Hash] Result Data
|
43
|
+
# @example
|
44
|
+
# Emarsys::Field.create(
|
45
|
+
# name: 'New field',
|
46
|
+
# application_type: 'shorttext',
|
47
|
+
# string_id: 'string_id_for_the_new_field'
|
48
|
+
# )
|
49
|
+
# Emarsys::Field.create(
|
50
|
+
# name: 'New number field',
|
51
|
+
# application_type: 'numeric'
|
52
|
+
# )
|
53
|
+
def create(name:, application_type:, string_id: nil, account: nil)
|
54
|
+
params = { name: name, application_type: application_type }
|
55
|
+
params[:string_id] = string_id if string_id
|
56
|
+
post account, 'field', params
|
57
|
+
end
|
36
58
|
end
|
37
59
|
|
38
60
|
end
|
@@ -23,7 +23,7 @@ module Emarsys
|
|
23
23
|
#
|
24
24
|
# @param filename [String] The filename
|
25
25
|
# @param file [String] Base64 encoded version of the file
|
26
|
-
# @param folder [Integer, String]
|
26
|
+
# @param folder [Integer, String] optional folder to put the file into
|
27
27
|
# @return [Hash] Result data
|
28
28
|
# @example
|
29
29
|
# Emarsys::File.create("my_file.jpg", "asdhkajsh...")
|
data/lib/emarsys/version.rb
CHANGED
@@ -83,10 +83,25 @@ describe Emarsys::Email do
|
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
|
+
describe ".unsubscribe" do
|
87
|
+
it "tracks unsubscribes with contact and list details" do
|
88
|
+
stub_params = {contact_uid: '1', email_id: '1', launch_list_id: '1'}
|
89
|
+
stub = stub_request(:post, "https://api.emarsys.net/api/v2/email/unsubscribe").with(:body => stub_params.to_json).to_return(standard_return_body)
|
90
|
+
|
91
|
+
Emarsys::Email.unsubscribe(stub_params)
|
92
|
+
expect(stub).to have_been_requested.once
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
86
96
|
describe ".response_summary" do
|
87
97
|
it "requests a single email" do
|
88
|
-
|
89
|
-
|
98
|
+
stub_params = {
|
99
|
+
launch_id: 123,
|
100
|
+
start_date: '2013-12-01 23:00:00',
|
101
|
+
end_date: '2013-12-02 23:00:00'
|
102
|
+
}
|
103
|
+
expect(stub_get('email/123/responsesummary/?end_date=2013-12-02%2023:00:00&launch_id=123&start_date=2013-12-01%2023:00:00') {
|
104
|
+
Emarsys::Email.response_summary(123, stub_params) }
|
90
105
|
).to have_been_requested.once
|
91
106
|
end
|
92
107
|
end
|
@@ -108,4 +123,15 @@ describe Emarsys::Email do
|
|
108
123
|
end
|
109
124
|
end
|
110
125
|
|
126
|
+
describe ".email_launches" do
|
127
|
+
it "queries email launches" do
|
128
|
+
stub_params = { emailId: 123 }
|
129
|
+
stub = stub_request(:post, 'https://api.emarsys.net/api/v2/email/getlaunchesofemail')
|
130
|
+
.with(body: stub_params.to_json)
|
131
|
+
.to_return(standard_return_body)
|
132
|
+
Emarsys::Email.email_launches(123)
|
133
|
+
expect(stub).to have_been_requested.once
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
111
137
|
end
|
@@ -22,4 +22,14 @@ describe Emarsys::Field do
|
|
22
22
|
).to have_been_requested.once
|
23
23
|
end
|
24
24
|
end
|
25
|
+
|
26
|
+
describe '.create' do
|
27
|
+
it 'creates a new custom field' do
|
28
|
+
expect(
|
29
|
+
stub_post('field') do
|
30
|
+
Emarsys::Field.create(name: 'New field', application_type: 'shorttext')
|
31
|
+
end
|
32
|
+
).to have_been_requested.once
|
33
|
+
end
|
34
|
+
end
|
25
35
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,83 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: emarsys
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Schoppmann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.3'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 3.5.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 3.5.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: webmock
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - <
|
73
|
+
- - "<"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '2.0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - <
|
80
|
+
- - "<"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '2.0'
|
83
83
|
description: A Ruby library for interacting with the Emarsys API.
|
@@ -87,9 +87,9 @@ executables: []
|
|
87
87
|
extensions: []
|
88
88
|
extra_rdoc_files: []
|
89
89
|
files:
|
90
|
-
- .gitignore
|
91
|
-
- .rspec
|
92
|
-
- .travis.yml
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- ".travis.yml"
|
93
93
|
- CHANGELOG.md
|
94
94
|
- Gemfile
|
95
95
|
- LICENSE.txt
|
@@ -161,17 +161,17 @@ require_paths:
|
|
161
161
|
- lib
|
162
162
|
required_ruby_version: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
|
-
- -
|
164
|
+
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
167
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
168
168
|
requirements:
|
169
|
-
- -
|
169
|
+
- - ">="
|
170
170
|
- !ruby/object:Gem::Version
|
171
171
|
version: '0'
|
172
172
|
requirements: []
|
173
173
|
rubyforge_project:
|
174
|
-
rubygems_version: 2.
|
174
|
+
rubygems_version: 2.5.2
|
175
175
|
signing_key:
|
176
176
|
specification_version: 4
|
177
177
|
summary: Easy to use ruby library for Emarsys Marketing Suite.
|