ecircle 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ecircle (0.0.9)
4
+ ecircle (0.1.0)
5
5
  activesupport
6
6
  i18n
7
7
  rake
data/README.md CHANGED
@@ -20,6 +20,7 @@ Features
20
20
  The following methods are implemented:
21
21
 
22
22
  * createMember
23
+ * createOrUpdateGroup
23
24
  * createOrUpdateUserByEmail
24
25
  * deleteGroup
25
26
  * deleteMember
@@ -38,7 +39,6 @@ To do
38
39
 
39
40
  * Fix TODOs in source code
40
41
  * Implement missing API methods:
41
- * createOrUpdateGroup
42
42
  * deleteUser
43
43
  * deleteUserByEmail
44
44
  * lookupGroups
@@ -76,8 +76,7 @@ Session tokens will be re-used to keep the number of session related traffic to
76
76
  Response
77
77
  -------------
78
78
 
79
- The ecircle gem will always return a wrapped response. Except for when it doesn't because I didn't find the time which is
80
- for create_or_update_user_by_email and logon (see examples below or the API doc).
79
+ The ecircle gem will always return a wrapped response for all API methods, except for the logon method (see examples below or the API doc).
81
80
 
82
81
  The wrapped response object is just a neat abstraction to hide Ecircle's horrible, horrible error handling from you and provides several methods for doing so.
83
82
 
@@ -101,26 +100,33 @@ Examples
101
100
  # Given you have called Ecircle.configure appropriatly...
102
101
 
103
102
  # 1.) Create a user
104
- uid = Ecircle.create_or_update_user_by_email 'your@email.com'
103
+ r = Ecircle.create_or_update_user_by_email 'your@email.com'
104
+ uid = r.ecircle_id
105
105
  puts "Ecircle user ID: #{uid}"
106
106
 
107
- # 2.) Add this user as a member to a group - e.g. for newsletters
108
- response = Ecircle.create_member uid, 'your_group_id'
109
- puts "Ecircle member Id: #{response.ecircle_id}"
107
+ # 2.) Create a group
108
+ r = Ecircle.create_or_update_group :name => 'ecircletestgroup', :description => 'ecircletestgroup', :email => 'email@your.ecircle.domain.de'
109
+ gid = r.ecircle_id
110
+ puts "Ecircle group ID: #{gid}"
110
111
 
111
- # 3.) Delete member from group - e.g. when he unsubscribes
112
+ # 3.) Add this user as a member to a group - e.g. for newsletters
113
+ r = Ecircle.create_member uid, gid
114
+ mid = r.ecircle_id
115
+ puts "Ecircle member Id: #{mid}"
116
+
117
+ # 4.) Delete member from group - e.g. when he unsubscribes
112
118
  Ecircle.delete_member mid
113
119
 
114
- # 4.) Send the user a transactional email:
120
+ # 5.) Send the user a transactional email:
115
121
  Ecircle.send_parametrized_single_message_to_user uid,
116
122
  your_template_id_at_ecircle,
117
123
  [ :name, :message ],
118
124
  [ 'Tom', 'welcome!' ]
119
125
 
120
- # 5.) Delete the group
126
+ # 6.) Delete the group
121
127
  Ecircle.delete_group your_group_id
122
128
 
123
- # 6.) Log out
129
+ # 7.) Log out
124
130
  Ecircle.logout
125
131
 
126
132
 
data/lib/ecircle/api.rb CHANGED
@@ -77,7 +77,7 @@ module Ecircle
77
77
  rescue Savon::SOAP::Fault => e
78
78
  return WrappedResponse.new(e)
79
79
  end
80
- WrappedResponse.new(:success => true, :ecircle_id => @response.body[:create_member_response][:create_member_return].to_s)
80
+ WrappedResponse.new :success => true, :ecircle_id => @response.body[:create_member_response][:create_member_return].to_s
81
81
  end
82
82
  end
83
83
 
@@ -90,16 +90,16 @@ module Ecircle
90
90
  def create_or_update_group group_attributes
91
91
  ensuring_logon do
92
92
  begin
93
- client.request :createOrUpdateGroup do
93
+ @response = client.request :createOrUpdateGroup do
94
94
  soap.body = {
95
95
  :session => auth_token,
96
- 'wsdl:groupXml' => Helper.build_group_xml(group_attributes)
96
+ :groupXml => Helper.build_group_xml(group_attributes)
97
97
  }
98
98
  end
99
99
  rescue Savon::SOAP::Fault => e
100
100
  return WrappedResponse.new(e)
101
101
  end
102
- WrappedResponse.new(:success => true)
102
+ WrappedResponse.new :success => true, :ecircle_id => @response[:create_or_update_group_response][:create_or_update_group_return].to_i
103
103
  end
104
104
  end
105
105
 
@@ -108,18 +108,21 @@ module Ecircle
108
108
  # for an example of the user xml
109
109
  # @param [Hash] user_xml, in it's most simple form a { :email => 'test@test.com' } is sufficient
110
110
  # @return [Integer] the user id
111
- # TODO Error handling is missing.
112
- # TODO Return a wrapped response.
113
111
  def create_or_update_user_by_email user_attributes
114
112
  ensuring_logon do
115
- @response = client.request :createOrUpdateUserByEmail do
116
- soap.body = {
117
- :session => auth_token, # TODO We can't use @auth_token here cause then the session_id is nil. Why?
118
- :userXml => Helper.build_user_xml(user_attributes),
119
- :sendMessage => 0
120
- }
113
+ begin
114
+ @response = client.request :createOrUpdateUserByEmail do
115
+ soap.body = {
116
+ :session => auth_token, # TODO We can't use @auth_token here cause then the session_id is nil. Why?
117
+ :userXml => Helper.build_user_xml(user_attributes),
118
+ :sendMessage => 0
119
+ }
120
+ end
121
+ rescue Savon::SOAP::Fault => e
122
+ return WrappedResponse.new(e)
121
123
  end
122
- @response.body[:create_or_update_user_by_email_response][:create_or_update_user_by_email_return].to_i
124
+ WrappedResponse.new :success => true,
125
+ :ecircle_id => @response.body[:create_or_update_user_by_email_response][:create_or_update_user_by_email_return].to_i
123
126
  end
124
127
  end
125
128
 
@@ -1,3 +1,3 @@
1
1
  module Ecircle
2
- VERSION = '0.0.9'
2
+ VERSION = '0.1.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecircle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-11-17 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &84616970 !ruby/object:Gem::Requirement
16
+ requirement: &75171370 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *84616970
24
+ version_requirements: *75171370
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: i18n
27
- requirement: &84616320 !ruby/object:Gem::Requirement
27
+ requirement: &75170720 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *84616320
35
+ version_requirements: *75170720
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &84615600 !ruby/object:Gem::Requirement
38
+ requirement: &75169990 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *84615600
46
+ version_requirements: *75169990
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: savon
49
- requirement: &84614520 !ruby/object:Gem::Requirement
49
+ requirement: &75169080 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 0.9.7
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *84614520
57
+ version_requirements: *75169080
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rspec
60
- requirement: &84611650 !ruby/object:Gem::Requirement
60
+ requirement: &75166030 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - =
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 2.6.0
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *84611650
68
+ version_requirements: *75166030
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: yard
71
- requirement: &84610850 !ruby/object:Gem::Requirement
71
+ requirement: &75165330 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *84610850
79
+ version_requirements: *75165330
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: ruby-debug19
82
- requirement: &84609900 !ruby/object:Gem::Requirement
82
+ requirement: &75164260 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *84609900
90
+ version_requirements: *75164260
91
91
  description: The ecircle gem aims to be a full-fledged client for all ecircle services.
92
92
  email:
93
93
  - timo.roessner@googlemail.com
@@ -127,7 +127,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
127
127
  version: '0'
128
128
  segments:
129
129
  - 0
130
- hash: 133028911
130
+ hash: 36995713
131
131
  required_rubygems_version: !ruby/object:Gem::Requirement
132
132
  none: false
133
133
  requirements:
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  version: '0'
137
137
  segments:
138
138
  - 0
139
- hash: 133028911
139
+ hash: 36995713
140
140
  requirements: []
141
141
  rubyforge_project: ecircle
142
142
  rubygems_version: 1.8.10