civicrm 1.2.2 → 1.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1001107c2cb7d6f1b6e399b88f1e2ee9a26c5196
4
- data.tar.gz: 1554925cb58d20a13e1f886e64091a8df937a062
3
+ metadata.gz: 4a770859b71bcf18bfff90a976e2dbbec6aa9af3
4
+ data.tar.gz: c884fdf962c79286c4bfd40dc3a606cbcbea06b6
5
5
  SHA512:
6
- metadata.gz: 3f8fcf9979014b625ea99e7b77b89b41921420bb0dc75c797b2af82a66ca6bddd44e851b6e7119be3078b0e9a1fb85bbaa979b6cda5cd14d2d96dae2f3db2b1a
7
- data.tar.gz: 54acf92001088dad4ab6703fbaba1461e9f1816ec5a8df2647298adc4494d53aacd91aafcb13685bec36ba5bcca1681bc57a9749aa3f1151bdfe9af64497a79b
6
+ metadata.gz: 3ad4d02efbc556f3e8eb8bcad2709b1771ea838d596c98c0d5ccabc16647977e73d2219fd5805b879c55ce6bad9c87eeb4853d779618bcaed28b435898261bd9
7
+ data.tar.gz: 28bd41a3ef1fa67487e6a46e86bed8604d730d157141c578f7457d5dff805477cecba12fcd604495358f629a469146b666d30e9701f38a6a81c105d32fe7ff40
@@ -16,6 +16,10 @@ module CiviCrm
16
16
  all(params).first
17
17
  end
18
18
 
19
+ def find_by!(params={})
20
+ find_by(params) or raise Errors::NotFound.new
21
+ end
22
+
19
23
  def first
20
24
  all.first
21
25
  end
@@ -131,6 +131,9 @@ module CiviCrm
131
131
  class Note < BaseResource
132
132
  entity :note
133
133
  end
134
+ class OptionGroup < BaseResource
135
+ entity :option_group
136
+ end
134
137
  class Phone < BaseResource
135
138
  entity :phone
136
139
  end
@@ -153,3 +156,6 @@ module CiviCrm
153
156
  entity :survey_respondant
154
157
  end
155
158
  end
159
+
160
+ require "civicrm/resources/financial_type"
161
+ require "civicrm/resources/option_value"
@@ -0,0 +1,27 @@
1
+ module CiviCrm
2
+ class FinancialType < BaseResource
3
+ entity :financial_type
4
+
5
+ @@_financial_type_cache = {}
6
+
7
+ def self.get(name, cache: true, create: Rails.env.development?)
8
+ cache_key = name
9
+
10
+ if cache && @@_financial_type_cache.key?(cache_key)
11
+ return @@_financial_type_cache[cache_key]
12
+ end
13
+
14
+ type = find_by("name" => name)
15
+ type ||= create(name: name) if create
16
+
17
+ if type
18
+ @@_financial_type_cache[cache_key] = type.id if cache
19
+ return type.id
20
+ end
21
+
22
+ raise Errors::NotFound.new(
23
+ "FinancialType with name=#{name}"
24
+ )
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,34 @@
1
+ module CiviCrm
2
+ class OptionValue < BaseResource
3
+ entity :option_value
4
+
5
+ @@_option_value_cache = {}
6
+
7
+ def self.get(group, name, cache: true, create: Rails.env.development?)
8
+ cache_key = [group, name]
9
+
10
+ if cache && @@_option_value_cache.key?(cache_key)
11
+ return @@_option_value_cache[cache_key]
12
+ end
13
+
14
+ option = find_by(
15
+ 'name' => name,
16
+ 'option_group_id.title' => group
17
+ )
18
+
19
+ if !option && create
20
+ group = OptionGroup.find_by!(title: group)
21
+ option = create(option_group_id: group.id, name: name)
22
+ end
23
+
24
+ if option
25
+ @@_option_value_cache[cache_key] = option.value if cache
26
+ return option.value
27
+ end
28
+
29
+ raise Errors::NotFound.new(
30
+ "#{group} with name=#{name}"
31
+ )
32
+ end
33
+ end
34
+ end
@@ -1,3 +1,3 @@
1
1
  module CiviCrm
2
- VERSION = '1.2.2'
2
+ VERSION = '1.2.5'
3
3
  end
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.2.2
4
+ version: 1.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Iskander Haziev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-01 00:00:00.000000000 Z
11
+ date: 2019-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -139,6 +139,8 @@ files:
139
139
  - lib/civicrm/profiling.rb
140
140
  - lib/civicrm/resource.rb
141
141
  - lib/civicrm/resources/base.rb
142
+ - lib/civicrm/resources/financial_type.rb
143
+ - lib/civicrm/resources/option_value.rb
142
144
  - lib/civicrm/version.rb
143
145
  - spec/requests/base_spec.rb
144
146
  - spec/resources/contact_spec.rb