pipe_drive_ruby_wrapper 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pipe_drive/base.rb +18 -7
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 975c71b436b22384e3afea10a07730a4c62c455a70d2eb071ad72705ef2eeda2
4
- data.tar.gz: 29b8c7a98cc9a65744a8b367d150e1f72a3c0684a601034a26a2bb81e00cdaf1
3
+ metadata.gz: 7a0306cb9643370e9c2bdc925d0b0b9d0457d0a397e918f64d007e33d96db583
4
+ data.tar.gz: 995f2307d138885030d5f0b2bfaacfc2c69680cd4817a4e34cef60ffd0a36364
5
5
  SHA512:
6
- metadata.gz: d1aab8a3d2d54b7154ec3a6c2fa691bafcb6f43170eeaa991821427a1a8c189c0a5db8d267496dc60c68d46fc7a44f4ede08c9c388b957649b2e4c62ff598c03
7
- data.tar.gz: f64451c47731ae413824f4e5041136eb2a203d0c6193887b2073e36f758c3331dbc617c2991f0e934099075d25a7683a059eadce3c427ca3cf472303c803fe4d
6
+ metadata.gz: 8f13c5c3cf4ca52b0d8d2418d1d2e7cf2770ab203679fb1efcf8153b9d0b1c59c4c34d587af15557942c37c92cc5972bc18c4484f95390897d6cf4309ba7ca34
7
+ data.tar.gz: beec160b8ab90d67935ec626cef412e28a0d06a44ab7081b21a6e56fe0e29d3b404f39d5127fd340b43765f687201ae15fc99bd140bf8a2c7b29b74d87812d72
@@ -109,13 +109,9 @@ module PipeDrive
109
109
  new_opts[key] = value
110
110
  else
111
111
  new_key = resource_class.field_keys[key][:key]
112
- if value.is_a?(Array)
113
- field_info = field_class.find_by_id(resource_class.field_keys[key][:id])
114
- new_value = value.map do |val|
115
- target = field_info.options.find{|f| f[:label] == val}
116
- target[:id] unless target.nil?
117
- end
118
- new_value.compact!
112
+ field_info = field_class.find_by_id(resource_class.field_keys[key][:id])
113
+ if field_info.field_type == 'set' || field_info.field_type == 'enum'
114
+ new_value = detect_option_value(field_info, value)
119
115
  else
120
116
  new_value = value
121
117
  end
@@ -124,6 +120,21 @@ module PipeDrive
124
120
  end
125
121
  new_opts
126
122
  end
123
+
124
+ private
125
+
126
+ def detect_option_value(field_info, value)
127
+ if value.is_a?(Array)
128
+ new_value = value.map do |val|
129
+ target = field_info.options.find{|f| f[:label] == val}
130
+ target[:id] unless target.nil?
131
+ end
132
+ new_value.compact
133
+ else
134
+ target = field_info.options.find{|f| f[:label] == value}
135
+ target.nil? ? nil : target[:id]
136
+ end
137
+ end
127
138
 
128
139
  end
129
140
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pipe_drive_ruby_wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - JiaRou Lee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-18 00:00:00.000000000 Z
11
+ date: 2018-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec