exact 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
  SHA1:
3
- metadata.gz: 84a6a669af80d51b9c64b1d652fa8bca6be89077
4
- data.tar.gz: 865b3306405fa1653a9f126d60c154e25d2bae4e
3
+ metadata.gz: 8a092cbb7141b2321d93b2e51967aab2ab1beb85
4
+ data.tar.gz: c1b18d831d1c400e9a6bdd7f3282c23b07c7e8e7
5
5
  SHA512:
6
- metadata.gz: 50a72ed9a2ee05b800298b61cdd2e92c13ffc493be3c2c6e63b1826454fd828945ea0ec4e18a152bab7dc7d12827de88f2c2ea271c2bbb64fec26dacc64d61c1
7
- data.tar.gz: 645119abfc84882c18914d9b7f33516dd5d6b45496878614c8b98c4d99cae0e501d55ff07d8ce53d449d3abcfe500ede42f84331bc20d56caba6a057aa15fbf6
6
+ metadata.gz: 3d6efbc561217ca41cd31a953c7726ee24345364347b25b829e920ddff0e79534947f896c1c887e09af5ea6a6787832fedee133bd88bc151dbe4739606a752d3
7
+ data.tar.gz: 0a2ade87d1590a9594784a92cd97d814bf85292eaaf6e3e4570a5cadfffa0b6c8ed30199efcfda8e712d40de103452aaa73e50e3c5d129dd59f441081ae7297d
@@ -22,11 +22,11 @@ module Exact
22
22
  attribute :Format, String
23
23
  attribute :IBAN, String
24
24
  attribute :ID, String
25
- attribute :Main, Boolean
25
+ attribute :Main, Boolean, default: true
26
26
  attribute :Modified, DateTime
27
27
  attribute :Modifier, String
28
28
  attribute :ModifierFullName, String
29
- attribute :Type, String
30
- attribute :TypeDescription, String
29
+ attribute :Type, String, default: 'A'
30
+ attribute :TypeDescription, String, default: 'Account'
31
31
  end
32
32
  end
@@ -26,7 +26,9 @@ module Exact
26
26
  end
27
27
 
28
28
  def self.exact_endpoint
29
- to_s.demodulize.pluralize.camelize
29
+ name = Object.const_get("#{self}::EXACT_ENDPOINT") rescue nil
30
+ name = to_s.demodulize.pluralize.camelize unless name
31
+ name
30
32
  end
31
33
 
32
34
  def exact_endpoint
@@ -50,8 +52,8 @@ module Exact
50
52
  end
51
53
 
52
54
  def self.create(attributes: {}, client:)
53
- exact_obj = Exactonline.const_get(to_s.demodulize).new(attributes)
54
- client.send("AddTo#{to_s.demodulize.pluralize}", exact_obj)
55
+ exact_obj = Exactonline.const_get(exact_endpoint.singularize).new(attributes)
56
+ client.send("AddTo#{exact_endpoint}", exact_obj)
55
57
  result = client.save_changes
56
58
  result.map! { |obj| Exact.const_get("#{to_s.demodulize}Mapping").convert obj }
57
59
  result.first
@@ -88,6 +90,7 @@ module Exact
88
90
  end
89
91
 
90
92
  def update(client:)
93
+ return false if guid.blank?
91
94
  client.send(exact_endpoint).filter("#{exact_guid_attribute} eq guid'#{guid}'")
92
95
  result = client.execute
93
96
  return false unless result.any?
@@ -101,11 +104,10 @@ module Exact
101
104
  end
102
105
 
103
106
  def save(client:)
104
- if guid.present?
107
+ if !guid.blank?
105
108
  update(client: client)
106
109
  else
107
- result = self.class.create(attributes: attributes, client: client) unless guid.present?
108
- self.attributes = result.attributes
110
+ self.attributes = self.class.create(attributes: attributes, client: client).attributes
109
111
  self
110
112
  end
111
113
  end
@@ -3,8 +3,9 @@ module Exact
3
3
  include ActiveModel::Model
4
4
  include Virtus.model
5
5
 
6
- EXACT_SERVICE = 'hrm'
7
- EXACT_GUID = 'ID'
6
+ EXACT_SERVICE = 'hrm'
7
+ EXACT_GUID = 'ID'
8
+ EXACT_ENDPOINT = 'Costcenters'
8
9
 
9
10
  attribute :Active, Boolean
10
11
  attribute :Code, String
@@ -3,8 +3,9 @@ module Exact
3
3
  include ActiveModel::Model
4
4
  include Virtus.model
5
5
 
6
- EXACT_SERVICE = 'hrm'
7
- EXACT_GUID = 'ID'
6
+ EXACT_SERVICE = 'hrm'
7
+ EXACT_GUID = 'ID'
8
+ EXACT_ENDPOINT = 'Costunits'
8
9
 
9
10
  attribute :Code, String
10
11
  attribute :Created, DateTime
data/lib/exact/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Exact
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exact
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
  - zzk