MissionHub 1.0.1 → 2.0.0
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/.gitignore +1 -0
- data/Gemfile +3 -0
- data/fixtures/vcr_cassettes/auth.yml +25 -52
- data/lib/missionhub.rb +10 -7
- data/lib/missionhub/base.rb +40 -0
- data/lib/missionhub/email_address.rb +5 -0
- data/lib/missionhub/followup_comment.rb +5 -0
- data/lib/missionhub/organization.rb +5 -0
- data/lib/missionhub/organizational_role.rb +5 -0
- data/lib/missionhub/person.rb +1 -123
- data/lib/missionhub/phone_number.rb +5 -0
- data/lib/missionhub/question.rb +5 -0
- data/lib/missionhub/rejoicable.rb +5 -0
- data/lib/missionhub/role.rb +5 -0
- data/lib/missionhub/sms_keyword.rb +5 -0
- data/lib/missionhub/survey.rb +5 -0
- data/lib/missionhub/version.rb +1 -1
- data/missionhub.gemspec +3 -3
- data/spec/lib/missionhub_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -2
- metadata +13 -37
- data/lib/console.rb +0 -25
- data/lib/missionhub/address.rb +0 -15
- data/lib/missionhub/api.rb +0 -43
data/.gitignore
CHANGED
data/Gemfile
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
http_interactions:
|
|
3
3
|
- request:
|
|
4
4
|
method: post
|
|
5
|
-
uri: http://
|
|
5
|
+
uri: http://stage.missionhub.com/oauth/access_token
|
|
6
6
|
body:
|
|
7
7
|
encoding: US-ASCII
|
|
8
8
|
string: grant_type=none&client_id=12&client_secret=
|
|
@@ -15,7 +15,7 @@ http_interactions:
|
|
|
15
15
|
Server:
|
|
16
16
|
- nginx/1.0.14
|
|
17
17
|
Date:
|
|
18
|
-
-
|
|
18
|
+
- Thu, 08 Nov 2012 13:49:26 GMT
|
|
19
19
|
Content-Type:
|
|
20
20
|
- application/json
|
|
21
21
|
Transfer-Encoding:
|
|
@@ -31,9 +31,9 @@ http_interactions:
|
|
|
31
31
|
X-Ua-Compatible:
|
|
32
32
|
- IE=Edge,chrome=1
|
|
33
33
|
X-Request-Id:
|
|
34
|
-
-
|
|
34
|
+
- 19536bac31ccee8569a1bdae781b7648
|
|
35
35
|
X-Runtime:
|
|
36
|
-
- '0.
|
|
36
|
+
- '0.123355'
|
|
37
37
|
X-Rack-Cache:
|
|
38
38
|
- invalidate, pass
|
|
39
39
|
body:
|
|
@@ -41,13 +41,13 @@ http_interactions:
|
|
|
41
41
|
string: ! '{"error":"invalid_client","error_description":"{\"error\": {\"message\":\"Client
|
|
42
42
|
ID and client secret do not match.\", \"code\": \"52\"}}"}'
|
|
43
43
|
http_version:
|
|
44
|
-
recorded_at:
|
|
44
|
+
recorded_at: Thu, 08 Nov 2012 13:47:09 GMT
|
|
45
45
|
- request:
|
|
46
46
|
method: post
|
|
47
|
-
uri: http://
|
|
47
|
+
uri: http://stage.missionhub.com/oauth/access_token
|
|
48
48
|
body:
|
|
49
49
|
encoding: US-ASCII
|
|
50
|
-
string: grant_type=none&client_id=12&client_secret=
|
|
50
|
+
string: grant_type=none&client_id=12&client_secret=33f84763tasf9c1fb4ce96adc4908b9ba285b510d0
|
|
51
51
|
headers: {}
|
|
52
52
|
response:
|
|
53
53
|
status:
|
|
@@ -57,7 +57,7 @@ http_interactions:
|
|
|
57
57
|
Server:
|
|
58
58
|
- nginx/1.0.14
|
|
59
59
|
Date:
|
|
60
|
-
-
|
|
60
|
+
- Thu, 08 Nov 2012 13:49:27 GMT
|
|
61
61
|
Content-Type:
|
|
62
62
|
- application/json
|
|
63
63
|
Transfer-Encoding:
|
|
@@ -73,24 +73,24 @@ http_interactions:
|
|
|
73
73
|
X-Ua-Compatible:
|
|
74
74
|
- IE=Edge,chrome=1
|
|
75
75
|
Etag:
|
|
76
|
-
- ! '"
|
|
76
|
+
- ! '"587793cf9f81936d3aa19ce565ea19cf"'
|
|
77
77
|
X-Request-Id:
|
|
78
|
-
-
|
|
78
|
+
- aae32e7e7ecd9ee631f7e24d277b0778
|
|
79
79
|
X-Runtime:
|
|
80
|
-
- '0.
|
|
80
|
+
- '0.047424'
|
|
81
81
|
X-Rack-Cache:
|
|
82
82
|
- invalidate, pass
|
|
83
83
|
body:
|
|
84
84
|
encoding: US-ASCII
|
|
85
|
-
string: ! '{"access_token":"
|
|
85
|
+
string: ! '{"access_token":"526bba947bfeb5a7d60206c75983dcf30aee5a68ef7bc7479c7a151cdce3c7e8","scope":"contacts,userinfo,contact_assignment,followup_comments,roles,organization_info"}'
|
|
86
86
|
http_version:
|
|
87
|
-
recorded_at:
|
|
87
|
+
recorded_at: Thu, 08 Nov 2012 13:47:10 GMT
|
|
88
88
|
- request:
|
|
89
89
|
method: post
|
|
90
|
-
uri: http://
|
|
90
|
+
uri: http://stage.missionhub.com/api/v2/contacts.json
|
|
91
91
|
body:
|
|
92
92
|
encoding: US-ASCII
|
|
93
|
-
string: person[
|
|
93
|
+
string: person[first_name]=Test&person[last_name]=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][0]=&answers[4954][1]=C3&answers[4954][2]=C4&org_id=5522&user_id=1615180&access_token=526bba947bfeb5a7d60206c75983dcf30aee5a68ef7bc7479c7a151cdce3c7e8
|
|
94
94
|
headers: {}
|
|
95
95
|
response:
|
|
96
96
|
status:
|
|
@@ -100,7 +100,7 @@ http_interactions:
|
|
|
100
100
|
Server:
|
|
101
101
|
- nginx/1.0.14
|
|
102
102
|
Date:
|
|
103
|
-
-
|
|
103
|
+
- Thu, 08 Nov 2012 13:49:28 GMT
|
|
104
104
|
Content-Type:
|
|
105
105
|
- application/json; charset=utf-8
|
|
106
106
|
Transfer-Encoding:
|
|
@@ -114,49 +114,22 @@ http_interactions:
|
|
|
114
114
|
X-Ua-Compatible:
|
|
115
115
|
- IE=Edge,chrome=1
|
|
116
116
|
Etag:
|
|
117
|
-
- ! '"
|
|
117
|
+
- ! '"e081d0440636fc4cf4a95aa23fc06f6b"'
|
|
118
118
|
Cache-Control:
|
|
119
119
|
- max-age=0, private, must-revalidate
|
|
120
120
|
Set-Cookie:
|
|
121
|
-
- _mh_session=
|
|
122
|
-
|
|
121
|
+
- _mh_session=d3e7b5065853a46631c59b937c6674de; path=/; expires=Sat, 10-Nov-2012
|
|
122
|
+
13:50:24 GMT; HttpOnly
|
|
123
|
+
- logged_in=true; path=/
|
|
123
124
|
X-Request-Id:
|
|
124
|
-
-
|
|
125
|
+
- d27fa3266be6e14b41b311a106a38ee0
|
|
125
126
|
X-Runtime:
|
|
126
|
-
- '
|
|
127
|
+
- '0.195808'
|
|
127
128
|
X-Rack-Cache:
|
|
128
129
|
- invalidate, pass
|
|
129
130
|
body:
|
|
130
131
|
encoding: US-ASCII
|
|
131
|
-
string: ! '{"
|
|
132
|
+
string: ! '{"id":2592834,"name":"Test User","assignment":{"assigned_to_person":[],"person_assigned_to":[]},"gender":"Female","status":"uncontacted","request_org_id":5522,"organizational_roles":[]}'
|
|
132
133
|
http_version:
|
|
133
|
-
recorded_at:
|
|
134
|
-
|
|
135
|
-
method: post
|
|
136
|
-
uri: http://www.missionhub.com/api/v2/contacts.json
|
|
137
|
-
body:
|
|
138
|
-
encoding: US-ASCII
|
|
139
|
-
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][]=&answers[4954][C3]=C3&answers[4954][C4]=C4&org_id=5522&user_id=1615180&access_token=e83b007f75ad49d480303f892de884204b7864bc817f0fb547c9d87444c39a75
|
|
140
|
-
headers: {}
|
|
141
|
-
response:
|
|
142
|
-
status:
|
|
143
|
-
code: 502
|
|
144
|
-
message: Bad Gateway
|
|
145
|
-
headers:
|
|
146
|
-
Server:
|
|
147
|
-
- nginx/1.0.14
|
|
148
|
-
Date:
|
|
149
|
-
- Wed, 10 Oct 2012 00:41:41 GMT
|
|
150
|
-
Content-Type:
|
|
151
|
-
- text/html
|
|
152
|
-
Connection:
|
|
153
|
-
- keep-alive
|
|
154
|
-
Content-Length:
|
|
155
|
-
- '172'
|
|
156
|
-
body:
|
|
157
|
-
encoding: US-ASCII
|
|
158
|
-
string: ! "<html>\r\n<head><title>502 Bad Gateway</title></head>\r\n<body bgcolor=\"white\">\r\n<center><h1>502
|
|
159
|
-
Bad Gateway</h1></center>\r\n<hr><center>nginx/1.2.2</center>\r\n</body>\r\n</html>\r\n"
|
|
160
|
-
http_version:
|
|
161
|
-
recorded_at: Wed, 10 Oct 2012 00:40:14 GMT
|
|
162
|
-
recorded_with: VCR 2.2.5
|
|
134
|
+
recorded_at: Thu, 08 Nov 2012 13:47:11 GMT
|
|
135
|
+
recorded_with: VCR 2.3.0
|
data/lib/missionhub.rb
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
Dir[File.dirname(__FILE__) + '/
|
|
1
|
+
Dir[File.dirname(__FILE__) + '/missionhub/*.rb'].each do |file|
|
|
2
2
|
require file
|
|
3
3
|
end
|
|
4
4
|
|
|
5
5
|
module MissionHub
|
|
6
|
-
|
|
6
|
+
class << self
|
|
7
|
+
attr_accessor :client_id, :client_secret, :site
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
# And we define a wrapper for the configuration block, that we'll use to set up
|
|
10
|
+
# our set of options
|
|
11
|
+
def config
|
|
12
|
+
yield self
|
|
9
13
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
instance_eval(&block)
|
|
14
|
+
self.site ||= "https://www.missionhub.com/apis/v3"
|
|
15
|
+
Base.site = site
|
|
16
|
+
end
|
|
14
17
|
end
|
|
15
18
|
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
module MissionHub
|
|
2
|
+
class Base < ActiveResource::Base
|
|
3
|
+
|
|
4
|
+
def self.connection(refresh = false)
|
|
5
|
+
if defined?(@connection) || superclass == Object
|
|
6
|
+
@connection = Connection.new(site, format) if refresh || @connection.nil?
|
|
7
|
+
@connection.proxy = proxy if proxy
|
|
8
|
+
@connection.auth_type = auth_type if auth_type
|
|
9
|
+
@connection.timeout = timeout if timeout
|
|
10
|
+
@connection
|
|
11
|
+
else
|
|
12
|
+
superclass.connection
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
class Connection < ActiveResource::Connection
|
|
18
|
+
|
|
19
|
+
private
|
|
20
|
+
|
|
21
|
+
def request(method, path, *arguments)
|
|
22
|
+
result = ActiveSupport::Notifications.instrument("request.active_resource") do |payload|
|
|
23
|
+
path = add_secret_to_path(path)
|
|
24
|
+
payload[:method] = method
|
|
25
|
+
payload[:request_uri] = "#{site.scheme}://#{site.host}:#{site.port}#{path}"
|
|
26
|
+
payload[:result] = http.send(method, path, *arguments)
|
|
27
|
+
end
|
|
28
|
+
handle_response(result)
|
|
29
|
+
rescue Timeout::Error => e
|
|
30
|
+
raise TimeoutError.new(e.message)
|
|
31
|
+
rescue OpenSSL::SSL::SSLError => e
|
|
32
|
+
raise SSLError.new(e.message)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def add_secret_to_path(path)
|
|
36
|
+
path += path.include?('?') ? '&' : '?'
|
|
37
|
+
path + "secret=#{MissionHub.client_secret}"
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
data/lib/missionhub/person.rb
CHANGED
|
@@ -1,127 +1,5 @@
|
|
|
1
|
-
require 'resolv'
|
|
2
|
-
|
|
3
1
|
module MissionHub
|
|
4
|
-
class Person
|
|
5
|
-
attr_accessor :current_address_attributes, :phone_number, :email_address, :gender, :firstName, :lastName, :answers, :phone_number
|
|
6
|
-
|
|
7
|
-
#align variable naming with MissionHub API
|
|
8
|
-
alias :first_name= :firstName=
|
|
9
|
-
alias :first_name :firstName
|
|
10
|
-
|
|
11
|
-
alias :last_name= :lastName=
|
|
12
|
-
alias :last_name :lastName
|
|
13
|
-
|
|
14
|
-
alias :phone= :phone_number=
|
|
15
|
-
alias :phone :phone_number
|
|
16
|
-
|
|
17
|
-
alias :address :current_address_attributes
|
|
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
|
-
|
|
24
|
-
def address=(address)
|
|
25
|
-
raise "Address must be a MissionHub::Person::Address" unless address.kind_of? MissionHub::Person::Address
|
|
26
|
-
@current_address_attributes = address
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def set_answer(id, message)
|
|
30
|
-
if @answers.nil?
|
|
31
|
-
@answers = Hash.new
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
if message.is_a?(String) or message.is_a?(Hash) or message.is_a?(Array)
|
|
35
|
-
if id.is_a?(Integer)
|
|
36
|
-
if message.is_a?(Array)
|
|
37
|
-
h = {}
|
|
38
|
-
count = 0
|
|
39
|
-
message.each do |v|
|
|
40
|
-
h[count] = v
|
|
41
|
-
count += 1
|
|
42
|
-
end
|
|
43
|
-
message = h
|
|
44
|
-
end
|
|
45
|
-
@answers[id] = message
|
|
46
|
-
else
|
|
47
|
-
raise "Invalid type for id"
|
|
48
|
-
end
|
|
49
|
-
else
|
|
50
|
-
raise "Invalid type for message"
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def get_answer(id)
|
|
55
|
-
@answers[id]
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
def current_address_attributes=(address)
|
|
59
|
-
raise "Address must be a MissionHub::Person::Address" unless address.kind_of? MissionHub::Person::Address
|
|
60
|
-
@current_address_attributes = address
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def phone
|
|
64
|
-
@phone_number[:number]
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def phone=(phone)
|
|
68
|
-
unless phone.empty?
|
|
69
|
-
@phone_number = {:number => phone.gsub(/[^0-9]/, ""), :primary => 0, :location => "mobile"}
|
|
70
|
-
else
|
|
71
|
-
raise "Phone appears to be empty"
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
def email_address
|
|
76
|
-
@email_address[:email]
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
def email_address=(email)
|
|
80
|
-
unless email.empty?
|
|
81
|
-
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]$/
|
|
82
|
-
raise "Email does not appear to be valid format"
|
|
83
|
-
else
|
|
84
|
-
raise "Email domain name appears to be incorrect" unless validate_email_domain(email)
|
|
85
|
-
@email_address = {:email => email, :primary => 0}
|
|
86
|
-
end
|
|
87
|
-
else
|
|
88
|
-
raise "Email appears to be empty"
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
def gender=(gender)
|
|
93
|
-
if gender == "male" or gender == "female"
|
|
94
|
-
@gender = gender
|
|
95
|
-
else
|
|
96
|
-
raise "Gender must be either male or female"
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
def validate_email_domain(email)
|
|
101
|
-
domain = email.match(/\@(.+)/)[1]
|
|
102
|
-
Resolv::DNS.open do |dns|
|
|
103
|
-
@mx = dns.getresources(domain, Resolv::DNS::Resource::IN::MX)
|
|
104
|
-
end
|
|
105
|
-
@mx.size > 0 ? true : false
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
def full_name
|
|
109
|
-
@firstName + " " + @lastName
|
|
110
|
-
end
|
|
2
|
+
class Person < Base
|
|
111
3
|
|
|
112
|
-
def hash
|
|
113
|
-
hash_to_return = {}
|
|
114
|
-
self.instance_variables.each do |var|
|
|
115
|
-
temp = self.instance_variable_get(var)
|
|
116
|
-
if not temp.nil? and var.to_s != "@mx"
|
|
117
|
-
if temp.kind_of? MissionHub::Person::Address
|
|
118
|
-
hash_to_return[var.to_s.gsub("@","")] = temp.hash
|
|
119
|
-
else
|
|
120
|
-
hash_to_return[var.to_s.gsub("@","")] = temp
|
|
121
|
-
end
|
|
122
|
-
end
|
|
123
|
-
end
|
|
124
|
-
return hash_to_return
|
|
125
|
-
end
|
|
126
4
|
end
|
|
127
5
|
end
|
data/lib/missionhub/version.rb
CHANGED
data/missionhub.gemspec
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
|
-
require File.expand_path('../lib/
|
|
2
|
+
require File.expand_path('../lib/missionhub/version', __FILE__)
|
|
3
3
|
|
|
4
4
|
Gem::Specification.new do |gem|
|
|
5
5
|
gem.authors = ["Tataihono Nikora"]
|
|
@@ -10,11 +10,11 @@ Gem::Specification.new do |gem|
|
|
|
10
10
|
|
|
11
11
|
gem.add_development_dependency 'minitest'
|
|
12
12
|
gem.add_development_dependency 'webmock'
|
|
13
|
-
gem.add_development_dependency 'vcr'
|
|
13
|
+
#gem.add_development_dependency 'vcr'
|
|
14
14
|
gem.add_development_dependency 'turn'
|
|
15
15
|
gem.add_development_dependency 'rake'
|
|
16
16
|
|
|
17
|
-
gem.add_dependency "
|
|
17
|
+
#gem.add_dependency "activeresource", "~> 4.0.0.beta"
|
|
18
18
|
|
|
19
19
|
gem.files = `git ls-files`.split($\)
|
|
20
20
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
data/spec/lib/missionhub_spec.rb
CHANGED
|
@@ -3,7 +3,7 @@ require_relative '../spec_helper'
|
|
|
3
3
|
describe MissionHub do
|
|
4
4
|
|
|
5
5
|
it "must have the base url set to the MissionHub API" do
|
|
6
|
-
MissionHub.base_uri.must_equal 'http://
|
|
6
|
+
MissionHub.base_uri.must_equal 'http://stage.missionhub.com/'
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
it "must have a defined client id" do
|
data/spec/spec_helper.rb
CHANGED
|
@@ -16,9 +16,9 @@ Turn.config do |c|
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
MissionHub.config do |c|
|
|
19
|
-
c.base_uri = 'http://
|
|
19
|
+
c.base_uri = 'http://stage.missionhub.com/'
|
|
20
20
|
c.client_id = 12
|
|
21
|
-
c.client_secret = '
|
|
21
|
+
c.client_secret = '33f84763tasf9c1fb4ce96adc4908b9ba285b510d0'
|
|
22
22
|
c.org_id = 5522
|
|
23
23
|
end
|
|
24
24
|
|
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:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
prerelease:
|
|
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-
|
|
12
|
+
date: 2012-12-18 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: minitest
|
|
@@ -43,22 +43,6 @@ dependencies:
|
|
|
43
43
|
- - ! '>='
|
|
44
44
|
- !ruby/object:Gem::Version
|
|
45
45
|
version: '0'
|
|
46
|
-
- !ruby/object:Gem::Dependency
|
|
47
|
-
name: vcr
|
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
|
49
|
-
none: false
|
|
50
|
-
requirements:
|
|
51
|
-
- - ! '>='
|
|
52
|
-
- !ruby/object:Gem::Version
|
|
53
|
-
version: '0'
|
|
54
|
-
type: :development
|
|
55
|
-
prerelease: false
|
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
-
none: false
|
|
58
|
-
requirements:
|
|
59
|
-
- - ! '>='
|
|
60
|
-
- !ruby/object:Gem::Version
|
|
61
|
-
version: '0'
|
|
62
46
|
- !ruby/object:Gem::Dependency
|
|
63
47
|
name: turn
|
|
64
48
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -91,22 +75,6 @@ dependencies:
|
|
|
91
75
|
- - ! '>='
|
|
92
76
|
- !ruby/object:Gem::Version
|
|
93
77
|
version: '0'
|
|
94
|
-
- !ruby/object:Gem::Dependency
|
|
95
|
-
name: httparty
|
|
96
|
-
requirement: !ruby/object:Gem::Requirement
|
|
97
|
-
none: false
|
|
98
|
-
requirements:
|
|
99
|
-
- - ~>
|
|
100
|
-
- !ruby/object:Gem::Version
|
|
101
|
-
version: 0.9.0
|
|
102
|
-
type: :runtime
|
|
103
|
-
prerelease: false
|
|
104
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
105
|
-
none: false
|
|
106
|
-
requirements:
|
|
107
|
-
- - ~>
|
|
108
|
-
- !ruby/object:Gem::Version
|
|
109
|
-
version: 0.9.0
|
|
110
78
|
description: Consume the MissionHub API easily with this Ruby Gem
|
|
111
79
|
email:
|
|
112
80
|
- tataihono.nikora@gmail.com
|
|
@@ -120,11 +88,19 @@ files:
|
|
|
120
88
|
- README.md
|
|
121
89
|
- Rakefile
|
|
122
90
|
- fixtures/vcr_cassettes/auth.yml
|
|
123
|
-
- lib/console.rb
|
|
124
91
|
- lib/missionhub.rb
|
|
125
|
-
- lib/missionhub/
|
|
126
|
-
- lib/missionhub/
|
|
92
|
+
- lib/missionhub/base.rb
|
|
93
|
+
- lib/missionhub/email_address.rb
|
|
94
|
+
- lib/missionhub/followup_comment.rb
|
|
95
|
+
- lib/missionhub/organization.rb
|
|
96
|
+
- lib/missionhub/organizational_role.rb
|
|
127
97
|
- lib/missionhub/person.rb
|
|
98
|
+
- lib/missionhub/phone_number.rb
|
|
99
|
+
- lib/missionhub/question.rb
|
|
100
|
+
- lib/missionhub/rejoicable.rb
|
|
101
|
+
- lib/missionhub/role.rb
|
|
102
|
+
- lib/missionhub/sms_keyword.rb
|
|
103
|
+
- lib/missionhub/survey.rb
|
|
128
104
|
- lib/missionhub/version.rb
|
|
129
105
|
- missionhub.gemspec
|
|
130
106
|
- spec/lib/missionhub/address_spec.rb
|
data/lib/console.rb
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
require File.expand_path(File.join(File.dirname(__FILE__), '/missionhub.rb'))
|
|
2
|
-
puts <<-TXT
|
|
3
|
-
Ruby lib for working with the MissionHub API's JSON interface.
|
|
4
|
-
The first thing you need to set is the Base URI for communicating
|
|
5
|
-
with your MissionHub Instance.
|
|
6
|
-
|
|
7
|
-
MissionHub.base_uri = 'http://www.missionhub.com/'
|
|
8
|
-
|
|
9
|
-
Then, you should set the authentication. You can find more info
|
|
10
|
-
on API Authentication at http://wiki.uscm.org/display/NCO/Authentication.
|
|
11
|
-
|
|
12
|
-
#OAuth Two Legged Authentication
|
|
13
|
-
MissionHub.client_id = 1
|
|
14
|
-
MissionHub.client_secret = '32jk248bkjf0875sdasjloy'
|
|
15
|
-
|
|
16
|
-
This library is a small wrapper around the REST interface.
|
|
17
|
-
|
|
18
|
-
TXT
|
|
19
|
-
|
|
20
|
-
MissionHub.config do |c|
|
|
21
|
-
# :outline - turn's original case/test outline mode [default]
|
|
22
|
-
c.base_uri = 'http://www.missionhub.com/'
|
|
23
|
-
c.client_id = 6
|
|
24
|
-
c.client_secret = '5b1913aa85720d7ede99dac1ad35fbf40bbc4490d9da0df346877832469daeb2'
|
|
25
|
-
end
|
data/lib/missionhub/address.rb
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
module MissionHub
|
|
2
|
-
class Person
|
|
3
|
-
class Address
|
|
4
|
-
attr_accessor :address1, :address2, :city, :country, :state, :zip
|
|
5
|
-
|
|
6
|
-
def hash
|
|
7
|
-
hash_to_return = {}
|
|
8
|
-
self.instance_variables.each do |var|
|
|
9
|
-
hash_to_return[var.to_s.gsub("@","")] = self.instance_variable_get(var)
|
|
10
|
-
end
|
|
11
|
-
hash_to_return
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
data/lib/missionhub/api.rb
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
require 'yaml'
|
|
2
|
-
require 'httparty'
|
|
3
|
-
|
|
4
|
-
module MissionHub
|
|
5
|
-
class API
|
|
6
|
-
include HTTParty
|
|
7
|
-
|
|
8
|
-
@access_token = ''
|
|
9
|
-
@scope = Array[]
|
|
10
|
-
|
|
11
|
-
def initialize
|
|
12
|
-
self.class.base_uri MissionHub.base_uri
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def auth
|
|
16
|
-
options = {:body => { :grant_type => 'none', :client_id => MissionHub.client_id, :client_secret => MissionHub.client_secret } }
|
|
17
|
-
response = self.class.post('/oauth/access_token', options)
|
|
18
|
-
raise 'invalid client' if response.parsed_response['access_token'].nil?
|
|
19
|
-
@access_token = response.parsed_response['access_token']
|
|
20
|
-
raise 'invalid scope' if response.parsed_response['scope'].nil?
|
|
21
|
-
@scope = response.parsed_response['scope'].split(',')
|
|
22
|
-
true
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def create_person(person)
|
|
26
|
-
raise "Not Authenticated" if @access_token.nil?
|
|
27
|
-
raise "Scope doesn't allow for contact creation" unless @scope.include?("contacts")
|
|
28
|
-
raise "Peron must be a MissionHub::Person" unless person.kind_of? MissionHub::Person
|
|
29
|
-
raise "First name must be set to create person" if person.first_name.nil?
|
|
30
|
-
|
|
31
|
-
#hard_coded user_id (given by developer of API)
|
|
32
|
-
person_hash = person.hash
|
|
33
|
-
person_hash.delete("answers")
|
|
34
|
-
options = {:body => { :person => person_hash, :answers => person.answers, :org_id => MissionHub.org_id, :user_id => 1615180, :access_token => @access_token} }
|
|
35
|
-
response = self.class.post('/api/v2/contacts.json', options)
|
|
36
|
-
if !response.parsed_response['error'].nil?
|
|
37
|
-
raise response.parsed_response['error']
|
|
38
|
-
else
|
|
39
|
-
response
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|