responsys-api 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjJjY2JmYjg3NDBmZmQ4NDBhMGM0ZWNiNDIxYzBlZjdmODQzYmQ5YQ==
4
+ OTNjZTgyNjk2Zjk4OTgyY2E5MzYwMTgwZDk1MjUzZWE3ZDNiYzI1Yg==
5
5
  data.tar.gz: !binary |-
6
- OGIyMTU3ZmY5Mzg3NmIwYmJlMWFhZmViMGNhYWUxMWM5NGQ3MzMwMg==
6
+ ZjZmMDFhMThmYmE3N2NkOTM2YjAyNzA0MDEwMDUyZjEwOWE3ZGI1Mg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YjNiZjc5OTAwYjMwMWI2YzZjZjBkYTQyOGI0N2E4YTc5NjgzYjA4MDc5NGVj
10
- YmFjMmIzYTQwYjQxMTIyNWQxY2NhZjNhZWJjMzY2NzcyZWE5MjcwMmM1ODll
11
- ZmM1N2Q4MjJlZmZhMTdjMzAyMTA2Mjc0MjZhZWEzNTdiMmE0Nzk=
9
+ ZGI2ZGQxNDAxM2QyMmY4ZjJhNTIyNmMyZjhkY2MwMWMyNGU0NDgyNTY2MWMz
10
+ MGVlNWQ4NDg0NWQ0N2M1M2FhODg1MjI3M2JjMjI3MjNjODU3M2E3YjJhODVi
11
+ MzkzZjQwZDk5OWY5NTI2MzgzMzZhNDQwYjdkNmM2MjIzZGE3N2M=
12
12
  data.tar.gz: !binary |-
13
- N2YwNmFhY2RkZTNkZDdmZjA1N2E4ZjJhMDc3NTcxODk3ZmEwNDlmYjU0MDQ2
14
- NzU4OTdlMTgxODcwMzMyYjIzYzQ1OTc5NjRlOWIyM2E2MGRjMTIzYTM4MDgy
15
- OGFjNzMwNmUwZDNhM2JiZTExMmQzZmZmMDg1ZTIzZDc1Mjc5MzM=
13
+ OTAwYjkyMjEzYTk5ODkzYmU1YmQ5MDVlY2MwMWE3ZmQxNzBiZTkxOThhYWVh
14
+ NWQ1N2E1MDcxMTdhMTBkMWM1Mzc0YjRhYmQ3MzZiYzEwNzFmMzY1N2VkNDRh
15
+ NTc5MzljZjY2ZDMyYmFlNTk2ODE0OGVmZGI2ZTgwMGVlOGY1YmI=
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # ResponsysApi
2
2
 
3
- A gem to help you communicate to the Responsys Interact SOAP API.
3
+ A gem to help you communicate to the Responsys Interact SOAP API. Currently supporting version 6.20.
4
4
 
5
5
  ## Documentation
6
6
 
@@ -83,6 +83,20 @@ The API client used by the gem logs in as soon as a the first method is called.
83
83
  Responsys::Api::Client.instance.logout
84
84
  ```
85
85
 
86
+ ###Notes
87
+
88
+ ####Invalid email format
89
+ If you try to call the API on a user that has an invalid email format, the API and the GEM will then reply with this message :
90
+ ```
91
+ {
92
+ :status=>"ok",
93
+ :result=>{
94
+ :recipient_id=>"-1",
95
+ :error_message=>"Record 0 = BAD EMAIL FORMAT"
96
+ }
97
+ }
98
+ ```
99
+
86
100
  ## Contributing
87
101
 
88
102
  1. Fork it
@@ -4,12 +4,12 @@ module Responsys
4
4
  module Api
5
5
  module Campaign
6
6
  include Responsys::Exceptions
7
-
7
+
8
8
  def trigger_message(campaign, recipients)
9
9
  raise ParameterException, I18n.t("api.campaign.incorrect_recipients_type") unless recipients.is_a? Array
10
10
  message = {
11
11
  campaign: campaign.to_api,
12
- recipientData: recipients.map(&:to_api)
12
+ recipientData: recipients.map(&:to_api)
13
13
  }
14
14
  api_method(:trigger_campaign_message, message)
15
15
  end
@@ -23,4 +23,4 @@ module Responsys
23
23
  end
24
24
  end
25
25
  end
26
- end
26
+ end
@@ -20,4 +20,4 @@ module Responsys
20
20
  end
21
21
  end
22
22
  end
23
- end
23
+ end
@@ -4,7 +4,7 @@ module Responsys
4
4
  class RecipientData
5
5
  attr_accessor :recipient, :optional_data
6
6
 
7
- def initialize(recipient, optional_data = Responsys::Api::Object::OptionalData.new)
7
+ def initialize(recipient, optional_data = [Responsys::Api::Object::OptionalData.new])
8
8
  @recipient = recipient
9
9
  @optional_data = optional_data
10
10
  end
@@ -12,7 +12,7 @@ module Responsys
12
12
  def to_api
13
13
  {
14
14
  recipient: @recipient.to_api,
15
- optionalData: @optional_data.to_api
15
+ optionalData: @optional_data.map(&:to_api)
16
16
  }
17
17
  end
18
18
  end
@@ -13,11 +13,23 @@ module Responsys
13
13
  @client = Client.instance
14
14
  end
15
15
 
16
- def add_to_list(list, subscribe = false)
16
+ def add_to_list(list, subscribe = false, details = {}, update_record = false)
17
17
  data = { EMAIL_ADDRESS_: @email, EMAIL_PERMISSION_STATUS_: subscribe ? "I" : "O" }
18
+
19
+ safe_details = {}
20
+ details.each do |k,v|
21
+ next if reserved_fields.include? r_key(k)
22
+ if [Time, Date, DateTime].include?(v.class)
23
+ safe_details[r_key(k)] = details[k].strftime('%Y-%m-%dT%H:%M:%S%z')
24
+ else
25
+ safe_details[r_key(k)] = details[k]
26
+ end
27
+ end
28
+
29
+ data = data.merge( safe_details )
18
30
  record = RecordData.new([data])
19
31
 
20
- @client.merge_list_members_riid(list, record, ListMergeRule.new(insertOnNoMatch: true, updateOnMatch: "NO_UPDATE"))
32
+ @client.merge_list_members_riid(list, record, ListMergeRule.new(insertOnNoMatch: true, updateOnMatch: ( update_record ? 'REPLACE_ALL' : 'NO_UPDATE' )))
21
33
  end
22
34
 
23
35
  def retrieve_profile_extension(profile_extension, fields)
@@ -69,6 +81,26 @@ module Responsys
69
81
 
70
82
  private
71
83
 
84
+ def r_key(k)
85
+ k.to_s.upcase.to_sym
86
+ end
87
+
88
+ def reserved_fields
89
+ # There are also the MOBILE and POSTAL fields. We should allow those to be set via this method
90
+ [
91
+ :RIID_,
92
+ :CREATED_SOURCE_IP_,
93
+ :CUSTOMER_ID_,
94
+ :EMAIL_ADDRESS_,
95
+ :EMAIL_DOMAIN_,
96
+ :EMAIL_ISP_,
97
+ :EMAIL_FORMAT_,
98
+ :EMAIL_PERMISSION_STATUS_,
99
+ :EMAIL_DELIVERABILITY_STATUS_,
100
+ :EMAIL_PERMISSION_REASON_,
101
+ ]
102
+ end
103
+
72
104
  def lookup_profile_via_key(profile_extension, key, value)
73
105
  @client.retrieve_profile_extension_records(profile_extension, QueryColumn.new(key), %w(RIID_), [value])
74
106
  end
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "responsys-api"
7
- spec.version = "0.0.4"
7
+ spec.version = "0.0.5"
8
8
  spec.authors = ["Dan DeMeyere", "Florian Lorrain", "Morgan Griggs", "Mike Rocco"]
9
9
  spec.email = ["dan@thredup.com", "florian.lorrain@thredup.com", "morgan@thredup.com", "michael.rocco@thredup.com"]
10
10
  spec.description = "A gem to integrate with the Responsys SOAP API"
@@ -16,7 +16,7 @@ describe Responsys::Api::Object::RecipientData do
16
16
  end
17
17
 
18
18
  it "should have an optional_data attribute of type Array" do
19
- expect(@recipient_data.optional_data).to be_a(Responsys::Api::Object::OptionalData)
19
+ expect(@recipient_data.optional_data).to include(Responsys::Api::Object::OptionalData)
20
20
  end
21
21
  end
22
22
 
@@ -37,7 +37,7 @@ describe Responsys::Api::Object::RecipientData do
37
37
  end
38
38
 
39
39
  it "should have an optionalData attribute of type Array" do
40
- expect(@recipient_data.to_api[:optionalData]).to be_a(Hash)
40
+ expect(@recipient_data.to_api[:optionalData]).to be_a(Array)
41
41
  end
42
42
  end
43
- end
43
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: responsys-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan DeMeyere
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-09-02 00:00:00.000000000 Z
14
+ date: 2014-09-19 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rubyntlm