pipe_drive_ruby_wrapper 0.1.0 → 0.1.1

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
  SHA256:
3
- metadata.gz: 2f24bb5abbf918344616ceabd2c5934d827b679dc3926e0a76b060556f8b0ae1
4
- data.tar.gz: 187ecc5a550e53683944140ddd6d5581e8c75220986395ede513143552983d5c
3
+ metadata.gz: b284c3238b3325431be152a084566d4b72d37c5ff297bfb11454f5efcd30f9b1
4
+ data.tar.gz: f78170f0a97ec45b6a37d7e0a857c64b161ca549fb60b96c585028f90dac0a69
5
5
  SHA512:
6
- metadata.gz: 144a7b8c10025bf67798ccfd139df42fd68a294d5ab34cbfc29d4ec2b78b23967db94676e3c65a4fb9b865e019257377889def5d2b7b357a03ff95357b968c9e
7
- data.tar.gz: 26487cc9cc903902a46b8dcf68cc10d59963350d917f728ebbfa4995761634bce3590f1841042965c38e06b86176f7d38a5371437f0cc6592e4ee6530c89882f
6
+ metadata.gz: '088ea8e8b1baeb2f2cbf68bfb5b391c0095d485a5ebc1dca1de372930dd6b213366b555c0f5e501d1223ee9ca82af537d2f2f21f532f387e2ae8fc506a7641ac'
7
+ data.tar.gz: 7d20b3d12674a628bf73a2d1c176ac3e08e485bdbb466bfe25b06d6a11e1fdef2fe6569cf439bb915475e056afd3c8f9ea805ae9c9aa15d90e4ed32de73c4749
@@ -28,12 +28,14 @@ module PipeDrive
28
28
  new_field.add_to_field_keys
29
29
  end
30
30
 
31
- def custom_field_setup
31
+ def field_keys_map
32
+ field_keys_map = Hash.new{|hash, key| hash[key] = {}}
32
33
  resource = correspond_resource.to_sym
33
34
  list.each do |field|
34
35
  field_name = parameterize(field.name, '_').to_sym
35
- PipeDrive.field_keys[resource][field_name] = field.key
36
+ field_keys_map[resource][field_name] = field.key
36
37
  end
38
+ field_keys_map
37
39
  end
38
40
 
39
41
  def cache_keys
@@ -44,7 +46,7 @@ module PipeDrive
44
46
  cache_field_name = parameterize(field_name, '_').to_sym
45
47
  pipedrive_key = cache_keys[cache_field_name]
46
48
  return pipedrive_key unless pipedrive_key.nil?
47
- custom_field_setup
49
+ PipeDrive.field_keys = nil
48
50
  pipedrive_key = cache_keys[cache_field_name]
49
51
  if pipedrive_key.nil?
50
52
  raise TargetNotFound.new(self.name, :name, field_name)
@@ -5,12 +5,14 @@ module PipeDrive
5
5
 
6
6
  class << self
7
7
 
8
- def setup_stage_ids
8
+ def stage_ids_map
9
+ stage_ids_map = Hash.new {|hash, key| hash[key] = {}}
9
10
  list.each do |stage|
10
11
  pipeline_name = parameterize(stage.pipeline_name, '_').to_sym
11
12
  stage_name = parameterize(stage.name, '_').to_sym
12
- PipeDrive.stage_ids[pipeline_name][stage_name] = stage.id
13
+ stage_ids_map[pipeline_name][stage_name] = stage.id
13
14
  end
15
+ stage_ids_map
14
16
  end
15
17
 
16
18
  end
@@ -11,25 +11,27 @@ module PipeDrive
11
11
  RESOURCE_CLASSES = %w[Organization Person Deal]
12
12
  FIELD_CLASSES = %w[OrganizationField PersonField DealField]
13
13
 
14
- class << self; attr_accessor :api_token, :field_keys, :stage_ids; end
14
+ class << self; attr_accessor :api_token; end
15
+ class << self; attr_writer :field_keys, :stage_ids; end
15
16
 
16
17
  class << self
17
18
  def setup
18
19
  yield self
20
+ self
21
+ end
19
22
 
20
- if field_keys.nil?
21
- self.field_keys = Hash.new{|hash, key| hash[key] = {}}
22
- FIELD_CLASSES.each do |class_name|
23
- const_get(class_name).custom_field_setup
24
- end
25
- end
26
-
27
- if stage_ids.nil?
28
- self.stage_ids = Hash.new{|hash, key| hash[key] = {}}
29
- Stage.setup_stage_ids
23
+ def field_keys
24
+ return @field_keys unless @field_keys.nil? || @field_keys.empty?
25
+ @field_keys = {}
26
+ FIELD_CLASSES.each do |class_name|
27
+ @field_keys.merge!(const_get(class_name).field_keys_map)
30
28
  end
29
+ @field_keys
30
+ end
31
31
 
32
- self
32
+ def stage_ids
33
+ return @stage_ids unless @stage_ids.nil? || @stage_ids.empty?
34
+ @stage_ids = Stage.stage_ids_map
33
35
  end
34
36
 
35
37
  def host
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pipe_drive_ruby_wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - JiaRou Lee