amorail 0.6.0 → 0.6.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: 6047ec19aa4839d30b29fc1cb9ee38079a04812b2ed6547d2e24e1e8ed16a57d
4
- data.tar.gz: 64bfbcd2f8574b70c420a274bd8707533b4f4334020d180fda7acb85cdcee509
3
+ metadata.gz: 0ad5de495defa31c023d17cb5733c2d51e56f4dd08b348e8259ee80986ec6c12
4
+ data.tar.gz: 2682594dd0d1c3661497b4712ad5751b9b7f7e2b67aa9f472151881ad8410e29
5
5
  SHA512:
6
- metadata.gz: 55fc29183cff4df2db947a76ceae748d289ebab1f1e88310e7c13234dd75886c87e9f68c41b782ba251be69f2226f386501974108ce2cc00fdc656e1ccdfe059
7
- data.tar.gz: da64fc02f0bc506319bd543e7b35cb5dfdd3b112cc04458f25904c5d9ece1bc38df8d659ca1d705e17fcea8e7cd82e954c7f4642048fb2ed627a03c0f1802b8c
6
+ metadata.gz: '089d26d7753c6b30108b65f119fa615e1ce3e7fad256ef4f4893d0737f9dcdcc4e5eabc42d49b75bb86c9dccc0ad5d8fe06779f0140d65450ddb58810b4998eb'
7
+ data.tar.gz: ff5cc0582d9bc552886efeb5bcb6fd0aa53a7ca930a682d1fba846719fc3be068966ea77103f5c20590c9f5597397f3cfe6518c02da6e7cf8220d5b3247adae6
@@ -34,7 +34,7 @@ module Amorail
34
34
 
35
35
  def amo_property(name, options = {})
36
36
  properties[name] = options
37
- attr_accessor(name)
37
+ attr_accessor(options.fetch(:method_name, name))
38
38
  end
39
39
 
40
40
  def attributes
@@ -89,7 +89,7 @@ module Amorail
89
89
  return if fields.nil?
90
90
 
91
91
  fields.each do |f|
92
- fname = f['code'] || f['name']
92
+ fname = custom_field_name(f)
93
93
  next if fname.nil?
94
94
 
95
95
  fname = "#{fname.downcase}="
@@ -98,6 +98,15 @@ module Amorail
98
98
  end
99
99
  end
100
100
 
101
+ def custom_field_name(field)
102
+ fname = field['code'] || field['name']
103
+ return if fname.nil?
104
+
105
+ fname = self.class.properties
106
+ .fetch(fname.downcase, {})[:method_name] || fname
107
+ fname
108
+ end
109
+
101
110
  # call safe method <safe_request>. safe_request call authorize
102
111
  # if current session undefined or expires.
103
112
  def push(method)
@@ -21,10 +21,9 @@ module Amorail # :nodoc: all
21
21
  props = properties.send(self.class.amo_name)
22
22
 
23
23
  custom_fields = []
24
-
25
24
  self.class.properties.each do |k, v|
26
25
  prop_id = props.send(k).id
27
- prop_val = { value: send(k) }.merge(v)
26
+ prop_val = { value: send(v.fetch(:method_name, k)) }.merge(v)
28
27
  custom_fields << { id: prop_id, values: [prop_val] }
29
28
  end
30
29
 
@@ -4,15 +4,15 @@ module Amorail
4
4
  # Return hash key as method call
5
5
  module MethodMissing
6
6
  def method_missing(method_sym, *arguments, &block)
7
- if data.key?(method_sym.to_s)
8
- data.fetch(method_sym.to_s)
7
+ if data.key?(method_sym.to_s.downcase)
8
+ data.fetch(method_sym.to_s.downcase)
9
9
  else
10
10
  super
11
11
  end
12
12
  end
13
13
 
14
14
  def respond_to_missing?(method_sym, *args)
15
- args.size.zero? && data.key?(method_sym.to_s)
15
+ args.size.zero? && data.key?(method_sym.to_s.downcase)
16
16
  end
17
17
  end
18
18
 
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Amorail version
4
4
  module Amorail
5
- VERSION = '0.6.0'
5
+ VERSION = '0.6.1'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amorail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - alekseenkoss
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-11-08 00:00:00.000000000 Z
12
+ date: 2019-11-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -270,7 +270,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
270
270
  - !ruby/object:Gem::Version
271
271
  version: '0'
272
272
  requirements: []
273
- rubygems_version: 3.0.4
273
+ rubygems_version: 3.0.6
274
274
  signing_key:
275
275
  specification_version: 4
276
276
  summary: Ruby API client for AmoCRM