intacctrb 0.6.5 → 0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fcb2eff5aa2bf248ac441bf1ea888e0db3f25fb343229e7c1d4599ed80e13d6a
4
- data.tar.gz: 8f9a3617ec7ba7fb403a1579082e1458073bc3186afc2675bc727bfc6353dc9c
3
+ metadata.gz: 2d4e19d9f812d2398ecefc363dc47ec23f47c73032b8b1cefa0a6c1315eef6b0
4
+ data.tar.gz: 4633dc926482dc271c874c5c49605da4654924368a008a3a47f0ba80bd0d40cf
5
5
  SHA512:
6
- metadata.gz: 45d4ccdc0f0396d3309b138794d19990fe7d6b4e7070acf4052fe4a286b8fda49147f5b8535b09429e561bd449856bf4a66bf4578839d4d5be55f1ef0359a4e6
7
- data.tar.gz: 1489a77d89728c8d3f44a4349764960140264c372493b6f302aca7c965e79b1a3cdfdabed646b9e3430b04350e3189814e24e9980dc492956520f7b8d13e5f20
6
+ metadata.gz: 0eccba7d30ebcbbfd4952ff4d92f7ba5fbd10a23fc4bd3a2612ecb0431a47a3c81acde2ca8d942ce301f06db7777d33bf64b783932bbbf5ec46dc0c3f2c09262
7
+ data.tar.gz: d8bd2f6d5c721b810df42c2429a9e65389c8b68af23e1397ab8daceadb6e69cccacd4bbcef97ad6a955b794adfa565441ea6cb601d275e44bf1d53a2258148e9
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- intacctrb (0.6.5)
4
+ intacctrb (0.7)
5
5
  hooks
6
6
  nokogiri
7
7
 
@@ -100,9 +100,9 @@ module IntacctRB
100
100
  end
101
101
  end
102
102
 
103
- def return_result(response)
103
+ def return_result(response, data = nil)
104
104
  if successful?
105
- data = OpenStruct.new({result: true, object: response})
105
+ data = OpenStruct.new({result: true, object: response, data: data})
106
106
  else
107
107
  data = OpenStruct.new({result: false})
108
108
  response.xpath("//result/errormessage/error").each do |error|
@@ -1,7 +1,7 @@
1
1
  module IntacctRB
2
2
  class Contact < IntacctRB::Base
3
3
  def create
4
- send_xml('create') do |xml|
4
+ response = send_xml('create') do |xml|
5
5
  xml.function(controlid: "1") {
6
6
  xml.send("create") {
7
7
  contact_xml(xml)
@@ -12,6 +12,34 @@ module IntacctRB
12
12
  return_result(response)
13
13
  end
14
14
 
15
+ def get_by_name(options = {})
16
+ # return false unless object.intacct_id.present?
17
+
18
+ options[:fields] = [
19
+ :contactid,
20
+ :contactname
21
+ ] if options[:fields].nil?
22
+
23
+ response = send_xml('get') do |xml|
24
+ xml.function(controlid: "f4") {
25
+ xml.readByName {
26
+ xml.object 'contact'
27
+ xml.keys object.try(:name) || options[:name]
28
+ xml.fields '*'
29
+ }
30
+ }
31
+ end
32
+
33
+ if successful?
34
+ data = OpenStruct.new({
35
+ id: response.at("//contact/RECORDNO").try(:content),
36
+ name: response.at("//contact/CONTACTNAME").try(:content)
37
+ })
38
+ end
39
+
40
+ return_result(response, data)
41
+ end
42
+
15
43
  def get(options = {})
16
44
  # return false unless object.intacct_id.present?
17
45
 
@@ -20,7 +48,7 @@ module IntacctRB
20
48
  :contactname
21
49
  ] if options[:fields].nil?
22
50
 
23
- send_xml('get') do |xml|
51
+ response = send_xml('get') do |xml|
24
52
  xml.function(controlid: "f4") {
25
53
  xml.read {
26
54
  xml.object 'contact'
@@ -31,13 +59,13 @@ module IntacctRB
31
59
  end
32
60
 
33
61
  if successful?
34
- @data = OpenStruct.new({
62
+ data = OpenStruct.new({
35
63
  id: response.at("//contact/RECORDNO").content,
36
64
  name: response.at("//contact/CONTACTNAME").content
37
65
  })
38
66
  end
39
67
 
40
- successful?
68
+ return_result(response, data)
41
69
  end
42
70
 
43
71
  def get_list *fields
@@ -49,7 +77,7 @@ module IntacctRB
49
77
  :termname
50
78
  ] if fields.empty?
51
79
 
52
- send_xml('get_list') do |xml|
80
+ response = send_xml('get_list') do |xml|
53
81
  xml.function(controlid: "f4") {
54
82
  xml.get_list(object: "contact", maxitems: "10", showprivate:"false") {
55
83
  # xml.fields {
@@ -70,14 +98,14 @@ module IntacctRB
70
98
  # end
71
99
  #
72
100
  # successful?
73
- puts response
101
+ return_result(response)
74
102
  end
75
103
 
76
104
  def update updated_contact = false
77
105
  @object = updated_contact if updated_contact
78
106
  return false unless object.intacct_id.present?
79
107
 
80
- send_xml('update') do |xml|
108
+ response = send_xml('update') do |xml|
81
109
  xml.function(controlid: "1") {
82
110
  xml.update {
83
111
  contact_xml(xml, true)
@@ -91,7 +119,7 @@ module IntacctRB
91
119
  def delete
92
120
  return false unless object.intacct_id.present?
93
121
 
94
- @response = send_xml('delete') do |xml|
122
+ response = send_xml('delete') do |xml|
95
123
  xml.function(controlid: "1") {
96
124
  xml.delete_contact(contactid: intacct_id)
97
125
  }
@@ -103,8 +131,8 @@ module IntacctRB
103
131
  def contact_xml(xml, is_update = false)
104
132
  xml.contact {
105
133
  xml.recordno object.intacct_id if object.intacct_id
106
- xml.contactname object.name unless (is_update || object.intacct_id.nil?)
107
- xml.printas object.name
134
+ xml.contactname object.name if object.name
135
+ xml.printas object.name if object.name
108
136
  # COMPANYNAME Optional string Company name
109
137
  # TAXABLE Optional boolean Taxable. Use false for No, true for Yes. (Default: true)
110
138
  # TAXGROUP Optional string Contact tax group name
@@ -1,7 +1,7 @@
1
1
  module IntacctRB
2
2
  class Employee < IntacctRB::Base
3
3
  def create
4
- send_xml('create') do |xml|
4
+ response = send_xml('create') do |xml|
5
5
  xml.function(controlid: "1") {
6
6
  xml.send("create") {
7
7
  employee_xml(xml)
@@ -20,7 +20,7 @@ module IntacctRB
20
20
  :contactname
21
21
  ] if options[:fields].nil?
22
22
 
23
- send_xml('get') do |xml|
23
+ response = send_xml('get') do |xml|
24
24
  xml.function(controlid: "f4") {
25
25
  xml.read {
26
26
  xml.object 'EMPLOYEE'
@@ -31,7 +31,7 @@ module IntacctRB
31
31
  end
32
32
 
33
33
  if successful?
34
- @data = OpenStruct.new({
34
+ data = OpenStruct.new({
35
35
  id: response.at("//EMPLOYEE/RECORDNO").content,
36
36
  name: response.at("//EMPLOYEE/PERSONALINFO/CONTACTNAME").content,
37
37
  contact_id: response.at("//EMPLOYEE/CONTACTKEY").content,
@@ -39,7 +39,37 @@ module IntacctRB
39
39
  })
40
40
  end
41
41
 
42
- successful?
42
+ return_result(response, data)
43
+ end
44
+
45
+ def get_by_employee_id(options = {})
46
+ # return false unless object.intacct_id.present?
47
+
48
+ # options[:fields] = [
49
+ # :contactid,
50
+ # :contactname
51
+ # ] if options[:fields].nil?
52
+
53
+ response = send_xml('get') do |xml|
54
+ xml.function(controlid: "f4") {
55
+ xml.readByName {
56
+ xml.object 'EMPLOYEE'
57
+ xml.keys object.try(:employee_id) || options[:employee_id]
58
+ xml.fields '*'
59
+ }
60
+ }
61
+ end
62
+
63
+ if successful?
64
+ data = OpenStruct.new({
65
+ id: response.at("//EMPLOYEE/RECORDNO").content,
66
+ name: response.at("//EMPLOYEE/PERSONALINFO/CONTACTNAME").content,
67
+ contact_id: response.at("//EMPLOYEE/CONTACTKEY").content,
68
+ employee_id: response.at("//EMPLOYEE/EMPLOYEEID").content
69
+ })
70
+ end
71
+
72
+ return_result(response, data)
43
73
  end
44
74
 
45
75
  def get_list *fields
@@ -51,7 +81,7 @@ module IntacctRB
51
81
  :termname
52
82
  ] if fields.empty?
53
83
 
54
- send_xml('get_list') do |xml|
84
+ response = send_xml('get_list') do |xml|
55
85
  xml.function(controlid: "f4") {
56
86
  xml.get_list(object: "employee", maxitems: "10", showprivate:"false") {
57
87
  # xml.fields {
@@ -62,24 +92,13 @@ module IntacctRB
62
92
  }
63
93
  }
64
94
  end
65
-
66
- # if successful?
67
- # @data = OpenStruct.new({
68
- # id: response.at("//customer//customerid").content,
69
- # name: response.at("//customer//name").content,
70
- # termname: response.at("//customer//termname").content
71
- # })
72
- # end
73
- #
74
- # successful?
75
- puts response
95
+ return_result(response)
76
96
  end
77
97
 
78
98
  def update updated_employee = false
79
99
  @object = updated_employee if updated_employee
80
100
  return false unless object.intacct_id.present?
81
-
82
- send_xml('update') do |xml|
101
+ response = send_xml('update') do |xml|
83
102
  xml.function(controlid: "1") {
84
103
  xml.update {
85
104
  employee_xml(xml)
@@ -93,7 +112,7 @@ module IntacctRB
93
112
  def delete
94
113
  return false unless object.intacct_id.present?
95
114
 
96
- @response = send_xml('delete') do |xml|
115
+ response = send_xml('delete') do |xml|
97
116
  xml.function(controlid: "1") {
98
117
  xml.delete_employee(employeeid: intacct_id)
99
118
  }
@@ -104,7 +123,7 @@ module IntacctRB
104
123
 
105
124
  def employee_xml xml
106
125
  xml.employee {
107
- xml.recordno if object.intacct_id
126
+ xml.recordno object.intacct_id if object.intacct_id
108
127
  xml.title object.title if object.title
109
128
  xml.personalinfo {
110
129
  xml.contactname object.name
@@ -1,3 +1,3 @@
1
1
  module IntacctRB
2
- VERSION = "0.6.5"
2
+ VERSION = "0.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: intacctrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.5
4
+ version: '0.7'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Hale
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-08 00:00:00.000000000 Z
11
+ date: 2018-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri