civicrm 1.3.2 → 1.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile.lock +17 -13
- data/README.md +24 -0
- data/VERSION +1 -1
- data/civicrm.gemspec +2 -1
- data/lib/civicrm.rb +2 -1
- data/lib/civicrm/actions/create.rb +5 -3
- data/lib/civicrm/client.rb +6 -4
- data/lib/civicrm/errors.rb +5 -5
- data/lib/civicrm/resources/base.rb +3 -0
- data/lib/civicrm/resources/custom_field.rb +2 -2
- data/lib/civicrm/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8368cd231e0941132210ff8bf11724816e59242958ac47d458eddb512b93aad4
|
4
|
+
data.tar.gz: 8df3d8a938b2b722c8329f2464bcb42b0e153464e1914fc21bc14721c340b707
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af3a1b5c342f2d22c3da940c958c2e0e926a1097b93b5bf32da901eba25881a066ab65732fab32c77a916eae6b7ec27d49f608f01c9f102f56451a4115a8707d
|
7
|
+
data.tar.gz: 71a5213a6e9fcc38c01310b2b9a06987284bb902512c2426113df859e24947d3a038ccdfb598e976b876a7218a40e0697829b177747d7b787ed0697dc4ebb786
|
data/Gemfile.lock
CHANGED
@@ -1,41 +1,44 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
civicrm (1.3.
|
4
|
+
civicrm (1.3.5)
|
5
5
|
activemodel
|
6
6
|
activesupport
|
7
|
-
nokogiri
|
7
|
+
nokogiri (>= 1.10.8)
|
8
8
|
rest-client (~> 2.0)
|
9
9
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
-
activemodel (
|
14
|
-
activesupport (=
|
15
|
-
activesupport (
|
13
|
+
activemodel (6.0.2.1)
|
14
|
+
activesupport (= 6.0.2.1)
|
15
|
+
activesupport (6.0.2.1)
|
16
16
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
17
|
i18n (>= 0.7, < 2)
|
18
18
|
minitest (~> 5.1)
|
19
19
|
tzinfo (~> 1.1)
|
20
|
+
zeitwerk (~> 2.2)
|
20
21
|
byebug (10.0.2)
|
21
|
-
concurrent-ruby (1.1.
|
22
|
+
concurrent-ruby (1.1.6)
|
22
23
|
diff-lcs (1.3)
|
23
24
|
domain_name (0.5.20190701)
|
24
25
|
unf (>= 0.0.5, < 1.0.0)
|
26
|
+
http-accept (1.7.0)
|
25
27
|
http-cookie (1.0.3)
|
26
28
|
domain_name (~> 0.5)
|
27
|
-
i18n (1.
|
29
|
+
i18n (1.8.2)
|
28
30
|
concurrent-ruby (~> 1.0)
|
29
|
-
mime-types (3.
|
31
|
+
mime-types (3.3.1)
|
30
32
|
mime-types-data (~> 3.2015)
|
31
|
-
mime-types-data (3.2019.
|
33
|
+
mime-types-data (3.2019.1009)
|
32
34
|
mini_portile2 (2.4.0)
|
33
|
-
minitest (5.
|
35
|
+
minitest (5.14.0)
|
34
36
|
netrc (0.11.0)
|
35
|
-
nokogiri (1.10.
|
37
|
+
nokogiri (1.10.8)
|
36
38
|
mini_portile2 (~> 2.4.0)
|
37
39
|
rake (10.0.3)
|
38
|
-
rest-client (2.0
|
40
|
+
rest-client (2.1.0)
|
41
|
+
http-accept (>= 1.7.0, < 2.0)
|
39
42
|
http-cookie (>= 1.0.2, < 2.0)
|
40
43
|
mime-types (>= 1.16, < 4.0)
|
41
44
|
netrc (~> 0.8)
|
@@ -53,11 +56,12 @@ GEM
|
|
53
56
|
rspec-support (~> 3.8.0)
|
54
57
|
rspec-support (3.8.0)
|
55
58
|
thread_safe (0.3.6)
|
56
|
-
tzinfo (1.2.
|
59
|
+
tzinfo (1.2.6)
|
57
60
|
thread_safe (~> 0.1)
|
58
61
|
unf (0.1.4)
|
59
62
|
unf_ext
|
60
63
|
unf_ext (0.0.7.6)
|
64
|
+
zeitwerk (2.2.2)
|
61
65
|
|
62
66
|
PLATFORMS
|
63
67
|
ruby
|
data/README.md
CHANGED
@@ -13,6 +13,9 @@ $ gem install civicrm
|
|
13
13
|
CiviCrm.api_base = "https://www.example.org/path/to/civi/codebase/"
|
14
14
|
CiviCrm.site_key = "YOUR_SITE_KEY"
|
15
15
|
CiviCrm.api_key = "..."
|
16
|
+
|
17
|
+
# Optional config
|
18
|
+
CiviCrm.timeout = 60 # Change request timeout in seconds (nil to disable)
|
16
19
|
```
|
17
20
|
|
18
21
|
## CiviCrm Objects
|
@@ -34,6 +37,27 @@ CiviCrm::Contact.find(1).delete
|
|
34
37
|
$ bundle exec rspec spec
|
35
38
|
```
|
36
39
|
|
40
|
+
## Debugging
|
41
|
+
|
42
|
+
Set these `ENV` options to a truthy value to print CiviCRM REST API data.
|
43
|
+
|
44
|
+
```DEBUG_CIVICRM_REQUEST```
|
45
|
+
|
46
|
+
Example:
|
47
|
+
|
48
|
+
```
|
49
|
+
[CiviCRM] [REQ] [FinancialType] [get] {"method":"post","timeout":null,"headers":{"user_agent":"CiviCrm RubyClient/1.3.6","request_id":"8168cbfc-36d1-4967-bf94-8fd72fd48455"},"payload":{"json":"{\"id\":12}"},"url":"..."}
|
50
|
+
```
|
51
|
+
|
52
|
+
```DEBUG_CIVICRM_RESPONSE```
|
53
|
+
|
54
|
+
Example:
|
55
|
+
|
56
|
+
```
|
57
|
+
[CiviCRM] [RES] [FinancialType] [get] {"is_error":0,"version":3,"count":1,"id":12,"values":{"12":{"id":"12","name":"Matching Gift","is_deductible":"0","is_active":"1"}}}
|
58
|
+
```
|
59
|
+
|
60
|
+
|
37
61
|
## Useful links
|
38
62
|
|
39
63
|
* https://docs.civicrm.org/dev/en/latest/api/interfaces/#rest-interface
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.3.7
|
data/civicrm.gemspec
CHANGED
@@ -12,11 +12,12 @@ spec = Gem::Specification.new do |s|
|
|
12
12
|
s.homepage = 'http://civicrm.org'
|
13
13
|
s.executables = 'civicrm'
|
14
14
|
s.require_paths = %w{lib}
|
15
|
+
s.required_ruby_version = '>= 2.0'
|
15
16
|
|
16
17
|
s.add_dependency('rest-client', '~> 2.0')
|
17
18
|
s.add_dependency('activesupport')
|
18
19
|
s.add_dependency('activemodel')
|
19
|
-
s.add_dependency('nokogiri')
|
20
|
+
s.add_dependency('nokogiri', '>= 1.10.8')
|
20
21
|
|
21
22
|
s.add_development_dependency('rake')
|
22
23
|
s.add_development_dependency('rspec', '~> 3.8')
|
data/lib/civicrm.rb
CHANGED
@@ -35,8 +35,9 @@ module CiviCrm
|
|
35
35
|
@@site_key = nil
|
36
36
|
@@api_base = 'https://www.example.org/path/to/civi/codebase'
|
37
37
|
@@api_version = 'v3'
|
38
|
+
@@timeout = 80
|
38
39
|
|
39
|
-
mattr_accessor :api_key, :api_base, :api_version, :site_key
|
40
|
+
mattr_accessor :api_key, :api_base, :api_version, :site_key, :timeout
|
40
41
|
|
41
42
|
def self.api_url(path = '')
|
42
43
|
base = "#{api_base}/civicrm/extern/rest.php?#{path}"
|
@@ -6,11 +6,13 @@ module CiviCrm
|
|
6
6
|
params = {'entity' => entity_class_name, 'action' => 'create'}
|
7
7
|
response = CiviCrm::Client.request(:post, params.merge(attrs))
|
8
8
|
|
9
|
-
if response
|
9
|
+
if response == 1
|
10
|
+
Resource.build_from(attrs, params)
|
11
|
+
elsif response.first.nil?
|
10
12
|
raise Error, "Couldn't create #{entity_class_name}"
|
13
|
+
else
|
14
|
+
Resource.build_from(response.first, params)
|
11
15
|
end
|
12
|
-
|
13
|
-
Resource.build_from(response.first, params)
|
14
16
|
end
|
15
17
|
end
|
16
18
|
|
data/lib/civicrm/client.rb
CHANGED
@@ -10,12 +10,13 @@ module CiviCrm
|
|
10
10
|
end
|
11
11
|
|
12
12
|
headers = {
|
13
|
-
:user_agent => "CiviCrm RubyClient/#{CiviCrm::VERSION}"
|
13
|
+
:user_agent => "CiviCrm RubyClient/#{CiviCrm::VERSION}",
|
14
|
+
:request_id => SecureRandom.uuid
|
14
15
|
}
|
15
16
|
|
16
17
|
opts = {
|
17
18
|
:method => :post,
|
18
|
-
:timeout =>
|
19
|
+
:timeout => CiviCrm.timeout,
|
19
20
|
:headers => headers
|
20
21
|
}
|
21
22
|
|
@@ -34,12 +35,13 @@ module CiviCrm
|
|
34
35
|
|
35
36
|
response = nil
|
36
37
|
|
38
|
+
puts("[CiviCRM] [REQ] [#{entity}] [#{action}] #{JSON.dump(opts)}") if ENV["DEBUG_CIVICRM_REQUEST"]
|
39
|
+
|
37
40
|
CiviCrm.time(params['entity'], params['action']) do
|
38
41
|
response = execute(opts)
|
39
42
|
end
|
40
43
|
|
41
|
-
puts(
|
42
|
-
puts(response) if ENV["DEBUG_CIVICRM_RESPONSE"]
|
44
|
+
puts("[CiviCRM] [RES] [#{entity}] [#{action}] #{response}") if ENV["DEBUG_CIVICRM_RESPONSE"]
|
43
45
|
|
44
46
|
body, code = response.body, response.code
|
45
47
|
|
data/lib/civicrm/errors.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
module CiviCrm
|
2
2
|
module Errors
|
3
|
-
class Unauthorized <
|
4
|
-
class InternalError <
|
5
|
-
class Forbidden <
|
6
|
-
class BadRequest <
|
7
|
-
class NotFound <
|
3
|
+
class Unauthorized < RuntimeError; end
|
4
|
+
class InternalError < RuntimeError; end
|
5
|
+
class Forbidden < RuntimeError; end
|
6
|
+
class BadRequest < RuntimeError; end
|
7
|
+
class NotFound < RuntimeError; end
|
8
8
|
end
|
9
9
|
end
|
@@ -5,7 +5,7 @@ module CiviCrm
|
|
5
5
|
@@_custom_field_cache = {}
|
6
6
|
|
7
7
|
def self.[](entity, field, cache: true)
|
8
|
-
cache_key =
|
8
|
+
cache_key = [entity.underscore, field].join("/")
|
9
9
|
|
10
10
|
if cache && @@_custom_field_cache.key?(cache_key)
|
11
11
|
return @@_custom_field_cache[cache_key]
|
@@ -24,7 +24,7 @@ module CiviCrm
|
|
24
24
|
end
|
25
25
|
|
26
26
|
raise Errors::NotFound.new(
|
27
|
-
"CustomField of #{entity} with name=#{
|
27
|
+
"CustomField of #{entity} with name=#{field}"
|
28
28
|
)
|
29
29
|
end
|
30
30
|
|
data/lib/civicrm/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: civicrm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Iskander Haziev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 1.10.8
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 1.10.8
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -160,7 +160,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
160
160
|
requirements:
|
161
161
|
- - ">="
|
162
162
|
- !ruby/object:Gem::Version
|
163
|
-
version: '0'
|
163
|
+
version: '2.0'
|
164
164
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
165
|
requirements:
|
166
166
|
- - ">="
|
@@ -168,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
168
|
version: '0'
|
169
169
|
requirements: []
|
170
170
|
rubyforge_project:
|
171
|
-
rubygems_version: 2.
|
171
|
+
rubygems_version: 2.7.11
|
172
172
|
signing_key:
|
173
173
|
specification_version: 4
|
174
174
|
summary: Ruby bindings for the CiviCRM API
|