infopark_crm_connector 0.9.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
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,16 +1,22 @@
1
1
  module Infopark; module Crm
2
- # ==== Please note
3
- # Implementation and naming may change
4
- #--
5
- # TBD sync with web service
6
- #++
2
+
3
+ ##
4
+ # @note Implementation and naming may change
7
5
  class System
6
+
7
+ ##
8
+ # Reads the definition of all WebCRM templates.
9
+ # @return [Hash]
10
+ # @webcrm_rest_url <code>GET /api/templates</code>
8
11
  def self.templates
9
12
  response = base.connection.get(path, base.headers)
10
13
  return response['templates'] if response.kind_of? Hash # ActiveResource 3.0
11
14
  base.format.decode(response.body)
12
15
  end
13
16
 
17
+ ##
18
+ # Sets the definition of all WebCRM templates
19
+ # @param hash [Hash] the new definition of all WebCRM templates
14
20
  def self.templates=(hash)
15
21
  data = {'templates' => hash}
16
22
  base.connection.put(path, base.format.encode(data), base.headers)
@@ -18,11 +24,11 @@ module Infopark; module Crm
18
24
 
19
25
  private
20
26
 
21
- def self.base #:nodoc:
22
- Infopark::Crm::Resource
27
+ def self.base
28
+ Infopark::Crm::Core::Resource
23
29
  end
24
30
 
25
- def self.path #:nodoc:
31
+ def self.path
26
32
  base.prefix + 'templates'
27
33
  end
28
34
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: infopark_crm_connector
3
3
  version: !ruby/object:Gem::Version
4
- hash: 63
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
+ - 1
7
8
  - 0
8
- - 9
9
- - 2
10
- version: 0.9.2
9
+ - 0
10
+ version: 1.0.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Infopark AG
@@ -15,12 +15,10 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-04-18 00:00:00 Z
18
+ date: 2012-09-14 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- name: activeresource
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
21
+ version_requirements: &id001 !ruby/object:Gem::Requirement
24
22
  none: false
25
23
  requirements:
26
24
  - - ">="
@@ -29,12 +27,12 @@ dependencies:
29
27
  segments:
30
28
  - 3
31
29
  version: "3"
30
+ prerelease: false
31
+ requirement: *id001
32
32
  type: :runtime
33
- version_requirements: *id001
33
+ name: activeresource
34
34
  - !ruby/object:Gem::Dependency
35
- name: backports
36
- prerelease: false
37
- requirement: &id002 !ruby/object:Gem::Requirement
35
+ version_requirements: &id002 !ruby/object:Gem::Requirement
38
36
  none: false
39
37
  requirements:
40
38
  - - ">="
@@ -44,65 +42,41 @@ dependencies:
44
42
  - 2
45
43
  - 3
46
44
  version: "2.3"
47
- type: :runtime
48
- version_requirements: *id002
49
- - !ruby/object:Gem::Dependency
50
- name: logger
51
45
  prerelease: false
52
- requirement: &id003 !ruby/object:Gem::Requirement
53
- none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- hash: 3
58
- segments:
59
- - 0
60
- version: "0"
46
+ requirement: *id002
61
47
  type: :runtime
62
- version_requirements: *id003
48
+ name: backports
63
49
  description: Infopark CRM Connector
64
50
  email: info@infopark.de
65
51
  executables: []
66
52
 
67
53
  extensions: []
68
54
 
69
- extra_rdoc_files:
70
- - README.rdoc
71
- - LICENSE
55
+ extra_rdoc_files: []
56
+
72
57
  files:
73
- - CHANGELOG.rdoc
58
+ - .yardopts
59
+ - CHANGELOG.markdown
74
60
  - LICENSE
75
- - README.rdoc
61
+ - README.markdown
76
62
  - lib/crm_connector.rb
77
63
  - lib/crm_connector/account.rb
78
64
  - lib/crm_connector/activity.rb
79
- - lib/crm_connector/base.rb
80
65
  - lib/crm_connector/configuration.rb
81
66
  - lib/crm_connector/contact.rb
82
67
  - lib/crm_connector/core.rb
83
- - lib/crm_connector/core/base.rb
84
68
  - lib/crm_connector/core/continuation_support.rb
85
69
  - lib/crm_connector/core/enumerator.rb
86
70
  - lib/crm_connector/core/known_attributes.rb
87
71
  - lib/crm_connector/core/resource.rb
88
72
  - lib/crm_connector/core/search_support.rb
89
73
  - lib/crm_connector/custom_type.rb
90
- - lib/crm_connector/debugging.rb
91
- - lib/crm_connector/default.rb
92
- - lib/crm_connector/default/account.rb
93
- - lib/crm_connector/default/activity.rb
94
- - lib/crm_connector/default/contact.rb
95
- - lib/crm_connector/default/custom_type.rb
96
- - lib/crm_connector/default/event.rb
97
- - lib/crm_connector/default/event_contact.rb
98
- - lib/crm_connector/default/mailing.rb
99
- - lib/crm_connector/default/resource.rb
100
- - lib/crm_connector/default/role.rb
74
+ - lib/crm_connector/errors.rb
75
+ - lib/crm_connector/errors/authentication_failed.rb
76
+ - lib/crm_connector/errors/base.rb
101
77
  - lib/crm_connector/event.rb
102
78
  - lib/crm_connector/event_contact.rb
103
- - lib/crm_connector/inheriting_resource.rb
104
79
  - lib/crm_connector/mailing.rb
105
- - lib/crm_connector/resource.rb
106
80
  - lib/crm_connector/role.rb
107
81
  - lib/crm_connector/system.rb
108
82
  - lib/infopark_crm_connector.rb
@@ -110,13 +84,8 @@ homepage: http://www.infopark.de
110
84
  licenses: []
111
85
 
112
86
  post_install_message:
113
- rdoc_options:
114
- - --charset
115
- - UTF-8
116
- - --main
117
- - README.rdoc
118
- - --title
119
- - Infopark CRM Connector 0.9.2 Documentation
87
+ rdoc_options: []
88
+
120
89
  require_paths:
121
90
  - lib
122
91
  required_ruby_version: !ruby/object:Gem::Requirement
data/CHANGELOG.rdoc DELETED
@@ -1,87 +0,0 @@
1
- === Version 0.9.2 - 2012-03-19
2
- * Security improvement for +Contact.authenticate+, +Contact.password_set+ and +contact.password_request+
3
-
4
- === Version 0.9.1 - 2012-02-28
5
- * Removed +Diary+. Please use +Activity+ instead.
6
- * Added +Mailing+
7
- * Added +appointment_*+ and +task_*+ fields to +Activity+
8
- * Added +role_names+ field to +Contact+
9
- * Added +tags+ field to +Activity+, +Account+ and +Contact+
10
-
11
- === Version 0.9 - 2012-01-27
12
- Initial Release of Infopark CRM Connector
13
-
14
- ==== Changes from OMC Connector to CRM Connector
15
- * Namespace changed from <tt>OmcConector::</tt> to <tt>Infopark::Crm::</tt>
16
- * Attribute names may have changed. For new attributes please refer to {Webservice API}[https://www.infopark.de/2486249/70-Webservice-API].
17
- * Works only with Infopark WebCRM.
18
-
19
- ===== Changed configuration
20
- * +live_server_groups_callback+ - replaces +contact_roles_callback+
21
-
22
- ===== New classes
23
- * +CustomType+
24
- * +Role+
25
- * +System+
26
-
27
- ===== New methods
28
- * +Account.search+
29
- * +Activity.search+
30
- * +Contact.search+
31
- * +Event.search+
32
- * +EventContact.search+
33
- * +contact.live_server_groups+ - replaces +contact.roles+
34
-
35
- ===== Removed classes
36
- * +AccountCollection+
37
- * +InquiryKind+ - use +CustomType+
38
- * +InquiryLink+
39
- * +Inquiry+ - use +Activity+
40
- * +Location+ - use +contact+ and +account+ properties
41
- * +Mailing+
42
- * +RegistrationInquiry+
43
- * +Session+
44
-
45
-
46
- ===== Removed methods
47
- * +account.contacts+ - use <tt>Contact.search(\:params => {\:acount_id => acount_id})</tt>
48
- * +Account.find_by_name+ - use +Account.search+
49
- * +account.inquiries+ - use <tt>Activity.search(:params => {:account_id => account_id})</tt>
50
- * +account.locations+
51
- * +contact.account_activities+ - use <tt>Activity.search(:query => {:account_id => account_id})</tt>
52
- * +contact.activities+ - use <tt>Activity.search(:params => {:contact_id => contact_id})</tt>
53
- * +contact.create_activity+
54
- * +contact.create_diary+
55
- * +contact.create_location_with_account_association+
56
- * +contact.create_location+
57
- * +contact.create_registration_request+
58
- * +contact.event_participation+
59
- * +contact.find_activity+
60
- * +Contact.find_by_email+ - use <tt>Contact.search(:params => {:email => email})</tt>
61
- * +Contact.find_by_login+ - use <tt>Contact.search(:params => {:login => login})</tt>
62
- * +Contact.languages+
63
- * +contact.location+
64
- * +Contact.lookup_uptions+
65
- * +contact.move_location+
66
- * +contact.roles+ - use +contact.live_server_groups+
67
- * +contact.serialized_attributes+ - use +contact.attributes+
68
- * +contact.subscriptions+
69
- * +Contact.titles+
70
- * +contact.update_location+
71
- * +contact.update_subscriptions+
72
- * +contact.validate_login+ - use <tt>Contact.search(:params => {:login => login})</tt>
73
- * <tt>event.attend(!)</tt>
74
- * +event.contacts+ - use <tt>EventContact.search(:event_id => event_id)</tt>
75
- * +Event.find_by_name+
76
- * <tt>event.inquire(!)</tt>
77
- * <tt>event.refuse(!)</tt>
78
- * <tt>event.register(!)</tt>
79
- * +event_contact.attend+ - use <tt>event_contact.status = 'attended'</tt>
80
- * +event_contact.inquire+ - use <tt>event_contact.status = 'unregistered'</tt>
81
- * +event_contact.refuse+ - use <tt>event_contact.status = 'refused'</tt>
82
- * +event_contact.register+ - use <tt>event_contact.status = 'registered'</tt>
83
- * +event_contact.update_details+
84
- * +inquiry.create_diary+
85
- * +inquiry.create_link+
86
- * +inquiry.diaries+
87
- * +inquiry.links+
data/README.rdoc DELETED
@@ -1,59 +0,0 @@
1
-
2
- ==Quick Start
3
-
4
- gem 'infopark_crm_connector'
5
-
6
- require 'infopark_crm_connector'
7
-
8
- Infopark::Crm.configure do |configuration|
9
- configuration.url = "https://webcrm.server/url"
10
- configuration.login = "webcrm_user"
11
- configuration.api_key = "api_key_of_webcrm_user"
12
- end
13
-
14
- # Communicate with the WebCRM
15
- Infopark::Crm::Contact.first.last_name
16
-
17
- See Infopark::Crm.configure for a complete list of configuration keys.
18
-
19
- The subclasses of Infopark::Crm::Resource (which itself inherits from
20
- ActiveResource::Base) represent the WebCRM's domain models (accounts, contacts, events etc.).
21
-
22
- ==Examples
23
- ===Contact
24
- # Retrieve the contact identified by the login 'root'
25
- contact = Infopark::Crm::Contact.search(:params => {:login => 'root'}).first
26
-
27
- # Change this contact's mail address
28
- contact.update_attribute(:email, 'root@example.com')
29
-
30
- # Send a new password request mail to the contact's address
31
- contact.password_request
32
-
33
- ===Activity
34
-
35
- # Configure a new activity kind
36
- Infopark::Crm::CustomType.create(:name => 'contact form', :kind => 'Activity',
37
- :states => ['new'])
38
-
39
- # Create a new activity
40
- activity = Infopark::Crm::Activity.new(:kind => 'contact form')
41
-
42
- # Set properties of this activity
43
- activity.title = 'Sprechen Sie Deutsch?'
44
-
45
- # Switch to a different request locale
46
- Infopark::Crm.configure {|c| c.locale = 'de'}
47
-
48
- # Post the activity (which is going to fail)
49
- activity.save
50
- # => false
51
-
52
- # Get to know what's missing
53
- activity.errors.messages
54
- # => {:state=>["ist kein gültiger Wert"]}
55
-
56
- For further information on the WebCRM web service, have a look at
57
- {this documentation}[https://www.infopark.com/2486249/70-Webservice-API].
58
-
59
- :include: LICENSE
@@ -1,4 +0,0 @@
1
- module Infopark; module Crm
2
- class Base < Core::Base # :nodoc:
3
- end
4
- end; end
@@ -1,111 +0,0 @@
1
- require 'active_support/core_ext/class/attribute_accessors'
2
-
3
- module Infopark; module Crm
4
- class ConnectorError < StandardError # :nodoc:
5
- end
6
-
7
- # Raised when a contact provides wrong credentials (token/password)
8
- #
9
- # This differs from the case when the web service api credentials are not accepted
10
- # (an ActiveResource error is raised then)
11
- class AuthenticationFailed < ConnectorError; end
12
- end; end
13
-
14
- module Infopark; module Crm; module Core
15
- class Base < ActiveResource::Base # :nodoc: all
16
-
17
- self.format = :json
18
- self.include_root_in_json = true
19
-
20
- cattr_accessor :locale
21
- cattr_accessor :http_host
22
-
23
- #--
24
- # TBD: drop when ActiveResource 3.0 support is dropped
25
- #++
26
- class SchemaSupport
27
- def self.schema_mapping
28
- @schema_mapping ||= {}
29
- end
30
-
31
- def self.add(mapping)
32
- schema_mapping.merge!(mapping)
33
- end
34
-
35
- def self.schema_type(type)
36
- default_mapping = ::ActiveResource::Schema::KNOWN_ATTRIBUTE_TYPES
37
- return type if default_mapping.include?(type.to_s)
38
- return schema_mapping[type.to_sym]
39
- end
40
-
41
- add :text => :string
42
- add :date => :string
43
- add :boolean => nil
44
- end
45
-
46
- def self.schema=(definition)
47
- ares_compatible_definition = {}
48
- definition.each do |k, v|
49
- ares_compatible_definition[k] = SchemaSupport.schema_type(v)
50
- end
51
- super(ares_compatible_definition)
52
- end
53
-
54
- #--
55
- # TBD: remove when https://github.com/rails/rails/issues/2479 is done
56
- #++
57
- def self.delete(id, options = {})
58
- connection.delete(element_path(id, options), headers)
59
- end
60
-
61
- def self.headers
62
- headers = super
63
- headers.merge!({"Accept-Language" => self.locale}) if self.locale
64
- headers.merge!({"Host" => self.http_host}) if self.http_host
65
- headers
66
- end
67
-
68
- def self.configure(configuration)
69
- self.site = configuration.url + '/' if configuration.url
70
- self.user = configuration.login
71
- self.password = configuration.api_key
72
- self.locale = configuration.locale
73
- self.http_host = configuration.http_host
74
- include Debugging if configuration.debug
75
- end
76
-
77
- # Support for field associatable errors (without humanized name guessing)
78
- def errors
79
- @errors ||= Errors.new(self)
80
- end
81
-
82
- class Errors < ActiveResource::Errors # :nodoc:
83
- # TBD temporary patch from https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/5616
84
- def from_json(json, save_cache = false)
85
- errors = ActiveSupport::JSON.decode(json)
86
- clear unless save_cache
87
- errors.each do |attr_name, messages|
88
- Array.wrap(messages).each { |message| add(attr_name.to_sym, message) }
89
- end
90
- end
91
-
92
- def from_xml(xml, *args)
93
- errors = Hash.from_xml(xml)['errors'] rescue {}
94
- structured_errors = Array.wrap(errors['machine_readables'])
95
- if structured_errors.first
96
- clear unless args.first # see ActiveResource::Errors#from_array
97
- structured_errors.each do |h|
98
- h.each do |key, value|
99
- add(key, value)
100
- end
101
- end
102
- else
103
- # legacy omc and simple rails responses
104
- from_array(errors['error'] || [], *args)
105
- end
106
- end
107
- end
108
-
109
- end
110
-
111
- end; end; end