maxcrm 0.0.0 → 0.0.1
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.rdoc +15 -1
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/lib/api.rb +31 -0
- data/lib/configuration.rb +30 -0
- data/lib/maxcrm.rb +12 -3
- data/maxcrm.gemspec +7 -2
- metadata +19 -3
data/README.rdoc
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
= maxcrm
|
2
2
|
|
3
|
-
Gem to work with maxcrm3.heroku.com
|
3
|
+
Gem to work with maxcrm3.heroku.com. Requires Rails 3.
|
4
|
+
|
5
|
+
You'll need a maxcrm.yml like this: (or MAXCRM_URL, MAXCRM_USERNAME, MAXCRM_PASSWORD in environment)
|
6
|
+
|
7
|
+
development:
|
8
|
+
url: http://maxcrm.heroku.com/
|
9
|
+
username: foo
|
10
|
+
password: bar
|
4
11
|
|
5
12
|
== Note on Patches/Pull Requests
|
6
13
|
|
@@ -15,3 +22,10 @@ Gem to work with maxcrm3.heroku.com
|
|
15
22
|
== Copyright
|
16
23
|
|
17
24
|
Copyright (c) 2010 Gwyn Morfey. See LICENSE for details.
|
25
|
+
|
26
|
+
|
27
|
+
== TODO
|
28
|
+
|
29
|
+
Fix config. issue
|
30
|
+
Make it actually do something
|
31
|
+
Setup Rails 3 as dependency
|
data/Rakefile
CHANGED
@@ -11,6 +11,7 @@ begin
|
|
11
11
|
gem.homepage = "http://github.com/gwynm/maxcrm-gem"
|
12
12
|
gem.authors = ["Gwyn Morfey"]
|
13
13
|
gem.add_development_dependency "rspec", ">= 1.2.9"
|
14
|
+
gem.add_dependency "rest-client", ">= 1.4"
|
14
15
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
16
|
end
|
16
17
|
Jeweler::GemcutterTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.1
|
data/lib/api.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
|
3
|
+
module Maxcrm
|
4
|
+
class << self
|
5
|
+
#Synchronously send an incident notification to maxcrm
|
6
|
+
#We need :user_email and :event_name
|
7
|
+
def send_incident(params)
|
8
|
+
raise MissingParameterError unless params[:user_email] && params[:event_name]
|
9
|
+
|
10
|
+
#Make HTTP call to the Maxcrm server
|
11
|
+
resource = RestClient::Resource.new(
|
12
|
+
incident_resource_url(params[:user_email]),
|
13
|
+
:user=>Maxcrm.config["user"],
|
14
|
+
:password=>Maxcrm.config["password"]
|
15
|
+
)
|
16
|
+
|
17
|
+
response = resource.post({"incident" => {"event_name" => params[:event_name]}})
|
18
|
+
return (response.code >= 200 and response.code < 300)
|
19
|
+
end
|
20
|
+
|
21
|
+
def incident_resource_url(email)
|
22
|
+
Maxcrm.config["url"] + "users/" + email_to_param(email) + "/incidents.json"
|
23
|
+
end
|
24
|
+
|
25
|
+
def email_to_param(email)
|
26
|
+
email.gsub(".","_")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class MissingParameterError < StandardError;end
|
31
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Maxcrm
|
2
|
+
class << self
|
3
|
+
def configure
|
4
|
+
Maxcrm.config = {}
|
5
|
+
load_configuration_from_heroku || load_configuration_from_yml || die_without_configuration
|
6
|
+
end
|
7
|
+
|
8
|
+
def load_configuration_from_heroku
|
9
|
+
if ENV['MAXCRM_URL']
|
10
|
+
@config={}
|
11
|
+
keys = %w(MAXCRM_URL MAXCRM_USERNAME MAXCRM_PASSWORD)
|
12
|
+
keys.each {|k| Maxcrm.config[k[7..999].downcase] = ENV[k]} #converts MAXCRM_URL to url
|
13
|
+
return true
|
14
|
+
end
|
15
|
+
false
|
16
|
+
end
|
17
|
+
|
18
|
+
def load_configuration_from_yml
|
19
|
+
if File.exist?(filename = Rails.root.join("config", "maxcrm.yml"))
|
20
|
+
Maxcrm.config = YAML::load_file(filename)[Rails.env]
|
21
|
+
return true
|
22
|
+
end
|
23
|
+
false
|
24
|
+
end
|
25
|
+
|
26
|
+
def die_without_configuration
|
27
|
+
raise "MaxCRM has not been configured. Please set the Heroku environment variables or create config/maxcrm.yml. See the MaxCRM gem's README for more information."
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/maxcrm.rb
CHANGED
@@ -1,5 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
require 'configuration'
|
2
|
+
require 'api'
|
3
|
+
|
4
|
+
module Maxcrm
|
5
|
+
class << self
|
6
|
+
attr_accessor :config #Use eg Maxcrm.config["url"]
|
7
|
+
end
|
8
|
+
|
9
|
+
class Railtie < Rails::Railtie
|
10
|
+
initializer "maxcrm.setup" do
|
11
|
+
Maxcrm.configure
|
12
|
+
end
|
4
13
|
end
|
5
14
|
end
|
data/maxcrm.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{maxcrm}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Gwyn Morfey"]
|
12
|
-
s.date = %q{2010-09-
|
12
|
+
s.date = %q{2010-09-20}
|
13
13
|
s.description = %q{Install this gem to your project to manage your users and events through MaxCRM.}
|
14
14
|
s.email = %q{gwyn@new-bamboo.co.uk}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -21,6 +21,8 @@ Gem::Specification.new do |s|
|
|
21
21
|
"README.rdoc",
|
22
22
|
"Rakefile",
|
23
23
|
"VERSION",
|
24
|
+
"lib/api.rb",
|
25
|
+
"lib/configuration.rb",
|
24
26
|
"lib/maxcrm.rb",
|
25
27
|
"maxcrm.gemspec",
|
26
28
|
"spec/maxcrm_spec.rb",
|
@@ -43,11 +45,14 @@ Gem::Specification.new do |s|
|
|
43
45
|
|
44
46
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
45
47
|
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
48
|
+
s.add_runtime_dependency(%q<rest-client>, [">= 1.4"])
|
46
49
|
else
|
47
50
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
51
|
+
s.add_dependency(%q<rest-client>, [">= 1.4"])
|
48
52
|
end
|
49
53
|
else
|
50
54
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
55
|
+
s.add_dependency(%q<rest-client>, [">= 1.4"])
|
51
56
|
end
|
52
57
|
end
|
53
58
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Gwyn Morfey
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-09-
|
17
|
+
date: 2010-09-20 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -32,6 +32,20 @@ dependencies:
|
|
32
32
|
version: 1.2.9
|
33
33
|
type: :development
|
34
34
|
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rest-client
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
segments:
|
44
|
+
- 1
|
45
|
+
- 4
|
46
|
+
version: "1.4"
|
47
|
+
type: :runtime
|
48
|
+
version_requirements: *id002
|
35
49
|
description: Install this gem to your project to manage your users and events through MaxCRM.
|
36
50
|
email: gwyn@new-bamboo.co.uk
|
37
51
|
executables: []
|
@@ -46,6 +60,8 @@ files:
|
|
46
60
|
- README.rdoc
|
47
61
|
- Rakefile
|
48
62
|
- VERSION
|
63
|
+
- lib/api.rb
|
64
|
+
- lib/configuration.rb
|
49
65
|
- lib/maxcrm.rb
|
50
66
|
- maxcrm.gemspec
|
51
67
|
- spec/maxcrm_spec.rb
|