infopark_crm_connector 0.9.2 → 1.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.
Files changed (40) hide show
  1. data/.yardopts +8 -0
  2. data/CHANGELOG.markdown +94 -0
  3. data/LICENSE +2 -0
  4. data/README.markdown +110 -0
  5. data/lib/crm_connector.rb +11 -15
  6. data/lib/crm_connector/account.rb +31 -2
  7. data/lib/crm_connector/activity.rb +61 -3
  8. data/lib/crm_connector/configuration.rb +2 -4
  9. data/lib/crm_connector/contact.rb +123 -3
  10. data/lib/crm_connector/core/continuation_support.rb +2 -1
  11. data/lib/crm_connector/core/enumerator.rb +20 -11
  12. data/lib/crm_connector/core/known_attributes.rb +3 -1
  13. data/lib/crm_connector/core/resource.rb +108 -16
  14. data/lib/crm_connector/core/search_support.rb +3 -1
  15. data/lib/crm_connector/custom_type.rb +20 -3
  16. data/lib/crm_connector/{default.rb → errors.rb} +1 -1
  17. data/lib/crm_connector/errors/authentication_failed.rb +10 -0
  18. data/lib/crm_connector/errors/base.rb +8 -0
  19. data/lib/crm_connector/event.rb +37 -2
  20. data/lib/crm_connector/event_contact.rb +38 -2
  21. data/lib/crm_connector/mailing.rb +35 -2
  22. data/lib/crm_connector/role.rb +7 -2
  23. data/lib/crm_connector/system.rb +14 -8
  24. metadata +22 -53
  25. data/CHANGELOG.rdoc +0 -87
  26. data/README.rdoc +0 -59
  27. data/lib/crm_connector/base.rb +0 -4
  28. data/lib/crm_connector/core/base.rb +0 -111
  29. data/lib/crm_connector/debugging.rb +0 -21
  30. data/lib/crm_connector/default/account.rb +0 -30
  31. data/lib/crm_connector/default/activity.rb +0 -54
  32. data/lib/crm_connector/default/contact.rb +0 -112
  33. data/lib/crm_connector/default/custom_type.rb +0 -24
  34. data/lib/crm_connector/default/event.rb +0 -23
  35. data/lib/crm_connector/default/event_contact.rb +0 -57
  36. data/lib/crm_connector/default/mailing.rb +0 -33
  37. data/lib/crm_connector/default/resource.rb +0 -10
  38. data/lib/crm_connector/default/role.rb +0 -9
  39. data/lib/crm_connector/inheriting_resource.rb +0 -30
  40. data/lib/crm_connector/resource.rb +0 -15
@@ -1,21 +0,0 @@
1
- require 'logger'
2
-
3
- module Infopark; module Crm
4
- module Debugging
5
-
6
- def logger
7
- self.class.logger
8
- end
9
-
10
- def self.included(base)
11
- base.logger ||= begin
12
- logger = Logger.new(STDERR)
13
- logger.progname = 'Infopark::Crm'
14
- logger.level = Logger::INFO
15
- logger
16
- end
17
- end
18
-
19
- end
20
-
21
- end; end
@@ -1,30 +0,0 @@
1
- module Infopark; module Crm; module Default
2
-
3
- class Account < Resource
4
- ##
5
- # :singleton-method: search
6
- # ==== RESTful Web Service
7
- # GET /api/accounts/search
8
- # ==== Examples
9
- # results = Infopark::Crm::Account.search(:params => {:account_group => account_group})
10
- # results = Infopark::Crm::Account.search(:params => {:q => 'full-text search'})
11
- has_search
12
-
13
- self.schema = {
14
- :account_group => :string,
15
- :country => :string,
16
- :extended_address => :string,
17
- :home_page => :string,
18
- :locality => :string,
19
- :name => :string,
20
- :org_name_address => :string,
21
- :org_unit_address => :string,
22
- :phone => :string,
23
- :postalcode => :string,
24
- :region => :string,
25
- :street_address => :string,
26
- :tags => :array,
27
- :want_geo_location => :boolean,
28
- }
29
- end
30
- end; end; end
@@ -1,54 +0,0 @@
1
- require 'ostruct'
2
-
3
- module Infopark; module Crm; module Default
4
- class Activity < Resource
5
- ##
6
- # :singleton-method: search
7
- # ==== RESTful Web Service
8
- # GET /api/activity/search
9
- # ==== Examples
10
- # results = Infopark::Crm::Activity.search(:params => {:state => 'created'})
11
- # results = Infopark::Crm::Activity.search(:params => {:kind => 'support case'})
12
- # results = Infopark::Crm::Activity.search(:params => {:contact_id => cid})
13
- # results = Infopark::Crm::Activity.search(:params => {:account_id => aid})
14
- # results = Infopark::Crm::Activity.search(:params => {:q => 'full-text search'})
15
- has_search
16
-
17
- self.schema = {
18
- :account_id => :string,
19
- :appointment_contact_id => :string,
20
- :appointment_dtend_at => :time,
21
- :appointment_dtstart_at => :time,
22
- :appointment_location => :string,
23
- :comment_notes => :string,
24
- :comment_published => :boolean,
25
- :contact_id => :string,
26
- :email_cc => :string,
27
- :kind => :string,
28
- :state => :string,
29
- :tags => :array,
30
- :task_due_at => :time,
31
- :task_owner_id => :string,
32
- :title => :string,
33
- }
34
-
35
- # Queries the WebCRM for the Contact with the id +contact_id+.
36
- # Returns +nil+ if +contact_id+ is +nil+.
37
- def contact
38
- Infopark::Crm::Contact.find(contact_id) if contact_id
39
- end
40
-
41
- # Queries the WebCRM for the Account with the id +account_id+.
42
- # Returns +nil+ if +account_id+ is +nil+.
43
- def account
44
- Infopark::Crm::Account.find(account_id) if account_id
45
- end
46
-
47
- # Queries the WebCRM for the CustomType with the id +kind+.
48
- # Returns +nil+ if +kind+ is +nil+.
49
- def custom_type
50
- Infopark::Crm::CustomType.find(kind) if kind
51
- end
52
-
53
- end
54
- end; end; end
@@ -1,112 +0,0 @@
1
- module Infopark; module Crm; module Default
2
- class Contact < Resource
3
-
4
- ##
5
- # :singleton-method: search
6
- # ==== RESTful Web Service
7
- # GET /api/contacts/search
8
- # ==== Examples
9
- # results = Infopark::Crm::Contact.search(:params => {:login => login})
10
- # results = Infopark::Crm::Contact.search(:params => {:email => email})
11
- # results = Infopark::Crm::Contact.search(:params => {:q => 'full-text search'})
12
- has_search
13
-
14
- self.schema = {
15
- :account_id => :string,
16
- :country => :string,
17
- :email => :string,
18
- :extended_address => :string,
19
- :fax => :string,
20
- :first_name => :string,
21
- :gender => :string,
22
- :job_title => :string,
23
- :language => :string,
24
- :last_name => :string,
25
- :locality => :string,
26
- :login => :string,
27
- :mobile_phone => :string,
28
- :name_prefix => :string,
29
- :org_name_address => :string,
30
- :org_unit_address => :string,
31
- :phone => :string,
32
- :postalcode => :string,
33
- :region => :string,
34
- :role_names => :array,
35
- :street_address => :string,
36
- :tags => :array,
37
- :want_email => :boolean,
38
- :want_geo_location => :boolean,
39
- :want_phonecall => :boolean,
40
- :want_snailmail => :boolean,
41
- }
42
-
43
- # Queries the WebCRM for the Account with the id +account_id+.
44
- # Returns +nil+ if +account_id+ is +nil+.
45
- def account
46
- Infopark::Crm::Account.find(account_id) if account_id
47
- end
48
-
49
- # ==== RESTful Web Service
50
- # POST /api/contacts/authenticate
51
- def self.authenticate(login, password)
52
- begin
53
- response = post(:authenticate, {}, format.encode({:login => login, :password => password}))
54
- result = format.decode(response.body)
55
- return find(result['id']) if result.kind_of? Hash # ActiveResource 3.0
56
- find(result)
57
- rescue ActiveResource::ResourceInvalid
58
- raise AuthenticationFailed
59
- end
60
- end
61
-
62
- # ==== RESTful Web Service
63
- # POST /api/contacts/password_set
64
- def self.password_set(password, token)
65
- response = post(:password_set, {}, format.encode({:password => password, :token => token}))
66
- result = format.decode(response.body)
67
- return result['message'] if result.kind_of? Hash # ActiveResource 3.0
68
- result
69
- end
70
-
71
- #--
72
- # ==== RESTful Web Service
73
- # POST /api/contacts/:id/password_set
74
- #--
75
- # TBD: build this api and use it
76
- #++
77
- # Shortcut to set the password of this contact.
78
- def password_set(password)
79
- token = password_request(:params => {:only_get_token => true})
80
- self.class.password_set(password, token)
81
- end
82
-
83
- # ==== RESTful Web Service
84
- # GET /api/contacts/:id/password_request
85
- #--
86
- # TBD: return nil instead of message for default parameters?
87
- #++
88
- def password_request(options = {})
89
- params = options[:params] || {}
90
- response = post(:password_request, {}, self.class.format.encode(params))
91
- result = self.class.format.decode(response.body)
92
- return result.values.first if result.kind_of? Hash # ActiveResource 3.0
93
- result
94
- end
95
-
96
- # Returns the live_server_groups of this contact as defined by Configuration.live_server_groups_callback
97
- def live_server_groups
98
- return @live_server_groups if defined?(@live_server_groups)
99
- callback = Configuration.live_server_groups_callback
100
- @live_server_groups = callback.call(self) if callback.respond_to?(:call)
101
- raise "live_server_groups_callback: not defined or unexpected result!" unless @live_server_groups
102
-
103
- @live_server_groups
104
- end
105
-
106
- # Overwrites live_server_groups, so live_server_groups_callback is not called for this object.
107
- def live_server_groups=(value)
108
- @live_server_groups = value
109
- end
110
-
111
- end
112
- end; end; end
@@ -1,24 +0,0 @@
1
- module Infopark; module Crm; module Default
2
- class CustomType < Resource
3
- self.schema = {
4
- :custom_attributes => :hash,
5
- :icon_css_class => :string,
6
- :kind => :string,
7
- :name => :string,
8
- :states => :array,
9
- }
10
-
11
- class CustomAttribute < Resource #:nodoc:
12
-
13
- self.include_root_in_json = false
14
-
15
- #--
16
- # TBD: this method is only needed until the deprecated Object#type is removed
17
- # Better: define self.schema
18
- #++
19
- def type #:nodoc:
20
- attributes['type']
21
- end
22
- end
23
- end
24
- end; end; end
@@ -1,23 +0,0 @@
1
- module Infopark; module Crm; module Default
2
- class Event < Resource
3
- ##
4
- # :singleton-method: search
5
- # ==== RESTful Web Service
6
- # GET /api/events/search
7
- # ==== Examples
8
- # results = Infopark::Crm::Event.search(:params => {:kind => kind})
9
- # results = Infopark::Crm::Event.search(:params => {:event_set => event_set})
10
- # results = Infopark::Crm::Event.search(:params => {:q => 'full-text search'})
11
- has_search
12
-
13
- self.schema = {
14
- :details => :string,
15
- :dtend_at => :time,
16
- :dtstart_at => :time,
17
- :event_set => :string,
18
- :kind => :string,
19
- :location => :string,
20
- :title => :string,
21
- }
22
- end
23
- end; end; end
@@ -1,57 +0,0 @@
1
- module Infopark; module Crm; module Default
2
- class EventContact < Resource
3
-
4
- ##
5
- # :singleton-method: search
6
- # ==== RESTful Web Service
7
- # GET /api/event_contacts/search
8
- # ==== Examples
9
- # results = Infopark::Crm::EventContacts.search(:params => {:event_id => eid})
10
- # results = Infopark::Crm::EventContacts.search(:params => {:contact_id => cid})
11
- # results = Infopark::Crm::EventContacts.search(:params => {:state => state})
12
- # results = Infopark::Crm::EventContacts.search(:params => {:q => 'full-text search'})
13
- has_search
14
-
15
- self.schema = {
16
- :state => :string,
17
- :contact_id => :string,
18
- :event_id => :string,
19
- }
20
-
21
- # Queries the WebCRM for the Contact with the id +contact_id+.
22
- # Returns +nil+ if +contact_id+ is +nil+.
23
- def contact
24
- Infopark::Crm::Contact.find(contact_id) if contact_id
25
- end
26
-
27
- # Queries the WebCRM for the Event with the id +event_id+.
28
- # Returns +nil+ if +event_id+ is +nil+.
29
- def event
30
- Infopark::Crm::Event.find(event_id) if event_id
31
- end
32
-
33
- # ==== DEPRECATED
34
- # Please use +search+ instead.
35
- # ==== RESTful Web Service
36
- # GET /api/event_contacts/find_all_by_event_id_and_state
37
- # ==== Examples
38
- # results = Infopark::Crm::EventContacts.find_by(:params => {:event_id => id})
39
- # count = Infopark::Crm::EventContacts.find_by(:params => {:event_id => id}).size
40
- def self.find_by(options)
41
- deprecated('EventContact.find_by', 'please use EventContact.search')
42
- get_with_continuation(:find_all_by_event_id_and_state, options)
43
- end
44
-
45
- # ==== DEPRECATED
46
- # Please use +search+ instead.
47
- # ==== RESTful Web Service
48
- # GET /api/event_contacts/find_by_event_id_and_contact_id
49
- # ==== Examples
50
- # result = Infopark::Crm::EventContacts.find_by_event_id_and_contact_id(e_id, c_id))
51
- def self.find_by_event_id_and_contact_id(event_id, contact_id)
52
- deprecated('EventContact.find_by_event_id_and_contact_id', 'please use EventContact.search')
53
- find(:find_by_event_id_and_contact_id, :params => {:event_id => event_id, :contact_id => contact_id})
54
- end
55
-
56
- end
57
- end; end; end
@@ -1,33 +0,0 @@
1
- module Infopark; module Crm; module Default
2
- class Mailing < Resource
3
-
4
- ##
5
- # :singleton-method: search
6
- # ==== RESTful Web Service
7
- # GET /api/mailing/search
8
- # ==== Examples
9
- # results = Infopark::Crm::Mailing.search(:params => {:event_id => event_id})
10
- # results = Infopark::Crm::Mailing.search(:params => {:only_unreleased => true})
11
- # results = Infopark::Crm::Mailing.search(:params => {:q => 'full-text search'})
12
- has_search
13
-
14
- self.schema = {
15
- :body => :string,
16
- :dtstart_at => :time,
17
- :email_from => :string,
18
- :email_reply_to => :string,
19
- :email_subject => :string,
20
- :event_id => :string,
21
- :html_body => :string,
22
- :mailing_type => :string,
23
- :title => :string,
24
- }
25
-
26
- # Queries the WebCRM for the Event with the id +event_id+.
27
- # Returns +nil+ if +event_id+ is +nil+.
28
- def event
29
- Infopark::Crm::Event.find(event_id) if event_id
30
- end
31
- end
32
-
33
- end; end; end
@@ -1,10 +0,0 @@
1
- # :stopdoc:
2
- module Infopark; module Crm
3
- module Default
4
- class Resource < Infopark::Crm::Resource
5
- def self.defines_webservice?
6
- to_s.start_with?("Infopark::Crm::Default")
7
- end
8
- end
9
- end
10
- end; end
@@ -1,9 +0,0 @@
1
- module Infopark; module Crm; module Default
2
- class Role < Resource
3
- self.schema = {
4
- :description => :string,
5
- :name => :string,
6
- :permissions => :array,
7
- }
8
- end
9
- end; end; end
@@ -1,30 +0,0 @@
1
- # :stopdoc:
2
- module Infopark; module Crm
3
- module InheritingResource
4
- module ClassMethods
5
- def element_name
6
- superclass.element_name
7
- end
8
-
9
- def prefix(*args)
10
- superclass.prefix(*args)
11
- end
12
-
13
- def collection_name
14
- superclass.collection_name
15
- end
16
-
17
- def schema
18
- superclass.schema
19
- end
20
-
21
- def known_attributes
22
- superclass.known_attributes
23
- end
24
- end
25
-
26
- def self.included(base)
27
- base.extend(ClassMethods)
28
- end
29
- end
30
- end; end
@@ -1,15 +0,0 @@
1
- module Infopark; module Crm
2
- ##
3
- # (Extendable) base class for every resource model
4
- #
5
- # Supports the ActiveResource::Base lifecycle methods, like
6
- # * Resource.create(attributes)
7
- # * Resource.new(attributes)
8
- # * Resource.find(id)
9
- # * resource.update_attributes(attributes)
10
- # * resource.valid?
11
- # * resource.save
12
- #
13
- # See the ActiveResource documentation for a detailed description.
14
- class Resource < Core::Resource; end
15
- end; end