responsys-api 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -1
- data/README.md +7 -3
- data/lib/responsys/api/campaign.rb +3 -3
- data/lib/responsys/api/client.rb +26 -2
- data/lib/responsys/api/list.rb +5 -9
- data/lib/responsys/api/object/custom_event.rb +1 -1
- data/lib/responsys/api/object/record_data.rb +1 -1
- data/lib/responsys/api/session.rb +3 -12
- data/lib/responsys/configuration.rb +98 -8
- data/lib/responsys/exceptions.rb +25 -0
- data/lib/responsys/i18n/en.yml +4 -35
- data/lib/responsys/member.rb +43 -28
- data/lib/responsys/monkey_patches.rb +17 -0
- data/lib/responsys_api.rb +2 -1
- data/responsys-api.gemspec +7 -1
- data/spec/api/client_spec.rb +18 -0
- data/spec/configuration_spec.rb +162 -0
- data/spec/fixtures/vcr_cassettes/member/has_subscribed.yml +1037 -0
- data/spec/member_spec.rb +30 -10
- data/spec/spec_helper.rb +1 -2
- data/spec/test_data.yml +6 -3
- metadata +51 -5
- data/lib/responsys/exceptions/all.rb +0 -1
- data/lib/responsys/exceptions/parameter_exception.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c58dabbbc30ada0598409ef51e03261727c7e9f
|
4
|
+
data.tar.gz: 99998f69378d08f201ef7f2237f5ba539ba7f835
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed4209c6e94719176a85d2a509473a324a73663ccc2ab98b947802a98c38bcbd990da8eafcca56a7efeae46a4cb6e7325171f43ee16212f64827d31528088f8b
|
7
|
+
data.tar.gz: 6f1c45aede0988f1d8bbe4961eb70dedbc3d062f7be0d8bff92177fc07b862f155de88a3a5b4be2672711162e497c173c3cd34a9e39667f16792bfd7331362b2
|
data/.travis.yml
CHANGED
@@ -4,9 +4,11 @@ rvm:
|
|
4
4
|
- 2.1.2
|
5
5
|
gemfile:
|
6
6
|
- Gemfile
|
7
|
+
before_install:
|
8
|
+
- gem install bundler -v 1.11.2
|
7
9
|
notifications:
|
8
10
|
email:
|
9
11
|
on_success: never
|
10
12
|
on_failure: never
|
11
13
|
slack:
|
12
|
-
secure: 8b8dwwpHEw7vYd5Vma/BK2dZBrKYpFtu8TN8+NtpW8Xp+boYY3hEaFCeeEySzDvacCBZFKjjvDxverOFd4jqml2MtOukNZ/zlFc7ZVybGsNirfisNucS7auvwoWPwVrzrHoNpB5nTLU4tm0tWdaKkfLa4Yssr/tEO8yBIGwT8ds=
|
14
|
+
secure: 8b8dwwpHEw7vYd5Vma/BK2dZBrKYpFtu8TN8+NtpW8Xp+boYY3hEaFCeeEySzDvacCBZFKjjvDxverOFd4jqml2MtOukNZ/zlFc7ZVybGsNirfisNucS7auvwoWPwVrzrHoNpB5nTLU4tm0tWdaKkfLa4Yssr/tEO8yBIGwT8ds=
|
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
A gem to help you communicate to the Responsys Interact SOAP API. Currently working of Responsys Interact version 6.20.
|
4
4
|
|
5
|
+
:warning: The REST version of the GEM is available on a [WIP branch](https://github.com/dandemeyere/responsys-api/tree/migration-to-rest-apis)
|
6
|
+
|
5
7
|
## Documentation
|
6
8
|
|
7
9
|
Have a look at our [wiki](https://github.com/dandemeyere/responsys-api/wiki) to understand the functionality this gem offers, how to use it, and some tips to help you avoid the same mistakes we ran into! If you have any questions or if you want to report a bug please create an [issue](https://github.com/dandemeyere/responsys-api/issues).
|
@@ -27,13 +29,15 @@ Responsys.configure do |config|
|
|
27
29
|
password: "your_responsys_password",
|
28
30
|
wsdl: "https://wsXXXX.responsys.net/webservices/wsdl/ResponsysWS_Level1.wsdl",
|
29
31
|
debug: false,
|
30
|
-
|
32
|
+
enabled: true,
|
33
|
+
savon_settings: { # Any Savon 2 settings, below are the default options
|
34
|
+
ssl_version: :TLSv1,
|
35
|
+
element_form_default: :qualified
|
36
|
+
}
|
31
37
|
}
|
32
38
|
end
|
33
39
|
```
|
34
40
|
|
35
|
-
Note that the debug option is optional and is set to false by default.
|
36
|
-
|
37
41
|
### Example
|
38
42
|
```ruby
|
39
43
|
#!/usr/bin/env ruby
|
@@ -6,8 +6,8 @@ module Responsys
|
|
6
6
|
include Responsys::Exceptions
|
7
7
|
|
8
8
|
def trigger_custom_event(custom_event, recipients)
|
9
|
-
raise ParameterException
|
10
|
-
raise ParameterException
|
9
|
+
raise ParameterException.new("api.campaign.incorrect_recipients_type") unless recipients.is_a? Array
|
10
|
+
raise ParameterException.new("api.object.custom_event.incorrect_event_object") unless custom_event.is_a? Responsys::Api::Object::CustomEvent
|
11
11
|
|
12
12
|
message = {
|
13
13
|
customEvent: custom_event.to_api,
|
@@ -17,7 +17,7 @@ module Responsys
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def trigger_message(campaign, recipients)
|
20
|
-
raise ParameterException
|
20
|
+
raise ParameterException.new("api.campaign.incorrect_recipients_type") unless recipients.is_a? Array
|
21
21
|
message = {
|
22
22
|
campaign: campaign.to_api,
|
23
23
|
recipientData: recipients.map(&:to_api)
|
data/lib/responsys/api/client.rb
CHANGED
@@ -2,6 +2,7 @@ module Responsys
|
|
2
2
|
module Api
|
3
3
|
class Client
|
4
4
|
include Responsys::Api::All
|
5
|
+
include Responsys::Exceptions
|
5
6
|
attr_accessor :client
|
6
7
|
|
7
8
|
#TODO allows to keep the use of .instance. The client is no longer a singleton so it needs to be removed in a newer release.
|
@@ -9,8 +10,17 @@ module Responsys
|
|
9
10
|
alias :instance :new
|
10
11
|
end
|
11
12
|
|
13
|
+
def initialize
|
14
|
+
@raise_exceptions = false
|
15
|
+
end
|
16
|
+
|
12
17
|
def api_method(action, message = nil, response_type = :hash)
|
13
|
-
raise
|
18
|
+
raise ParameterException.new("api.client.api_method.wrong_action_#{action.to_s}") if action.to_sym == :login || action.to_sym == :logout
|
19
|
+
|
20
|
+
unless Responsys.configuration.enabled?
|
21
|
+
raise DisabledException.new if @raise_exceptions
|
22
|
+
return "disabled"
|
23
|
+
end
|
14
24
|
|
15
25
|
SessionPool.instance.with do |session|
|
16
26
|
begin
|
@@ -25,12 +35,26 @@ module Responsys
|
|
25
35
|
else
|
26
36
|
response
|
27
37
|
end
|
28
|
-
rescue
|
38
|
+
rescue Savon::Error => e
|
29
39
|
Responsys::Helper.format_response_with_errors(e)
|
30
40
|
end
|
31
41
|
end
|
32
42
|
end
|
33
43
|
|
44
|
+
# For internal use ONLY
|
45
|
+
def run(exception_raising = false)
|
46
|
+
old_raise_exceptions = @raise_exceptions
|
47
|
+
@raise_exceptions = exception_raising
|
48
|
+
begin
|
49
|
+
yield(self)
|
50
|
+
rescue DisabledException => e
|
51
|
+
raise e if @raise_exceptions
|
52
|
+
return "disabled"
|
53
|
+
ensure
|
54
|
+
@raise_exceptions = old_raise_exceptions
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
34
58
|
def available_operations
|
35
59
|
SessionPool.instance.with do |session|
|
36
60
|
session.operations
|
data/lib/responsys/api/list.rb
CHANGED
@@ -4,6 +4,7 @@ module Responsys
|
|
4
4
|
module Api
|
5
5
|
module List
|
6
6
|
include Responsys::Api::Object
|
7
|
+
|
7
8
|
def retrieve_list_members(interact_object, query_column, field_list, ids_to_retrieve)
|
8
9
|
message = {
|
9
10
|
list: interact_object.to_api,
|
@@ -15,24 +16,19 @@ module Responsys
|
|
15
16
|
api_method(:retrieve_list_members, message)
|
16
17
|
end
|
17
18
|
|
18
|
-
def merge_list_members(interact_object, record_data, merge_rule = ListMergeRule.new)
|
19
|
+
def merge_list_members(interact_object, record_data, merge_rule = ListMergeRule.new, riid = false)
|
19
20
|
message = {
|
20
21
|
list: interact_object.to_api,
|
21
22
|
recordData: record_data.to_api,
|
22
23
|
mergeRule: merge_rule.to_api
|
23
24
|
}
|
24
25
|
|
25
|
-
|
26
|
+
method_name = riid ? "merge_list_members_riid" : "merge_list_members"
|
27
|
+
api_method(method_name.to_sym, message)
|
26
28
|
end
|
27
29
|
|
28
30
|
def merge_list_members_riid(interact_object, record_data, merge_rule = ListMergeRule.new)
|
29
|
-
|
30
|
-
list: interact_object.to_api,
|
31
|
-
recordData: record_data.to_api,
|
32
|
-
mergeRule: merge_rule.to_api
|
33
|
-
}
|
34
|
-
|
35
|
-
api_method(:merge_list_members_riid, message)
|
31
|
+
merge_list_members(interact_object, record_data, merge_rule, true)
|
36
32
|
end
|
37
33
|
end
|
38
34
|
end
|
@@ -6,7 +6,7 @@ module Responsys
|
|
6
6
|
attr_accessor :event_name, :event_id, :event_string_data_mapping, :event_number_data_mapping, :event_date_data_mapping
|
7
7
|
|
8
8
|
def initialize(event_name="", event_id="", options={})
|
9
|
-
raise ParameterException
|
9
|
+
raise ParameterException.new("api.object.custom_event.empty_event") if event_name.blank? && event_id.blank?
|
10
10
|
@event_name = event_name || ""
|
11
11
|
@event_id = event_id || ""
|
12
12
|
@event_string_data_mapping = options[:event_string_data_mapping] || ""
|
@@ -7,7 +7,7 @@ module Responsys
|
|
7
7
|
attr_accessor :field_names, :records
|
8
8
|
|
9
9
|
def initialize(data)
|
10
|
-
raise ParameterException
|
10
|
+
raise ParameterException.new("api.object.record_data.incorrect_record_data_type") unless data.is_a? Array
|
11
11
|
|
12
12
|
self.field_names = data.map { |record| record.keys }.flatten.uniq
|
13
13
|
|
@@ -5,19 +5,10 @@ module Responsys
|
|
5
5
|
include Responsys::Api::Authentication
|
6
6
|
|
7
7
|
def initialize
|
8
|
-
|
9
|
-
@credentials = {
|
10
|
-
username: settings[:username],
|
11
|
-
password: settings[:password]
|
12
|
-
}
|
8
|
+
global_configuration = Responsys.configuration
|
13
9
|
|
14
|
-
|
15
|
-
|
16
|
-
if settings[:debug]
|
17
|
-
@savon_client = Savon.client(wsdl: settings[:wsdl], element_form_default: :qualified, ssl_version: ssl_version, log_level: :debug, log: true, pretty_print_xml: true)
|
18
|
-
else
|
19
|
-
@savon_client = Savon.client(wsdl: settings[:wsdl], element_form_default: :qualified, ssl_version: ssl_version)
|
20
|
-
end
|
10
|
+
@credentials = global_configuration.api_credentials
|
11
|
+
@savon_client = Savon.client(global_configuration.savon_settings)
|
21
12
|
end
|
22
13
|
|
23
14
|
def run(method, message)
|
@@ -3,17 +3,40 @@ module Responsys
|
|
3
3
|
attr_accessor :settings
|
4
4
|
|
5
5
|
def initialize
|
6
|
-
@settings = {
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
6
|
+
@settings = {}
|
7
|
+
end
|
8
|
+
|
9
|
+
def savon_settings
|
10
|
+
settings_hash = if @settings[:wsdl].present?
|
11
|
+
{ wsdl: @settings[:wsdl] }
|
12
|
+
else
|
13
|
+
{
|
14
|
+
endpoint: @settings[:endpoint],
|
15
|
+
namespace: @settings[:namespace]
|
14
16
|
}
|
17
|
+
end
|
18
|
+
|
19
|
+
@settings[:savon_settings].merge(settings_hash)
|
20
|
+
end
|
21
|
+
|
22
|
+
def api_credentials
|
23
|
+
{
|
24
|
+
username: @settings[:username],
|
25
|
+
password: @settings[:password]
|
15
26
|
}
|
16
27
|
end
|
28
|
+
|
29
|
+
def session_settings
|
30
|
+
@settings[:sessions]
|
31
|
+
end
|
32
|
+
|
33
|
+
def debug?
|
34
|
+
!!(@settings[:debug])
|
35
|
+
end
|
36
|
+
|
37
|
+
def enabled?
|
38
|
+
!!(@settings[:enabled])
|
39
|
+
end
|
17
40
|
end
|
18
41
|
|
19
42
|
class << self
|
@@ -26,6 +49,73 @@ module Responsys
|
|
26
49
|
|
27
50
|
def self.configure
|
28
51
|
yield(configuration)
|
52
|
+
|
53
|
+
check_configuration
|
54
|
+
|
55
|
+
prepare!
|
56
|
+
|
29
57
|
Responsys::Api::SessionPool.init
|
30
58
|
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def self.check_configuration
|
63
|
+
raise Responsys::Exceptions::GenericException.new("configuration.api_description_not_provided") if absent_api_description?
|
64
|
+
raise Responsys::Exceptions::GenericException.new("configuration.api_credentials_not_provided") if absent_api_credentials?
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.prepare!
|
68
|
+
@configuration.settings = default_settings_hash.merge(@configuration.settings)
|
69
|
+
@configuration.settings[:savon_settings] = savon_settings
|
70
|
+
@configuration.settings[:sessions] = sessions
|
71
|
+
|
72
|
+
add_debug_options! if @configuration.debug?
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.savon_settings
|
76
|
+
default_settings_hash[:savon_settings].merge!(@configuration.settings[:savon_settings])
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.sessions
|
80
|
+
default_settings_hash[:sessions].merge!(@configuration.settings[:sessions])
|
81
|
+
end
|
82
|
+
|
83
|
+
def self.add_debug_options!
|
84
|
+
@configuration.settings[:savon_settings] = debug_savon_options.merge!(@configuration.settings[:savon_settings])
|
85
|
+
end
|
86
|
+
|
87
|
+
def self.debug_savon_options
|
88
|
+
{ log_level: :debug, log: true, pretty_print_xml: true }
|
89
|
+
end
|
90
|
+
|
91
|
+
def self.absent_api_description?
|
92
|
+
wsdl = @configuration.settings[:wsdl].present?
|
93
|
+
endpoint = @configuration.settings[:endpoint].present?
|
94
|
+
namespace = @configuration.settings[:namespace].present?
|
95
|
+
|
96
|
+
return false if wsdl
|
97
|
+
|
98
|
+
return !(endpoint && namespace) if endpoint || namespace
|
99
|
+
|
100
|
+
true
|
101
|
+
end
|
102
|
+
|
103
|
+
def self.absent_api_credentials?
|
104
|
+
@configuration.settings[:username].blank? || @configuration.settings[:password].blank?
|
105
|
+
end
|
106
|
+
|
107
|
+
def self.default_settings_hash
|
108
|
+
{
|
109
|
+
enabled: true,
|
110
|
+
debug: false,
|
111
|
+
sessions: {
|
112
|
+
size: 80,
|
113
|
+
timeout: 30
|
114
|
+
},
|
115
|
+
savon_settings: {
|
116
|
+
ssl_version: :TLSv1,
|
117
|
+
element_form_default: :qualified
|
118
|
+
}
|
119
|
+
}
|
120
|
+
end
|
31
121
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Responsys
|
2
|
+
module Exceptions
|
3
|
+
class BaseException < Exception
|
4
|
+
def initialize(message_key = nil)
|
5
|
+
if message_key.nil?
|
6
|
+
super
|
7
|
+
else
|
8
|
+
super(Responsys::Helper.get_message(message_key))
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class ParameterException < Responsys::Exceptions::BaseException
|
14
|
+
end
|
15
|
+
|
16
|
+
class DisabledException < Responsys::Exceptions::BaseException
|
17
|
+
def initialize
|
18
|
+
super("gem_is_disabled")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class GenericException < Responsys::Exceptions::BaseException
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/responsys/i18n/en.yml
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
en:
|
2
2
|
responsys_api:
|
3
|
+
gem_is_disabled: "The query couldn't be performed because the GEM is disabled."
|
4
|
+
configuration:
|
5
|
+
api_description_not_provided: A WSDL or endpoint+namespace is needed.
|
6
|
+
api_credentials_not_provided: No credentials are provided in the configuration.
|
3
7
|
api:
|
4
8
|
object:
|
5
9
|
field_type:
|
@@ -18,41 +22,6 @@ en:
|
|
18
22
|
empty_event: The event_name or event_id must be specified
|
19
23
|
incorrect_event_object: "custom_event must be a CustomEvent instance"
|
20
24
|
client:
|
21
|
-
available_methods:
|
22
|
-
- wsdl
|
23
|
-
- endpoint
|
24
|
-
- namespace
|
25
|
-
- raise_errors
|
26
|
-
- proxy
|
27
|
-
- headers
|
28
|
-
- open_timeout
|
29
|
-
- read_timeout
|
30
|
-
- ssl_verify_mode
|
31
|
-
- ssl_version
|
32
|
-
- ssl_cert_file
|
33
|
-
- ssl_cert_key_file
|
34
|
-
- ssl_ca_cert_file
|
35
|
-
- ssl_cert_key_password
|
36
|
-
- convert_request_keys_to
|
37
|
-
- soap_header
|
38
|
-
- element_form_default
|
39
|
-
- env_namespace
|
40
|
-
- namespace_identifier
|
41
|
-
- namespaces
|
42
|
-
- encoding
|
43
|
-
- soap_version
|
44
|
-
- basic_auth
|
45
|
-
- digest_auth
|
46
|
-
- wsse_auth
|
47
|
-
- wsse_timestamp
|
48
|
-
- ntlm
|
49
|
-
- strip_namespaces
|
50
|
-
- convert_response_tags_to
|
51
|
-
- logger
|
52
|
-
- log_level
|
53
|
-
- log
|
54
|
-
- filters
|
55
|
-
- pretty_print_xml
|
56
25
|
api_method:
|
57
26
|
wrong_action_login: Please use the dedicated login method
|
58
27
|
wrong_action_logout: Please use the dedicated logout method
|
data/lib/responsys/member.rb
CHANGED
@@ -7,10 +7,9 @@ module Responsys
|
|
7
7
|
include Responsys::Api::Object
|
8
8
|
attr_accessor :email, :user_riid, :client
|
9
9
|
|
10
|
-
def initialize(email, riid = nil
|
10
|
+
def initialize(email, riid = nil)
|
11
11
|
@email = email
|
12
12
|
@user_riid = riid
|
13
|
-
@client = client
|
14
13
|
end
|
15
14
|
|
16
15
|
def add_to_list(list, subscribe = false, details = {}, update_record = false)
|
@@ -29,54 +28,70 @@ module Responsys
|
|
29
28
|
data = data.merge( safe_details )
|
30
29
|
record = RecordData.new([data])
|
31
30
|
|
32
|
-
|
31
|
+
Client.new.run do |client|
|
32
|
+
client.merge_list_members_riid(list, record, ListMergeRule.new(insertOnNoMatch: true, updateOnMatch: (update_record ? 'REPLACE_ALL' : 'NO_UPDATE')))
|
33
|
+
end
|
33
34
|
end
|
34
35
|
|
35
36
|
def retrieve_profile_extension(profile_extension, fields)
|
36
|
-
|
37
|
-
|
37
|
+
Client.new.run do |client|
|
38
|
+
return Responsys::Helper.format_response_with_message("member.riid_missing") if @user_riid.nil?
|
39
|
+
return Responsys::Helper.format_response_with_message("member.record_not_found") unless present_in_profile?(profile_extension, true)
|
38
40
|
|
39
|
-
|
41
|
+
client.retrieve_profile_extension_records(profile_extension, QueryColumn.new("RIID"), fields, [@user_riid])
|
42
|
+
end
|
40
43
|
end
|
41
44
|
|
42
45
|
def subscribe(list)
|
43
|
-
|
46
|
+
Client.new.run do |client|
|
47
|
+
update(list, [{ EMAIL_ADDRESS_: @email, EMAIL_PERMISSION_STATUS_: "I" }])
|
48
|
+
end
|
44
49
|
end
|
45
50
|
|
46
51
|
def unsubscribe(list)
|
47
|
-
|
52
|
+
Client.new.run do |client|
|
53
|
+
update(list, [{ EMAIL_ADDRESS_: @email, EMAIL_PERMISSION_STATUS_: "O" }])
|
54
|
+
end
|
48
55
|
end
|
49
56
|
|
50
57
|
def update(list, data)
|
51
|
-
|
58
|
+
Client.new.run(true) do |client|
|
59
|
+
return Responsys::Helper.format_response_with_message("member.record_not_found") unless present_in_list?(list, true)
|
52
60
|
|
53
|
-
|
54
|
-
|
61
|
+
record = RecordData.new(data)
|
62
|
+
client.merge_list_members(list, record)
|
63
|
+
end
|
55
64
|
end
|
56
65
|
|
57
|
-
def present_in_profile?(list)
|
58
|
-
|
66
|
+
def present_in_profile?(list, raising = false)
|
67
|
+
Client.new.run(raising) do |client|
|
68
|
+
return Responsys::Helper.format_response_with_message("member.riid_missing") if @user_riid.nil?
|
59
69
|
|
60
|
-
|
70
|
+
response = lookup_profile_via_key(list, "RIID", @user_riid)
|
61
71
|
|
62
|
-
|
72
|
+
!(response[:status] == "failure" && response[:error][:code] == "RECORD_NOT_FOUND")
|
73
|
+
end
|
63
74
|
end
|
64
75
|
|
65
|
-
def present_in_list?(list)
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
76
|
+
def present_in_list?(list, raising = false)
|
77
|
+
Client.new.run(raising) do |client|
|
78
|
+
if !@user_riid.nil?
|
79
|
+
response = lookup_list_via_key(list, "RIID", @user_riid)
|
80
|
+
else
|
81
|
+
response = lookup_list_via_key(list, "EMAIL_ADDRESS", @email)
|
82
|
+
end
|
71
83
|
|
72
|
-
|
84
|
+
!(response[:status] == "failure" && response[:error][:code] == "RECORD_NOT_FOUND")
|
85
|
+
end
|
73
86
|
end
|
74
87
|
|
75
|
-
def subscribed?(list)
|
76
|
-
|
88
|
+
def subscribed?(list, raising = false)
|
89
|
+
Client.new.run(raising) do |client|
|
90
|
+
return Responsys::Helper.format_response_with_message("member.record_not_found") unless present_in_list?(list, true)
|
77
91
|
|
78
|
-
|
79
|
-
|
92
|
+
response = client.retrieve_list_members(list, QueryColumn.new("EMAIL_ADDRESS"), %w(EMAIL_PERMISSION_STATUS_), [@email])
|
93
|
+
response[:data][0][:EMAIL_PERMISSION_STATUS_] == "I"
|
94
|
+
end
|
80
95
|
end
|
81
96
|
|
82
97
|
private
|
@@ -102,11 +117,11 @@ module Responsys
|
|
102
117
|
end
|
103
118
|
|
104
119
|
def lookup_profile_via_key(profile_extension, key, value)
|
105
|
-
|
120
|
+
Client.new.run(true) { |client| client.retrieve_profile_extension_records(profile_extension, QueryColumn.new(key), %w(RIID_), [value]) }
|
106
121
|
end
|
107
122
|
|
108
123
|
def lookup_list_via_key(list, key, value)
|
109
|
-
|
124
|
+
Client.new.run(true) { |client| client.retrieve_list_members(list, QueryColumn.new(key), %w(EMAIL_PERMISSION_STATUS_), [value]) }
|
110
125
|
end
|
111
126
|
end
|
112
127
|
end
|