exactly 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,12 +13,15 @@ module Exactly
13
13
  end
14
14
  end
15
15
 
16
- class TriggeredSendFailed < ExactlyError
16
+ class CreateError < ExactlyError
17
17
  def message
18
18
  @response.to_hash[:create_response][:results][:status_message]
19
19
  end
20
20
  end
21
21
 
22
+ class TriggeredSendFailed < CreateError; end
23
+ class UpsertSubscriberFailed < CreateError; end
24
+
22
25
  class Client
23
26
  def initialize(username, password)
24
27
  client.wsse.credentials username, password
@@ -28,6 +31,35 @@ module Exactly
28
31
  @client ||= ::Savon::Client.new("https://webservice.s6.exacttarget.com/etframework.wsdl")
29
32
  end
30
33
 
34
+ def upsert_subscriber(customer_key, email, lists = [])
35
+ response = client.request "CreateRequest", :xmlns => "http://exacttarget.com/wsdl/partnerAPI" do
36
+ http.headers['SOAPAction'] = 'Create'
37
+ body = {
38
+ "Options" => {
39
+ "SaveOptions" => [
40
+ "SaveOption" => {
41
+ "PropertyName" => "*",
42
+ "SaveAction" => "UpdateAdd"
43
+ }
44
+ ]
45
+ },
46
+ "Objects" => {
47
+ "CustomerKey" => customer_key,
48
+ "EmailAddress" => email,
49
+ "Lists" => Array(lists).map{|list_id|
50
+ { "ID" => list_id }
51
+ }
52
+ },
53
+ :attributes! => { "Objects" => { "xsi:type" => "Subscriber" }}
54
+ }
55
+
56
+ soap.body = body
57
+ end
58
+ if response.to_hash[:create_response][:overall_status] != 'OK'
59
+ raise Exactly::UpsertSubscriberFailed.new(response)
60
+ end
61
+ end
62
+
31
63
  def upsert_data_extension(customer_key, properties)
32
64
  response = client.request "UpdateRequest", :xmlns => "http://exacttarget.com/wsdl/partnerAPI" do
33
65
  http.headers['SOAPAction'] = 'Update'
@@ -85,7 +117,7 @@ module Exactly
85
117
  },
86
118
  "Subscribers" => {
87
119
  "EmailAddress" => attributes[:email],
88
- "SubscriberKey" => attributes[:email],
120
+ "SubscriberKey" => attributes[:subscriber_key],
89
121
  "Attributes" => attributes_without_email.map do
90
122
  |k, v| { "Name" => k, "Value" => v }
91
123
  end
@@ -1,3 +1,3 @@
1
1
  module Exactly
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,58 +1,55 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: exactly
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 0
8
- - 4
9
- version: 0.0.4
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.5
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Jacob Atzen
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2012-12-19 00:00:00 +01:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- type: :runtime
22
- version_requirements: &id001 !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- segments:
27
- - 0
28
- - 9
29
- - 5
30
- version: 0.9.5
12
+ date: 2013-07-29 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
31
15
  name: savon
32
- requirement: *id001
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.9.5
22
+ type: :runtime
33
23
  prerelease: false
34
- - !ruby/object:Gem::Dependency
35
- type: :development
36
- version_requirements: &id002 !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- segments:
41
- - 0
42
- version: "0"
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.9.5
30
+ - !ruby/object:Gem::Dependency
43
31
  name: rake
44
- requirement: *id002
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
45
39
  prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
46
  description: ExactTarget SOAP API client
47
- email:
47
+ email:
48
48
  - jacob@incremental.dk
49
49
  executables: []
50
-
51
50
  extensions: []
52
-
53
51
  extra_rdoc_files: []
54
-
55
- files:
52
+ files:
56
53
  - .gitignore
57
54
  - Gemfile
58
55
  - LICENSE
@@ -62,35 +59,28 @@ files:
62
59
  - lib/exactly.rb
63
60
  - lib/exactly/client.rb
64
61
  - lib/exactly/version.rb
65
- has_rdoc: true
66
62
  homepage: http://github.com/lokalebasen/exactly
67
63
  licenses: []
68
-
69
64
  post_install_message:
70
65
  rdoc_options: []
71
-
72
- require_paths:
66
+ require_paths:
73
67
  - lib
74
- required_ruby_version: !ruby/object:Gem::Requirement
75
- requirements:
76
- - - ">="
77
- - !ruby/object:Gem::Version
78
- segments:
79
- - 0
80
- version: "0"
81
- required_rubygems_version: !ruby/object:Gem::Requirement
82
- requirements:
83
- - - ">="
84
- - !ruby/object:Gem::Version
85
- segments:
86
- - 0
87
- version: "0"
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ! '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
88
80
  requirements: []
89
-
90
81
  rubyforge_project:
91
- rubygems_version: 1.3.6
82
+ rubygems_version: 1.8.23
92
83
  signing_key:
93
84
  specification_version: 3
94
85
  summary: Making it easier to interact with ExactTargets SOAP API
95
86
  test_files: []
96
-