MissionHub 1.0rc2 → 1.0rc3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -5,7 +5,7 @@ Consume the MissionHub API easily with this Ruby Gem
5
5
 
6
6
  Add this line to your application's Gemfile:
7
7
 
8
- gem 'missionhub'
8
+ gem 'MissionHub'
9
9
 
10
10
  And then execute:
11
11
 
@@ -13,7 +13,7 @@ And then execute:
13
13
 
14
14
  Or install it yourself as:
15
15
 
16
- $ gem install missionhub
16
+ $ gem install MissionHub
17
17
 
18
18
  ## Usage
19
19
 
@@ -5,7 +5,7 @@ http_interactions:
5
5
  uri: http://www.missionhub.com/oauth/access_token
6
6
  body:
7
7
  encoding: US-ASCII
8
- string: grant_type=none&client_id=6&client_secret=05fbcedcf2b2ea3958b359b51796b14b1c04c19a
8
+ string: grant_type=none&client_id=12&client_secret=83f84763001c1fb4ce96adc4908b9ba285b510d6
9
9
  headers: {}
10
10
  response:
11
11
  status:
@@ -15,7 +15,7 @@ http_interactions:
15
15
  Server:
16
16
  - nginx/1.0.14
17
17
  Date:
18
- - Tue, 02 Oct 2012 22:34:39 GMT
18
+ - Wed, 03 Oct 2012 22:39:16 GMT
19
19
  Content-Type:
20
20
  - application/json
21
21
  Transfer-Encoding:
@@ -31,156 +31,18 @@ http_interactions:
31
31
  X-Ua-Compatible:
32
32
  - IE=Edge,chrome=1
33
33
  Etag:
34
- - ! '"5433947c658216a0f750764a263167da"'
35
- X-Request-Id:
36
- - f7c1b81b77d8afd6dc0599de0598cb2a
37
- X-Runtime:
38
- - '0.201593'
39
- X-Rack-Cache:
40
- - invalidate, pass
41
- body:
42
- encoding: US-ASCII
43
- string: ! '{"access_token":"11b341eeb9b9d6401944e8310ea82283e3927b1b3a8b77335d0992373b047deb","scope":"contacts,userinfo,contact_assignment,followup_comments,roles,organization_info"}'
44
- http_version:
45
- recorded_at: Tue, 02 Oct 2012 22:33:28 GMT
46
- - request:
47
- method: post
48
- uri: http://www.missionhub.com/oauth/access_token
49
- body:
50
- encoding: US-ASCII
51
- string: grant_type=none&client_id=6&client_secret=
52
- headers: {}
53
- response:
54
- status:
55
- code: 400
56
- message: Bad Request
57
- headers:
58
- Server:
59
- - nginx/1.0.14
60
- Date:
61
- - Tue, 02 Oct 2012 22:34:39 GMT
62
- Content-Type:
63
- - application/json
64
- Transfer-Encoding:
65
- - chunked
66
- Connection:
67
- - keep-alive
68
- Status:
69
- - '400'
70
- X-Powered-By:
71
- - Phusion Passenger (mod_rails/mod_rack) 3.0.15
72
- Cache-Control:
73
- - no-store
74
- X-Ua-Compatible:
75
- - IE=Edge,chrome=1
76
- X-Request-Id:
77
- - 830a7ef7ae292f2be4ff646ca5750f5d
78
- X-Runtime:
79
- - '0.031778'
80
- X-Rack-Cache:
81
- - invalidate, pass
82
- body:
83
- encoding: US-ASCII
84
- string: ! '{"error":"invalid_client","error_description":"{\"error\": {\"message\":\"Client
85
- ID and client secret do not match.\", \"code\": \"52\"}}"}'
86
- http_version:
87
- recorded_at: Tue, 02 Oct 2012 22:33:29 GMT
88
- - request:
89
- method: post
90
- uri: http://www.missionhub.com/api/v2/contacts.json
91
- body:
92
- encoding: US-ASCII
93
- string: person[firstName]=Test&person[lastName]=User&person[email_address]=mail%40google.com&person[gender]=female&person[current_address_attributes][address1]=123%20Somewhere%20St&person[current_address_attributes][address2]=Dept%202500&person[current_address_attributes][city]=Orlando&person[current_address_attributes][country]=US&person[current_address_attributes][state]=FL&person[current_address_attributes][zip]=32832&answers[4952]=Hello%20World&org_id=6774&user_id=1615180&access_token=11b341eeb9b9d6401944e8310ea82283e3927b1b3a8b77335d0992373b047deb
94
- headers: {}
95
- response:
96
- status:
97
- code: 200
98
- message: OK
99
- headers:
100
- Server:
101
- - nginx/1.0.14
102
- Date:
103
- - Tue, 02 Oct 2012 22:34:41 GMT
104
- Content-Type:
105
- - application/json; charset=utf-8
106
- Transfer-Encoding:
107
- - chunked
108
- Connection:
109
- - keep-alive
110
- Status:
111
- - '200'
112
- X-Powered-By:
113
- - Phusion Passenger (mod_rails/mod_rack) 3.0.15
114
- X-Ua-Compatible:
115
- - IE=Edge,chrome=1
116
- Etag:
117
- - ! '"8f0ddbec1e2c4a3ee368d905e342a557"'
118
- Cache-Control:
119
- - max-age=0, private, must-revalidate
120
- Set-Cookie:
121
- - _mh_session=0df192db43584bcb75bb8c65cef20f08; path=/; expires=Thu, 04-Oct-2012
122
- 22:34:39 GMT; HttpOnly
123
- - logged_in=true; path=/
124
- X-Request-Id:
125
- - 75864fbaa173037b73666f912dd09707
126
- X-Runtime:
127
- - '0.478109'
128
- X-Rack-Cache:
129
- - invalidate, pass
130
- body:
131
- encoding: US-ASCII
132
- string: ! '{"id":2592529,"name":"Test User","assignment":{"assigned_to_person":[],"person_assigned_to":[]},"gender":"female","status":"uncontacted","request_org_id":6774,"first_contact_date":"2012-10-02
133
- 22:34:38 UTC","date_surveyed":"2012-10-02 22:34:38 UTC","organizational_roles":[]}'
134
- http_version:
135
- recorded_at: Tue, 02 Oct 2012 22:33:30 GMT
136
- - request:
137
- method: post
138
- uri: http://www.missionhub.com/api/v2/contacts.json
139
- body:
140
- encoding: US-ASCII
141
- string: person[firstName]=Test&person[lastName]=User&person[email_address]=mail%40google.com&person[gender]=female&person[current_address_attributes][address1]=123%20Somewhere%20St&person[current_address_attributes][address2]=Dept%202500&person[current_address_attributes][city]=Orlando&person[current_address_attributes][country]=US&person[current_address_attributes][state]=FL&person[current_address_attributes][zip]=32832&answers[4952]=Hello%20World&answers[4953]=R2&answers[4955]=D2&answers[4954][2]=C3&answers[4954][3]=C4&org_id=6774&user_id=1615180&access_token=11b341eeb9b9d6401944e8310ea82283e3927b1b3a8b77335d0992373b047deb
142
- headers: {}
143
- response:
144
- status:
145
- code: 200
146
- message: OK
147
- headers:
148
- Server:
149
- - nginx/1.0.14
150
- Date:
151
- - Tue, 02 Oct 2012 22:38:59 GMT
152
- Content-Type:
153
- - application/json; charset=utf-8
154
- Transfer-Encoding:
155
- - chunked
156
- Connection:
157
- - keep-alive
158
- Status:
159
- - '200'
160
- X-Powered-By:
161
- - Phusion Passenger (mod_rails/mod_rack) 3.0.15
162
- X-Ua-Compatible:
163
- - IE=Edge,chrome=1
164
- Etag:
165
- - ! '"6fb7f46d4c45fe2d3382eaaf2a12bbcf"'
166
- Cache-Control:
167
- - max-age=0, private, must-revalidate
168
- Set-Cookie:
169
- - _mh_session=eaf0f05cdb6efc004b0a1d1860a2032a; path=/; expires=Thu, 04-Oct-2012
170
- 22:38:14 GMT; HttpOnly
171
- - logged_in=true; path=/
34
+ - ! '"d0d53d93eea872825c2d3ddf4602b136"'
172
35
  X-Request-Id:
173
- - c2c3b8a9648d3bbf1e204e0c38a336a4
36
+ - 349184278b44962580048593d664a0cc
174
37
  X-Runtime:
175
- - '0.901663'
38
+ - '0.021574'
176
39
  X-Rack-Cache:
177
40
  - invalidate, pass
178
41
  body:
179
42
  encoding: US-ASCII
180
- string: ! '{"id":2592532,"name":"Test User","assignment":{"assigned_to_person":[],"person_assigned_to":[]},"gender":"female","status":"uncontacted","request_org_id":6774,"first_contact_date":"2012-10-02
181
- 22:38:14 UTC","date_surveyed":"2012-10-02 22:38:14 UTC","organizational_roles":[]}'
182
- http_version:
183
- recorded_at: Tue, 02 Oct 2012 22:37:48 GMT
43
+ string: ! '{"access_token":"b08f825c2543643e561ba92b296028c4de2887a17179269c311ba680a96574d6","scope":"contacts,userinfo,contact_assignment,followup_comments,roles,organization_info"}'
44
+ http_version:
45
+ recorded_at: Wed, 03 Oct 2012 22:38:06 GMT
184
46
  - request:
185
47
  method: post
186
48
  uri: http://www.missionhub.com/oauth/access_token
@@ -196,7 +58,7 @@ http_interactions:
196
58
  Server:
197
59
  - nginx/1.0.14
198
60
  Date:
199
- - Tue, 02 Oct 2012 23:12:32 GMT
61
+ - Wed, 03 Oct 2012 22:39:17 GMT
200
62
  Content-Type:
201
63
  - application/json
202
64
  Transfer-Encoding:
@@ -212,66 +74,23 @@ http_interactions:
212
74
  X-Ua-Compatible:
213
75
  - IE=Edge,chrome=1
214
76
  X-Request-Id:
215
- - 91024aeaccf492cc12391d87befaa36b
77
+ - bc57010e2ca62e9c3ac610e8fd5f7444
216
78
  X-Runtime:
217
- - '0.004484'
79
+ - '0.052999'
218
80
  X-Rack-Cache:
219
81
  - invalidate, pass
220
82
  body:
221
83
  encoding: US-ASCII
222
84
  string: ! '{"error":"invalid_client","error_description":"{\"error\": {\"message\":\"Client
223
85
  ID and client secret do not match.\", \"code\": \"52\"}}"}'
224
- http_version:
225
- recorded_at: Tue, 02 Oct 2012 23:11:21 GMT
226
- - request:
227
- method: post
228
- uri: http://www.missionhub.com/oauth/access_token
229
- body:
230
- encoding: US-ASCII
231
- string: grant_type=none&client_id=12&client_secret=83f84763001c1fb4ce96adc4908b9ba285b510d6
232
- headers: {}
233
- response:
234
- status:
235
- code: 200
236
- message: OK
237
- headers:
238
- Server:
239
- - nginx/1.0.14
240
- Date:
241
- - Tue, 02 Oct 2012 23:12:32 GMT
242
- Content-Type:
243
- - application/json
244
- Transfer-Encoding:
245
- - chunked
246
- Connection:
247
- - keep-alive
248
- Status:
249
- - '200'
250
- X-Powered-By:
251
- - Phusion Passenger (mod_rails/mod_rack) 3.0.15
252
- Cache-Control:
253
- - no-store
254
- X-Ua-Compatible:
255
- - IE=Edge,chrome=1
256
- Etag:
257
- - ! '"8e7d0338744d5a62ee5c240f3f2ebb30"'
258
- X-Request-Id:
259
- - 399d5091e15a9b4621d55060d10b3f58
260
- X-Runtime:
261
- - '0.012341'
262
- X-Rack-Cache:
263
- - invalidate, pass
264
- body:
265
- encoding: US-ASCII
266
- string: ! '{"access_token":"03a6f575b13657a0dad1b6ff07a099d9088fed26617758dd374b0c985a502a79","scope":"contacts,userinfo,contact_assignment,followup_comments,roles,organization_info"}'
267
- http_version:
268
- recorded_at: Tue, 02 Oct 2012 23:11:22 GMT
86
+ http_version:
87
+ recorded_at: Wed, 03 Oct 2012 22:38:07 GMT
269
88
  - request:
270
89
  method: post
271
90
  uri: http://www.missionhub.com/api/v2/contacts.json
272
91
  body:
273
92
  encoding: US-ASCII
274
- string: person[firstName]=Test&person[lastName]=User&person[email_address]=mail%40google.com&person[gender]=female&person[current_address_attributes][address1]=123%20Somewhere%20St&person[current_address_attributes][address2]=Dept%202500&person[current_address_attributes][city]=Orlando&person[current_address_attributes][country]=US&person[current_address_attributes][state]=FL&person[current_address_attributes][zip]=32832&answers[4952]=Hello%20World&answers[4953]=R2&answers[4955]=D2&answers[4954][2]=C3&answers[4954][3]=C4&org_id=5522&user_id=1615180&access_token=03a6f575b13657a0dad1b6ff07a099d9088fed26617758dd374b0c985a502a79
93
+ string: person[firstName]=Test&person[lastName]=User&person[gender]=female&person[current_address_attributes][address1]=123%20Somewhere%20St&person[current_address_attributes][address2]=Dept%202500&person[current_address_attributes][city]=Orlando&person[current_address_attributes][country]=US&person[current_address_attributes][state]=FL&person[current_address_attributes][zip]=32832&person[email_address][email]=mail%40google.com&person[email_address][primary]=0&person[phone_number][number]=021021021&person[phone_number][primary]=0&person[phone_number][location]=mobile&answers[4952]=Hello%20World&answers[4953]=R2&answers[4955]=D2&answers[4954][2]=C3&answers[4954][3]=C4&org_id=5522&user_id=1615180&access_token=b08f825c2543643e561ba92b296028c4de2887a17179269c311ba680a96574d6
275
94
  headers: {}
276
95
  response:
277
96
  status:
@@ -281,7 +100,7 @@ http_interactions:
281
100
  Server:
282
101
  - nginx/1.0.14
283
102
  Date:
284
- - Tue, 02 Oct 2012 23:12:50 GMT
103
+ - Wed, 03 Oct 2012 22:39:18 GMT
285
104
  Content-Type:
286
105
  - application/json; charset=utf-8
287
106
  Transfer-Encoding:
@@ -295,22 +114,22 @@ http_interactions:
295
114
  X-Ua-Compatible:
296
115
  - IE=Edge,chrome=1
297
116
  Etag:
298
- - ! '"fa696d44203f05b4311fbf064e85e2d0"'
117
+ - ! '"3dcdd09d5cbaecb64214082017b4217f"'
299
118
  Cache-Control:
300
119
  - max-age=0, private, must-revalidate
301
120
  Set-Cookie:
302
- - _mh_session=76da570805214bd26bb6301dac676ad5; path=/; expires=Thu, 04-Oct-2012
303
- 23:12:05 GMT; HttpOnly
121
+ - _mh_session=442712f2622c96725ffa979ebf420216; path=/; expires=Fri, 05-Oct-2012
122
+ 22:39:16 GMT; HttpOnly
123
+ - logged_in=true; path=/
304
124
  X-Request-Id:
305
- - 2fecf45d93bc215c4e407a6c5cfa8ad0
125
+ - fc4796e6abe7872a110570a706b0bf12
306
126
  X-Runtime:
307
- - '5.431635'
127
+ - '0.158785'
308
128
  X-Rack-Cache:
309
129
  - invalidate, pass
310
130
  body:
311
131
  encoding: US-ASCII
312
- string: ! '{"meta":{"request_time":1349219525},"error":"undefined method `user''
313
- for nil:NilClass"}'
314
- http_version:
315
- recorded_at: Tue, 02 Oct 2012 23:11:39 GMT
132
+ string: ! '{"id":2592834,"name":"Test User","assignment":{"assigned_to_person":[],"person_assigned_to":[]},"gender":"female","request_org_id":5522,"organizational_roles":[]}'
133
+ http_version:
134
+ recorded_at: Wed, 03 Oct 2012 22:38:08 GMT
316
135
  recorded_with: VCR 2.2.5
@@ -33,7 +33,11 @@ module MissionHub
33
33
  person_hash.delete("answers")
34
34
  options = {:body => { :person => person_hash, :answers => person.answers, :org_id => MissionHub.org_id, :user_id => 1615180, :access_token => @access_token} }
35
35
  response = self.class.post('/api/v2/contacts.json', options)
36
- response["id"].to_i
36
+ if !response.parsed_response['error'].nil?
37
+ raise response.parsed_response['error']
38
+ else
39
+ response.parsed_response['id'].to_i
40
+ end
37
41
  end
38
42
  end
39
43
  end
@@ -2,7 +2,7 @@ require 'resolv'
2
2
 
3
3
  module MissionHub
4
4
  class Person
5
- attr_accessor :current_address_attributes, :phone_number, :email_address, :gender, :firstName, :lastName, :answers
5
+ attr_accessor :current_address_attributes, :phone_number, :email_address, :gender, :firstName, :lastName, :answers, :phone_number
6
6
 
7
7
  #align variable naming with MissionHub API
8
8
  alias :first_name= :firstName=
@@ -11,8 +11,16 @@ module MissionHub
11
11
  alias :last_name= :lastName=
12
12
  alias :last_name :lastName
13
13
 
14
+ alias :phone= :phone_number=
15
+ alias :phone :phone_number
16
+
14
17
  alias :address :current_address_attributes
15
18
 
19
+ def phone=(phone)
20
+ raise "Phone must be a MissionHub::Person::Phone" unless phone.kind_of? MissionHub::Person::Phone
21
+ @phone_number = phone
22
+ end
23
+
16
24
  def address=(address)
17
25
  raise "Address must be a MissionHub::Person::Address" unless address.kind_of? MissionHub::Person::Address
18
26
  @current_address_attributes = address
@@ -43,13 +51,17 @@ module MissionHub
43
51
  @current_address_attributes = address
44
52
  end
45
53
 
54
+ def email_address
55
+ @email_address[:email]
56
+ end
57
+
46
58
  def email_address=(email)
47
59
  unless email.empty?
48
60
  unless email =~ /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/
49
61
  raise "Email does not appear to be valid format"
50
62
  else
51
63
  raise "Email domain name appears to be incorrect" unless validate_email_domain(email)
52
- @email_address = email
64
+ @email_address = {:email => email, :primary => 0}
53
65
  end
54
66
  else
55
67
  raise "Email appears to be empty"
@@ -81,10 +93,10 @@ module MissionHub
81
93
  self.instance_variables.each do |var|
82
94
  temp = self.instance_variable_get(var)
83
95
  if not temp.nil? and var.to_s != "@mx"
84
- if not temp.kind_of? MissionHub::Person::Address
85
- hash_to_return[var.to_s.gsub("@","")] = temp
86
- else
96
+ if temp.kind_of? MissionHub::Person::Address or temp.kind_of? MissionHub::Person::Phone
87
97
  hash_to_return[var.to_s.gsub("@","")] = temp.hash
98
+ else
99
+ hash_to_return[var.to_s.gsub("@","")] = temp
88
100
  end
89
101
  end
90
102
  end
@@ -1,3 +1,3 @@
1
1
  module MissionHub
2
- VERSION = "1.0rc2"
2
+ VERSION = "1.0rc3"
3
3
  end
@@ -83,6 +83,11 @@ describe MissionHub::API do
83
83
  person.set_answer(4955, "D2")
84
84
  hash_answer = {"2" => "C3", "3" => "C4"}
85
85
  person.set_answer(4954, hash_answer)
86
+ phone = MissionHub::Person::Phone.new
87
+ phone.number = "021021021"
88
+ phone.primary = 0
89
+ phone.location = "mobile"
90
+ person.phone = phone
86
91
  response = api.create_person(person)
87
92
  response.must_be_instance_of Fixnum
88
93
  end
@@ -16,6 +16,19 @@ describe MissionHub::Person do
16
16
  end
17
17
  end
18
18
 
19
+ describe "Set Phone" do
20
+ it "must throw exception when phone is wrong type" do
21
+ phone_error = lambda { person.phone = '' }
22
+ phone_error.must_raise RuntimeError
23
+ end
24
+
25
+ it "must be able to set phone" do
26
+ phone = MissionHub::Person::Phone.new
27
+ person.phone = phone
28
+ person.phone.must_equal phone
29
+ end
30
+ end
31
+
19
32
  describe "Set Email" do
20
33
  it "must throw exception when email is empty" do
21
34
  email_error = lambda { person.email_address = '' }
data/spec/spec_helper.rb CHANGED
@@ -16,7 +16,6 @@ Turn.config do |c|
16
16
  end
17
17
 
18
18
  MissionHub.config do |c|
19
- # :outline - turn's original case/test outline mode [default]
20
19
  c.base_uri = 'http://www.missionhub.com/'
21
20
  c.client_id = 12
22
21
  c.client_secret = '83f84763001c1fb4ce96adc4908b9ba285b510d6'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: MissionHub
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0rc2
4
+ version: 1.0rc3
5
5
  prerelease: 3
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-02 00:00:00.000000000 Z
12
+ date: 2012-10-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest