ecircle 0.1.4 → 0.1.5

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.1.4)
4
+ ecircle (0.1.5)
5
5
  activesupport
6
6
  i18n
7
7
  rake
@@ -28,7 +28,7 @@ GEM
28
28
  metaclass (0.0.1)
29
29
  mocha (0.10.0)
30
30
  metaclass (~> 0.0.1)
31
- multi_json (1.0.3)
31
+ multi_json (1.0.4)
32
32
  nokogiri (1.5.0)
33
33
  nori (1.0.2)
34
34
  rack (1.3.5)
data/lib/ecircle/api.rb CHANGED
@@ -18,8 +18,8 @@ module Ecircle
18
18
  # @private
19
19
  def client
20
20
  @client ||= Savon::Client.new do
21
- wsdl.document = Ecircle.configuration.wsdl
22
- wsdl.endpoint = Ecircle.configuration.endpoint
21
+ wsdl.document = Ecircle.configuration.wsdl
22
+ wsdl.endpoint = Ecircle.configuration.endpoint
23
23
  wsdl.namespace = Ecircle.configuration.namespace
24
24
  end
25
25
  end
@@ -32,19 +32,16 @@ module Ecircle
32
32
  # @param [Boolean] send_message send a message by ecircle
33
33
  # @return [WrappedResponse]
34
34
  def create_member user_id, group_id, invite = false, send_message = false
35
- response = client.request :createMember do
36
- soap.body = {
37
- :session => obtain_auth_token,
38
- :userId => user_id,
39
- :groupId => group_id,
40
- :invite => invite.to_s,
41
- :sendMessage => send_message.to_s
42
- }
35
+ body = {
36
+ :userId => user_id,
37
+ :groupId => group_id,
38
+ :invite => invite.to_s,
39
+ :sendMessage => send_message.to_s
40
+ }
41
+
42
+ request(:createMember, body) do |response|
43
+ { :ecircle_id => response.body[:create_member_response][:create_member_return].to_s }
43
44
  end
44
- WrappedResponse.new :success => true,
45
- :ecircle_id => response.body[:create_member_response][:create_member_return].to_s
46
- rescue Savon::SOAP::Fault => e
47
- WrappedResponse.new(e)
48
45
  end
49
46
 
50
47
  # Create or update group
@@ -54,16 +51,13 @@ module Ecircle
54
51
  # @return [WrappedResponse]
55
52
  # Important note: `email` must be unique across all groups AND must be a subdomain of the system you registered at ecircle.
56
53
  def create_or_update_group group_attributes
57
- response = client.request :createOrUpdateGroup do
58
- soap.body = {
59
- :session => obtain_auth_token,
60
- :groupXml => Helper.build_group_xml(group_attributes)
61
- }
54
+ body = {
55
+ :groupXml => Helper.build_group_xml(group_attributes)
56
+ }
57
+
58
+ request(:createOrUpdateGroup, body) do |response|
59
+ { :ecircle_id => response[:create_or_update_group_response][:create_or_update_group_return].to_i }
62
60
  end
63
- WrappedResponse.new :success => true,
64
- :ecircle_id => response[:create_or_update_group_response][:create_or_update_group_return].to_i
65
- rescue Savon::SOAP::Fault => e
66
- WrappedResponse.new(e)
67
61
  end
68
62
 
69
63
  # Create or update user by email
@@ -72,17 +66,14 @@ module Ecircle
72
66
  # @param [Hash] user_xml, in it's most simple form a { :email => 'test@test.com' } is sufficient
73
67
  # @return [Integer] the user id
74
68
  def create_or_update_user_by_email user_attributes
75
- response = client.request :createOrUpdateUserByEmail do
76
- soap.body = {
77
- :session => obtain_auth_token,
78
- :userXml => Helper.build_user_xml(user_attributes),
79
- :sendMessage => 0
80
- }
69
+ body = {
70
+ :userXml => Helper.build_user_xml(user_attributes),
71
+ :sendMessage => 0
72
+ }
73
+
74
+ request(:createOrUpdateUserByEmail, body) do |response|
75
+ { :ecircle_id => response.body[:create_or_update_user_by_email_response][:create_or_update_user_by_email_return].to_i }
81
76
  end
82
- WrappedResponse.new :success => true,
83
- :ecircle_id => response.body[:create_or_update_user_by_email_response][:create_or_update_user_by_email_return].to_i
84
- rescue Savon::SOAP::Fault => e
85
- WrappedResponse.new(e)
86
77
  end
87
78
 
88
79
  # Delete a member.
@@ -90,15 +81,7 @@ module Ecircle
90
81
  # @param [Integer] group_id ecircle group id
91
82
  # @return [WrappedResponse]
92
83
  def delete_group group_id
93
- response = client.request :deleteGroup do
94
- soap.body = {
95
- :session => obtain_auth_token,
96
- :memberId => group_id
97
- }
98
- end
99
- WrappedResponse.new(:success => true)
100
- rescue Savon::SOAP::Fault => e
101
- WrappedResponse.new(e)
84
+ request(:deleteGroup, :memberId => group_id)
102
85
  end
103
86
 
104
87
  # Delete a member.
@@ -106,15 +89,25 @@ module Ecircle
106
89
  # @param [Integer] member_id ecircle member id
107
90
  # @return [WrappedResponse]
108
91
  def delete_member member_id
109
- client.request :deleteMember do
110
- soap.body = {
111
- :session => obtain_auth_token,
112
- :memberId => member_id
113
- }
114
- end
115
- WrappedResponse.new(:success => true)
116
- rescue Savon::SOAP::Fault => e
117
- WrappedResponse.new(e)
92
+ request(:deleteMember, :memberId => member_id)
93
+ end
94
+
95
+ # Send a parametrized single message to user - you need an existing ecircle template ID for this.
96
+ #
97
+ # @param [Integer] user_id ecircle user_id
98
+ # @param [Integer] message_id the ecircle template ID
99
+ # @param [Array] the names of the variables you want to interpolate in the template
100
+ # @param [Array] the values of the variables you want to interpolate in the template
101
+ # @return [WrappedResponse]
102
+ def send_parametrized_single_message_to_user user_id, message_id, names = [], values = []
103
+ body = {
104
+ :singleMessageId => message_id,
105
+ :userId => user_id,
106
+ :names => names,
107
+ :values => values
108
+ }
109
+
110
+ request(:sendParametrizedSingleMessageToUser, body)
118
111
  end
119
112
 
120
113
  # Logon. You don't need to call this explicitly but it's useful for debugging.
@@ -145,32 +138,10 @@ module Ecircle
145
138
  def logout
146
139
  client.request :logout do
147
140
  soap.body = {
148
- :session => auth_token,
149
- }
150
- end
151
- WrappedResponse.new(:success => true)
152
- end
153
-
154
- # Send a parametrized single message to user - you need an existing ecircle template ID for this.
155
- #
156
- # @param [Integer] user_id ecircle user_id
157
- # @param [Integer] message_id the ecircle template ID
158
- # @param [Array] the names of the variables you want to interpolate in the template
159
- # @param [Array] the values of the variables you want to interpolate in the template
160
- # @return [WrappedResponse]
161
- def send_parametrized_single_message_to_user user_id, message_id, names = [], values = []
162
- client.request :sendParametrizedSingleMessageToUser do
163
- soap.body = {
164
- :session => obtain_auth_token,
165
- :singleMessageId => message_id,
166
- :userId => user_id,
167
- :names => names,
168
- :values => values
141
+ :session => auth_token,
169
142
  }
170
143
  end
171
144
  WrappedResponse.new(:success => true)
172
- rescue Savon::SOAP::Fault => e
173
- WrappedResponse.new(e)
174
145
  end
175
146
 
176
147
  def obtain_auth_token
@@ -182,5 +153,19 @@ module Ecircle
182
153
  def auth_token_valid?
183
154
  @auth_token_last_used_at && Time.now - @auth_token_last_used_at < AUTH_TOKEN_TIMEOUT
184
155
  end
156
+
157
+ private
158
+
159
+ def request function_name, body
160
+ body[:session] = obtain_auth_token
161
+ begin
162
+ response = client.request(function_name) { soap.body = body }
163
+ response_hash = block_given? ? yield(response) : {}
164
+ response_hash[:success] = true
165
+ WrappedResponse.new(response_hash)
166
+ rescue Savon::SOAP::Fault => e
167
+ WrappedResponse.new(e)
168
+ end
169
+ end
185
170
  end
186
171
  end
@@ -1,3 +1,3 @@
1
1
  module Ecircle
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end
metadata CHANGED
@@ -1,126 +1,122 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ecircle
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.5
4
5
  prerelease:
5
- version: 0.1.4
6
6
  platform: ruby
7
- authors:
8
- - "Timo R\xC3\xB6\xC3\x9Fner"
7
+ authors:
8
+ - Timo Rößner
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-11-28 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2011-11-29 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: activesupport
17
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &76855100 !ruby/object:Gem::Requirement
18
17
  none: false
19
- requirements:
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
23
22
  type: :runtime
24
23
  prerelease: false
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
24
+ version_requirements: *76855100
25
+ - !ruby/object:Gem::Dependency
27
26
  name: i18n
28
- requirement: &id002 !ruby/object:Gem::Requirement
27
+ requirement: &76854560 !ruby/object:Gem::Requirement
29
28
  none: false
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: "0"
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
34
33
  type: :runtime
35
34
  prerelease: false
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
35
+ version_requirements: *76854560
36
+ - !ruby/object:Gem::Dependency
38
37
  name: rake
39
- requirement: &id003 !ruby/object:Gem::Requirement
38
+ requirement: &76853770 !ruby/object:Gem::Requirement
40
39
  none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- version: "0"
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
45
44
  type: :runtime
46
45
  prerelease: false
47
- version_requirements: *id003
48
- - !ruby/object:Gem::Dependency
46
+ version_requirements: *76853770
47
+ - !ruby/object:Gem::Dependency
49
48
  name: savon
50
- requirement: &id004 !ruby/object:Gem::Requirement
49
+ requirement: &76853010 !ruby/object:Gem::Requirement
51
50
  none: false
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
55
54
  version: 0.9.7
56
55
  type: :runtime
57
56
  prerelease: false
58
- version_requirements: *id004
59
- - !ruby/object:Gem::Dependency
57
+ version_requirements: *76853010
58
+ - !ruby/object:Gem::Dependency
60
59
  name: random_data
61
- requirement: &id005 !ruby/object:Gem::Requirement
60
+ requirement: &76851190 !ruby/object:Gem::Requirement
62
61
  none: false
63
- requirements:
64
- - - "="
65
- - !ruby/object:Gem::Version
62
+ requirements:
63
+ - - =
64
+ - !ruby/object:Gem::Version
66
65
  version: 1.5.2
67
66
  type: :development
68
67
  prerelease: false
69
- version_requirements: *id005
70
- - !ruby/object:Gem::Dependency
68
+ version_requirements: *76851190
69
+ - !ruby/object:Gem::Dependency
71
70
  name: rspec
72
- requirement: &id006 !ruby/object:Gem::Requirement
71
+ requirement: &76850300 !ruby/object:Gem::Requirement
73
72
  none: false
74
- requirements:
75
- - - "="
76
- - !ruby/object:Gem::Version
73
+ requirements:
74
+ - - =
75
+ - !ruby/object:Gem::Version
77
76
  version: 2.6.0
78
77
  type: :development
79
78
  prerelease: false
80
- version_requirements: *id006
81
- - !ruby/object:Gem::Dependency
79
+ version_requirements: *76850300
80
+ - !ruby/object:Gem::Dependency
82
81
  name: savon_spec
83
- requirement: &id007 !ruby/object:Gem::Requirement
82
+ requirement: &76849380 !ruby/object:Gem::Requirement
84
83
  none: false
85
- requirements:
84
+ requirements:
86
85
  - - ~>
87
- - !ruby/object:Gem::Version
86
+ - !ruby/object:Gem::Version
88
87
  version: 0.1.6
89
88
  type: :development
90
89
  prerelease: false
91
- version_requirements: *id007
92
- - !ruby/object:Gem::Dependency
90
+ version_requirements: *76849380
91
+ - !ruby/object:Gem::Dependency
93
92
  name: yard
94
- requirement: &id008 !ruby/object:Gem::Requirement
93
+ requirement: &76848980 !ruby/object:Gem::Requirement
95
94
  none: false
96
- requirements:
97
- - - ">="
98
- - !ruby/object:Gem::Version
99
- version: "0"
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
100
99
  type: :development
101
100
  prerelease: false
102
- version_requirements: *id008
103
- - !ruby/object:Gem::Dependency
101
+ version_requirements: *76848980
102
+ - !ruby/object:Gem::Dependency
104
103
  name: ruby-debug19
105
- requirement: &id009 !ruby/object:Gem::Requirement
104
+ requirement: &76825740 !ruby/object:Gem::Requirement
106
105
  none: false
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: "0"
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
111
110
  type: :development
112
111
  prerelease: false
113
- version_requirements: *id009
112
+ version_requirements: *76825740
114
113
  description: The ecircle gem aims to be a full-fledged client for all ecircle services.
115
- email:
114
+ email:
116
115
  - timo.roessner@googlemail.com
117
116
  executables: []
118
-
119
117
  extensions: []
120
-
121
118
  extra_rdoc_files: []
122
-
123
- files:
119
+ files:
124
120
  - .gitignore
125
121
  - .rspec
126
122
  - .rvmrc
@@ -144,39 +140,35 @@ files:
144
140
  - spec/fixtures/logon/success.xml
145
141
  - spec/job_package_spec.rb
146
142
  - spec/spec_helper.rb
147
- homepage: ""
143
+ homepage: ''
148
144
  licenses: []
149
-
150
145
  post_install_message:
151
146
  rdoc_options: []
152
-
153
- require_paths:
147
+ require_paths:
154
148
  - lib
155
- required_ruby_version: !ruby/object:Gem::Requirement
149
+ required_ruby_version: !ruby/object:Gem::Requirement
156
150
  none: false
157
- requirements:
158
- - - ">="
159
- - !ruby/object:Gem::Version
160
- hash: -815952973
161
- segments:
151
+ requirements:
152
+ - - ! '>='
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ segments:
162
156
  - 0
163
- version: "0"
164
- required_rubygems_version: !ruby/object:Gem::Requirement
157
+ hash: 992601939
158
+ required_rubygems_version: !ruby/object:Gem::Requirement
165
159
  none: false
166
- requirements:
167
- - - ">="
168
- - !ruby/object:Gem::Version
169
- hash: -815952973
170
- segments:
160
+ requirements:
161
+ - - ! '>='
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ segments:
171
165
  - 0
172
- version: "0"
166
+ hash: 992601939
173
167
  requirements: []
174
-
175
168
  rubyforge_project: ecircle
176
- rubygems_version: 1.8.11
169
+ rubygems_version: 1.8.10
177
170
  signing_key:
178
171
  specification_version: 3
179
172
  summary: Ecircle gem
180
173
  test_files: []
181
-
182
174
  has_rdoc: